diff --git a/MDfile/RELEASE_NOTES_v2.8.15.md b/MDfile/RELEASE_NOTES_v2.8.15.md new file mode 100644 index 0000000..ae83105 --- /dev/null +++ b/MDfile/RELEASE_NOTES_v2.8.15.md @@ -0,0 +1,11 @@ +# BMC Hub v2.8.15 + +## ALSO-perioder på ordrelinjer + +- Viser perioden fra `Actual Charge Interval` på en ny linje under produktnavnet. +- Migration 248 retter eksisterende, ikke-eksporterede ALSO-ordrekladder. +- Allerede eksporterede ordre ændres ikke. + +## Opgradering + +Kør `migrations/248_also_order_period_line_break.sql` efter deployment. diff --git a/VERSION b/VERSION index 63cb62f..92e6e77 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.8.14 +2.8.15 diff --git a/app/modules/also/backend/service.py b/app/modules/also/backend/service.py index 09f11dc..565ca84 100644 --- a/app/modules/also/backend/service.py +++ b/app/modules/also/backend/service.py @@ -2027,7 +2027,7 @@ class AlsoService: description = line.get("product_name") or line.get("matched_product_name") or "Cloud abonnement" charge_period = _format_charge_period(line.get("charge_interval")) if charge_period: - description = f"{description} · Periode: {charge_period}" + description = f"{description}\nPeriode: {charge_period}" draft_lines.append( { diff --git a/migrations/248_also_order_period_line_break.sql b/migrations/248_also_order_period_line_break.sql new file mode 100644 index 0000000..c5a0538 --- /dev/null +++ b/migrations/248_also_order_period_line_break.sql @@ -0,0 +1,26 @@ +BEGIN; + +-- Put the ALSO billing period on its own line for pending order drafts. +UPDATE ordre_drafts +SET lines_json = ( + SELECT jsonb_agg( + CASE + WHEN item->>'source_type' = 'also_cloud' + AND COALESCE(item->>'description', '') LIKE '% · Periode: %' + THEN jsonb_set( + item, + '{description}', + to_jsonb(replace(item->>'description', ' · Periode: ', E'\nPeriode: ')) + ) + ELSE item + END + ORDER BY ordinality + ) + FROM jsonb_array_elements(lines_json) WITH ORDINALITY AS source(item, ordinality) + ), + updated_at = CURRENT_TIMESTAMP +WHERE sync_status = 'pending' + AND invoice_aggregate_key LIKE 'also-cloud-%' + AND lines_json::text LIKE '% · Periode: %'; + +COMMIT;