feat(core-flows,types,cart): add credit lines to cart (#11419)

* feat(core-flows,types,cart): add credit lines to cart

* chore: fix specs

* chore: credit lines hook

* chore: update types

* chore: added credit line totals

* chore: add totals fields to query config

* chore: add complete cart hook

* chore: add credit lines creation to order

* chore: pr ready for review

* chore: fix tests

* Apply suggestions from code review

* chore: fix types

* chore: adjust summary calculations with new totals
This commit is contained in:
Riqwan Thamir
2025-02-24 14:34:36 +01:00
committed by GitHub
parent be566ca6fb
commit fb2e86484a
27 changed files with 802 additions and 58 deletions
@@ -8,20 +8,19 @@ OrderChangeProcessing.registerActionType(ChangeActionType.CREDIT_LINE_ADD, {
let existing = creditLines.find((cl) => cl.id === action.reference_id)
if (!existing) {
existing = {
id: action.reference_id!,
const newCreditLine = {
order_id: currentOrder.id,
amount: action.amount!,
reference: action.reference,
reference_id: action.reference_id,
}
creditLines.push(existing)
creditLines.push(newCreditLine as any)
setActionReference(newCreditLine, action, options)
currentOrder.credit_lines = creditLines
}
setActionReference(existing, action, options)
currentOrder.credit_lines = creditLines
},
validate({ action }) {
if (action.amount == null) {