feat: add separate calc vat field
This commit is contained in:
parent
3b60582e66
commit
8535924d53
3 changed files with 22 additions and 4 deletions
|
|
@ -1103,11 +1103,17 @@ model Product {
|
||||||
price Float
|
price Float
|
||||||
agentPrice Float
|
agentPrice Float
|
||||||
serviceCharge Float
|
serviceCharge Float
|
||||||
vatIncluded Boolean?
|
|
||||||
expenseType String?
|
expenseType String?
|
||||||
|
|
||||||
|
vatIncluded Boolean @default(true)
|
||||||
calcVat 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)
|
status Status @default(CREATED)
|
||||||
statusOrder Int @default(0)
|
statusOrder Int @default(0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,10 @@ type ProductCreate = {
|
||||||
serviceCharge: number;
|
serviceCharge: number;
|
||||||
vatIncluded?: boolean;
|
vatIncluded?: boolean;
|
||||||
calcVat?: boolean;
|
calcVat?: boolean;
|
||||||
|
agentPriceVatIncluded?: boolean;
|
||||||
|
agentPriceCalcVat?: boolean;
|
||||||
|
serviceChargeVatIncluded?: boolean;
|
||||||
|
serviceChargeCalcVat?: boolean;
|
||||||
expenseType?: string;
|
expenseType?: string;
|
||||||
selectedImage?: string;
|
selectedImage?: string;
|
||||||
shared?: boolean;
|
shared?: boolean;
|
||||||
|
|
@ -77,6 +81,10 @@ type ProductUpdate = {
|
||||||
remark?: string;
|
remark?: string;
|
||||||
vatIncluded?: boolean;
|
vatIncluded?: boolean;
|
||||||
calcVat?: boolean;
|
calcVat?: boolean;
|
||||||
|
agentPriceVatIncluded?: boolean;
|
||||||
|
agentPriceCalcVat?: boolean;
|
||||||
|
serviceChargeVatIncluded?: boolean;
|
||||||
|
serviceChargeCalcVat?: boolean;
|
||||||
expenseType?: string;
|
expenseType?: string;
|
||||||
selectedImage?: string;
|
selectedImage?: string;
|
||||||
shared?: boolean;
|
shared?: boolean;
|
||||||
|
|
|
||||||
|
|
@ -478,9 +478,11 @@ export class QuotationController extends Controller {
|
||||||
const list = body.productServiceList.map((v, i) => {
|
const list = body.productServiceList.map((v, i) => {
|
||||||
const p = product.find((p) => p.id === v.productId)!;
|
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 originalPrice = body.agentPrice ? p.agentPrice : p.price;
|
||||||
const finalPriceWithVat = precisionRound(
|
const finalPriceWithVat = precisionRound(
|
||||||
originalPrice + (p.vatIncluded ? 0 : originalPrice * VAT_DEFAULT),
|
originalPrice + (vatIncluded ? 0 : originalPrice * VAT_DEFAULT),
|
||||||
);
|
);
|
||||||
|
|
||||||
const price = finalPriceWithVat;
|
const price = finalPriceWithVat;
|
||||||
|
|
@ -743,9 +745,11 @@ export class QuotationController extends Controller {
|
||||||
const list = body.productServiceList?.map((v, i) => {
|
const list = body.productServiceList?.map((v, i) => {
|
||||||
const p = product.find((p) => p.id === v.productId)!;
|
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 originalPrice = record.agentPrice ? p.agentPrice : p.price;
|
||||||
const finalPriceWithVat = precisionRound(
|
const finalPriceWithVat = precisionRound(
|
||||||
originalPrice + (p.vatIncluded ? 0 : originalPrice * VAT_DEFAULT),
|
originalPrice + (vatIncluded ? 0 : originalPrice * VAT_DEFAULT),
|
||||||
);
|
);
|
||||||
|
|
||||||
const price = finalPriceWithVat;
|
const price = finalPriceWithVat;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue