feat: add separate calc vat field

This commit is contained in:
Methapon2001 2025-01-27 11:50:16 +07:00
parent 3b60582e66
commit 8535924d53
3 changed files with 22 additions and 4 deletions

View file

@ -1103,10 +1103,16 @@ model Product {
price Float
agentPrice Float
serviceCharge Float
vatIncluded Boolean?
expenseType String?
calcVat Boolean @default(true)
vatIncluded Boolean @default(true)
calcVat Boolean @default(true)
agentPriceVatIncluded Boolean? @default(true)
agentPriceCalcVat Boolean? @default(true)
serviceChargeVatIncluded Boolean? @default(true)
serviceChargeCalcVat Boolean? @default(true)
status Status @default(CREATED)
statusOrder Int @default(0)

View file

@ -58,6 +58,10 @@ type ProductCreate = {
serviceCharge: number;
vatIncluded?: boolean;
calcVat?: boolean;
agentPriceVatIncluded?: boolean;
agentPriceCalcVat?: boolean;
serviceChargeVatIncluded?: boolean;
serviceChargeCalcVat?: boolean;
expenseType?: string;
selectedImage?: string;
shared?: boolean;
@ -77,6 +81,10 @@ type ProductUpdate = {
remark?: string;
vatIncluded?: boolean;
calcVat?: boolean;
agentPriceVatIncluded?: boolean;
agentPriceCalcVat?: boolean;
serviceChargeVatIncluded?: boolean;
serviceChargeCalcVat?: boolean;
expenseType?: string;
selectedImage?: string;
shared?: boolean;

View file

@ -478,9 +478,11 @@ export class QuotationController extends Controller {
const list = body.productServiceList.map((v, i) => {
const p = product.find((p) => p.id === v.productId)!;
const vatIncluded = body.agentPrice ? p.agentPriceVatIncluded : p.vatIncluded;
const originalPrice = body.agentPrice ? p.agentPrice : p.price;
const finalPriceWithVat = precisionRound(
originalPrice + (p.vatIncluded ? 0 : originalPrice * VAT_DEFAULT),
originalPrice + (vatIncluded ? 0 : originalPrice * VAT_DEFAULT),
);
const price = finalPriceWithVat;
@ -743,9 +745,11 @@ export class QuotationController extends Controller {
const list = body.productServiceList?.map((v, i) => {
const p = product.find((p) => p.id === v.productId)!;
const vatIncluded = record.agentPrice ? p.agentPriceVatIncluded : p.vatIncluded;
const originalPrice = record.agentPrice ? p.agentPrice : p.price;
const finalPriceWithVat = precisionRound(
originalPrice + (p.vatIncluded ? 0 : originalPrice * VAT_DEFAULT),
originalPrice + (vatIncluded ? 0 : originalPrice * VAT_DEFAULT),
);
const price = finalPriceWithVat;