Browse Source

YT-2596tofixed四舍五入问题

intex_online20250522
张立 3 weeks ago
parent
commit
0553ba19d4
  1. 60
      src/views/wms/deliversettlementManage/customerSaleInvoiceRequestMain/CustomerSaleInvoiceBasicForm.vue
  2. 8
      src/views/wms/deliversettlementManage/customerSaleInvoiceRequestMain/index.vue

60
src/views/wms/deliversettlementManage/customerSaleInvoiceRequestMain/CustomerSaleInvoiceBasicForm.vue

@ -61,17 +61,17 @@
async (formRef, formModel, tableData) => {
const { taxRate = 0,moldUntaxedAmount=0 } = formModel
// 1 mainBeforeTaxAmount : *
let mainBeforeTaxAmount = tableData.reduce((prev, item) =>prev + Number((Number(item['sumPrice'])*Number(item['qty'])).toFixed(2)),0).toFixed(2)
let mainBeforeTaxAmount = Math.round(tableData.reduce((prev, item) =>prev + Number( Math.round((Number(item['sumPrice'])*Number(item['qty'])) * 100) / 100),0) * 100) / 100
// 2 mainTaxAmount = *
let mainTaxAmount = tableData.reduce((prev, item) =>prev + Number((Number(item['beforeTaxAmount'])*Number(taxRate)*0.01).toFixed(2)),0).toFixed(2)
let mainTaxAmount = Math.round(tableData.reduce((prev, item) =>prev + Number(Math.round((Number(item['beforeTaxAmount'])*Number(taxRate)*0.01)* 100) / 100),0)* 100) / 100
// 5 materialsUntaxedAmount : *
let materialsUntaxedAmount = tableData.reduce((prev, item) =>prev + Number((Number(item['price'])*Number(item['qty'])).toFixed(2)),0).toFixed(2)
let materialsUntaxedAmount = Math.round(tableData.reduce((prev, item) =>prev + Number(Math.round((Number(item['price'])*Number(item['qty']))* 100) / 100),0)* 100) / 100
// 6 materialsTaxAmount = * *
let materialsTaxAmount = tableData.reduce((prev, item) => prev + Number((Number((Number(item['price']) * Number(item['qty'])).toFixed(2)) * Number(taxRate) * 0.01).toFixed(2)), 0).toFixed(2)
let materialsTaxAmount = Math.round(tableData.reduce((prev, item) => prev + Number(Math.round((Number(Math.round((Number(item['price']) * Number(item['qty']))* 100) / 100) * Number(taxRate) * 0.01)* 100) / 100), 0)* 100) / 100
//  7= *
let alreadyMoldUntaxedAmount = tableData.reduce((prev, item) =>prev + Number((Number(item['allocationPrice'])*Number(item['qty'])).toFixed(2)),0).toFixed(2)
let alreadyMoldUntaxedAmount = Math.round(tableData.reduce((prev, item) =>prev + Number(Math.round((Number(item['allocationPrice'])*Number(item['qty']))* 100) / 100),0)* 100) / 100
// 8 alreadyMoldTaxAmount == * *
let alreadyMoldTaxAmount = tableData.reduce((prev, item) => prev + Number((Number((Number(item['allocationPrice']) * Number(item['qty'])).toFixed(2)) * Number(taxRate) * 0.01).toFixed(2)), 0).toFixed(2)
let alreadyMoldTaxAmount = Math.round(tableData.reduce((prev, item) => prev + Number(Math.round((Number(Math.round((Number(item['allocationPrice']) * Number(item['qty']))* 100) / 100) * Number(taxRate) * 0.01)* 100) / 100), 0)* 100) / 100
const allAmountNum = await getAllocationAmount(formModel.customerStatementNumber)
const sumObject = {
@ -80,7 +80,7 @@
//
taxAmount:mainTaxAmount,
// mainAdTaxAmount =+
adTaxAmount: (Number(mainBeforeTaxAmount) + Number(mainTaxAmount)).toFixed(2),
adTaxAmount: Math.round((Number(mainBeforeTaxAmount) + Number(mainTaxAmount))* 100) / 100,
//
moldUntaxedAmount:allAmountNum.moldUntaxedAmount,
//
@ -92,17 +92,17 @@
// -
materialsTaxAmount: materialsTaxAmount,
// -= +
materialsTaxTotal: (Number(materialsUntaxedAmount) + Number(materialsTaxAmount)).toFixed(2),
materialsTaxTotal: Math.round((Number(materialsUntaxedAmount) + Number(materialsTaxAmount))* 100) / 100,
//
alreadyMoldUntaxedAmount: alreadyMoldUntaxedAmount,
//
alreadyMoldTaxAmount: alreadyMoldTaxAmount,
// =-
moldTaxAmountDiff: (Number(alreadyMoldUntaxedAmount) - Number(allAmountNum.moldUntaxedAmount)).toFixed(2),
moldTaxAmountDiff: Math.round((Number(alreadyMoldUntaxedAmount) - Number(allAmountNum.moldUntaxedAmount))* 100) / 100,
// =+
alreadyMoldTaxTotal: (Number(alreadyMoldUntaxedAmount) + Number(alreadyMoldTaxAmount)).toFixed(2),
alreadyMoldTaxTotal: Math.round((Number(alreadyMoldUntaxedAmount) + Number(alreadyMoldTaxAmount))* 100) / 100,
// alreadyMoldTaxAmount = -
moldTaxAmountDifference: (Number(allAmountNum.moldTaxAmount) - Number(alreadyMoldTaxAmount)).toFixed(2),
moldTaxAmountDifference: Math.round((Number(allAmountNum.moldTaxAmount) - Number(alreadyMoldTaxAmount))* 100) / 100,
}
formRef.value.setValues(sumObject)
}
@ -169,7 +169,7 @@ const onChange =async (field, cur, formRefParams)=>{
const allAmountNum = await getAllocationAmount(formRef.value.formRef.formModel.customerStatementNumber)
console.log(99,allAmountNum)
// // 2. mainTaxAmount = */100
// let mainTaxAmount = Number(beforeTaxAmount*taxRate*0.01).toFixed(2)
// let mainTaxAmount = Math.round(Number(beforeTaxAmount*taxRate*0.01)* 100) / 100
formRef.value.formRef.setValues({
beforeTaxAmount: allAmountNum.beforeTaxAmount,
//
@ -196,8 +196,8 @@ const onChange =async (field, cur, formRefParams)=>{
moldTaxAmountDiff: allAmountNum.moldTaxAmountDiff,
// =+
alreadyMoldTaxTotal: allAmountNum.alreadyMoldTaxTotal,
// alreadyMoldTaxAmount = -
moldTaxAmountDifference: (Number(allAmountNum.moldTaxAmount) - Number(allAmountNum.alreadyMoldTaxAmount)).toFixed(2),
// alreadyMoldTaxAmount = -
moldTaxAmountDifference: Math.round((Number(allAmountNum.moldTaxAmount) - Number(allAmountNum.alreadyMoldTaxAmount))* 100) / 100,
})
}
} else if (field == 'invoiceType') {
@ -214,7 +214,7 @@ const inputNumberChange = (field, index, row, val) => {
row['allocationPrice'] = row['beforeTaxAmount']/row['qty'] - row['price']
// = +
row['sumPrice'] = (row['price'] + row['allocationPrice']).toFixed(11)
row['sumPrice'] =Math.round((row['price'] + row['allocationPrice'])* 100000000000) / 100000000000
// taxAmount */100,2
row['taxAmount'] = (row['beforeTaxAmount'] * formRef.value.formRef.formModel['taxRate'])/100 //
@ -349,9 +349,9 @@ const searchTableSuccess = (formField, searchField, val, formRef, type, row ) =>
//
const initTableDataPrice = ()=>{
tableData.value.forEach(item=>{
item['sumPrice'] = (item['price'] + item['allocationPrice']).toFixed(11)
item['sumPrice'] = Math.round((item['price'] + item['allocationPrice'])* 100000000000) / 100000000000
// *2
item['beforeTaxAmount'] = Number(new Decimal(Number(item['sumPrice'])).mul(new Decimal(item['qty'])).toNumber().toFixed(2))
item['beforeTaxAmount'] = Math.round((new Decimal(Number(item['sumPrice'])).mul(new Decimal(item['qty'])).toNumber())* 100) / 100
// taxAmount */100,2
item['taxAmount'] = (item['beforeTaxAmount'] * formRef.value.formRef.formModel['taxRate'])/100 //
@ -389,31 +389,31 @@ const getAllocationAmount = async (customerStatementNumber) => {
const res = await CustomerSaleInvoiceMainApi.getAllocationAmount(curNumber.value,customerStatementNumber, formRef.value.formRef.formModel.taxRate)
return {
//
beforeTaxAmount:res?.mainBeforeTaxAmount?.toFixed(2) || '',
beforeTaxAmount:res?.mainBeforeTaxAmount ? Math.round(res?.mainBeforeTaxAmount * 100) / 100 : '',
//
taxAmount:res?.mainTaxAmount?.toFixed(2) || '',
taxAmount:res?.mainTaxAmount ? Math.round(res?.mainTaxAmount * 100) / 100 : '',
// mainAdTaxAmount =+
adTaxAmount: res?.mainAdTaxAmount?.toFixed(2) || '',
adTaxAmount: res?.mainAdTaxAmount?Math.round(res?.mainAdTaxAmount * 100) / 100 : '',
//
moldUntaxedAmount:res?.moldUntaxedAmount?.toFixed(2) || '',
moldUntaxedAmount:res?.moldUntaxedAmount? Math.round(res?.moldUntaxedAmount * 100) / 100 :'',
//
moldTaxAmount:res?.moldTaxAmount?.toFixed(2) || '',
moldTaxAmount:res?.moldTaxAmount?Math.round(res?.moldTaxAmount * 100) / 100 : '',
//
moldTaxTotal:res?.moldTaxTotal?.toFixed(2) || '',
moldTaxTotal:res?.moldTaxTotal?Math.round(res?.moldTaxTotal * 100) / 100: '',
// -
materialsUntaxedAmount: res?.materialsUntaxedAmount?.toFixed(2) || '',
materialsUntaxedAmount: res?.materialsUntaxedAmount?Math.round(res?.materialsUntaxedAmount * 100) / 100 : '',
// -
materialsTaxAmount: res?.materialsTaxAmount?.toFixed(2) || '',
materialsTaxAmount: res?.materialsTaxAmount? Math.round(res?.materialsTaxAmount * 100) / 100 : '',
// -= +
materialsTaxTotal:res?.materialsTaxTotal?.toFixed(2) || '',
materialsTaxTotal:res?.materialsTaxTotal? Math.round(res?.materialsTaxTotal * 100) / 100: '',
//
alreadyMoldUntaxedAmount: res?.alreadyMoldUntaxedAmount?.toFixed(2) || '',
alreadyMoldUntaxedAmount: res?.alreadyMoldUntaxedAmount? Math.round(res?.alreadyMoldUntaxedAmount * 100) / 100 :'',
//
alreadyMoldTaxAmount: res?.alreadyMoldTaxAmount?.toFixed(2) || '',
alreadyMoldTaxAmount: res?.alreadyMoldTaxAmount ? Math.round(res?.alreadyMoldTaxAmount * 100) / 100: '',
// =-
moldTaxAmountDiff: res?.moldTaxAmountDiff?.toFixed(2) || '',
moldTaxAmountDiff: res?.moldTaxAmountDiff?Math.round(res?.moldTaxAmountDiff * 100) / 100: '',
// =+
alreadyMoldTaxTotal: res?.alreadyMoldTaxTotal?.toFixed(2) || '',
alreadyMoldTaxTotal: res?.alreadyMoldTaxTotal? Math.round(res?.alreadyMoldTaxTotal * 100) / 100 : '',
}
}
defineExpose({openForm,openFormTable})

8
src/views/wms/deliversettlementManage/customerSaleInvoiceRequestMain/index.vue

@ -64,13 +64,13 @@
@handleMainFefresh='handleMainFefresh'
>
<template #taxAmount="scrop">
{{scrop.row.taxAmount.toFixed(2)}}
{{ Math.round(scrop.row.taxAmount * 100) / 100}}
</template>
<template #afterTaxAmount="scrop">
{{scrop.row.afterTaxAmount.toFixed(2)}}
{{Math.round(scrop.row.afterTaxAmount * 100) / 100}}
</template>
<template #beforeTaxAmount="scrop">
{{scrop.row.beforeTaxAmount.toFixed(2)}}
{{Math.round(scrop.row.beforeTaxAmount * 100) / 100}}
</template>
</Detail>
@ -351,7 +351,7 @@ const detailBasicFormOnChange = (field, cur, formRef1) => {
const { beforeTaxAmount = 0, taxAmount = 0, qty = 0, price, allocationPrice, taxRate = 1 } = formRef1.value.formModel
formRef1.value.setValues({
// = +,2
afterTaxAmount: Number((Number(beforeTaxAmount) + Number(taxAmount)).toFixed(2)),
afterTaxAmount: Math.round((Number(beforeTaxAmount) + Number(taxAmount)) * 100) / 100,
// /-
allocationPrice: Number(Number(Number(beforeTaxAmount)/Number(qty)) - Number(price)),
// = +

Loading…
Cancel
Save