feat(invoices): per-line percentage discount and separate fakturamarkning (#2084)
* feat(invoices): per-line percentage discount and separate fakturamarkning User request: rabatt i procent per artikelrad, and a marking field separate from Er referens. - invoice_items.discount_percent (0-100, default 0): line_total and vat_amount are stored NET of the discount. Shared exact-ore math in lib/invoices/line-amounts.ts (gross, discount, net) used by the web builder, staged-operation commit, editor preview, PDF, and Peppol. Undiscounted lines keep the legacy unrounded qty*price byte-identical. - ROT/RUT deduction computes on the discounted net line total. - invoices.invoice_marking: printed on the PDF next to the references and mapped to Peppol BT-10 BuyerReference (marking wins over your_reference; either satisfies the BT-10 requirement). - Peppol renders the discount as a BG-27 line AllowanceCharge (reason code 95, MultiplierFactorNumeric, Amount, BaseAmount). - Editor: "Lagg till rabatt" in the row menu (same reveal pattern as ROT/RUT), Markning row next to Er referens, forval chip, review dialog shows discounts and marking. - Plumbed through v1 REST projections, MCP create/get/update invoice tools, pending-operations update path, and copy-invoice (discount copied; marking deliberately not, it is recipient-specific). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJAt9yM7tgZ69f1XnNnq52 * fix(invoices): carry discount_percent through every deduction, credit, convert and preview path Skeptic + CI findings on the discount/marking feature, one pass: - generateRotRutLines and propose-send-lines now pass discount_percent into computeDeduction: the send/credit/cash verifikat booked 1513 on the GROSS line while deduction_total, the PDF and the Skatteverket claim carried the net, stranding the difference on 1513 and pushing 1510 negative once the customer paid. Test pins 1513=3000/1510=7000 for a 20%-discounted 10 000 kr ROT line. - preview-pdf route accepts discount_percent (net totals + net-based deduction) and invoice_marking; the editor now sends the marking, so the preview equals the invoice it becomes. - Credit notes carry discount_percent (buildCreditNoteItem, v1 credit route select+insert, MCP credit executor) and invoice_marking, so the kreditfaktura face arithmetic multiplies out and shows the Rabatt column (ML 17 kap 24 §). - Proforma->invoice convert copies discount_percent + invoice_marking: the converted invoice previously failed Peppol LINE_TOTAL_MISMATCH and lost the rebate on the next builder pass. - Editor hides the discount menu in self-billed mode (the self-billed wire shape has no discount; previewed net would book gross). - MCP staging and commitCreateInvoice reject a non-number discount_percent (a string coerced past the range check but was ignored by the totals math and still stored). - Regenerated skills/accounted-api (apiskill:check CI failure). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJAt9yM7tgZ69f1XnNnq52 --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
84c8e1ce59
commit
f216a60bf8
@@ -3813,6 +3813,7 @@
|
||||
"chip_received": "Received {date}",
|
||||
"chip_delivery": "Delivery date {date}",
|
||||
"chip_your_reference": "Your reference: {reference}",
|
||||
"chip_invoice_marking": "Marking: {marking}",
|
||||
"chip_stripe_auto": "Stripe link created on send",
|
||||
"chip_payment_link": "Payment link added",
|
||||
"chip_ore_off": "No öre rounding",
|
||||
@@ -3831,6 +3832,10 @@
|
||||
"ready_create": "Ready to review: everything else has sensible defaults.",
|
||||
"ready_edit": "Ready to save.",
|
||||
"ready_self_billed": "Ready to register.",
|
||||
"row_menu_add_discount": "Add discount",
|
||||
"row_menu_remove_discount": "Remove discount",
|
||||
"discount_label": "Discount",
|
||||
"validation_discount_range": "The discount must be between 0 and 100 percent",
|
||||
"row_menu_set_account": "Set posting account",
|
||||
"row_menu_remove_account": "Remove posting account",
|
||||
"row_menu_set_dimensions": "Set cost centre/project",
|
||||
@@ -3899,6 +3904,8 @@
|
||||
"your_reference_placeholder": "Customer contact person",
|
||||
"our_reference_label": "Our reference",
|
||||
"our_reference_placeholder": "Your name",
|
||||
"invoice_marking_label": "Marking",
|
||||
"invoice_marking_placeholder": "E.g. cost center or order no.",
|
||||
"payment_link_label": "Payment link (optional)",
|
||||
"payment_link_placeholder": "https://buy.stripe.com/…",
|
||||
"payment_link_hint": "Paste a payment link created for this specific invoice (e.g. in Stripe). Make sure the amount matches and preferably limit the link to a single payment. The link is shown as a button in the invoice email and as a QR code on the PDF.",
|
||||
@@ -4015,6 +4022,7 @@
|
||||
"total": "Total",
|
||||
"your_reference": "Your reference:",
|
||||
"our_reference": "Our reference:",
|
||||
"invoice_marking": "Marking:",
|
||||
"notes_prefix": "Note: {notes}"
|
||||
},
|
||||
"invoice_bank_setup": {
|
||||
|
||||
@@ -3813,6 +3813,7 @@
|
||||
"chip_received": "Mottagen {date}",
|
||||
"chip_delivery": "Leveransdatum {date}",
|
||||
"chip_your_reference": "Er referens: {reference}",
|
||||
"chip_invoice_marking": "Märkning: {marking}",
|
||||
"chip_stripe_auto": "Stripe-länk skapas vid utskick",
|
||||
"chip_payment_link": "Betalningslänk inlagd",
|
||||
"chip_ore_off": "Ingen öresavrundning",
|
||||
@@ -3831,6 +3832,10 @@
|
||||
"ready_create": "Klar att granska: allt annat har smarta förval.",
|
||||
"ready_edit": "Klart att spara.",
|
||||
"ready_self_billed": "Klar att registrera.",
|
||||
"row_menu_add_discount": "Lägg till rabatt",
|
||||
"row_menu_remove_discount": "Ta bort rabatt",
|
||||
"discount_label": "Rabatt",
|
||||
"validation_discount_range": "Rabatten måste vara mellan 0 och 100 procent",
|
||||
"row_menu_set_account": "Ange bokföringskonto",
|
||||
"row_menu_remove_account": "Ta bort bokföringskonto",
|
||||
"row_menu_set_dimensions": "Ange kostnadsställe/projekt",
|
||||
@@ -3899,6 +3904,8 @@
|
||||
"your_reference_placeholder": "Kontaktperson hos kund",
|
||||
"our_reference_label": "Vår referens",
|
||||
"our_reference_placeholder": "Ditt namn",
|
||||
"invoice_marking_label": "Märkning",
|
||||
"invoice_marking_placeholder": "T.ex. kostnadsställe eller ordernr",
|
||||
"payment_link_label": "Betalningslänk (valfritt)",
|
||||
"payment_link_placeholder": "https://buy.stripe.com/…",
|
||||
"payment_link_hint": "Klistra in en betalningslänk skapad för just denna faktura (t.ex. i Stripe). Kontrollera att beloppet stämmer och begränsa gärna länken till en betalning. Länken visas som en knapp i fakturamejlet och som QR-kod på PDF:en.",
|
||||
@@ -4015,6 +4022,7 @@
|
||||
"total": "Totalt",
|
||||
"your_reference": "Er referens:",
|
||||
"our_reference": "Vår referens:",
|
||||
"invoice_marking": "Märkning:",
|
||||
"notes_prefix": "Anteckning: {notes}"
|
||||
},
|
||||
"invoice_bank_setup": {
|
||||
|
||||
Reference in New Issue
Block a user