Commit 36e14a23 authored by 我在何方's avatar 我在何方

收款单核销数据错误bug

parent 56488a37
...@@ -45,38 +45,27 @@ ...@@ -45,38 +45,27 @@
</tr> </tr>
<tr v-for="(items, indexs) in receiptAccountList" :key="indexs"> <tr v-for="(items, indexs) in receiptAccountList" :key="indexs">
<td><dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="items.collectionCurrencyId" />应收合计</td> <td><dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="items.collectionCurrencyId" />应收合计</td>
<td >{{ `${item.receivableAmount - item.discountTotal }(${item.receivableAmount} - ${item.discountTotal})` }}</td> <td ><span v-if="items.discountTotal>0">{{ `${items.receivableAmount - items.discountTotal }(${items.receivableAmount} - ${items.discountTotal})` }}</span>
<span v-else>{{ `${items.receivableAmount - items.discountTotal }` }}</span>
</td>
<td>汇率</td> <td>汇率</td>
<td>{{ items.collectionRate.toFixed(6)}}</td> <td>{{ items.collectionRate}}</td>
<td>收款金额(<dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="items.collectionCurrencyId" />)</td> <td>收款金额(<dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="items.collectionCurrencyId" />)</td>
<td colspan="3">{{ items.collectionAmount.toFixed(6)}}</td> <td colspan="3">{{ items.collectionAmount}}</td>
</tr> </tr>
</table> </table>
<div style="text-align: center;border-left:1px solid #666;border-right: 1px solid #666;height: 36px;line-height: 36px;"> <div style="text-align: center;border-left:1px solid #666;border-right: 1px solid #666;height: 36px;line-height: 36px;">
银行信息 银行信息
</div> </div>
<div style="display: flex;align-items: center;border-top: 1px solid #666;border-left:1px solid #666;border-right: 1px solid #666;"> <div style="display: flex;align-items: center;border-top: 1px solid #666;border-left:1px solid #666;border-right: 1px solid #666;" v-for="(bankTiem,index) in receiptAccountList" :key="index">
<div style="padding:6px 0;width: 12.5%;text-align: center;border-right: 1px solid #666;"> <div style="padding:6px 0;width: 12.5%;text-align: center;border-right: 1px solid #666;" >
<p style="margin: 0;word-break: break-all;">户名:</p> <p style="margin: 0;word-break: break-all;">户名:{{bankTiem.platformAccountName}}</p>
<p style="margin: 0;word-break: break-all;">银行名称:</p> <p style="margin: 0;word-break: break-all;">银行名称:{{bankTiem.platformAccountBlankName}}</p>
<p style="margin: 0;word-break: break-all;">A/C NO</p> <p style="margin: 0;word-break: break-all;">A/C NO{{bankTiem.platformAccountNo}}</p>
</div> </div>
<div style="padding:6px 0;width: 87.5%;text-align: center;"> <div style="padding:6px 0;width: 87.5%;text-align: center;">
<p style="margin: 0;">应收人民币:¥</p> <p style="margin: 0;">应收<dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="bankTiem.currencyId" />:¥{{bankTiem.receivableAmount}}</p>
<p style="margin: 0;">优惠后人民币:¥</p> <!-- <p style="margin: 0;">未收:¥{{bankTiem.noReceipt}}</p> -->
<p style="margin: 0;">未收:¥</p>
</div>
</div>
<div style="display: flex;align-items: center;border-top: 1px solid #666;border-left:1px solid #666;border-right: 1px solid #666;">
<div style="padding:6px 0;width: 12.5%;text-align: center;border-right: 1px solid #666;">
<p style="margin: 0;word-break: break-all;">户名:</p>
<p style="margin: 0;word-break: break-all;">银行名称:</p>
<p style="margin: 0;word-break: break-all;">A/C NO</p>
</div>
<div style="padding:6px 0;width: 87.5%;text-align: center;">
<p style="margin: 0;">应收美元:$</p>
<p style="margin: 0;">优惠后美元:$</p>
<p style="margin: 0;">未收:$</p>
</div> </div>
</div> </div>
<div style="display: flex;align-items: center;border: 1px solid #666;"> <div style="display: flex;align-items: center;border: 1px solid #666;">
...@@ -106,7 +95,7 @@ ...@@ -106,7 +95,7 @@
import lodop from '@/utils/lodop' import lodop from '@/utils/lodop'
import NP from 'number-precision' import NP from 'number-precision'
import {getOrder} from '@/api/ecw/order' import {getOrder} from '@/api/ecw/order'
import { getReceiptInfoByIds, getInvoicingItem,getReceiptAccountList } from "@/api/ecw/financial"; import { getReceiptInfoByIds, getInvoicingItem,getReceiptAccountList,getReceivableItem} from "@/api/ecw/financial";
export default { export default {
name: "PrintVoucher", name: "PrintVoucher",
...@@ -130,7 +119,8 @@ ...@@ -130,7 +119,8 @@
deptData:[], deptData:[],
deptArr:[], deptArr:[],
id:0, id:0,
orderData:[] orderData:[],
detailed:[]
} }
}, },
async created() { async created() {
...@@ -159,31 +149,32 @@ ...@@ -159,31 +149,32 @@
if(that.$route.query.id){ if(that.$route.query.id){
that.id = that.$route.query.id that.id = that.$route.query.id
that.getCollectionData() that.getCollectionData()
that.getList()
getInvoicingItem({id: this.id}).then(res => { getInvoicingItem({id: this.id}).then(res => {
this.list = res.data this.list = res.data
if(this.list.length>0) this.getOrder(this.list[0].orderId) if(this.list.length>0) this.getOrder(this.list[0].orderId)
}) })
} }
getReceiptAccountList({ id: this.id }).then(res => { getReceiptAccountList({ id: this.id }).then(res => {
if (res.data.length > 0) { // if (res.data.length > 0) {
// totalAmount // // totalAmount
res.data = [...res.data, { // res.data = [...res.data, {
type: 'total', // type: 'total',
writeOffAmount: res.data.reduce((total, currentValue) => NP.plus(total, currentValue.writeOffAmount || 0), 0), // writeOffAmount: res.data.reduce((total, currentValue) => NP.plus(total, currentValue.writeOffAmount || 0), 0),
collectionAmount: [0, 0, 0] // collectionAmount: [0, 0, 0]
}] // }]
} // }
// 收款总计 // 收款总计
const dollarList = res.data.filter(v => v.collectionCurrencyId == 1) // const dollarList = res.data.filter(v => v.collectionCurrencyId == 1)
const dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount || 0), 0) // const dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount || 0), 0)
const rmbList = res.data.filter(v => v.collectionCurrencyId == 2) // const rmbList = res.data.filter(v => v.collectionCurrencyId == 2)
const rmb = rmbList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount || 0), 0) // const rmb = rmbList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount || 0), 0)
const nairaList = res.data.filter(v => v.collectionCurrencyId == 3) // const nairaList = res.data.filter(v => v.collectionCurrencyId == 3)
const naira = nairaList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount || 0), 0) // const naira = nairaList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount || 0), 0)
res.data[res.data.length -1].collectionAmount = [dollar, rmb, naira] // res.data[res.data.length -1].collectionAmount = [dollar, rmb, naira]
// this.$set(this.form, 'receiptAccountList', [...this.form.receiptAccountList]) // this.$set(this.form, 'receiptAccountList', [...this.form.receiptAccountList])
const dollarListByList = this.list.filter(v => v.currencyId === 1) const dollarListByList = this.list.filter(v => v.currencyId === 1)
...@@ -201,8 +192,8 @@ ...@@ -201,8 +192,8 @@
const n = res.data.find(v => v.currencyId == 3) const n = res.data.find(v => v.currencyId == 3)
n && (n.discountTotal = discountNaira) n && (n.discountTotal = discountNaira)
console.log(res.data)
this.$set(this.form, 'receiptAccountList', [...res.data]) this.$set(this, 'receiptAccountList', [...res.data])
this.$nextTick(() => { this.$nextTick(() => {
// this.form.receiptAccountList.forEach((item, index) => { // this.form.receiptAccountList.forEach((item, index) => {
// this.rateChange(item, index) // this.rateChange(item, index)
...@@ -212,6 +203,18 @@ ...@@ -212,6 +203,18 @@
}, },
methods: { methods: {
getList() {
getReceivableItem({ id: this.id }).then(res => {
this.detailed = res.data.map(v => ({
...v,
amountDate: this.parseTime(v.amountDate, '{y}-{m}-{d}'),
accountNo: +v.accountNo,
rate:parseFloat(v.rate).toFixed(6),
attr: v.attr ? v.attr.split(',').map(t => ({ name: t.slice(t.lastIndexOf('/') + 1), url: t })) : []
}))
this.calculation()
})
},
getCollectionData(){ getCollectionData(){
let that = this let that = this
getReceiptInfoByIds({id:that.id}).then(res =>{ getReceiptInfoByIds({id:that.id}).then(res =>{
...@@ -219,6 +222,21 @@ ...@@ -219,6 +222,21 @@
that.form.departmentName = that.deptData.find(v => v.id == that.form.departmentId).name that.form.departmentName = that.deptData.find(v => v.id == that.form.departmentId).name
}) })
}, },
handleAddReceiptItem() {
let recepted = []
this.detailed.forEach(item => {
if(!recepted[item.currencyId]){
recepted[item.currencyId] = item.amount
}else recepted[item.currencyId] = NP.plus(recepted[item.currencyId], item.amount)
})
console.log('rece',recepted)
let collom = []
this.receiptAccountList.forEach(item => {
if(recepted[item.currencyId]){
item.noReceipt = +parseFloat(item.receivableAmount-recepted[item.currencyId])
}
})
},
getOrder(orderId){ getOrder(orderId){
getOrder(orderId).then(response => { getOrder(orderId).then(response => {
this.orderData = response.data this.orderData = response.data
......
...@@ -259,13 +259,13 @@ ...@@ -259,13 +259,13 @@
<template slot="label"> <template slot="label">
{{ $t('核销基准金额') }}<dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="showCurrencyId" /> {{ $t('核销基准金额') }}<dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="showCurrencyId" />
</template> </template>
{{ verificationData.writtenOff.toFixed(6) }} {{ writeOffAmount}}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template slot="label"> <template slot="label">
{{ $t('已核销比例') }}<dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="showCurrencyId" /> {{ $t('已核销比例') }}<dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="showCurrencyId" />
</template> </template>
{{ verificationData.WriteOffProportion }}% {{ WriteOffProportion }}%
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</el-card> </el-card>
...@@ -278,11 +278,15 @@ ...@@ -278,11 +278,15 @@
<el-form ref="addForm" :model="addForm" label-width="150px"> <el-form ref="addForm" :model="addForm" label-width="150px">
<el-form-item :label="$t('收款单号')">{{ form.receiptNo }}</el-form-item> <el-form-item :label="$t('收款单号')">{{ form.receiptNo }}</el-form-item>
<el-form-item :label="$t('剩余应收金额')"> <el-form-item :label="$t('剩余应收金额')">
<div> <template v-if="surplusData.length==0">
<div>{{ remainingAmount.usAmount.toFixed(6) }}{{ $t('美元') }}</div> 0
<div>{{ remainingAmount.rmbAmount.toFixed(6) }}{{ $t('人民币') }}</div> </template>
<div>{{ remainingAmount.nairaAmount.toFixed(6) }}{{ $t('奈拉') }}</div> <div v-else>
<div v-for="(amount, currency) in surplusData" :key="currency">
<span v-if="amount"> {{amount}}<dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="currency" /></span>
</div>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item :label="$t('收款账户')" prop="accountNo" :rules="{ required: true, trigger: ['blur', 'change'], message: $t('收款账户不能为空') }"> <el-form-item :label="$t('收款账户')" prop="accountNo" :rules="{ required: true, trigger: ['blur', 'change'], message: $t('收款账户不能为空') }">
<el-select v-if="!isView" v-model="addForm.accountNo" :placeholder="$t('请选择收款账户')" style="width: 220px" @change="accountChange"> <el-select v-if="!isView" v-model="addForm.accountNo" :placeholder="$t('请选择收款账户')" style="width: 220px" @change="accountChange">
...@@ -439,7 +443,8 @@ export default { ...@@ -439,7 +443,8 @@ export default {
usAmount: 0, usAmount: 0,
rmbAmount: 0, rmbAmount: 0,
nairaAmount: 0 nairaAmount: 0
} },
surplusData:[]
} }
}, },
computed: { computed: {
...@@ -474,6 +479,22 @@ export default { ...@@ -474,6 +479,22 @@ export default {
} }
}) })
return total return total
},
// 已核销总金额
writeOffAmount(){
let total = 0
this.detailed.forEach(item => {
total = NP.plus(total, item.writeOffAmount)
})
return total.toFixed(6)
},
WriteOffProportion(){
let total = 0
this.detailed.forEach(item => {
total = NP.plus(total, item.writeOffAmount)
})
let portion = NP.divide(total,this.form.receiptAccountList.find(item=>item.type=='total').writeOffAmount)
return (portion*100).toFixed(2)
} }
}, },
watch: { watch: {
...@@ -561,41 +582,47 @@ export default { ...@@ -561,41 +582,47 @@ export default {
const nairaList = verificationList.filter(v => v.currencyId === 3) const nairaList = verificationList.filter(v => v.currencyId === 3)
const naira = nairaList.length > 0 ? nairaList.reduce((total, currentValue) => NP.plus(total, currentValue.amount || 0), 0) : 0 const naira = nairaList.length > 0 ? nairaList.reduce((total, currentValue) => NP.plus(total, currentValue.amount || 0), 0) : 0
const usCount = NP.plus(dollar, NP.times(this.RMBtoUS(), rmb), NP.times(this.NANtoUS(), naira)) // const usCount = NP.plus(dollar, NP.times(this.RMBtoUS(), rmb), NP.times(this.NANtoUS(), naira))
const rmbCount = NP.plus(rmb, NP.times(this.UStoRMB(), dollar), NP.times(this.NANtoRMB(), naira)) // const rmbCount = NP.plus(rmb, NP.times(this.UStoRMB(), dollar), NP.times(this.NANtoRMB(), naira))
const nairaCount = NP.plus(naira, NP.times(this.UStoNAN(), dollar), NP.times(this.RMBtoNAN(), rmb)) // const nairaCount = NP.plus(naira, NP.times(this.UStoNAN(), dollar), NP.times(this.RMBtoNAN(), rmb))
this.verificationData.usCount = usCount // this.verificationData.usCount = usCount
this.verificationData.rmbCount = rmbCount // this.verificationData.rmbCount = rmbCount
this.verificationData.nairaCount = nairaCount // this.verificationData.nairaCount = nairaCount
this.verificationData.usCount = dollar
this.verificationData.rmbCount = rmb
this.verificationData.nairaCount = naira
if (this.showCurrencyId === 1) { // 美元 if (verificationList.indexOf(1)>-1) { // 美元
this.verificationData.writtenOff = usCount this.verificationData.writtenOff = dollar
this.verificationData.WriteOffProportion = NP.times(NP.divide(usCount, this.form.receivableTotalAmount), 100) this.verificationData.WriteOffProportion = NP.times(NP.divide(dollar, this.form.receivableTotalAmount), 100)
const remaining = NP.minus(this.form.receivableTotalAmount, usCount) const remaining = NP.minus(this.form.receivableTotalAmount, dollar)
this.remainingAmount = { // this.remainingAmount = {
usAmount: remaining, // usAmount: remaining,
rmbAmount: NP.times(this.UStoRMB(), remaining), // rmbAmount: NP.times(this.UStoRMB(), remaining),
nairaAmount: NP.times(this.UStoNAN(), remaining) // nairaAmount: NP.times(this.UStoNAN(), remaining)
} // }
this.remainingAmount.usAmount = remaining
} else if (this.showCurrencyId === 2) { // 人民币 } else if (this.showCurrencyId === 2) { // 人民币
this.verificationData.writtenOff = rmbCount this.verificationData.writtenOff = rmb
this.verificationData.WriteOffProportion = NP.times(NP.divide(rmbCount, this.form.receivableTotalAmount), 100) this.verificationData.WriteOffProportion = NP.times(NP.divide(rmb, this.form.receivableTotalAmount), 100)
const remaining = NP.minus(this.form.receivableTotalAmount, rmbCount) const remaining = NP.minus(this.form.receivableTotalAmount, rmb)
this.remainingAmount = { // this.remainingAmount = {
usAmount: NP.times(this.RMBtoUS(), remaining), // usAmount: NP.times(this.RMBtoUS(), remaining),
rmbAmount: remaining, // rmbAmount: remaining,
nairaAmount: NP.times(this.RMBtoNAN(), remaining) // nairaAmount: NP.times(this.RMBtoNAN(), remaining)
} // }
this.remainingAmount.rmbAmount = remaining
} else if (this.showCurrencyId === 3) { // 奈拉 } else if (this.showCurrencyId === 3) { // 奈拉
this.verificationData.writtenOff = nairaCount this.verificationData.writtenOff = naira
this.verificationData.WriteOffProportion = NP.times(NP.divide(nairaCount, this.form.receivableTotalAmount), 100) this.verificationData.WriteOffProportion = NP.times(NP.divide(naira, this.form.receivableTotalAmount), 100)
const remaining = NP.minus(this.form.receivableTotalAmount, nairaCount) const remaining = NP.minus(this.form.receivableTotalAmount, naira)
this.remainingAmount = { // this.remainingAmount = {
usAmount: NP.times(this.NANtoUS(), remaining), // usAmount: NP.times(this.NANtoUS(), remaining),
rmbAmount: NP.times(this.NANtoRMB(), remaining), // rmbAmount: NP.times(this.NANtoRMB(), remaining),
nairaAmount: remaining // nairaAmount: remaining
} // }
this.remainingAmount.nairaAmount = remaining
} }
}, },
accountChange(val){ accountChange(val){
...@@ -768,6 +795,47 @@ export default { ...@@ -768,6 +795,47 @@ export default {
this.openAddDialog = false this.openAddDialog = false
}, },
handleAddReceiptItem() { handleAddReceiptItem() {
this.surplusData = []
let recepted = []
this.detailed.forEach(item => {
if(!recepted[item.currencyId]){
recepted[item.currencyId] = item.amount
}else recepted[item.currencyId] = NP.plus(recepted[item.currencyId], item.amount)
})
console.log('rece',recepted)
let collom = []
this.form.receiptAccountList.forEach(item => {
if(item.type!='total'){
if(!collom[item.currencyId]){
collom[item.currencyId] = item.receivableAmount-item.discountTotal
}else collom[item.currencyId] = NP.plus(collom[item.currencyId], item.receivableAmount)
}
})
console.log('collom',collom)
if(recepted.length>collom.length){
recepted.forEach((amount,currency)=>{
if(amount){
if(collom[currency]){
if((collom[currency]-amount)!=0) this.surplusData[currency] = +parseFloat((collom[currency]-amount).toPrecision(12))
}else{
this.surplusData[currency] = -amount
}
}
})
}else{
collom.forEach((amount,currency)=>{
if(amount){
if(recepted[currency]){
if((amount-recepted[currency])!=0) this.surplusData[currency] = +parseFloat((amount-recepted[currency]).toPrecision(12))
}else{
this.surplusData[currency] = amount
}
}
})
}
console.log(this.surplusData)
this.addForm = {} this.addForm = {}
this.openAddDialog = true this.openAddDialog = true
this.isView = false this.isView = false
......
...@@ -193,13 +193,13 @@ ...@@ -193,13 +193,13 @@
> >
<el-button v-if="scope.row.state == 1 || scope.row.state == 2 || scope.row.state == 3" size="mini" type="text" @click="verificationCancelClick(scope.row)">{{ $t('收款') }}</el-button> <el-button v-if="scope.row.state == 1 || scope.row.state == 2 || scope.row.state == 3" size="mini" type="text" @click="verificationCancelClick(scope.row)">{{ $t('收款') }}</el-button>
<el-button v-if="scope.row.state == 0 || scope.row.state == 1" size="mini" type="text" @click="deleteClick(scope.row)">{{ $t('删除') }}</el-button> <el-button v-if="scope.row.state == 0 || scope.row.state == 1" size="mini" type="text" @click="deleteClick(scope.row)">{{ $t('删除') }}</el-button>
<!-- <el-button <el-button
v-if="scope.row.state != 0" v-if="scope.row.state != 0"
size="mini" size="mini"
type="text" type="text"
@click="toprint(scope.row.id)" @click="toprint(scope.row.id)"
>{{ $t('打印') }}</el-button >{{ $t('打印') }}</el-button
> --> >
<el-button <el-button
v-if="scope.row.state != 0" v-if="scope.row.state != 0"
size="mini" size="mini"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment