12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- '''
- Created on 21 Jan 2023 @author: vnc-console
- '''
- import gspread
- from gspread.client import BackoffClient
- from winmentor import WinMentor
- from beautiful_date import * # @UnusedWildImport
- g_sheet = '17ZympS8FjiCqsGbkKz1CPN_7NKdV_idXmYs61Mdxnsc'
- # g_sheet = '1G4l7Klb34Nu1h7lBNvA-q4FB5WlQmtoxS3xLFM5XEVw' # HUN
- gc = gspread.service_account(filename='../Pygsheet-4a83fcaf2282.json', client_factory=BackoffClient)
- # print(gc.list_spreadsheet_files())
- gsh = gc.open_by_key(g_sheet)
- sh1 = gsh.worksheet('ROU')
- # sh1 = gsh.worksheet('HUN') # HUN
- exclude = ['ABRON',
- 'ASCOMVEL',
- 'ASDONAT',
- 'ASPRO',
- 'ASIONAG',
- 'ASIVP',
- 'ALPHA',
- 'ASOBS',
- 'BANXI',
- 'BREIS',
- 'COMELECT',
- 'ECOPROT',
- 'EVEREST',
- 'FLAUR',
- 'GBZPFA',
- 'JOART',
- 'LUXWIN',
- 'MATILAND',
- 'MOCAN',
- 'SCOM',
- 'TERHOV'
- 'UNION',
- 'RECYC']
- head = ['Denumire', 'CF', 'J', 'Adresa', 'Oras', 'Judet', 'Prescurtat', 'Admin', 'AdminP', 'RCNP', 'Obs']
- mentor = WinMentor()
- office = list(mentor.filtered_firmlist(headers=head, ban=exclude)) # generator
- date = (D.today() - 1 * months).strftime('%m_%Y')
- mentor_date = (D.today() - 1 * months).strftime('%Y_%m')
- print(f'period should be "{date}"', end='\n' * 2)
- col_NAME = sh1.col_values(2)[2:]
- col_TAX = sh1.col_values(18)[2:]
- col_PER = sh1.col_values(3)[2:]
- col_CHKM = sh1.col_values(22)[2:]
- cond_range = zip(col_NAME, col_TAX, col_PER, col_CHKM)
- def main(month_=None):
- for name, tax, period, mail in cond_range:
- for company in office:
- condition = name == company[0] and tax == '.00' and period == date and mail == '1'
- if condition:
- if month_:
- if month_ >= mentor.get_last_month(company[6]):
- current_month = mentor.get_last_month(company[6])
- else:
- current_month = month_
- else:
- current_month = mentor.get_last_month(company[6])
- if current_month == mentor_date:
- account = mentor.verif_cont(company[6] + '/' + current_month + './NCONT.DB')
- print(f'...processing-->>{name}')
- cell = sh1.find(f'{name}_{date}', in_column=1)
- # Update cells
- sh1.update_cell(cell.row, 6, mentor.vat_payable(account))
- print('writing VAT')
- sh1.update_cell(cell.row, 8, mentor.vat_final(account))
- print('writing VAT total')
- contrs = [mentor.CAS_payable(account),
- mentor.CASS_payable(account),
- mentor.sal_tax_payable(account)]
- contr = sum(contrs)
- sh1.update_cell(cell.row, 10, contr)
- print('writing contributions')
- sh1.update_cell(cell.row, 11, mentor.cam_payable(account))
- print('writing CAM')
- sh1.update_cell(cell.row, 14, mentor.tax_payable(account))
- print('writing income tax')
- sh1.update_cell(cell.row, 17, mentor.div_tax_payable(account))
- print('writing dividend tax')
- sh1.update_cell(cell.row, 19, mentor.an_inc(account, 0, 6, 8))
- print('writing turnover')
- sh1.update_cell(cell.row, 20, mentor.result(account, 0, 6, 8))
- print('writing result', end='\n' * 2)
- if __name__ == '__main__':
- main(month_='2022_12')
|