|
@@ -17,6 +17,7 @@ class Test(unittest.TestCase):
|
|
|
template2 = templates.get_template('partners.txt')
|
|
|
|
|
|
code_string = r'(?<=Cod TVA: )[a-zA-Z0-9]*|(?<=VAT no.: )[a-zA-Z0-9]*|(?<=Reg. code: )[a-zA-Z0-9]*|(?<=Cod unic de înregistrare: )[a-zA-Z0-9]*'
|
|
|
+ reg_string = r'(?<=Reg. code: )[a-zA-Z0-9]*'
|
|
|
name_string = r'[a-zA-Z0-9. ]*(?=\nRidewave SRL)'
|
|
|
value_string = r'(?<=otal \(RON\):\n)[a-zA-Z0-9.]*'
|
|
|
docn_string = r'(?<=Factura nr. )[a-zA-Z\n0-9-]*|(?<=Invoice no. )[a-zA-Z\n0-9-]*'
|
|
@@ -30,7 +31,7 @@ class Test(unittest.TestCase):
|
|
|
numbers = []
|
|
|
notes = []
|
|
|
dates = []
|
|
|
- for root, _dir, files in os.walk(r'f:\Gdrive\Misc\Dosar-Contabilitate\Ridewave\2024_06'):
|
|
|
+ for root, _dir, files in os.walk(r'f:\Gdrive\Misc\Dosar-Contabilitate\Ridewave\2024_04\e-Fact'):
|
|
|
for file in files:
|
|
|
if file.endswith('.pdf'):
|
|
|
with pymupdf.open(os.path.join(root, file)) as doc:
|
|
@@ -43,6 +44,8 @@ class Test(unittest.TestCase):
|
|
|
buyer_code = re.search(self.code_string, txt).group() # noqa E:if match None
|
|
|
if buyer_code == '49340170':
|
|
|
buyer_code = input(f'enter code manually for {buyer_name.group()}') # noqa E:if match None
|
|
|
+ elif buyer_code.startswith('J'):
|
|
|
+ buyer_code = re.search(r'(?<=Cod TVA: )[a-zA-Z0-9]*|(?<=VAT no.: )[a-zA-Z0-9]*', txt).group() # noqa E:if match None
|
|
|
elif buyer_code == '14532901':
|
|
|
buyer_code = '42717800'
|
|
|
|
|
@@ -67,18 +70,13 @@ class Test(unittest.TestCase):
|
|
|
for date, name, code, value, number, note in zip(df['dates'], df['names'], df['codes'], df['values'], df['numbers'], df['notes']):
|
|
|
invoice = BoltSaleInvoice(doc_data=date, buyer_name=name, buyer_code=code, total_value=value, doc_number=number, doc_notes=note)
|
|
|
invoices.append(invoice)
|
|
|
- partner = Partner(vat_code=code)
|
|
|
+ partner = Partner(vat_code=code, name=name)
|
|
|
partners.append(partner)
|
|
|
data = {'AnLucru': datetime.date.today().year,
|
|
|
'LunaLucru': get_last_month(0),
|
|
|
'TotalFacturi': len(df),
|
|
|
'documents': invoices,
|
|
|
- # 'NrDoc': [],
|
|
|
- # 'NumarBonuri': [],
|
|
|
- # 'Data': [],
|
|
|
- # 'Observatii': [],
|
|
|
'Code': 'TRANSPMF'
|
|
|
- # 'Pret': []
|
|
|
}
|
|
|
data2 = {'partners': partners}
|
|
|
output = self.template.render(data)
|
|
@@ -91,6 +89,7 @@ class Test(unittest.TestCase):
|
|
|
with open(output_file, 'w') as text:
|
|
|
text.write(output)
|
|
|
with open(output_file2, 'w') as text:
|
|
|
+ # output2.encode('utf-8')
|
|
|
text.write(output2)
|
|
|
|
|
|
|