summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-01-06 13:12:07 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-01-06 13:12:07 +0700
commit89d4e9c8df4babbaa8daccdf4a6f77fee8a06123 (patch)
treef0c19dc643bba24342d488af55e40b5295a24b75
parentf4217b5493477d8238165f9390dd6c6f8a597b33 (diff)
change validation npwp on sale order
-rwxr-xr-xindoteknik_custom/models/sale_order.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index d75c9fe9..cb963122 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -374,12 +374,16 @@ class SaleOrder(models.Model):
if self.state not in ['draft', 'sent']:
raise UserError("Status harus draft atau sent")
- if not self._validate_npwp():
- raise UserError("Isi NPWP Dengan Benar!")
+ self._validate_npwp()
def _validate_npwp(self):
- pattern = r'^\d{16,}$'
- return re.match(pattern, self.npwp) is not None
+ num_digits = sum(c.isdigit() for c in self.npwp)
+
+ if num_digits <= 10:
+ raise UserError("NPWP harus memiliki minimal 10 digit")
+
+ # pattern = r'^\d{10,}$'
+ # return re.match(pattern, self.npwp) is not None
def sale_order_approve(self):
self.check_due()