fix: calculate credit note price
This commit is contained in:
parent
d51531cd4d
commit
1486ce79ab
1 changed files with 8 additions and 7 deletions
|
|
@ -13,6 +13,7 @@ import {
|
|||
Security,
|
||||
Tags,
|
||||
} from "tsoa";
|
||||
import config from "../config.json";
|
||||
|
||||
import prisma from "../db";
|
||||
|
||||
|
|
@ -53,6 +54,7 @@ function globalAllow(user: RequestWithUser["user"]) {
|
|||
const listAllowed = ["system", "head_of_admin", "admin", "executive", "accountant"];
|
||||
return user.roles?.some((v) => listAllowed.includes(v)) || false;
|
||||
}
|
||||
const VAT_DEFAULT = config.vat;
|
||||
|
||||
const permissionCond = createPermCondition(globalAllow);
|
||||
const permissionCheck = createPermCheck(globalAllow);
|
||||
|
|
@ -346,9 +348,9 @@ export class CreditNoteController extends Controller {
|
|||
).length;
|
||||
|
||||
const price =
|
||||
c.productService.pricePerUnit -
|
||||
c.productService.discount / c.productService.amount +
|
||||
c.productService.vat / c.productService.amount;
|
||||
c.productService.pricePerUnit *
|
||||
(1 + (c.productService.product.serviceChargeCalcVat ? VAT_DEFAULT : 0)) -
|
||||
c.productService.discount;
|
||||
|
||||
if (serviceChargeStepCount && successCount) {
|
||||
return a + price - c.productService.product.serviceCharge * successCount;
|
||||
|
|
@ -424,7 +426,6 @@ export class CreditNoteController extends Controller {
|
|||
let textData = "";
|
||||
|
||||
let dataCustomerId: string[] = [];
|
||||
let textWorkList: string[] = [];
|
||||
let dataUserId: string[] = [];
|
||||
|
||||
if (res) {
|
||||
|
|
@ -541,9 +542,9 @@ export class CreditNoteController extends Controller {
|
|||
).length;
|
||||
|
||||
const price =
|
||||
c.productService.pricePerUnit -
|
||||
c.productService.discount / c.productService.amount +
|
||||
c.productService.vat / c.productService.amount;
|
||||
c.productService.pricePerUnit *
|
||||
(1 + (c.productService.product.serviceChargeCalcVat ? VAT_DEFAULT : 0)) -
|
||||
c.productService.discount;
|
||||
|
||||
if (serviceChargeStepCount && successCount) {
|
||||
return a + price - c.productService.product.serviceCharge * successCount;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue