feat: Add DiscountConditions (#1230)

* feat: Add DiscountCondition entity + Join table per relation (#1146)

* feat: Convert DiscountService to TypeScript (#1149)

* feat: Add DiscountRepository + bulk insert and remove (#1156)

* feat: Add `conditions` to payload in `POST /discounts` and `POST /discounts/:id` (#1170)

* feat: Add DiscountRuleCondition entity

* fix relation

* fix join key

* Add discount rule condition repo

* add join table per relation

* Convert DiscountService to TypeScript

* feat: Add DiscountConditionRepository

* Add migration + remove use of valid_for

* revert changes to files, not done yet

* init work on create discount endpoint

* Add conditions to create discount endpoint

* Add conditions to update discount endpoint

* Add unique constraint to discount condition

* integration tests passing

* fix imports of models

* fix tests (excluding totals calculations)

* Fix commented code

* add unique constraint on discount condition

* Add generic way of generating retrieve configs

* Requested changes + ExactlyOne validator

* Remove isLocal flag from error handler

* Use postgres error constant

* remove commented code

* feat: Add `isValidForProduct` to check if Discount is valid for a given Product (#1172)

* feat: Add `canApplyForCustomer` to check if Discount is valid for customer groups (#1212)

* feat: Add `calculateDiscountForLineItem` (#1224)

* feat: Adds discount condition test factory (#1228)

* Remove use of valid_for

* Tests passing

* Remove valid_for form relations

* Add integration tests for applying discounts to cart
This commit is contained in:
Oliver Windall Juhl
2022-03-24 16:47:50 +01:00
committed by GitHub
parent b7f699654b
commit a610805917
60 changed files with 4805 additions and 2021 deletions
@@ -1,7 +1,6 @@
import SendGrid from "@sendgrid/mail"
import { NotificationService } from "medusa-interfaces"
import { humanizeAmount, zeroDecimalCurrencies } from "medusa-core-utils"
import { NotificationService } from "medusa-interfaces"
class SendGridService extends NotificationService {
static identifier = "sendgrid"
@@ -293,7 +292,7 @@ class SendGridService extends NotificationService {
* @param {string} from - sender of email
* @param {string} to - receiver of email
* @param {Object} data - data to send in mail (match with template)
* @returns {Promise} result of the send operation
* @return {Promise} result of the send operation
*/
async sendEmail(options) {
try {
@@ -321,7 +320,6 @@ class SendGridService extends NotificationService {
"shipping_address",
"discounts",
"discounts.rule",
"discounts.rule.valid_for",
"shipping_methods",
"shipping_methods.shipping_option",
"payments",
@@ -366,7 +364,6 @@ class SendGridService extends NotificationService {
"shipping_address",
"discounts",
"discounts.rule",
"discounts.rule.valid_for",
"shipping_methods",
"shipping_methods.shipping_option",
"payments",
@@ -465,7 +462,6 @@ class SendGridService extends NotificationService {
"shipping_address",
"discounts",
"discounts.rule",
"discounts.rule.valid_for",
"shipping_methods",
"shipping_methods.shipping_option",
"payments",
@@ -624,7 +620,6 @@ class SendGridService extends NotificationService {
"items.tax_lines",
"discounts",
"discounts.rule",
"discounts.rule.valid_for",
"shipping_address",
"returns",
],
@@ -747,7 +742,6 @@ class SendGridService extends NotificationService {
"items",
"discounts",
"discounts.rule",
"discounts.rule.valid_for",
"shipping_address",
"swaps",
"swaps.additional_items",
@@ -875,7 +869,6 @@ class SendGridService extends NotificationService {
"items.tax_lines",
"discounts",
"discounts.rule",
"discounts.rule.valid_for",
"shipping_address",
"swaps",
"swaps.additional_items",
@@ -985,7 +978,6 @@ class SendGridService extends NotificationService {
"items.tax_lines",
"discounts",
"discounts.rule",
"discounts.rule.valid_for",
"swaps",
"swaps.additional_items",
"swaps.additional_items.tax_lines",