chore: merge money amounts and price set money amounts (#6768)
what: - merges price set money amounts and money amount
This commit is contained in:
@@ -59,63 +59,63 @@ moduleIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
const moneyAmountsData = [
|
||||
{
|
||||
id: "money-amount-PLN",
|
||||
id: "psma-PLN",
|
||||
currency_code: "PLN",
|
||||
amount: 1000,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
},
|
||||
{
|
||||
id: "money-amount-company_id-EUR",
|
||||
id: "psma-company_id-EUR",
|
||||
currency_code: "EUR",
|
||||
amount: 500,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
},
|
||||
{
|
||||
id: "money-amount-company_id-PLN",
|
||||
id: "psma-company_id-PLN",
|
||||
currency_code: "PLN",
|
||||
amount: 400,
|
||||
min_quantity: 1,
|
||||
max_quantity: 5,
|
||||
},
|
||||
{
|
||||
id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
currency_code: "PLN",
|
||||
amount: 300,
|
||||
min_quantity: 1,
|
||||
max_quantity: 4,
|
||||
},
|
||||
{
|
||||
id: "money-amount-region_id+company_id-PLN",
|
||||
id: "psma-region_id+company_id-PLN",
|
||||
currency_code: "PLN",
|
||||
amount: 999,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
},
|
||||
{
|
||||
id: "money-amount-region_id-PLN-5-qty",
|
||||
id: "psma-region_id-PLN-5-qty",
|
||||
currency_code: "PLN",
|
||||
amount: 250,
|
||||
min_quantity: 4,
|
||||
max_quantity: 10,
|
||||
},
|
||||
{
|
||||
id: "money-amount-region_id-PL-EUR",
|
||||
id: "psma-region_id_company_id-PL-EUR",
|
||||
currency_code: "EUR",
|
||||
amount: 200,
|
||||
min_quantity: 1,
|
||||
max_quantity: 3,
|
||||
},
|
||||
{
|
||||
id: "money-amount-region_id-PL-EUR-4-qty",
|
||||
id: "psma-region_id_company_id-PL-EUR-4-qty",
|
||||
currency_code: "EUR",
|
||||
amount: 50,
|
||||
min_quantity: 4,
|
||||
max_quantity: 10,
|
||||
},
|
||||
{
|
||||
id: "money-amount-region_id-PL-EUR-customer-group",
|
||||
id: "psma-region_id_company_id-PL-EUR-customer-group",
|
||||
currency_code: "EUR",
|
||||
amount: 100,
|
||||
min_quantity: 1,
|
||||
@@ -137,56 +137,80 @@ moduleIntegrationTestRunner({
|
||||
id: "psma-PLN",
|
||||
title: "psma PLN",
|
||||
price_set_id: "price-set-PLN",
|
||||
money_amount_id: "money-amount-PLN",
|
||||
currency_code: "PLN",
|
||||
amount: 1000,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
rules_count: 0,
|
||||
},
|
||||
{
|
||||
id: "psma-company_id-EUR",
|
||||
title: "psma EUR - company_id",
|
||||
price_set_id: "price-set-EUR",
|
||||
money_amount_id: "money-amount-company_id-EUR",
|
||||
currency_code: "EUR",
|
||||
amount: 500,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
rules_count: 1,
|
||||
},
|
||||
{
|
||||
id: "psma-company_id-PLN",
|
||||
title: "psma PLN - company_id",
|
||||
price_set_id: "price-set-PLN",
|
||||
money_amount_id: "money-amount-company_id-PLN",
|
||||
currency_code: "PLN",
|
||||
amount: 400,
|
||||
min_quantity: 1,
|
||||
max_quantity: 5,
|
||||
rules_count: 1,
|
||||
},
|
||||
{
|
||||
id: "psma-region_id-PLN",
|
||||
title: "psma PLN - region_id",
|
||||
price_set_id: "price-set-PLN",
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
currency_code: "PLN",
|
||||
amount: 300,
|
||||
min_quantity: 1,
|
||||
max_quantity: 4,
|
||||
rules_count: 1,
|
||||
},
|
||||
{
|
||||
id: "psma-region_id+company_id-PLN",
|
||||
title: "psma region_id + company_id",
|
||||
price_set_id: "price-set-PLN",
|
||||
money_amount_id: "money-amount-region_id+company_id-PLN",
|
||||
currency_code: "PLN",
|
||||
amount: 999,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
rules_count: 2,
|
||||
},
|
||||
{
|
||||
id: "psma-region_id-PLN-5-qty",
|
||||
title: "psma PLN - region_id 5 qty",
|
||||
price_set_id: "price-set-PLN",
|
||||
money_amount_id: "money-amount-region_id-PLN-5-qty",
|
||||
currency_code: "PLN",
|
||||
amount: 250,
|
||||
min_quantity: 4,
|
||||
max_quantity: 10,
|
||||
rules_count: 1,
|
||||
},
|
||||
{
|
||||
id: "psma-region_id_company_id-PL-EUR",
|
||||
title: "psma PLN - region_id PL with EUR currency",
|
||||
price_set_id: "price-set-PLN",
|
||||
money_amount_id: "money-amount-region_id-PL-EUR",
|
||||
currency_code: "EUR",
|
||||
amount: 200,
|
||||
min_quantity: 1,
|
||||
max_quantity: 3,
|
||||
rules_count: 2,
|
||||
},
|
||||
{
|
||||
id: "psma-region_id_company_id-PL-EUR-4-qty",
|
||||
title: "psma PLN - region_id PL with EUR currency for quantity 4",
|
||||
price_set_id: "price-set-PLN",
|
||||
money_amount_id: "money-amount-region_id-PL-EUR-4-qty",
|
||||
currency_code: "EUR",
|
||||
amount: 50,
|
||||
min_quantity: 4,
|
||||
max_quantity: 10,
|
||||
rules_count: 2,
|
||||
},
|
||||
{
|
||||
@@ -194,7 +218,10 @@ moduleIntegrationTestRunner({
|
||||
title:
|
||||
"psma PLN - region_id PL with EUR currency for customer group",
|
||||
price_set_id: "price-set-PLN",
|
||||
money_amount_id: "money-amount-region_id-PL-EUR-customer-group",
|
||||
currency_code: "EUR",
|
||||
amount: 100,
|
||||
min_quantity: 1,
|
||||
max_quantity: 3,
|
||||
rules_count: 3,
|
||||
},
|
||||
]
|
||||
@@ -378,14 +405,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -400,14 +427,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 1000,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-PLN",
|
||||
id: "psma-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-PLN",
|
||||
id: "psma-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -434,14 +461,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -456,14 +483,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 300,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 4,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -490,14 +517,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -512,14 +539,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 1000,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-PLN",
|
||||
id: "psma-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-PLN",
|
||||
id: "psma-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -546,14 +573,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -568,14 +595,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -602,14 +629,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -624,14 +651,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 300,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 4,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -658,14 +685,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -680,14 +707,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 1000,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-PLN",
|
||||
id: "psma-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-PLN",
|
||||
id: "psma-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -714,14 +741,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 250,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN-5-qty",
|
||||
id: "psma-region_id-PLN-5-qty",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 4,
|
||||
max_quantity: 10,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN-5-qty",
|
||||
id: "psma-region_id-PLN-5-qty",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 4,
|
||||
@@ -753,14 +780,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -775,14 +802,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 300,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 4,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -814,14 +841,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -837,14 +864,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 100,
|
||||
currency_code: "EUR",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-region_id-PL-EUR-customer-group",
|
||||
id: "psma-region_id_company_id-PL-EUR-customer-group",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 3,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-region_id-PL-EUR-customer-group",
|
||||
id: "psma-region_id_company_id-PL-EUR-customer-group",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -876,14 +903,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -899,14 +926,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 300,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 4,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -938,14 +965,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -961,14 +988,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 1000,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-PLN",
|
||||
id: "psma-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-PLN",
|
||||
id: "psma-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -995,14 +1022,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1017,14 +1044,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1055,14 +1082,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1077,14 +1104,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 300,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 4,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1119,14 +1146,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1141,14 +1168,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 400,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: expect.any(String),
|
||||
price_list_type: "sale",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1190,14 +1217,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1212,14 +1239,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 400,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: expect.any(String),
|
||||
price_list_type: "sale",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1253,14 +1280,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1275,14 +1302,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 400,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: expect.any(String),
|
||||
price_list_type: "sale",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1313,14 +1340,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1335,14 +1362,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 1000,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: expect.any(String),
|
||||
price_list_type: "sale",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1376,14 +1403,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1398,14 +1425,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 232,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: expect.any(String),
|
||||
price_list_type: "override",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: expect.any(String),
|
||||
price_list_type: "override",
|
||||
min_quantity: null,
|
||||
@@ -1438,14 +1465,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1460,14 +1487,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 300,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 4,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-region_id-PLN",
|
||||
id: "psma-region_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1500,14 +1527,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1522,14 +1549,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 300,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 4,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1575,14 +1602,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1597,14 +1624,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 400,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: expect.any(String),
|
||||
price_list_type: "sale",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1651,14 +1678,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1673,14 +1700,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 400,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-company_id-PLN",
|
||||
id: "psma-company_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 5,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-company_id-PLN",
|
||||
id: "psma-company_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1726,14 +1753,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1748,14 +1775,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 400,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: "money-amount-company_id-PLN",
|
||||
id: "psma-company_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
max_quantity: 5,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: "money-amount-company_id-PLN",
|
||||
id: "psma-company_id-PLN",
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1803,14 +1830,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: "EUR",
|
||||
calculated_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: id,
|
||||
price_list_type: "sale",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1854,14 +1881,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1876,14 +1903,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 400,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: expect.any(String),
|
||||
price_list_type: "sale",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
@@ -1927,14 +1954,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: null,
|
||||
currency_code: null,
|
||||
calculated_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: null,
|
||||
id: null,
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: null,
|
||||
@@ -1949,14 +1976,14 @@ moduleIntegrationTestRunner({
|
||||
original_amount: 400,
|
||||
currency_code: "PLN",
|
||||
calculated_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: expect.any(String),
|
||||
price_list_type: "sale",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
},
|
||||
original_price: {
|
||||
money_amount_id: expect.any(String),
|
||||
id: expect.any(String),
|
||||
price_list_id: null,
|
||||
price_list_type: null,
|
||||
min_quantity: 1,
|
||||
|
||||
@@ -1,411 +0,0 @@
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { IPricingModuleService } from "@medusajs/types"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||
import { createMoneyAmounts } from "../../../__fixtures__/money-amount"
|
||||
import { createPriceRules } from "../../../__fixtures__/price-rule"
|
||||
import { createPriceSets } from "../../../__fixtures__/price-set"
|
||||
import { createPriceSetMoneyAmounts } from "../../../__fixtures__/price-set-money-amount"
|
||||
import { createRuleTypes } from "../../../__fixtures__/rule-type"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
moduleIntegrationTestRunner({
|
||||
moduleName: Modules.PRICING,
|
||||
testSuite: ({
|
||||
MikroOrmWrapper,
|
||||
service,
|
||||
}: SuiteOptions<IPricingModuleService>) => {
|
||||
describe("PricingModule Service - MoneyAmount", () => {
|
||||
let testManager: SqlEntityManager
|
||||
beforeEach(async () => {
|
||||
testManager = await MikroOrmWrapper.forkManager()
|
||||
await createMoneyAmounts(testManager)
|
||||
})
|
||||
|
||||
describe("listMoneyAmounts", () => {
|
||||
it("list moneyAmounts", async () => {
|
||||
const moneyAmountsResult = await service.listMoneyAmounts()
|
||||
|
||||
expect(moneyAmountsResult).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "money-amount-USD",
|
||||
amount: 500,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "money-amount-EUR",
|
||||
amount: 400,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "money-amount-CAD",
|
||||
amount: 600,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("should list moneyAmounts by id", async () => {
|
||||
const moneyAmountsResult = await service.listMoneyAmounts({
|
||||
id: ["money-amount-USD"],
|
||||
})
|
||||
|
||||
expect(moneyAmountsResult).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "money-amount-USD",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("should list moneyAmounts with relations and selects", async () => {
|
||||
const moneyAmountsResult = await service.listMoneyAmounts(
|
||||
{
|
||||
id: ["money-amount-USD"],
|
||||
},
|
||||
{
|
||||
select: ["id", "min_quantity", "currency_code"],
|
||||
}
|
||||
)
|
||||
|
||||
const serialized = JSON.parse(JSON.stringify(moneyAmountsResult))
|
||||
|
||||
expect(serialized).toEqual([
|
||||
{
|
||||
id: "money-amount-USD",
|
||||
amount: null,
|
||||
min_quantity: "1",
|
||||
currency_code: "USD",
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe("listAndCountMoneyAmounts", () => {
|
||||
it("should return moneyAmounts and count", async () => {
|
||||
const [moneyAmountsResult, count] =
|
||||
await service.listAndCountMoneyAmounts()
|
||||
|
||||
expect(count).toEqual(3)
|
||||
expect(moneyAmountsResult).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "money-amount-USD",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "money-amount-EUR",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "money-amount-CAD",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("should return moneyAmounts and count when filtered", async () => {
|
||||
const [moneyAmountsResult, count] =
|
||||
await service.listAndCountMoneyAmounts({
|
||||
id: ["money-amount-USD"],
|
||||
})
|
||||
|
||||
expect(count).toEqual(1)
|
||||
expect(moneyAmountsResult).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "money-amount-USD",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("list moneyAmounts with relations and selects", async () => {
|
||||
const [moneyAmountsResult, count] =
|
||||
await service.listAndCountMoneyAmounts(
|
||||
{
|
||||
id: ["money-amount-USD"],
|
||||
},
|
||||
{
|
||||
select: ["id", "min_quantity", "currency_code", "amount"],
|
||||
}
|
||||
)
|
||||
|
||||
const serialized = JSON.parse(JSON.stringify(moneyAmountsResult))
|
||||
|
||||
expect(count).toEqual(1)
|
||||
expect(serialized).toEqual([
|
||||
{
|
||||
id: "money-amount-USD",
|
||||
amount: 500,
|
||||
min_quantity: "1",
|
||||
currency_code: "USD",
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it("should return moneyAmounts and count when using skip and take", async () => {
|
||||
const [moneyAmountsResult, count] =
|
||||
await service.listAndCountMoneyAmounts({}, { skip: 1, take: 1 })
|
||||
|
||||
expect(count).toEqual(3)
|
||||
expect(moneyAmountsResult).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "money-amount-EUR",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("should return requested fields", async () => {
|
||||
const [moneyAmountsResult, count] =
|
||||
await service.listAndCountMoneyAmounts(
|
||||
{},
|
||||
{
|
||||
take: 1,
|
||||
select: ["id"],
|
||||
}
|
||||
)
|
||||
|
||||
const serialized = JSON.parse(JSON.stringify(moneyAmountsResult))
|
||||
|
||||
expect(count).toEqual(3)
|
||||
expect(serialized).toEqual([
|
||||
{
|
||||
id: "money-amount-CAD",
|
||||
amount: null,
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe("retrieveMoneyAmount", () => {
|
||||
const id = "money-amount-USD"
|
||||
const amount = 500
|
||||
|
||||
it("should return moneyAmount for the given id", async () => {
|
||||
const moneyAmount = await service.retrieveMoneyAmount(id)
|
||||
|
||||
expect(moneyAmount).toEqual(
|
||||
expect.objectContaining({
|
||||
id,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("should throw an error when moneyAmount with id does not exist", async () => {
|
||||
let error
|
||||
|
||||
try {
|
||||
await service.retrieveMoneyAmount("does-not-exist")
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(
|
||||
"MoneyAmount with id: does-not-exist was not found"
|
||||
)
|
||||
})
|
||||
|
||||
it("should throw an error when a id is not provided", async () => {
|
||||
let error
|
||||
|
||||
try {
|
||||
await service.retrieveMoneyAmount(undefined as unknown as string)
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error.message).toEqual("moneyAmount - id must be defined")
|
||||
})
|
||||
|
||||
it("should return moneyAmount based on config select param", async () => {
|
||||
const moneyAmount = await service.retrieveMoneyAmount(id, {
|
||||
select: ["id", "amount"],
|
||||
})
|
||||
|
||||
const serialized = JSON.parse(JSON.stringify(moneyAmount))
|
||||
|
||||
expect(serialized).toEqual({
|
||||
id,
|
||||
amount,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("deleteMoneyAmounts", () => {
|
||||
const id = "money-amount-USD"
|
||||
|
||||
it("should delete the moneyAmounts given an id successfully", async () => {
|
||||
await service.deleteMoneyAmounts([id])
|
||||
|
||||
const moneyAmounts = await service.listMoneyAmounts({
|
||||
id: [id],
|
||||
})
|
||||
|
||||
expect(moneyAmounts).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe("softDeleteMoneyAmounts", () => {
|
||||
const id = "money-amount-USD"
|
||||
|
||||
it("should softDelete money amounts successfully", async () => {
|
||||
await createPriceSets(testManager)
|
||||
await createRuleTypes(testManager)
|
||||
await createPriceSetMoneyAmounts(testManager)
|
||||
await createPriceRules(testManager)
|
||||
|
||||
await service.softDeleteMoneyAmounts([id])
|
||||
|
||||
const [moneyAmount] = await service.listMoneyAmounts(
|
||||
{ id: [id] },
|
||||
{
|
||||
relations: [
|
||||
"price_set_money_amount",
|
||||
"price_set_money_amount.price_rules",
|
||||
],
|
||||
withDeleted: true,
|
||||
}
|
||||
)
|
||||
|
||||
expect(moneyAmount).toBeTruthy()
|
||||
|
||||
const deletedAt = moneyAmount.deleted_at
|
||||
|
||||
expect(moneyAmount).toEqual(
|
||||
expect.objectContaining({
|
||||
deleted_at: deletedAt,
|
||||
price_set_money_amount: expect.objectContaining({
|
||||
deleted_at: null,
|
||||
price_rules: [
|
||||
expect.objectContaining({
|
||||
deleted_at: null,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("restoreMoneyAmounts", () => {
|
||||
const id = "money-amount-USD"
|
||||
|
||||
it("should restore softDeleted priceSetMoneyAmount and PriceRule when restoring soft-deleting money amount", async () => {
|
||||
await createPriceSets(testManager)
|
||||
await createRuleTypes(testManager)
|
||||
await createPriceSetMoneyAmounts(testManager)
|
||||
await createPriceRules(testManager)
|
||||
await service.softDeleteMoneyAmounts([id])
|
||||
await service.restoreMoneyAmounts([id])
|
||||
|
||||
const [moneyAmount] = await service.listMoneyAmounts(
|
||||
{
|
||||
id: [id],
|
||||
},
|
||||
{
|
||||
relations: [
|
||||
"price_set_money_amount",
|
||||
"price_set_money_amount.price_rules",
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
expect(moneyAmount).toBeTruthy()
|
||||
|
||||
const deletedAt = null
|
||||
|
||||
expect(moneyAmount).toEqual(
|
||||
expect.objectContaining({
|
||||
deleted_at: deletedAt,
|
||||
price_set_money_amount: expect.objectContaining({
|
||||
deleted_at: deletedAt,
|
||||
price_rules: [
|
||||
expect.objectContaining({
|
||||
deleted_at: deletedAt,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("updateMoneyAmounts", () => {
|
||||
const id = "money-amount-USD"
|
||||
|
||||
it("should update the amount of the moneyAmount successfully", async () => {
|
||||
await service.updateMoneyAmounts([
|
||||
{
|
||||
id,
|
||||
amount: 700,
|
||||
},
|
||||
])
|
||||
|
||||
const moneyAmount = JSON.parse(
|
||||
JSON.stringify(
|
||||
await service.retrieveMoneyAmount(id, { select: ["amount"] })
|
||||
)
|
||||
)
|
||||
|
||||
expect(moneyAmount.amount).toEqual(700)
|
||||
})
|
||||
|
||||
it("should update the currency of the moneyAmount successfully", async () => {
|
||||
await service.updateMoneyAmounts([
|
||||
{
|
||||
id,
|
||||
currency_code: "EUR",
|
||||
},
|
||||
])
|
||||
|
||||
const moneyAmount = await service.retrieveMoneyAmount(id, {})
|
||||
|
||||
expect(moneyAmount.currency_code).toEqual("EUR")
|
||||
})
|
||||
|
||||
it("should throw an error when a id does not exist", async () => {
|
||||
let error
|
||||
|
||||
try {
|
||||
await service.updateMoneyAmounts([
|
||||
{
|
||||
id: "does-not-exist",
|
||||
amount: 666,
|
||||
},
|
||||
])
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(
|
||||
'MoneyAmount with id "does-not-exist" not found'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("createMoneyAmounts", () => {
|
||||
it("should create a moneyAmount successfully", async () => {
|
||||
await service.createMoneyAmounts([
|
||||
{
|
||||
id: "money-amount-TESM",
|
||||
currency_code: "USD",
|
||||
amount: 333,
|
||||
min_quantity: 1,
|
||||
max_quantity: 4,
|
||||
},
|
||||
])
|
||||
|
||||
const [moneyAmount] = await service.listMoneyAmounts({
|
||||
id: ["money-amount-TESM"],
|
||||
})
|
||||
|
||||
expect(moneyAmount).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "money-amount-TESM",
|
||||
currency_code: "USD",
|
||||
amount: 333,
|
||||
min_quantity: "1",
|
||||
max_quantity: "4",
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
@@ -270,12 +270,10 @@ moduleIntegrationTestRunner({
|
||||
])
|
||||
|
||||
const [priceList] = await service.listPriceLists(
|
||||
{
|
||||
id: [createdId],
|
||||
},
|
||||
{ id: [createdId] },
|
||||
{
|
||||
relations: [
|
||||
"price_set_money_amounts.money_amount",
|
||||
"price_set_money_amounts",
|
||||
"price_set_money_amounts.price_set",
|
||||
"price_list_rules.price_list_rule_values",
|
||||
"price_list_rules.rule_type",
|
||||
@@ -283,9 +281,9 @@ moduleIntegrationTestRunner({
|
||||
select: [
|
||||
"id",
|
||||
"starts_at",
|
||||
"price_set_money_amounts.money_amount.amount",
|
||||
"price_set_money_amounts.money_amount.currency_code",
|
||||
"price_set_money_amounts.money_amount.price_list_id",
|
||||
"price_set_money_amounts.amount",
|
||||
"price_set_money_amounts.currency_code",
|
||||
"price_set_money_amounts.price_list_id",
|
||||
"price_list_rules.price_list_rule_values.value",
|
||||
"price_list_rules.rule_type.rule_attribute",
|
||||
],
|
||||
@@ -301,10 +299,8 @@ moduleIntegrationTestRunner({
|
||||
price_list: expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
}),
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
]),
|
||||
price_list_rules: expect.arrayContaining([
|
||||
@@ -432,16 +428,16 @@ moduleIntegrationTestRunner({
|
||||
},
|
||||
{
|
||||
relations: [
|
||||
"price_set_money_amounts.money_amount",
|
||||
"price_set_money_amounts",
|
||||
"price_set_money_amounts.price_set",
|
||||
"price_list_rules.price_list_rule_values",
|
||||
"price_list_rules.rule_type",
|
||||
],
|
||||
select: [
|
||||
"id",
|
||||
"price_set_money_amounts.money_amount.amount",
|
||||
"price_set_money_amounts.money_amount.currency_code",
|
||||
"price_set_money_amounts.money_amount.price_list_id",
|
||||
"price_set_money_amounts.amount",
|
||||
"price_set_money_amounts.currency_code",
|
||||
"price_set_money_amounts.price_list_id",
|
||||
"price_list_rules.price_list_rule_values.value",
|
||||
"price_list_rules.rule_type.rule_attribute",
|
||||
],
|
||||
@@ -456,10 +452,8 @@ moduleIntegrationTestRunner({
|
||||
price_list: expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
}),
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
]),
|
||||
price_list_rules: expect.arrayContaining([
|
||||
@@ -540,7 +534,7 @@ moduleIntegrationTestRunner({
|
||||
},
|
||||
{
|
||||
relations: [
|
||||
"price_set_money_amounts.money_amount",
|
||||
"price_set_money_amounts",
|
||||
"price_set_money_amounts.price_set",
|
||||
"price_set_money_amounts.price_rules",
|
||||
"price_list_rules.price_list_rule_values",
|
||||
@@ -550,9 +544,9 @@ moduleIntegrationTestRunner({
|
||||
"id",
|
||||
"price_set_money_amounts.price_rules.value",
|
||||
"price_set_money_amounts.rules_count",
|
||||
"price_set_money_amounts.money_amount.amount",
|
||||
"price_set_money_amounts.money_amount.currency_code",
|
||||
"price_set_money_amounts.money_amount.price_list_id",
|
||||
"price_set_money_amounts.amount",
|
||||
"price_set_money_amounts.currency_code",
|
||||
"price_set_money_amounts.price_list_id",
|
||||
"price_list_rules.price_list_rule_values.value",
|
||||
"price_list_rules.rule_type.rule_attribute",
|
||||
],
|
||||
@@ -574,10 +568,8 @@ moduleIntegrationTestRunner({
|
||||
price_list: expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
}),
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
amount: 400,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
rules_count: 0,
|
||||
@@ -585,10 +577,8 @@ moduleIntegrationTestRunner({
|
||||
price_list: expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
}),
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 600,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
amount: 600,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
]),
|
||||
price_list_rules: expect.arrayContaining([
|
||||
@@ -683,7 +673,7 @@ moduleIntegrationTestRunner({
|
||||
},
|
||||
{
|
||||
relations: [
|
||||
"price_set_money_amounts.money_amount",
|
||||
"price_set_money_amounts",
|
||||
"price_set_money_amounts.price_set",
|
||||
"price_set_money_amounts.price_rules",
|
||||
"price_list_rules.price_list_rule_values",
|
||||
@@ -693,9 +683,9 @@ moduleIntegrationTestRunner({
|
||||
"id",
|
||||
"price_set_money_amounts.price_rules.value",
|
||||
"price_set_money_amounts.rules_count",
|
||||
"price_set_money_amounts.money_amount.amount",
|
||||
"price_set_money_amounts.money_amount.currency_code",
|
||||
"price_set_money_amounts.money_amount.price_list_id",
|
||||
"price_set_money_amounts.amount",
|
||||
"price_set_money_amounts.currency_code",
|
||||
"price_set_money_amounts.price_list_id",
|
||||
"price_list_rules.price_list_rule_values.value",
|
||||
"price_list_rules.rule_type.rule_attribute",
|
||||
],
|
||||
@@ -711,10 +701,8 @@ moduleIntegrationTestRunner({
|
||||
price_list: expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
}),
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 123,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
amount: 123,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
]),
|
||||
price_list_rules: [],
|
||||
@@ -794,7 +782,7 @@ moduleIntegrationTestRunner({
|
||||
},
|
||||
{
|
||||
relations: [
|
||||
"price_set_money_amounts.money_amount",
|
||||
"price_set_money_amounts",
|
||||
"price_set_money_amounts.price_set",
|
||||
"price_set_money_amounts.price_rules",
|
||||
"price_set_money_amounts.price_rules.rule_type",
|
||||
@@ -806,9 +794,9 @@ moduleIntegrationTestRunner({
|
||||
"price_set_money_amounts.price_rules.value",
|
||||
"price_set_money_amounts.price_rules.rule_type.rule_attribute",
|
||||
"price_set_money_amounts.rules_count",
|
||||
"price_set_money_amounts.money_amount.amount",
|
||||
"price_set_money_amounts.money_amount.currency_code",
|
||||
"price_set_money_amounts.money_amount.price_list_id",
|
||||
"price_set_money_amounts.amount",
|
||||
"price_set_money_amounts.currency_code",
|
||||
"price_set_money_amounts.price_list_id",
|
||||
"price_list_rules.price_list_rule_values.value",
|
||||
"price_list_rules.rule_type.rule_attribute",
|
||||
],
|
||||
@@ -832,10 +820,8 @@ moduleIntegrationTestRunner({
|
||||
}),
|
||||
}),
|
||||
],
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 123,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
amount: 123,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
]),
|
||||
price_list_rules: [],
|
||||
@@ -892,7 +878,7 @@ moduleIntegrationTestRunner({
|
||||
{ id: ["price-list-1"] },
|
||||
{
|
||||
relations: [
|
||||
"price_set_money_amounts.money_amount",
|
||||
"price_set_money_amounts",
|
||||
"price_set_money_amounts.price_set",
|
||||
"price_set_money_amounts.price_rules",
|
||||
"price_set_money_amounts.price_rules.rule_type",
|
||||
@@ -904,9 +890,9 @@ moduleIntegrationTestRunner({
|
||||
"price_set_money_amounts.price_rules.value",
|
||||
"price_set_money_amounts.price_rules.rule_type.rule_attribute",
|
||||
"price_set_money_amounts.rules_count",
|
||||
"price_set_money_amounts.money_amount.amount",
|
||||
"price_set_money_amounts.money_amount.currency_code",
|
||||
"price_set_money_amounts.money_amount.price_list_id",
|
||||
"price_set_money_amounts.amount",
|
||||
"price_set_money_amounts.currency_code",
|
||||
"price_set_money_amounts.price_list_id",
|
||||
"price_list_rules.price_list_rule_values.value",
|
||||
"price_list_rules.rule_type.rule_attribute",
|
||||
],
|
||||
@@ -936,10 +922,8 @@ moduleIntegrationTestRunner({
|
||||
price_list: expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
}),
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 123,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
amount: 123,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
]),
|
||||
price_list_rules: [],
|
||||
|
||||
@@ -3,7 +3,6 @@ import { CreatePriceRuleDTO, IPricingModuleService } from "@medusajs/types"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { SuiteOptions, moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { PriceSetMoneyAmount } from "../../../../src"
|
||||
import { createMoneyAmounts } from "../../../__fixtures__/money-amount"
|
||||
import { createPriceRules } from "../../../__fixtures__/price-rule"
|
||||
import { createPriceSets } from "../../../__fixtures__/price-set"
|
||||
import { createPriceSetMoneyAmounts } from "../../../__fixtures__/price-set-money-amount"
|
||||
@@ -22,7 +21,6 @@ moduleIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
testManager = await MikroOrmWrapper.forkManager()
|
||||
|
||||
await createMoneyAmounts(testManager)
|
||||
await createPriceSets(testManager)
|
||||
await createRuleTypes(testManager)
|
||||
await createPriceSetMoneyAmounts(testManager)
|
||||
@@ -274,18 +272,12 @@ moduleIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should create a PriceRule successfully", async () => {
|
||||
const [ma] = await createMoneyAmounts(testManager, [
|
||||
{
|
||||
amount: 100,
|
||||
currency_code: "EUR",
|
||||
},
|
||||
])
|
||||
|
||||
const psma: PriceSetMoneyAmount = testManager.create(
|
||||
PriceSetMoneyAmount,
|
||||
{
|
||||
currency_code: "EUR",
|
||||
amount: 100,
|
||||
price_set_id: "price-set-1",
|
||||
money_amount_id: ma.id,
|
||||
title: "test",
|
||||
rules_count: 0,
|
||||
}
|
||||
|
||||
@@ -86,10 +86,10 @@ moduleIntegrationTestRunner({
|
||||
{
|
||||
select: [
|
||||
"id",
|
||||
"price_set_money_amounts.money_amount.id",
|
||||
"price_set_money_amounts.money_amount.amount",
|
||||
"price_set_money_amounts.id",
|
||||
"price_set_money_amounts.amount",
|
||||
],
|
||||
relations: ["price_set_money_amounts.money_amount"],
|
||||
relations: ["price_set_money_amounts"],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -100,10 +100,8 @@ moduleIntegrationTestRunner({
|
||||
id: "price-set-1",
|
||||
price_set_money_amounts: [
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
id: "money-amount-USD",
|
||||
amount: 500,
|
||||
}),
|
||||
id: "price-set-money-amount-USD",
|
||||
amount: 500,
|
||||
}),
|
||||
],
|
||||
},
|
||||
@@ -148,8 +146,12 @@ moduleIntegrationTestRunner({
|
||||
id: ["price-set-1"],
|
||||
},
|
||||
{
|
||||
select: ["id", "min_quantity", "money_amounts.id"],
|
||||
relations: ["price_set_money_amounts.money_amount"],
|
||||
select: [
|
||||
"id",
|
||||
"price_set_money_amounts.amount",
|
||||
"price_set_money_amounts.id",
|
||||
],
|
||||
relations: ["price_set_money_amounts"],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -161,9 +163,8 @@ moduleIntegrationTestRunner({
|
||||
id: "price-set-1",
|
||||
price_set_money_amounts: [
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
id: "money-amount-USD",
|
||||
}),
|
||||
id: "price-set-money-amount-USD",
|
||||
amount: 500,
|
||||
}),
|
||||
],
|
||||
},
|
||||
@@ -380,10 +381,9 @@ moduleIntegrationTestRunner({
|
||||
],
|
||||
price_set_money_amounts: [
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
rules_count: 1,
|
||||
}),
|
||||
],
|
||||
})
|
||||
@@ -419,16 +419,12 @@ moduleIntegrationTestRunner({
|
||||
],
|
||||
price_set_money_amounts: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 150,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
amount: 150,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
]),
|
||||
})
|
||||
@@ -460,10 +456,8 @@ moduleIntegrationTestRunner({
|
||||
],
|
||||
price_set_money_amounts: [
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
],
|
||||
price_rules: [
|
||||
@@ -540,7 +534,7 @@ moduleIntegrationTestRunner({
|
||||
{
|
||||
relations: [
|
||||
"rule_types",
|
||||
"price_set_money_amounts.money_amount",
|
||||
"price_set_money_amounts",
|
||||
"price_rules",
|
||||
],
|
||||
}
|
||||
@@ -560,10 +554,8 @@ moduleIntegrationTestRunner({
|
||||
],
|
||||
price_set_money_amounts: [
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 500,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
amount: 500,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
],
|
||||
rule_types: [
|
||||
@@ -625,7 +617,7 @@ moduleIntegrationTestRunner({
|
||||
|
||||
const [priceSet] = await service.list(
|
||||
{ id: ["price-set-1"] },
|
||||
{ relations: ["price_set_money_amounts.money_amount"] }
|
||||
{ relations: ["price_set_money_amounts"] }
|
||||
)
|
||||
|
||||
expect(priceSet).toEqual(
|
||||
@@ -633,10 +625,8 @@ moduleIntegrationTestRunner({
|
||||
id: "price-set-1",
|
||||
price_set_money_amounts: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
]),
|
||||
})
|
||||
@@ -669,7 +659,7 @@ moduleIntegrationTestRunner({
|
||||
|
||||
const priceSets = await service.list(
|
||||
{ id: ["price-set-1", "price-set-2"] },
|
||||
{ relations: ["price_set_money_amounts.money_amount"] }
|
||||
{ relations: ["price_set_money_amounts"] }
|
||||
)
|
||||
|
||||
expect(priceSets).toEqual([
|
||||
@@ -677,10 +667,8 @@ moduleIntegrationTestRunner({
|
||||
id: "price-set-1",
|
||||
price_set_money_amounts: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
amount: 100,
|
||||
currency_code: "USD",
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
@@ -688,10 +676,8 @@ moduleIntegrationTestRunner({
|
||||
id: "price-set-2",
|
||||
price_set_money_amounts: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
money_amount: expect.objectContaining({
|
||||
amount: 150,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
amount: 150,
|
||||
currency_code: "EUR",
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user