Merge pull request #1120 from chaotixkilla/fix-individual-discounts
Fix customer active individual discounts
This commit is contained in:
commit
1d523b6762
2 changed files with 4 additions and 4 deletions
|
|
@ -37,8 +37,8 @@ function getAvailableIndividualDiscounts () {
|
|||
}), res))
|
||||
}
|
||||
|
||||
function getCustomerIndividualDiscounts (customerId) {
|
||||
const sql = `SELECT * FROM individual_discounts WHERE customer_id=$1 LIMIT 1`
|
||||
function getCustomerActiveIndividualDiscount (customerId) {
|
||||
const sql = `SELECT * FROM individual_discounts WHERE customer_id=$1 AND soft_deleted=false LIMIT 1`
|
||||
return db.oneOrNone(sql, [customerId]).then(res => {
|
||||
if (!_.isNil(res)) {
|
||||
return {
|
||||
|
|
@ -68,7 +68,7 @@ module.exports = {
|
|||
deletePromoCode,
|
||||
getNumberOfAvailablePromoCodes,
|
||||
getAvailableIndividualDiscounts,
|
||||
getCustomerIndividualDiscounts,
|
||||
getCustomerActiveIndividualDiscount,
|
||||
createIndividualDiscount,
|
||||
deleteIndividualDiscount
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ function addOrUpdateCustomer (req) {
|
|||
})
|
||||
})
|
||||
.then(customer => {
|
||||
return loyalty.getCustomerIndividualDiscounts(customer.id)
|
||||
return loyalty.getCustomerActiveIndividualDiscount(customer.id)
|
||||
.then(discount => ({ ...customer, discount }))
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue