fix(vat): map Əlavə 8 rows to real child fieldnames

populate_vat_tables built Əlavə 8 Tablo 2 rows with keys that do not exist
on "Declaration of value added tax Elave 8 2ci" (şəxsinadı, şəxsinvöeni,
sertifikatınseriyası, nsi, xidmətindəyəri). set_table() assigned them onto
the child object without error, so rows were created empty.

Map to the actual fieldnames. The doctype stores series and number in a
single "Sertifikatın seriya / nömrəsi" field, so cert_no is written whole
and _split_cert_no is dropped.

Also widen the two Int fields: the value column truncated decimals, and
VÖEN is an identifier that must not lose leading zeros — both now match
Elave 8 1ci.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ali 2026-07-09 13:39:08 +00:00
parent afd65ce302
commit 1aba387f87
2 changed files with 7 additions and 25 deletions

View File

@ -7,7 +7,6 @@ from frappe import _
from frappe.utils import flt, getdate, add_months, cint
from datetime import datetime, date
import calendar
import re
class Declarationofvalueaddedtax(Document):
pass
@ -27,21 +26,6 @@ ACT_TYPE_MAP = {
}
def _split_cert_no(cert_no):
"""Split a combined certificate number into (series, number).
Leading letters are the series, the trailing digits are the number, e.g.
"Az10000001" -> ("Az", "10000001"). If there are no leading letters the
whole value becomes the number. The series field is 3 chars wide, so it is
capped to 3 to avoid truncation errors.
"""
s = (cert_no or "").strip()
m = re.match(r"^([^\d]+)(\d.*)$", s)
if m:
return m.group(1).strip()[:3], m.group(2).strip()
return "", s
def _period_filters(year, month):
"""Build report filters (company + month date range) from year + month."""
from frappe.utils import get_last_day
@ -122,13 +106,11 @@ def populate_vat_tables(year, month):
# item amount is kept per certificate (no splitting across certificates).
elave_8_2 = []
for r in (certificate_get_data(filters) or []):
series, number = _split_cert_no(r.get("cert_no"))
elave_8_2.append({
"şəxsinadı": r.get("taxpayer_full_name"),
"şəxsinvöeni": r.get("voen") or None,
"sertifikatınseriyası": series,
"nsi": number,
"xidmətindəyəri": r.get("value"),
"sertifikatınseriyanömrəsi": r.get("cert_no"),
"sertifikattəqdimolunanşəxsinvöeni": r.get("voen") or None,
"sertifikattəqdimolunanşəxsinadı": r.get("taxpayer_full_name"),
"sertifikataltındatəqdimolunanmallarınişlərinxidmətlərindəyəri": r.get("value"),
})
return {

View File

@ -20,7 +20,7 @@
},
{
"fieldname": "sertifikatt\u0259qdimolunan\u015f\u0259xsinv\u00f6eni",
"fieldtype": "Int",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Sertifikat t\u0259qdim olunan \u015f\u0259xsin V\u00f6eni"
},
@ -32,7 +32,7 @@
},
{
"fieldname": "sertifikatalt\u0131ndat\u0259qdimolunanmallar\u0131ni\u015fl\u0259rinxidm\u0259tl\u0259rind\u0259y\u0259ri",
"fieldtype": "Int",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Sertifikat alt\u0131nda t\u0259qdim olunan mallar\u0131n (i\u015fl\u0259rin, xidm\u0259tl\u0259rin) d\u0259y\u0259ri"
}
@ -40,7 +40,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2026-06-29 12:04:23.750868",
"modified": "2026-07-09 10:00:00.000000",
"modified_by": "nihad_m@jeysoft.az",
"module": "Taxes Az",
"name": "Declaration of value added tax Elave 8 2ci",