|
|
@ -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}) |
|
|
|