Fix/polish discount (#569)

* formatting and optional "is_dynamic" on updates

* formatting

* uppercasing discount code on update

* multiple regions fail with fixed discounts

* discount testing

* testing

* spelling

* removed comment

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
This commit is contained in:
Philip Korsholm
2021-10-26 13:20:38 +02:00
committed by GitHub
parent 9f1ae87605
commit 68c2a4fe3a
7 changed files with 408 additions and 29 deletions
@@ -46,7 +46,6 @@ describe("POST /admin/discounts", () => {
value: 10,
allocation: "total",
},
is_dynamic: false,
}
)
})
@@ -55,7 +55,7 @@ export default async (req, res) => {
const { discount_id } = req.params
const schema = Validator.object().keys({
code: Validator.string().optional(),
is_dynamic: Validator.boolean().default(false),
is_dynamic: Validator.boolean().optional(),
rule: Validator.object()
.keys({
id: Validator.string().required(),
@@ -86,7 +86,6 @@ export default async (req, res) => {
const discountService = req.scope.resolve("discountService")
await discountService.update(discount_id, value)
const discount = await discountService.retrieve(discount_id, {
select: defaultFields,
relations: defaultRelations,