Merge branch 'hotfix/gift-card-creation' into develop

This commit is contained in:
Sebastian Rindom
2021-03-08 16:14:22 +01:00
4 changed files with 88 additions and 9 deletions
@@ -381,6 +381,10 @@ class SendGridService extends NotificationService {
relations: ["region", "order"],
})
if (!giftCard.order) {
return
}
const taxRate = giftCard.region.tax_rate / 100
return {
@@ -20,9 +20,12 @@ export default async (req, res) => {
try {
const giftCardService = req.scope.resolve("giftCardService")
await giftCardService.create(value)
const newly = await giftCardService.create({
...value,
balance: value.value,
})
const giftCard = await giftCardService.retrieve(id, {
const giftCard = await giftCardService.retrieve(newly.id, {
select: defaultFields,
relations: defaultRelations,
})
@@ -108,13 +108,6 @@ class GiftCardService extends BaseService {
)
}
if (!giftCard.order_id) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Gift card is missing order_id`
)
}
// Will throw if region does not exist
const region = await this.regionService_.retrieve(giftCard.region_id)