Skip to content

Commit 4c30fd3

Browse files
committed
feat: indicate vat validation status in crm
1 parent 655adae commit 4c30fd3

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

weblate_web/crm/templates/payments/customer_detail.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
{{ object.get_notify_emails|join:", " }}
1515
<br>
1616
{% if object.vat %}
17-
{{ object.vat }}
17+
{{ object.vat }} (
18+
{% if object.vat_recently_validated %}
19+
validated on {{ object.vat_validated }}
20+
{% else %}
21+
<strong>not validated</strong>
22+
{% endif %}
23+
)
1824
<br>
1925
{% endif %}
2026
{{ object.address }},

weblate_web/payments/models.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,18 @@ def merge(self, other: Customer, *, user: User | None = None) -> None:
336336
)
337337
other.delete()
338338

339+
@property
340+
def vat_recently_validated(self) -> bool:
341+
return (
342+
self.vat_validated is not None
343+
and self.vat_validated > timezone.now() - timedelta(days=VAT_VALIDITY_DAYS)
344+
)
345+
339346
def prepayment_validation(self, *, automated: bool = False):
340347
from weblate_web.crm.models import Interaction # noqa: PLC0415
341348

342-
now = timezone.now()
343-
344349
# Skip payment originated validation if we have validated recently
345-
if (
346-
not automated
347-
and self.vat_validated is not None
348-
and self.vat_validated > now - timedelta(days=VAT_VALIDITY_DAYS)
349-
):
350+
if not automated and self.vat_recently_validated:
350351
# Perform offline validation only
351352
validate_vatin_offline(self.vat)
352353
return

0 commit comments

Comments
 (0)