fix: bill calc
This commit is contained in:
@@ -50,11 +50,11 @@ export class BillsService {
|
||||
|
||||
for (const value of values) {
|
||||
const waterCost = new Decimal(waterRate).mul(value.waterUsage);
|
||||
const sewageCost = waterCost.mul(waterCost);
|
||||
const subtotal = waterCost.add(sewageCost);
|
||||
const sewageCost = waterCost.mul(0.3);
|
||||
const subtotal = waterCost.plus(sewageCost);
|
||||
|
||||
const tax = subtotal.mul(0.1);
|
||||
const totalPrice = subtotal.add(tax);
|
||||
const totalPrice = subtotal.plus(tax);
|
||||
const company = companyMap.get(value.companyId);
|
||||
if (!company) {
|
||||
throw new BadRequestException(CompanyMessage.COMPANY_NOT_FOUND);
|
||||
@@ -73,7 +73,7 @@ export class BillsService {
|
||||
const invoiceItem = em.create(InvoiceItem, {
|
||||
name: "قبض آب",
|
||||
count: value.waterUsage,
|
||||
unitPrice: new Decimal(waterRate),
|
||||
unitPrice: totalPrice,
|
||||
discount: new Decimal(0),
|
||||
totalPrice,
|
||||
invoice,
|
||||
@@ -167,15 +167,14 @@ export class BillsService {
|
||||
|
||||
for (const company of companies) {
|
||||
const subtotal = new Decimal(chargeRate).mul(company.metrage);
|
||||
const tax = subtotal.mul(0.1);
|
||||
const totalPrice = subtotal.add(tax);
|
||||
const totalPrice = subtotal;
|
||||
|
||||
const invoice = em.create(Invoice, {
|
||||
company,
|
||||
totalPrice,
|
||||
originalPrice: totalPrice,
|
||||
dueDate,
|
||||
tax,
|
||||
tax: new Decimal(0),
|
||||
business,
|
||||
bill,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user