diff --git a/app/services/subscription_matrix.py b/app/services/subscription_matrix.py index 9d87127..58fd289 100644 --- a/app/services/subscription_matrix.py +++ b/app/services/subscription_matrix.py @@ -174,6 +174,11 @@ class SubscriptionMatrixService: invoice_text_parts.append(str(val)) elif 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') if other_ref: invoice_text_parts.append(str(other_ref)) @@ -194,6 +199,7 @@ class SubscriptionMatrixService: and "abonnement" not in invoice_text ): continue + line_period = self._extract_period_from_text(line_description) or invoice_period if not product_number and not product_name: 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 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_to = self._end_of_month(period_from) period_from_str = period_from.isoformat().split('T')[0]