fix: wrong condition
This commit is contained in:
parent
0410c56060
commit
82fd331205
1 changed files with 3 additions and 6 deletions
|
|
@ -156,7 +156,7 @@ export class QuotationPayment extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const paymentSum = await prisma.payment.aggregate({
|
const paymentSum = await tx.payment.aggregate({
|
||||||
_sum: { amount: true },
|
_sum: { amount: true },
|
||||||
where: {
|
where: {
|
||||||
invoice: {
|
invoice: {
|
||||||
|
|
@ -166,10 +166,6 @@ export class QuotationPayment extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (body.paymentStatus === "PaymentSuccess") {
|
|
||||||
paymentSum._sum.amount = (paymentSum._sum.amount || 0) + payment.amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
await tx.quotation.update({
|
await tx.quotation.update({
|
||||||
where: { id: quotation.id },
|
where: { id: quotation.id },
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -178,7 +174,8 @@ export class QuotationPayment extends Controller {
|
||||||
? "PaymentSuccess"
|
? "PaymentSuccess"
|
||||||
: "PaymentInProcess",
|
: "PaymentInProcess",
|
||||||
requestData:
|
requestData:
|
||||||
quotation.quotationStatus === "PaymentPending"
|
body.paymentStatus === "PaymentSuccess" &&
|
||||||
|
(paymentSum._sum.amount || 0) - payment.amount <= 0
|
||||||
? {
|
? {
|
||||||
create: quotation.worker.map((v) => ({
|
create: quotation.worker.map((v) => ({
|
||||||
employeeId: v.employeeId,
|
employeeId: v.employeeId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue