feat: detect if agent price

This commit is contained in:
Methapon2001 2025-01-09 16:02:41 +07:00
parent d5e0c56da3
commit 77dbdac012

View file

@ -273,11 +273,17 @@ export class CreditNoteController extends Controller {
(v) => v.productId === c.productService.productId, (v) => v.productId === c.productService.productId,
)?.stepCount; )?.stepCount;
const successCount = c.stepStatus.filter((v) => v.workStatus === "Completed").length; const successCount = c.stepStatus.filter(
(v) => v.workStatus === RequestWorkStatus.Completed,
).length;
const price = c.request.quotation.agentPrice ? "price" : "agentPrice";
if (serviceChargeStepCount && successCount) { if (serviceChargeStepCount && successCount) {
return ( return (
a + c.productService.product.price - c.productService.product.serviceCharge * successCount a +
c.productService.product[price] -
c.productService.product.serviceCharge * successCount
); );
} }
return a + c.productService.product.price; return a + c.productService.product.price;
@ -400,11 +406,17 @@ export class CreditNoteController extends Controller {
(v) => v.productId === c.productService.productId, (v) => v.productId === c.productService.productId,
)?.stepCount; )?.stepCount;
const successCount = c.stepStatus.filter((v) => v.workStatus === "Completed").length; const successCount = c.stepStatus.filter(
(v) => v.workStatus === RequestWorkStatus.Completed,
).length;
const price = c.request.quotation.agentPrice ? "price" : "agentPrice";
if (serviceChargeStepCount && successCount) { if (serviceChargeStepCount && successCount) {
return ( return (
a + c.productService.product.price - c.productService.product.serviceCharge * successCount a +
c.productService.product[price] -
c.productService.product.serviceCharge * successCount
); );
} }
return a + c.productService.product.price; return a + c.productService.product.price;