fix: Prefer line-level period text and broaden invoice title parsing
- Parse 'periode/abonnement' from line description - Broaden invoice title fields used for period detection - Prefer line period over invoice period - Improve month assignment accuracy
This commit is contained in:
parent
3a19f8233e
commit
0b5d98fdc4
@ -174,6 +174,11 @@ class SubscriptionMatrixService:
|
|||||||
invoice_text_parts.append(str(val))
|
invoice_text_parts.append(str(val))
|
||||||
elif notes:
|
elif notes:
|
||||||
invoice_text_parts.append(str(notes))
|
invoice_text_parts.append(str(notes))
|
||||||
|
# Common title/description fields
|
||||||
|
for key in ["heading", "description", "text", "subject"]:
|
||||||
|
val = invoice.get(key)
|
||||||
|
if val:
|
||||||
|
invoice_text_parts.append(str(val))
|
||||||
other_ref = invoice.get('otherReference') or invoice.get('orderNumberDb')
|
other_ref = invoice.get('otherReference') or invoice.get('orderNumberDb')
|
||||||
if other_ref:
|
if other_ref:
|
||||||
invoice_text_parts.append(str(other_ref))
|
invoice_text_parts.append(str(other_ref))
|
||||||
@ -194,6 +199,7 @@ class SubscriptionMatrixService:
|
|||||||
and "abonnement" not in invoice_text
|
and "abonnement" not in invoice_text
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
line_period = self._extract_period_from_text(line_description) or invoice_period
|
||||||
|
|
||||||
if not product_number and not product_name:
|
if not product_number and not product_name:
|
||||||
logger.debug(f"Skipping line without product number: {line}")
|
logger.debug(f"Skipping line without product number: {line}")
|
||||||
@ -210,7 +216,12 @@ class SubscriptionMatrixService:
|
|||||||
|
|
||||||
# If no period on line, use invoice date as month
|
# If no period on line, use invoice date as month
|
||||||
if not period_from_str:
|
if not period_from_str:
|
||||||
if invoice_period:
|
if line_period:
|
||||||
|
period_from = line_period
|
||||||
|
period_to = self._end_of_month(period_from)
|
||||||
|
period_from_str = period_from.isoformat().split('T')[0]
|
||||||
|
period_to_str = period_to.isoformat().split('T')[0]
|
||||||
|
elif invoice_period:
|
||||||
period_from = invoice_period
|
period_from = invoice_period
|
||||||
period_to = self._end_of_month(period_from)
|
period_to = self._end_of_month(period_from)
|
||||||
period_from_str = period_from.isoformat().split('T')[0]
|
period_from_str = period_from.isoformat().split('T')[0]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user