diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2025-01-13 15:01:43 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2025-01-13 15:01:43 +0700 |
| commit | 8579a74d62ea1c730159fc6969fabdb44285b288 (patch) | |
| tree | e7db04f17a9089f225e1bebf5558b825a94fda90 | |
| parent | 14a677c77defd6f5c92af2db6f128e3f7227ddf6 (diff) | |
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 '' |
