feat: line item adjustments (#1319)

* add: crud services + model + totals

* fix: enforce unique constraint on line item adjustment model and update service (#1241)

* add: unique constraint on model + fix service

* fix: unique constraint

* fix: add cascade on delete + fix discount relation

* fix: remove optional unique prop

* add: tests for ensuring line item adjustment db constraints (#1279)

* add: tests for ensuring db constraints

* fix: use given when then

* feat: adjust cart to include line item adjustments (#1242)

* fix: cart service + cart tests

* fix: remaining tests

* fix: swap tests

* fix: add relationship + fix oas

* refactor: applyDiscount

* fix: refactor applyDiscount and fix + add unit tests

* fix: plugins tests

* feat: line item adjustments draft orders (#1243)

* fix: draft order tests

* fix: constraint

* fix: wrong variable name

* fix: unique constraint

* progress: add tests

* fix: add cascade on delete + fix discount relation

* fix: remove optional unique prop

* fix: cart removeLineItem + tests

* fix: cart unit tests

* fix: update snapshot

* remove: verbose option

* rename arg

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>

* add: create adjustments for swap additional_items

* add: create adjustments for return lines

* fix: unit test for creating adjustment for additional_items

* fix: create adjustments only for non return items + no deletion when item is a return item

* add: integration tests

* refactor: use refreshAdjustments method

* refactor test

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
This commit is contained in:
Zakaria El Asri
2022-04-12 13:49:31 +00:00
committed by GitHub
parent 607a382b4e
commit 1cfeb5dbd8
45 changed files with 3290 additions and 581 deletions
@@ -427,6 +427,7 @@ Object {
"idempotency_key": null,
"items": Array [
Object {
"adjustments": Array [],
"allow_discounts": true,
"cart_id": null,
"claim_order_id": null,
@@ -761,6 +762,7 @@ Object {
"idempotency_key": null,
"items": Array [
Object {
"adjustments": Array [],
"allow_discounts": true,
"cart_id": null,
"claim_order_id": null,
@@ -982,6 +984,7 @@ Object {
"idempotency_key": null,
"items": Array [
Object {
"adjustments": Array [],
"allow_discounts": true,
"cart_id": null,
"claim_order_id": null,
@@ -1248,6 +1251,7 @@ Object {
"idempotency_key": null,
"items": Array [
Object {
"adjustments": Array [],
"allow_discounts": true,
"cart_id": null,
"claim_order_id": null,
@@ -1569,6 +1573,7 @@ Object {
"idempotency_key": null,
"items": Array [
Object {
"adjustments": Array [],
"allow_discounts": true,
"cart_id": null,
"claim_order_id": null,
@@ -107,6 +107,7 @@ describe("medusa-plugin-sendgrid", () => {
},
items: [
{
adjustments: [],
created_at: expect.any(Date),
updated_at: expect.any(Date),
order_id: expect.any(String),
@@ -227,6 +228,7 @@ describe("medusa-plugin-sendgrid", () => {
},
items: [
{
adjustments: [],
created_at: expect.any(Date),
updated_at: expect.any(Date),
order_id: expect.any(String),
@@ -285,6 +287,7 @@ describe("medusa-plugin-sendgrid", () => {
},
items: [
{
adjustments: [],
created_at: expect.any(Date),
updated_at: expect.any(Date),
order_id: expect.any(String),