diff options
| author | trisusilo <tri.susilo@altama.co.id> | 2025-01-13 08:02:20 +0000 |
|---|---|---|
| committer | trisusilo <tri.susilo@altama.co.id> | 2025-01-13 08:02:20 +0000 |
| commit | ebb101b78f930cdce77c418edbe73ffda6dd5de9 (patch) | |
| tree | 309a816c20ca8c32c4583525289b8c90d8988944 | |
| parent | b475576d635a14d905822cfdba58729f9691e385 (diff) | |
| parent | 8579a74d62ea1c730159fc6969fabdb44285b288 (diff) | |
Merged in feature/coretax_export_fakture (pull request #262)
feedback buyrTIN
| -rw-r--r-- | indoteknik_custom/models/coretax_fatur.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index 2f85a97f..74f9c8b7 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -14,6 +14,10 @@ class CoretaxFaktur(models.Model): def validate_and_format_number(slef, input_number): # Hapus semua karakter non-digit cleaned_number = re.sub(r'\D', '', input_number) + + total_sum = sum(int(char) for char in cleaned_number) + if total_sum == 0 : + return '0000000000000000' # Hitung jumlah digit digit_count = len(cleaned_number) @@ -44,8 +48,8 @@ class CoretaxFaktur(models.Model): for invoice in invoices: tax_invoice = ET.SubElement(list_of_tax_invoice, 'TaxInvoice') - buyerTIN = self.validate_and_format_number(invoice.partner_id.npwp) if invoice.partner_id.customer_type == 'pkp' else '0000000000000000' - buyerIDTKU = buyerTIN.ljust(len(buyerTIN) + 6, '0') if invoice.partner_id.customer_type == 'pkp' else '000000' + buyerTIN = self.validate_and_format_number(invoice.partner_id.npwp) + buyerIDTKU = buyerTIN.ljust(len(buyerTIN) + 6, '0') if sum(int(char) for char in buyerTIN) > 0 else '000000' # Tambahkan elemen faktur ET.SubElement(tax_invoice, 'TaxInvoiceDate').text = invoice.invoice_date.strftime('%Y-%m-%d') if invoice.invoice_date else '' |
