feat(finance): 优化应付单付款与收票逻辑
- 修改计算工具函数,确保数值运算精度 - 更新应付单页面字段映射,统一命名规范 - 增加税率输入框并同步到库存信息 - 调整应付单合并支付与收票计划的处理方式 - 完善应付单实体类结构及数据库映射关系 - 优化采购订单关联应付单的生成逻辑 - 引入厂家开票时间字段以完善票据管理流程dev_1.0.0
parent
a19909d1bf
commit
3e45254fc1
|
|
@ -19,17 +19,17 @@ export function toFixed(value, dp = DEFAULT_DP) {
|
||||||
|
|
||||||
// 加法
|
// 加法
|
||||||
export function add(a, b, dp = DEFAULT_DP) {
|
export function add(a, b, dp = DEFAULT_DP) {
|
||||||
return D(a).plus(b).toDecimalPlaces(dp).toNumber()
|
return D(a).plus(D(b)).toDecimalPlaces(dp).toNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 减法
|
// 减法
|
||||||
export function sub(a, b, dp = DEFAULT_DP) {
|
export function sub(a, b, dp = DEFAULT_DP) {
|
||||||
return D(a).minus(b).toDecimalPlaces(dp).toNumber()
|
return D(a).minus(D(b)).toDecimalPlaces(dp).toNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 乘法
|
// 乘法
|
||||||
export function mul(a, b, dp = DEFAULT_DP) {
|
export function mul(a, b, dp = DEFAULT_DP) {
|
||||||
return D(a).times(b).toDecimalPlaces(dp).toNumber()
|
return D(a).times(D(b)).toDecimalPlaces(dp).toNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 除法
|
// 除法
|
||||||
|
|
|
||||||
|
|
@ -50,24 +50,24 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<div class="detail-item"><strong>未付款金额:</strong> {{ formData.unpaidAmount }}</div>
|
<div class="detail-item"><strong>未付款金额:</strong> {{ formData.unpaidPaymentAmount }}</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<div class="detail-item"><strong>已付款金额:</strong> {{ formData.paidAmount }}</div>
|
<div class="detail-item"><strong>已付款金额:</strong> {{ formData.paidPaymentAmount }}</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<div class="detail-item"><strong>付款中金额:</strong> {{ formData.payingAmount }}</div>
|
<div class="detail-item"><strong>付款中金额:</strong> {{ this.$calc.sub(this.$calc.sub(formData.totalPriceWithTax,formData.paidPaymentAmount),formData.unpaidPaymentAmount) }}</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<div class="detail-item"><strong>未收票金额:</strong> {{ formData.unInvoicedAmount }}</div>
|
<div class="detail-item"><strong>未收票金额:</strong> {{ formData.unreceivedTicketAmount }}</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<div class="detail-item"><strong>已收票金额:</strong> {{ formData.invoicedAmount }}</div>
|
<div class="detail-item"><strong>已收票金额:</strong> {{ formData.receivedTicketAmount }}</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<div class="detail-item"><strong>收票中金额:</strong> {{ formData.invoicingAmount }}</div>
|
<div class="detail-item"><strong>收票中金额:</strong> {{ this.$calc.sub(this.$calc.sub(formData.totalPriceWithTax,formData.receivedTicketAmount),formData.unreceivedTicketAmount)}}</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,8 @@
|
||||||
<el-divider content-position="left">采购应付单表</el-divider>
|
<el-divider content-position="left">采购应付单表</el-divider>
|
||||||
<el-table :data="payableOrdersWithPlans" border max-height="300px" style="margin-bottom: 20px;">
|
<el-table :data="payableOrdersWithPlans" border max-height="300px" style="margin-bottom: 20px;">
|
||||||
<el-table-column label="应付单编号" align="center" prop="payableBillCode" width="150"/>
|
<el-table-column label="应付单编号" align="center" prop="payableBillCode" width="150"/>
|
||||||
<el-table-column label="预计付款时间" align="center" prop="estimatedPaymentTime" width="180"/>
|
<el-table-column label="预计付款时间" align="center" prop="planPaymentDate" width="180"/>
|
||||||
<el-table-column label="付款计划" align="center" width="100">
|
<el-table-column label="付款计划" align="center" width="100" prop="planAmount">
|
||||||
<template slot-scope="scope">
|
|
||||||
<span>{{ scope.row.paymentPlans ? scope.row.paymentPlans.length : 0 }} 条计划</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="项目名称" align="center" prop="projectName" width="150"/>
|
<el-table-column label="项目名称" align="center" prop="projectName" width="150"/>
|
||||||
<el-table-column label="合同编号" align="center" prop="orderCode" width="150"/>
|
<el-table-column label="合同编号" align="center" prop="orderCode" width="150"/>
|
||||||
|
|
@ -192,24 +189,35 @@ export default {
|
||||||
this.form.paymentBillType = 'FROM_PAYABLE'; // Default
|
this.form.paymentBillType = 'FROM_PAYABLE'; // Default
|
||||||
|
|
||||||
// Initialize payableOrdersWithPlans
|
// Initialize payableOrdersWithPlans
|
||||||
this.payableOrdersWithPlans = this.payableOrders.map(order => ({
|
this.payableOrdersWithPlans = this.payableOrders.map(order => {
|
||||||
...order,
|
const paymentPlans = order.paymentPlans ? [...order.paymentPlans] : [];
|
||||||
paymentPlans: order.paymentPlans || [], // Retain existing plans if any, otherwise empty
|
if (paymentPlans.length === 0 && order.lastPaymentPlanId) {
|
||||||
totalPriceWithTax: order.totalPriceWithTax || 0, // Ensure numeric for calculations
|
paymentPlans.push({
|
||||||
unpaidAmount: order.unpaidAmount || 0,
|
id: order.lastPaymentPlanId,
|
||||||
paidAmount: order.paidAmount || 0, // Ensure numeric for calculations
|
planAmount: order.planAmount,
|
||||||
}));
|
planPaymentDate: order.planPaymentDate,
|
||||||
|
planRate: this.$calc.mul(this.$calc.div(order.planAmount, order.totalPriceWithTax, 4), 100)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...order,
|
||||||
|
paymentPlans: paymentPlans, // Retain existing plans if any, otherwise empty
|
||||||
|
totalPriceWithTax: order.totalPriceWithTax || 0, // Ensure numeric for calculations
|
||||||
|
unpaidAmount: order.unpaidAmount || 0,
|
||||||
|
paidAmount: order.paidAmount || 0, // Ensure numeric for calculations
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
handleClose() {
|
handleClose() {
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
},
|
},
|
||||||
handleChooseConfirm() {
|
handleChooseConfirm() {
|
||||||
if (!this.$refs.planSelector || !this.$refs.planSelector.selectedPlan) {
|
if (!this.$refs.planSelector) {
|
||||||
this.$modal.msgError('无法获取计划选择器组件或其选择的计划');
|
this.$modal.msgError('无法获取计划选择器组件');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const selectedPlans = this.$refs.planSelector.selectedPlan;
|
const selectedPlans = this.$refs.planSelector.selectedPlan || [];
|
||||||
|
|
||||||
const orderIndex = this.payableOrdersWithPlans.findIndex(o => o.id === this.choosePayable.id);
|
const orderIndex = this.payableOrdersWithPlans.findIndex(o => o.id === this.choosePayable.id);
|
||||||
if (orderIndex === -1) {
|
if (orderIndex === -1) {
|
||||||
|
|
@ -219,27 +227,11 @@ export default {
|
||||||
|
|
||||||
const currentOrder = this.payableOrdersWithPlans[orderIndex];
|
const currentOrder = this.payableOrdersWithPlans[orderIndex];
|
||||||
|
|
||||||
// Ensure the paymentPlans array exists
|
// Update the payment plans for the specific order
|
||||||
if (!currentOrder.paymentPlans) {
|
this.$set(currentOrder, 'paymentPlans', [...selectedPlans]);
|
||||||
this.$set(currentOrder, 'paymentPlans', []);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new plans, checking for duplicates by plan ID
|
|
||||||
let addedCount = 0;
|
|
||||||
selectedPlans.forEach(newPlan => {
|
|
||||||
const existingPlan = currentOrder.paymentPlans.find(p => p.id === newPlan.id);
|
|
||||||
if (!existingPlan) {
|
|
||||||
currentOrder.paymentPlans.push(newPlan);
|
|
||||||
addedCount++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.isPaymentPlanSelectorOpen = false;
|
this.isPaymentPlanSelectorOpen = false;
|
||||||
if (addedCount > 0) {
|
this.$modal.msgSuccess(`已更新付款计划选择,共 ${selectedPlans.length} 条`);
|
||||||
this.$modal.msgSuccess(`成功补充 ${addedCount} 条付款计划`);
|
|
||||||
} else {
|
|
||||||
this.$modal.msgWarning('没有新的付款计划被添加');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
handleConfirm() {
|
handleConfirm() {
|
||||||
// Validate main form fields
|
// Validate main form fields
|
||||||
|
|
@ -283,6 +275,7 @@ export default {
|
||||||
// Collect all payable orders with their updated payment plans
|
// Collect all payable orders with their updated payment plans
|
||||||
payableOrders: this.payableOrdersWithPlans.map(order => ({
|
payableOrders: this.payableOrdersWithPlans.map(order => ({
|
||||||
id: order.id,
|
id: order.id,
|
||||||
|
taxRate: order.taxRate,
|
||||||
payableBillCode: order.payableBillCode,
|
payableBillCode: order.payableBillCode,
|
||||||
paymentPlans: order.paymentPlans.map(plan => ({
|
paymentPlans: order.paymentPlans.map(plan => ({
|
||||||
planPaymentDate: plan.planPaymentDate,
|
planPaymentDate: plan.planPaymentDate,
|
||||||
|
|
|
||||||
|
|
@ -30,17 +30,24 @@
|
||||||
></el-date-picker>
|
></el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="厂家开票时间" prop="vendorTicketTime">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="form.vendorTicketTime"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd HH:mm:ss"
|
||||||
|
placeholder="选择日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-divider content-position="left">采购应付单表</el-divider>
|
<el-divider content-position="left">采购应付单表</el-divider>
|
||||||
<el-table :data="payableOrdersWithPlans" border max-height="300px" style="margin-bottom: 20px;">
|
<el-table :data="payableOrdersWithPlans" border max-height="300px" style="margin-bottom: 20px;">
|
||||||
<el-table-column label="应付单编号" align="center" prop="payableBillCode" width="150"/>
|
<el-table-column label="应付单编号" align="center" prop="payableBillCode" width="150"/>
|
||||||
<el-table-column label="预计收票时间" align="center" prop="estimatedPaymentTime" width="180"/>
|
<el-table-column label="预计收票时间" align="center" prop="planTicketDate" width="180"/>
|
||||||
<el-table-column label="收票计划" align="center" width="100">
|
<el-table-column label="收票计划" align="center" width="100" prop="planTicketAmount">
|
||||||
<template slot-scope="scope">
|
|
||||||
<span>{{ scope.row.ticketPlans ? scope.row.ticketPlans.length : 0 }} 条计划</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="项目名称" align="center" prop="projectName" width="150"/>
|
<el-table-column label="项目名称" align="center" prop="projectName" width="150"/>
|
||||||
<el-table-column label="合同编号" align="center" prop="orderCode" width="150"/>
|
<el-table-column label="合同编号" align="center" prop="orderCode" width="150"/>
|
||||||
|
|
@ -134,6 +141,7 @@ export default {
|
||||||
ticketBillType: 'FROM_PAYABLE', // Default to a type, or make it dynamic
|
ticketBillType: 'FROM_PAYABLE', // Default to a type, or make it dynamic
|
||||||
vendorName: '',
|
vendorName: '',
|
||||||
ticketTime: null,
|
ticketTime: null,
|
||||||
|
vendorTicketTime: null,
|
||||||
},
|
},
|
||||||
payableOrdersWithPlans: [], // Each order will now have its own ticketPlans array
|
payableOrdersWithPlans: [], // Each order will now have its own ticketPlans array
|
||||||
isTicketPlanSelectorOpen: false,
|
isTicketPlanSelectorOpen: false,
|
||||||
|
|
@ -185,31 +193,44 @@ export default {
|
||||||
const allSameVendor = this.payableOrders.every(order => order.vendorName === firstVendorName);
|
const allSameVendor = this.payableOrders.every(order => order.vendorName === firstVendorName);
|
||||||
this.form.vendorName = allSameVendor ? firstVendorName : '多个制造商';
|
this.form.vendorName = allSameVendor ? firstVendorName : '多个制造商';
|
||||||
this.form.ticketTime = null; // Reset time
|
this.form.ticketTime = null; // Reset time
|
||||||
|
this.form.vendorTicketTime = null;
|
||||||
} else {
|
} else {
|
||||||
this.form.vendorName = '';
|
this.form.vendorName = '';
|
||||||
this.form.ticketTime = null;
|
this.form.ticketTime = null;
|
||||||
|
this.form.vendorTicketTime = null;
|
||||||
}
|
}
|
||||||
this.form.ticketBillType = 'FROM_PAYABLE'; // Default
|
this.form.ticketBillType = 'FROM_PAYABLE'; // Default
|
||||||
|
|
||||||
// Initialize payableOrdersWithPlans
|
// Initialize payableOrdersWithPlans
|
||||||
this.payableOrdersWithPlans = this.payableOrders.map(order => ({
|
this.payableOrdersWithPlans = this.payableOrders.map(order => {
|
||||||
...order,
|
const ticketPlans = order.ticketPlans ? [...order.ticketPlans] : [];
|
||||||
ticketPlans: order.ticketPlans || [], // Retain existing plans if any, otherwise empty
|
if (ticketPlans.length === 0 && order.lastTicketPlanId) {
|
||||||
totalPriceWithTax: order.totalPriceWithTax || 0, // Ensure numeric for calculations
|
ticketPlans.push({
|
||||||
unInvoicedAmount: order.unInvoicedAmount || 0,
|
id: order.lastTicketPlanId,
|
||||||
invoicedAmount: order.invoicedAmount || 0, // Ensure numeric for calculations
|
planAmount: order.planTicketAmount,
|
||||||
}));
|
planTicketDate: order.planTicketDate,
|
||||||
|
planRate: this.$calc.mul(this.$calc.div(order.planTicketAmount, order.totalPriceWithTax, 4), 100)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...order,
|
||||||
|
ticketPlans: ticketPlans, // Retain existing plans if any, otherwise empty
|
||||||
|
totalPriceWithTax: order.totalPriceWithTax || 0, // Ensure numeric for calculations
|
||||||
|
unInvoicedAmount: order.unInvoicedAmount || 0,
|
||||||
|
invoicedAmount: order.invoicedAmount || 0, // Ensure numeric for calculations
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
handleClose() {
|
handleClose() {
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
},
|
},
|
||||||
handleChooseConfirm() {
|
handleChooseConfirm() {
|
||||||
if (!this.$refs.planSelector || !this.$refs.planSelector.selectedPlan) {
|
if (!this.$refs.planSelector) {
|
||||||
this.$modal.msgError('无法获取计划选择器组件或其选择的计划');
|
this.$modal.msgError('无法获取计划选择器组件');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const selectedPlans = this.$refs.planSelector.selectedPlan;
|
const selectedPlans = this.$refs.planSelector.selectedPlan || [];
|
||||||
|
|
||||||
const orderIndex = this.payableOrdersWithPlans.findIndex(o => o.id === this.choosePayable.id);
|
const orderIndex = this.payableOrdersWithPlans.findIndex(o => o.id === this.choosePayable.id);
|
||||||
if (orderIndex === -1) {
|
if (orderIndex === -1) {
|
||||||
|
|
@ -219,27 +240,11 @@ export default {
|
||||||
|
|
||||||
const currentOrder = this.payableOrdersWithPlans[orderIndex];
|
const currentOrder = this.payableOrdersWithPlans[orderIndex];
|
||||||
|
|
||||||
// Ensure the ticketPlans array exists
|
// Update the ticket plans for the specific order
|
||||||
if (!currentOrder.ticketPlans) {
|
this.$set(currentOrder, 'ticketPlans', [...selectedPlans]);
|
||||||
this.$set(currentOrder, 'ticketPlans', []);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new plans, checking for duplicates by plan ID
|
|
||||||
let addedCount = 0;
|
|
||||||
selectedPlans.forEach(newPlan => {
|
|
||||||
const existingPlan = currentOrder.ticketPlans.find(p => p.id === newPlan.id);
|
|
||||||
if (!existingPlan) {
|
|
||||||
currentOrder.ticketPlans.push(newPlan);
|
|
||||||
addedCount++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.isTicketPlanSelectorOpen = false;
|
this.isTicketPlanSelectorOpen = false;
|
||||||
if (addedCount > 0) {
|
this.$modal.msgSuccess(`已更新收票计划选择,共 ${selectedPlans.length} 条`);
|
||||||
this.$modal.msgSuccess(`成功补充 ${addedCount} 条收票计划`);
|
|
||||||
} else {
|
|
||||||
this.$modal.msgWarning('没有新的收票计划被添加');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
handleConfirm() {
|
handleConfirm() {
|
||||||
// Validate main form fields
|
// Validate main form fields
|
||||||
|
|
@ -251,6 +256,10 @@ export default {
|
||||||
this.$modal.msgError('请选择预计收票时间');
|
this.$modal.msgError('请选择预计收票时间');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!this.form.vendorTicketTime) {
|
||||||
|
this.$modal.msgError('请选择厂家开票时间');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Validate each payable order's ticket plans
|
// Validate each payable order's ticket plans
|
||||||
for (const order of this.payableOrdersWithPlans) {
|
for (const order of this.payableOrdersWithPlans) {
|
||||||
|
|
@ -280,6 +289,7 @@ export default {
|
||||||
const mergedReceiptData = {
|
const mergedReceiptData = {
|
||||||
ticketBillType: this.form.ticketBillType,
|
ticketBillType: this.form.ticketBillType,
|
||||||
ticketTime: this.form.ticketTime,
|
ticketTime: this.form.ticketTime,
|
||||||
|
vendorTicketTime: this.form.vendorTicketTime,
|
||||||
// Collect all payable orders with their updated ticket plans
|
// Collect all payable orders with their updated ticket plans
|
||||||
payableOrders: this.payableOrdersWithPlans.map(order => ({
|
payableOrders: this.payableOrdersWithPlans.map(order => ({
|
||||||
id: order.id,
|
id: order.id,
|
||||||
|
|
@ -307,6 +317,7 @@ export default {
|
||||||
ticketBillType: 'FROM_PAYABLE',
|
ticketBillType: 'FROM_PAYABLE',
|
||||||
vendorName: '',
|
vendorName: '',
|
||||||
ticketTime: null,
|
ticketTime: null,
|
||||||
|
vendorTicketTime: null,
|
||||||
};
|
};
|
||||||
this.payableOrdersWithPlans = [];
|
this.payableOrdersWithPlans = [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,8 @@
|
||||||
<el-table-column label="项目名称" align="center" prop="projectName" width="150" />
|
<el-table-column label="项目名称" align="center" prop="projectName" width="150" />
|
||||||
<el-table-column label="应付单编号" align="center" prop="payableBillCode" width="150" />
|
<el-table-column label="应付单编号" align="center" prop="payableBillCode" width="150" />
|
||||||
<!-- <el-table-column label="生成时间" align="center" prop="createTime" width="180"/>-->
|
<!-- <el-table-column label="生成时间" align="center" prop="createTime" width="180"/>-->
|
||||||
<el-table-column label="预计付款时间" align="center" prop="estimatedPaymentTime" width="180"/>
|
<el-table-column label="预计付款时间" align="center" prop="planPaymentDate" width="180"/>
|
||||||
<el-table-column label="预计付款金额" align="center" prop="totalPriceWithTax" width="120" />
|
<el-table-column label="预计付款金额" align="center" prop="planAmount" width="120" />
|
||||||
<el-table-column label="该制造商是否有预付单" align="center" prop="hasAdvancePayment" width="150" />
|
<el-table-column label="该制造商是否有预付单" align="center" prop="hasAdvancePayment" width="150" />
|
||||||
<!-- <el-table-column label="预付金额" align="center" prop="advancePaymentAmount" width="120" />-->
|
<!-- <el-table-column label="预付金额" align="center" prop="advancePaymentAmount" width="120" />-->
|
||||||
<el-table-column label="制造商名称" align="center" prop="vendorName" width="150" />
|
<el-table-column label="制造商名称" align="center" prop="vendorName" width="150" />
|
||||||
|
|
@ -167,7 +167,8 @@
|
||||||
<!-- >生成收票单</el-button>-->
|
<!-- >生成收票单</el-button>-->
|
||||||
<!-- </template>-->
|
<!-- </template>-->
|
||||||
<!-- </el-table-column>-->
|
<!-- </el-table-column>-->
|
||||||
<el-table-column label="未付款金额" align="center" prop="unpaidAmount" width="120" />
|
<el-table-column label="未付款金额" align="center" prop="unpaidPaymentAmount" width="120" />
|
||||||
|
<el-table-column label="未收票金额" align="center" prop="unreceivedTicketAmount" width="120" />
|
||||||
<!-- <el-table-column label="付款中金额" align="center" prop="payingAmount" width="120" />-->
|
<!-- <el-table-column label="付款中金额" align="center" prop="payingAmount" width="120" />-->
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160" fixed="right">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160" fixed="right">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,6 @@
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-refresh-left"
|
icon="el-icon-refresh-left"
|
||||||
v-show="scope.row.approveStatus=='1'"
|
|
||||||
@click="handleReturn(scope.row)"
|
@click="handleReturn(scope.row)"
|
||||||
>退回</el-button>
|
>退回</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,8 @@ export default {
|
||||||
productDesc: this.form.productDesc,
|
productDesc: this.form.productDesc,
|
||||||
innerPrice: this.form.price,
|
innerPrice: this.form.price,
|
||||||
warehouseId: this.form.warehouseId,
|
warehouseId: this.form.warehouseId,
|
||||||
warehouseName: this.form.warehouseName
|
warehouseName: this.form.warehouseName,
|
||||||
|
taxRate: this.form.taxRate
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.form.inventoryInfoList.push(...productsToAdd);
|
this.form.inventoryInfoList.push(...productsToAdd);
|
||||||
|
|
@ -479,6 +480,7 @@ export default {
|
||||||
innerPrice: order.price,
|
innerPrice: order.price,
|
||||||
quantity: order.quantity,
|
quantity: order.quantity,
|
||||||
warehouseId: order.warehouseId,
|
warehouseId: order.warehouseId,
|
||||||
|
taxRate:order.taxRate
|
||||||
}];
|
}];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -600,6 +602,7 @@ export default {
|
||||||
item.warehouseId=this.form.warehouseId;
|
item.warehouseId=this.form.warehouseId;
|
||||||
item.warehouseName=this.form.warehouseName;
|
item.warehouseName=this.form.warehouseName;
|
||||||
item.innerPrice=this.form.price;
|
item.innerPrice=this.form.price;
|
||||||
|
item.taxRate=this.form.taxRate;
|
||||||
})
|
})
|
||||||
this.$modal.msgSuccess("导入成功");
|
this.$modal.msgSuccess("导入成功");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,13 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="6" v-if="isImported">
|
||||||
|
<el-form-item label="税率" prop="taxRate">
|
||||||
|
<el-input v-model="taxRate" placeholder="请输入税率"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
|
|
@ -214,7 +221,6 @@ export default {
|
||||||
item.warehouseName = this.warehouseName;
|
item.warehouseName = this.warehouseName;
|
||||||
item.warehouseId = this.warehouseId;
|
item.warehouseId = this.warehouseId;
|
||||||
item.innerPrice = this.price;
|
item.innerPrice = this.price;
|
||||||
item.taxRate = this.taxRate;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.total = this.snList.length;
|
this.total = this.snList.length;
|
||||||
|
|
@ -240,6 +246,9 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isImported) {
|
||||||
|
this.snList.forEach(item => item.taxRate = this.taxRate)
|
||||||
|
}
|
||||||
const data = {
|
const data = {
|
||||||
...this.form,
|
...this.form,
|
||||||
productSnList: this.selectedSnList.map(item => item.productSn),
|
productSnList: this.selectedSnList.map(item => item.productSn),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.ruoyi.sip.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ruoyi.sip.domain.OmsPaymentBill;
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
@ -18,8 +17,6 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.sip.service.IOmsPaymentBillService;
|
import com.ruoyi.sip.service.IOmsPaymentBillService;
|
||||||
import com.ruoyi.sip.service.IOmsInvoiceReceiptBillService;
|
import com.ruoyi.sip.service.IOmsInvoiceReceiptBillService;
|
||||||
import com.ruoyi.sip.domain.OmsInvoiceReceiptBill;
|
|
||||||
import org.springframework.ui.ModelMap;
|
|
||||||
|
|
||||||
import com.ruoyi.sip.domain.dto.MergedPaymentDataDto;
|
import com.ruoyi.sip.domain.dto.MergedPaymentDataDto;
|
||||||
import com.ruoyi.sip.domain.dto.MergedReceiptDataDto;
|
import com.ruoyi.sip.domain.dto.MergedReceiptDataDto;
|
||||||
|
|
@ -89,17 +86,17 @@ public class OmsPayableBillController extends BaseController
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 新增保存采购应付单
|
// * 新增保存采购应付单
|
||||||
*/
|
// */
|
||||||
@RequiresPermissions("finance:payable:add")
|
// @RequiresPermissions("finance:payable:add")
|
||||||
@Log(title = "采购应付单", businessType = BusinessType.INSERT)
|
// @Log(title = "采购应付单", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/add")
|
// @PostMapping("/add")
|
||||||
@ResponseBody
|
// @ResponseBody
|
||||||
public AjaxResult addSave(OmsPayableBill omsPayableBill)
|
// public AjaxResult addSave(OmsPayableBill omsPayableBill)
|
||||||
{
|
// {
|
||||||
return toAjax(omsPayableBillService.insertOmsPayableBill(omsPayableBill));
|
// return toAjax(omsPayableBillService.insertOmsPayableBill(omsPayableBill, vendorInfo.getPayConfigDay()));
|
||||||
}
|
// }
|
||||||
@RequiresPermissions("finance:payable:query")
|
@RequiresPermissions("finance:payable:query")
|
||||||
@Log(title = "采购应付单", businessType = BusinessType.INSERT)
|
@Log(title = "采购应付单", businessType = BusinessType.INSERT)
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.sip.domain;
|
package com.ruoyi.sip.domain;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ public class OmsPayableBill extends BaseEntity
|
||||||
|
|
||||||
/** 主键ID */
|
/** 主键ID */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
private List<Long> idList;
|
||||||
|
|
||||||
/** 应付单编号 */
|
/** 应付单编号 */
|
||||||
@Excel(name = "应付单编号")
|
@Excel(name = "应付单编号")
|
||||||
|
|
@ -32,10 +33,10 @@ public class OmsPayableBill extends BaseEntity
|
||||||
@Excel(name = "生成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
@Excel(name = "生成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
/** 预计付款时间 */
|
/** 最后付款计划ID */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
private Long lastPaymentPlanId;
|
||||||
@Excel(name = "预计付款时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
/** 最后票据计划ID */
|
||||||
private Date estimatedPaymentTime;
|
private Long lastTicketPlanId;
|
||||||
|
|
||||||
/** 制造商编码 */
|
/** 制造商编码 */
|
||||||
@Excel(name = "制造商编码")
|
@Excel(name = "制造商编码")
|
||||||
|
|
@ -71,6 +72,7 @@ public class OmsPayableBill extends BaseEntity
|
||||||
/** 税额 */
|
/** 税额 */
|
||||||
@Excel(name = "税额")
|
@Excel(name = "税额")
|
||||||
private BigDecimal taxAmount;
|
private BigDecimal taxAmount;
|
||||||
|
private BigDecimal taxRate;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -82,12 +84,34 @@ public class OmsPayableBill extends BaseEntity
|
||||||
private Date estimatedPaymentTimeEnd;
|
private Date estimatedPaymentTimeEnd;
|
||||||
private Date estimatedPaymentTimeStart;
|
private Date estimatedPaymentTimeStart;
|
||||||
|
|
||||||
private BigDecimal unpaidAmount;
|
|
||||||
private BigDecimal paidAmount;
|
|
||||||
private BigDecimal payingAmount;
|
|
||||||
|
|
||||||
|
/** 已付款金额 */
|
||||||
|
@Excel(name = "已付款金额")
|
||||||
|
private BigDecimal paidPaymentAmount;
|
||||||
|
|
||||||
|
/** 未付款金额 */
|
||||||
|
@Excel(name = "未付款金额")
|
||||||
|
private BigDecimal unpaidPaymentAmount;
|
||||||
|
|
||||||
|
/** 已收票金额 */
|
||||||
|
@Excel(name = "已收票金额")
|
||||||
|
private BigDecimal receivedTicketAmount;
|
||||||
|
|
||||||
|
/** 未收票金额 */
|
||||||
|
@Excel(name = "未收票金额")
|
||||||
|
private BigDecimal unreceivedTicketAmount;
|
||||||
|
|
||||||
|
/** 计划付款日期 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date planPaymentDate;
|
||||||
|
private Date planTicketDate;
|
||||||
|
|
||||||
|
/** 计划金额 */
|
||||||
|
private BigDecimal planAmount;
|
||||||
|
private BigDecimal planTicketAmount;
|
||||||
|
|
||||||
|
private Date planPaymentDateStart;
|
||||||
|
private Date planPaymentDateEnd;
|
||||||
|
|
||||||
private List<OmsPayablePaymentDetail> detailList;
|
private List<OmsPayablePaymentDetail> detailList;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,13 +124,13 @@ public class VendorInfo extends BaseEntity
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum PayTypeEnum {
|
public enum PayTypeEnum {
|
||||||
INNER_PAY("0", "入库付款"),
|
INNER_PAY(0, "入库付款"),
|
||||||
OUTER_PAY("1", "出库付款"),
|
OUTER_PAY(1, "出库付款"),
|
||||||
;
|
;
|
||||||
private final String desc;
|
private final String desc;
|
||||||
private final String code;
|
private final Integer code;
|
||||||
|
|
||||||
PayTypeEnum(String code, String desc) {
|
PayTypeEnum(Integer code, String desc) {
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
||||||
public class MergedReceiptDataDto {
|
public class MergedReceiptDataDto {
|
||||||
private String ticketBillType;
|
private String ticketBillType;
|
||||||
private Date ticketTime;
|
private Date ticketTime;
|
||||||
|
private Date vendorTicketTime;
|
||||||
private List<PayableOrderReceiptDto> payableOrders;
|
private List<PayableOrderReceiptDto> payableOrders;
|
||||||
private BigDecimal totalMergeTicketAmount;
|
private BigDecimal totalMergeTicketAmount;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,14 @@ package com.ruoyi.sip.domain.dto;
|
||||||
import com.ruoyi.sip.domain.OmsPayablePaymentPlan;
|
import com.ruoyi.sip.domain.OmsPayablePaymentPlan;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class PayableOrderDto {
|
public class PayableOrderDto {
|
||||||
private Long id;
|
private Long id;
|
||||||
private String payableBillCode;
|
private String payableBillCode;
|
||||||
|
private BigDecimal taxRate;
|
||||||
private List<OmsPayablePaymentPlan> paymentPlans;
|
private List<OmsPayablePaymentPlan> paymentPlans;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,13 @@ package com.ruoyi.sip.domain.dto;
|
||||||
import com.ruoyi.sip.domain.OmsPayableTicketPlan;
|
import com.ruoyi.sip.domain.OmsPayableTicketPlan;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class PayableOrderReceiptDto {
|
public class PayableOrderReceiptDto {
|
||||||
private Long id;
|
private Long id;
|
||||||
private String payableBillCode;
|
private String payableBillCode;
|
||||||
|
private BigDecimal taxRate;
|
||||||
private List<OmsPayableTicketPlan> ticketPlans;
|
private List<OmsPayableTicketPlan> ticketPlans;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,21 @@ public interface OmsPayableBillMapper
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除采购应付单
|
* 批量删除采购应付单
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的数据主键集合
|
* @param ids 需要删除的数据主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteOmsPayableBillByIds(String[] ids);
|
public int deleteOmsPayableBillByIds(String[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量更新应付单的付款相关信息
|
||||||
|
*
|
||||||
|
* @param payableBills 需要更新的应付单列表
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateBatchPayableBillPaymentInfo(List<OmsPayableBill> payableBills);
|
||||||
|
|
||||||
Integer selectMaxCodeByPrefix(String codePrefix);
|
Integer selectMaxCodeByPrefix(String codePrefix);
|
||||||
|
|
||||||
|
int updateBatchPayableBillTicketInfo(List<OmsPayableBill> omsPayableBills);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,6 @@ public interface OmsPayablePaymentDetailMapper {
|
||||||
void insertBatch(List<OmsPayablePaymentDetail> addList);
|
void insertBatch(List<OmsPayablePaymentDetail> addList);
|
||||||
|
|
||||||
List<PaymentBillPayableDetailDTO> listPayableByPaymentCode(List<String> paymentBillCodeList);
|
List<PaymentBillPayableDetailDTO> listPayableByPaymentCode(List<String> paymentBillCodeList);
|
||||||
|
|
||||||
|
List<OmsPayablePaymentDetail> selectByPaymentPlanIds(@Param("paymentPlanIds") List<Long> paymentPlanIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,4 +59,8 @@ public interface OmsPayablePaymentPlanMapper {
|
||||||
* @return 付款计划ID列表
|
* @return 付款计划ID列表
|
||||||
*/
|
*/
|
||||||
public List<Long> selectOmsPayablePaymentPlanIdsByPayableBillId(Long payableBillId);
|
public List<Long> selectOmsPayablePaymentPlanIdsByPayableBillId(Long payableBillId);
|
||||||
|
|
||||||
|
OmsPayablePaymentPlan firstUnPayPlan(Long payableBillId);
|
||||||
|
|
||||||
|
List<OmsPayablePaymentPlan> listDetailByPayableBillIdList(List<Long> idList);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,4 +70,6 @@ public interface OmsPayableTicketDetailMapper
|
||||||
|
|
||||||
List<OmsPayableTicketDetail> listByPayableBillIdList(List<Long> payableBillId);
|
List<OmsPayableTicketDetail> listByPayableBillIdList(List<Long> payableBillId);
|
||||||
|
|
||||||
|
List<OmsPayableTicketDetail> selectByTicketPlanIds(List<Long> ticketPlanIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -58,4 +58,6 @@ public interface OmsPayableTicketPlanMapper
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteOmsPayableTicketPlanByIds(Long[] ids);
|
public int deleteOmsPayableTicketPlanByIds(Long[] ids);
|
||||||
|
|
||||||
|
OmsPayableTicketPlan firstUnPayPlan(Long payableBillId);
|
||||||
}
|
}
|
||||||
|
|
@ -32,11 +32,12 @@ public interface IOmsPayableBillService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增采购应付单
|
* 新增采购应付单
|
||||||
*
|
*
|
||||||
* @param omsPayableBill 采购应付单
|
* @param omsPayableBill 采购应付单
|
||||||
|
* @param payConfigDay
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertOmsPayableBill(OmsPayableBill omsPayableBill);
|
public int insertOmsPayableBill(OmsPayableBill omsPayableBill, Integer payConfigDay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改采购应付单
|
* 修改采购应付单
|
||||||
|
|
@ -77,6 +78,8 @@ public interface IOmsPayableBillService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int mergeAndInitiateReceipt(MergedReceiptDataDto dto);
|
public int mergeAndInitiateReceipt(MergedReceiptDataDto dto);
|
||||||
|
public int updatePaymentAmount(List<Long> idList);
|
||||||
|
public int updateTicketAmount(List<Long> idList);
|
||||||
|
|
||||||
OmsPayableBill query(Long id);
|
OmsPayableBill query(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,6 @@ public interface IOmsPayablePaymentDetailService {
|
||||||
void applyRefund(String payableBillCode, String payableBillCode1);
|
void applyRefund(String payableBillCode, String payableBillCode1);
|
||||||
|
|
||||||
List<PaymentBillPayableDetailDTO> listPayableByPaymentCode(String paymentBillCode);
|
List<PaymentBillPayableDetailDTO> listPayableByPaymentCode(String paymentBillCode);
|
||||||
|
|
||||||
|
List<OmsPayablePaymentDetail> selectByPaymentPlanIds(List<Long> paymentPlanIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,4 +68,6 @@ public interface IOmsPayableTicketDetailService
|
||||||
void clearRelationPayable(String ticketBillCode);
|
void clearRelationPayable(String ticketBillCode);
|
||||||
|
|
||||||
List<OmsPayableTicketDetail> listByPayableBillIdList(List<Long> collect);
|
List<OmsPayableTicketDetail> listByPayableBillIdList(List<Long> collect);
|
||||||
|
|
||||||
|
List<OmsPayableTicketDetail> selectByTicketPlanIds(List<Long> ticketPlanIds);
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,6 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.ShiroUtils;
|
import com.ruoyi.common.utils.ShiroUtils;
|
||||||
|
|
@ -62,7 +61,7 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOmsPayableBillService payableBillService;
|
private IOmsPayableBillService payableBillService;
|
||||||
|
|
||||||
@Value("${oms.inventory.innerTax:1.13}")
|
@Value("${oms.inventory.innerTax:0.13}")
|
||||||
private String defaultTax;
|
private String defaultTax;
|
||||||
/**
|
/**
|
||||||
* 查询产品库存
|
* 查询产品库存
|
||||||
|
|
@ -247,23 +246,26 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService {
|
||||||
}
|
}
|
||||||
OmsPayableBill payableBill = new OmsPayableBill();
|
OmsPayableBill payableBill = new OmsPayableBill();
|
||||||
payableBill.setProductCode(inventoryOuter.getProductCode());
|
payableBill.setProductCode(inventoryOuter.getProductCode());
|
||||||
payableBill.setEstimatedPaymentTime(DateUtils.addDays(DateUtils.getNowDate(), vendorInfo.getPayConfigDay()));
|
// payableBill.setEstimatedPaymentTime(DateUtils.addDays(DateUtils.getNowDate(), vendorInfo.getPayConfigDay()));
|
||||||
payableBill.setProductType(productInfo.getType());
|
payableBill.setProductType(productInfo.getType());
|
||||||
payableBill.setVendorCode(productInfo.getVendorCode());
|
payableBill.setVendorCode(productInfo.getVendorCode());
|
||||||
payableBill.setInventoryCode(inventoryDelivery.getOuterCode());
|
payableBill.setInventoryCode(inventoryDelivery.getOuterCode());
|
||||||
BigDecimal allPrice = inventoryInfos.stream().map(InventoryInfo::getInnerPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
BigDecimal allPrice = inventoryInfos.stream().map(InventoryInfo::getInnerPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
payableBill.setTotalPriceWithTax(allPrice);
|
payableBill.setTotalPriceWithTax(allPrice);
|
||||||
payableBill.setTotalPriceWithoutTax(allPrice.divide(new BigDecimal(defaultTax), 2, RoundingMode.HALF_UP));
|
BigDecimal defaultTaxRate = new BigDecimal(defaultTax);
|
||||||
|
BigDecimal allPriceWithOutTax = inventoryInfos.stream().map(item ->
|
||||||
|
{
|
||||||
|
BigDecimal taxRate = item.getTaxRate() == null ? defaultTaxRate : item.getTaxRate();
|
||||||
|
return item.getInnerPrice().divide(BigDecimal.ONE.add(taxRate), 2, RoundingMode.HALF_UP);
|
||||||
|
})
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
payableBill.setTaxRate(inventoryInfos.get(0).getTaxRate() == null ? defaultTaxRate : inventoryInfos.get(0).getTaxRate());
|
||||||
|
payableBill.setTotalPriceWithoutTax(allPriceWithOutTax);
|
||||||
payableBill.setTaxAmount(allPrice.subtract(payableBill.getTotalPriceWithoutTax()));
|
payableBill.setTaxAmount(allPrice.subtract(payableBill.getTotalPriceWithoutTax()));
|
||||||
payableBill.setProjectCode(inventoryDelivery.getProjectCode());
|
payableBill.setProductCode(inventoryDelivery.getProductCode());
|
||||||
payableBill.setOrderCode(inventoryDelivery.getOrderCode());
|
payableBill.setOrderCode(inventoryDelivery.getOrderCode());
|
||||||
payableBillService.insertOmsPayableBill(payableBill);
|
payableBillService.insertOmsPayableBill(payableBill, vendorInfo.getPayConfigDay());
|
||||||
List<InventoryInfo> saveList = inventoryInfos.stream().map(item -> {
|
List<InventoryInfo> saveList = inventoryInfos.stream().peek(item -> item.setPayableBillCode(payableBill.getPayableBillCode())).collect(Collectors.toList());
|
||||||
InventoryInfo inventoryInfo = new InventoryInfo();
|
|
||||||
inventoryInfo.setProductSn(item.getProductSn());
|
|
||||||
inventoryInfo.setPayableBillCode(payableBill.getPayableBillCode());
|
|
||||||
return inventoryInfo;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
inventoryInfoService.saveBatch(saveList);
|
inventoryInfoService.saveBatch(saveList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -311,6 +313,10 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recall(Long id) {
|
public void recall(Long id) {
|
||||||
|
//todo 判断应付或应收状态 不允许退
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
InventoryDelivery inventoryDelivery = inventoryDeliveryMapper.selectInventoryDeliveryById(id);
|
InventoryDelivery inventoryDelivery = inventoryDeliveryMapper.selectInventoryDeliveryById(id);
|
||||||
deleteInventoryOuterById(id);
|
deleteInventoryOuterById(id);
|
||||||
List<ProjectProductInfo> projectProductInfos = projectProductInfoService.listDeliveryProductByOrderCode(Collections.singletonList(inventoryDelivery.getOrderCode()));
|
List<ProjectProductInfo> projectProductInfos = projectProductInfoService.listDeliveryProductByOrderCode(Collections.singletonList(inventoryDelivery.getOrderCode()));
|
||||||
|
|
@ -345,7 +351,6 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService {
|
||||||
//修改累计发货数量
|
//修改累计发货数量
|
||||||
productInfoService.updateCumulativeCount(-inventoryDelivery.getQuantity(), inventoryDelivery.getProductCode());
|
productInfoService.updateCumulativeCount(-inventoryDelivery.getQuantity(), inventoryDelivery.getProductCode());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import com.ruoyi.common.utils.ShiroUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.sip.domain.*;
|
import com.ruoyi.sip.domain.*;
|
||||||
import com.ruoyi.sip.dto.inventory.InventoryInfoExcelDto;
|
import com.ruoyi.sip.dto.inventory.InventoryInfoExcelDto;
|
||||||
|
import com.ruoyi.sip.dto.inventory.OmsPurchaseOrderItemDto;
|
||||||
import com.ruoyi.sip.service.*;
|
import com.ruoyi.sip.service.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
@ -49,9 +50,10 @@ public class OmsInventoryInnerServiceImpl implements IOmsInventoryInnerService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOmsPurchaseOrderService purchaseOrderService;
|
private IOmsPurchaseOrderService purchaseOrderService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOmsPayableBillService payableBillService;
|
private IOmsPayableBillService payableBillService;
|
||||||
@Value("${oms.inventory.innerTax:1.13}")
|
@Value("${oms.inventory.innerTax:0.13}")
|
||||||
private String defaultTax;
|
private String defaultTax;
|
||||||
/**
|
/**
|
||||||
* 查询入库单信息
|
* 查询入库单信息
|
||||||
|
|
@ -147,19 +149,32 @@ public class OmsInventoryInnerServiceImpl implements IOmsInventoryInnerService {
|
||||||
if (vendorInfo != null && VendorInfo.PayTypeEnum.INNER_PAY.getCode().equals(vendorInfo.getPayType())) {
|
if (vendorInfo != null && VendorInfo.PayTypeEnum.INNER_PAY.getCode().equals(vendorInfo.getPayType())) {
|
||||||
BigDecimal reduce = inventoryInfoList.stream().map(InventoryInfo::getInnerPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
BigDecimal reduce = inventoryInfoList.stream().map(InventoryInfo::getInnerPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
//服务金额为单价* 数量 没有具体的详情
|
//服务金额为单价* 数量 没有具体的详情
|
||||||
BigDecimal totalPriceWithTax =Arrays.asList("11","22").contains(omsInventoryInner.getProductCode())?
|
BigDecimal totalPriceWithTax = Arrays.asList("11", "22").contains(omsInventoryInner.getProductType()) ?
|
||||||
reduce.multiply(new BigDecimal(omsInventoryInner.getQuantity())).setScale(2, RoundingMode.HALF_UP)
|
reduce.multiply(new BigDecimal(omsInventoryInner.getQuantity())).setScale(2, RoundingMode.HALF_UP)
|
||||||
: reduce;
|
: reduce;
|
||||||
//生成应付单
|
//生成应付单
|
||||||
payableBill.setInventoryCode(omsInventoryInner.getInnerCode());
|
payableBill.setInventoryCode(omsInventoryInner.getInnerCode());
|
||||||
payableBill.setVendorCode(omsInventoryInner.getVendorCode());
|
payableBill.setVendorCode(omsInventoryInner.getVendorCode());
|
||||||
payableBill.setProductType(productInfos.get(0).getType());
|
payableBill.setProductType(productInfos.get(0).getType());
|
||||||
payableBill.setProjectCode(omsInventoryInner.getProductCode());
|
payableBill.setProductCode(omsInventoryInner.getProductCode());
|
||||||
payableBill.setEstimatedPaymentTime(DateUtils.addDays(DateUtils.getNowDate(), vendorInfo.getPayConfigDay()));
|
|
||||||
payableBill.setTotalPriceWithTax(totalPriceWithTax);
|
payableBill.setTotalPriceWithTax(totalPriceWithTax);
|
||||||
payableBill.setTotalPriceWithoutTax(totalPriceWithTax.divide(new BigDecimal(defaultTax), 2, RoundingMode.HALF_UP));
|
String purchaseNo = omsInventoryInner.getPurchaseNo();
|
||||||
|
BigDecimal taxRate = null;
|
||||||
|
if (StringUtils.isNotEmpty(purchaseNo)) {
|
||||||
|
OmsPurchaseOrderItemDto query = new OmsPurchaseOrderItemDto();
|
||||||
|
query.setPurchaseNo(purchaseNo);
|
||||||
|
List<OmsPurchaseOrderItemDto> omsPurchaseOrderItemDtos = purchaseOrderService.listItem(query);
|
||||||
|
Map<String, BigDecimal> decimalMap = omsPurchaseOrderItemDtos.stream().collect(Collectors.toMap(OmsPurchaseOrderItemDto::getProductCode, OmsPurchaseOrderItemDto::getTaxRate, (v1, v2) -> v1));
|
||||||
|
taxRate = decimalMap.get(omsInventoryInner.getProductCode());
|
||||||
|
|
||||||
|
}
|
||||||
|
BigDecimal finalTaxRate = taxRate == null ? new BigDecimal(defaultTax) : taxRate;
|
||||||
|
BigDecimal withoutTax = inventoryInfoList.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b.getInnerPrice().divide(BigDecimal.ONE.add(finalTaxRate), 2, RoundingMode.HALF_UP)), BigDecimal::add);
|
||||||
|
payableBill.setTotalPriceWithoutTax(withoutTax);
|
||||||
|
payableBill.setTaxRate(finalTaxRate);
|
||||||
|
payableBill.setTaxAmount(totalPriceWithTax);
|
||||||
payableBill.setTaxAmount(totalPriceWithTax.subtract(payableBill.getTotalPriceWithoutTax()));
|
payableBill.setTaxAmount(totalPriceWithTax.subtract(payableBill.getTotalPriceWithoutTax()));
|
||||||
payableBillService.insertOmsPayableBill(payableBill);
|
payableBillService.insertOmsPayableBill(payableBill, vendorInfo.getPayConfigDay());
|
||||||
}
|
}
|
||||||
inventoryInfoList.forEach(item->{
|
inventoryInfoList.forEach(item->{
|
||||||
item.setInnerCode(omsInventoryInner.getInnerCode());
|
item.setInnerCode(omsInventoryInner.getInnerCode());
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@ import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.PageUtils;
|
import com.ruoyi.common.utils.PageUtils;
|
||||||
import com.ruoyi.common.utils.ShiroUtils;
|
import com.ruoyi.common.utils.ShiroUtils;
|
||||||
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import com.ruoyi.sip.domain.*;
|
import com.ruoyi.sip.domain.*;
|
||||||
import com.ruoyi.sip.domain.dto.MergedPaymentDataDto;
|
import com.ruoyi.sip.domain.dto.MergedPaymentDataDto;
|
||||||
import com.ruoyi.sip.domain.dto.MergedReceiptDataDto;
|
import com.ruoyi.sip.domain.dto.MergedReceiptDataDto;
|
||||||
|
|
@ -14,8 +16,10 @@ import com.ruoyi.sip.domain.dto.PayableOrderDto;
|
||||||
import com.ruoyi.sip.domain.dto.PayableOrderReceiptDto;
|
import com.ruoyi.sip.domain.dto.PayableOrderReceiptDto;
|
||||||
import com.ruoyi.sip.mapper.OmsPayableBillMapper;
|
import com.ruoyi.sip.mapper.OmsPayableBillMapper;
|
||||||
import com.ruoyi.sip.mapper.OmsPayablePaymentPlanMapper;
|
import com.ruoyi.sip.mapper.OmsPayablePaymentPlanMapper;
|
||||||
|
import com.ruoyi.sip.mapper.OmsPayableTicketPlanMapper;
|
||||||
import com.ruoyi.sip.service.*;
|
import com.ruoyi.sip.service.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
@ -32,6 +36,7 @@ import java.util.stream.Collectors;
|
||||||
* @date 2025-10-22
|
* @date 2025-10-22
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OmsPayableBillMapper omsPayableBillMapper;
|
private OmsPayableBillMapper omsPayableBillMapper;
|
||||||
|
|
@ -39,6 +44,8 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OmsPayablePaymentPlanMapper omsPayablePaymentPlanMapper;
|
private OmsPayablePaymentPlanMapper omsPayablePaymentPlanMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OmsPayableTicketPlanMapper omsPayableTicketPlanMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOmsPaymentBillService omsPaymentBillService;
|
private IOmsPaymentBillService omsPaymentBillService;
|
||||||
|
|
||||||
|
|
@ -52,7 +59,8 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOmsPayableTicketDetailService omsPayableTicketDetailService;
|
private IOmsPayableTicketDetailService omsPayableTicketDetailService;
|
||||||
|
@Value("${oms.inventory.innerTax:0.13}")
|
||||||
|
private String defaultTax;
|
||||||
/**
|
/**
|
||||||
* 查询采购应付单
|
* 查询采购应付单
|
||||||
*
|
*
|
||||||
|
|
@ -73,27 +81,7 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
@Override
|
@Override
|
||||||
public List<OmsPayableBill> selectOmsPayableBillList(OmsPayableBill omsPayableBill) {
|
public List<OmsPayableBill> selectOmsPayableBillList(OmsPayableBill omsPayableBill) {
|
||||||
List<OmsPayableBill> omsPayableBills = omsPayableBillMapper.selectOmsPayableBillList(omsPayableBill);
|
List<OmsPayableBill> omsPayableBills = omsPayableBillMapper.selectOmsPayableBillList(omsPayableBill);
|
||||||
PageUtils.clearPage();
|
//todo 是否有预付单信息
|
||||||
if (CollUtil.isNotEmpty(omsPayableBills)){
|
|
||||||
List<Long> idList = omsPayableBills.stream().map(OmsPayableBill::getId).distinct().collect(Collectors.toList());
|
|
||||||
List<OmsPayablePaymentDetail> omsPayablePaymentDetails = omsPayablePaymentDetailService.listByPayableBillIdList(idList);
|
|
||||||
Map<Long, Map<String, BigDecimal>> planMap = omsPayablePaymentDetails.stream().collect(Collectors.groupingBy(OmsPayablePaymentDetail::getPayableBillId,
|
|
||||||
Collectors.groupingBy(
|
|
||||||
item->item.getPaymentStatus()==null?OmsPaymentBill.PaymentStatusEnum.WAIT_PAYMENT.getCode(): item.getPaymentStatus(),
|
|
||||||
Collectors.reducing(
|
|
||||||
BigDecimal.ZERO,
|
|
||||||
detail -> (detail.getPaymentAmount() != null) ? detail.getPaymentAmount() : BigDecimal.ZERO,
|
|
||||||
BigDecimal::add
|
|
||||||
))));
|
|
||||||
omsPayableBills.forEach(bill -> {
|
|
||||||
|
|
||||||
bill.setPaidAmount(planMap.getOrDefault(bill.getId(), Collections.emptyMap()).getOrDefault(OmsPaymentBill.PaymentStatusEnum.PAYMENT.getCode(), BigDecimal.ZERO));
|
|
||||||
bill.setPayingAmount(planMap.getOrDefault(bill.getId(), Collections.emptyMap()).getOrDefault(OmsPaymentBill.PaymentStatusEnum.WAIT_PAYMENT.getCode(), BigDecimal.ZERO));
|
|
||||||
bill.setUnpaidAmount(bill.getTotalPriceWithTax().subtract(bill.getPaidAmount()).subtract(bill.getPayingAmount()));
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return omsPayableBills;
|
return omsPayableBills;
|
||||||
}
|
}
|
||||||
|
|
@ -102,12 +90,19 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
* 新增采购应付单
|
* 新增采购应付单
|
||||||
*
|
*
|
||||||
* @param omsPayableBill 采购应付单
|
* @param omsPayableBill 采购应付单
|
||||||
|
* @param payConfigDay
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int insertOmsPayableBill(OmsPayableBill omsPayableBill) {
|
public int insertOmsPayableBill(OmsPayableBill omsPayableBill, Integer payConfigDay) {
|
||||||
//生成采购应付单编号
|
//生成采购应付单编号
|
||||||
|
|
||||||
|
omsPayableBill.setUnpaidPaymentAmount(omsPayableBill.getTotalPriceWithTax());
|
||||||
|
omsPayableBill.setUnreceivedTicketAmount(omsPayableBill.getTotalPriceWithTax());
|
||||||
|
omsPayableBill.setPaidPaymentAmount(BigDecimal.ZERO);
|
||||||
|
omsPayableBill.setReceivedTicketAmount(BigDecimal.ZERO);
|
||||||
|
|
||||||
omsPayableBill.setPayableBillCode(generatePayableBillCode());
|
omsPayableBill.setPayableBillCode(generatePayableBillCode());
|
||||||
omsPayableBill.setCreateTime(DateUtils.getNowDate());
|
omsPayableBill.setCreateTime(DateUtils.getNowDate());
|
||||||
omsPayableBill.setCreateBy(ShiroUtils.getUserId().toString());
|
omsPayableBill.setCreateBy(ShiroUtils.getUserId().toString());
|
||||||
|
|
@ -117,13 +112,33 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
OmsPayablePaymentPlan defaultPlan = new OmsPayablePaymentPlan();
|
OmsPayablePaymentPlan defaultPlan = new OmsPayablePaymentPlan();
|
||||||
defaultPlan.setPayableBillId(omsPayableBill.getId());
|
defaultPlan.setPayableBillId(omsPayableBill.getId());
|
||||||
defaultPlan.setPlanPaymentDate(omsPayableBill.getEstimatedPaymentTime());
|
defaultPlan.setPlanPaymentDate(DateUtils.addDays(DateUtils.getNowDate(), payConfigDay));
|
||||||
defaultPlan.setPlanAmount(omsPayableBill.getTotalPriceWithTax());
|
defaultPlan.setPlanAmount(omsPayableBill.getTotalPriceWithTax());
|
||||||
defaultPlan.setPlanRate(new java.math.BigDecimal(100));
|
defaultPlan.setPlanRate(new java.math.BigDecimal("100"));
|
||||||
defaultPlan.setRemark("默认付款计划");
|
defaultPlan.setRemark("默认付款计划");
|
||||||
defaultPlan.setCreateBy(ShiroUtils.getLoginName());
|
defaultPlan.setCreateBy(ShiroUtils.getUserId().toString());
|
||||||
omsPayablePaymentPlanMapper.batchOmsPayablePaymentPlan(java.util.Collections.singletonList(defaultPlan));
|
omsPayablePaymentPlanMapper.insertOmsPayablePaymentPlan(defaultPlan);
|
||||||
|
omsPayableBill.setLastPaymentPlanId(defaultPlan.getId());
|
||||||
|
//创建收票计划
|
||||||
|
OmsPayableTicketPlan omsPayableTicketPlan = new OmsPayableTicketPlan();
|
||||||
|
omsPayableTicketPlan.setPayableBillId(omsPayableBill.getId());
|
||||||
|
omsPayableTicketPlan.setPlanTicketDate(DateUtils.addDays(DateUtils.getNowDate(), payConfigDay));
|
||||||
|
omsPayableTicketPlan.setPlanAmount(omsPayableBill.getTotalPriceWithTax());
|
||||||
|
omsPayableTicketPlan.setPlanRate(new java.math.BigDecimal("100"));
|
||||||
|
omsPayableTicketPlan.setRemark("默认收票计划");
|
||||||
|
omsPayableTicketPlan.setCreateBy(ShiroUtils.getUserId().toString());
|
||||||
|
omsPayableTicketPlan.setCreateTime(DateUtils.getNowDate());
|
||||||
|
omsPayableTicketPlanMapper.insertOmsPayableTicketPlan(omsPayableTicketPlan);
|
||||||
|
omsPayableBill.setLastTicketPlanId(omsPayableTicketPlan.getId());
|
||||||
|
|
||||||
|
updateOmsPayableBill(omsPayableBill);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,6 +167,7 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
@Override
|
@Override
|
||||||
public int updateOmsPayableBill(OmsPayableBill omsPayableBill) {
|
public int updateOmsPayableBill(OmsPayableBill omsPayableBill) {
|
||||||
omsPayableBill.setUpdateTime(DateUtils.getNowDate());
|
omsPayableBill.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
omsPayableBill.setUpdateBy(ShiroUtils.getUserId().toString());
|
||||||
return omsPayableBillMapper.updateOmsPayableBill(omsPayableBill);
|
return omsPayableBillMapper.updateOmsPayableBill(omsPayableBill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,25 +200,25 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
|
||||||
public int mergeAndInitiatePayment(MergedPaymentDataDto dto) {
|
public int mergeAndInitiatePayment(MergedPaymentDataDto dto) {
|
||||||
// 1. Calculate Tax Totals
|
// 1. Calculate Tax Totals
|
||||||
BigDecimal totalWithoutTax = BigDecimal.ZERO;
|
BigDecimal totalWithoutTax = BigDecimal.ZERO;
|
||||||
Map<Long, OmsPayableBill> billMap = new java.util.HashMap<>();
|
if (CollUtil.isEmpty(dto.getPayableOrders())) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
// Fetch bills once
|
// Fetch bills once
|
||||||
for (PayableOrderDto order : dto.getPayableOrders()) {
|
for (PayableOrderDto order : dto.getPayableOrders()) {
|
||||||
OmsPayableBill bill = omsPayableBillMapper.selectOmsPayableBillById(order.getId());
|
|
||||||
billMap.put(order.getId(), bill);
|
|
||||||
// todo 此处存疑 税额的计算到底应该怎么计算
|
|
||||||
for (OmsPayablePaymentPlan plan : order.getPaymentPlans()) {
|
for (OmsPayablePaymentPlan plan : order.getPaymentPlans()) {
|
||||||
if (bill.getTotalPriceWithTax() != null && bill.getTotalPriceWithTax().compareTo(BigDecimal.ZERO) != 0) {
|
// 计算每个 plan 的未税金额 = planAmount / (1 + 税率),保留两位小数
|
||||||
// ratio = planAmount / totalWithTax
|
BigDecimal taxRate = order.getTaxRate();
|
||||||
BigDecimal ratio = plan.getPlanAmount().divide(bill.getTotalPriceWithTax(), 10, java.math.RoundingMode.HALF_UP);
|
if (taxRate == null || taxRate.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
// planWithoutTax = totalWithoutTax * ratio
|
// 如果税率为空或小于0,则默认为0
|
||||||
BigDecimal planWithoutTax = bill.getTotalPriceWithoutTax().multiply(ratio).setScale(2, java.math.RoundingMode.HALF_UP);
|
taxRate = new BigDecimal(defaultTax);
|
||||||
totalWithoutTax = totalWithoutTax.add(planWithoutTax);
|
|
||||||
}
|
}
|
||||||
|
// 计算未税金额 = planAmount / (1 + 税率)
|
||||||
|
BigDecimal divisor = BigDecimal.ONE.add(taxRate);
|
||||||
|
BigDecimal planWithoutTax = plan.getPlanAmount().divide(divisor, 2, java.math.RoundingMode.HALF_UP);
|
||||||
|
totalWithoutTax = totalWithoutTax.add(planWithoutTax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,17 +229,48 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
paymentBill.setVendorCode(firstPayableBill.getVendorCode());
|
paymentBill.setVendorCode(firstPayableBill.getVendorCode());
|
||||||
paymentBill.setPaymentTime(dto.getEstimatedPaymentTime());
|
paymentBill.setPaymentTime(dto.getEstimatedPaymentTime());
|
||||||
paymentBill.setTotalPriceWithTax(dto.getTotalMergePaymentAmount());
|
paymentBill.setTotalPriceWithTax(dto.getTotalMergePaymentAmount());
|
||||||
|
|
||||||
// Set Calculated Tax Info
|
// Set Calculated Tax Info
|
||||||
paymentBill.setTotalPriceWithoutTax(totalWithoutTax);
|
paymentBill.setTotalPriceWithoutTax(totalWithoutTax);
|
||||||
paymentBill.setTaxAmount(dto.getTotalMergePaymentAmount().subtract(totalWithoutTax));
|
paymentBill.setTaxAmount(dto.getTotalMergePaymentAmount().subtract(totalWithoutTax));
|
||||||
|
|
||||||
paymentBill.setPaymentBillType(OmsPaymentBill.PaymentBillTypeEnum.FROM_PAYABLE.getCode());
|
paymentBill.setPaymentBillType(OmsPaymentBill.PaymentBillTypeEnum.FROM_PAYABLE.getCode());
|
||||||
omsPaymentBillService.insertOmsPaymentBill(paymentBill);
|
omsPaymentBillService.insertOmsPaymentBill(paymentBill);
|
||||||
|
|
||||||
// 3. 创建付款明细
|
// 3. 创建付款明细 - 防止重复付款
|
||||||
|
// 收集所有支付计划ID
|
||||||
|
List<Long> allPaymentPlanIds = dto.getPayableOrders().stream()
|
||||||
|
.flatMap(order -> order.getPaymentPlans().stream())
|
||||||
|
.map(OmsPayablePaymentPlan::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 查询现有的付款明细记录
|
||||||
|
Map<Long, OmsPayablePaymentDetail> existingDetailsMap = new java.util.HashMap<>();
|
||||||
|
if (!allPaymentPlanIds.isEmpty()) {
|
||||||
|
List<OmsPayablePaymentDetail> existingDetails = omsPayablePaymentDetailService.selectByPaymentPlanIds(allPaymentPlanIds);
|
||||||
|
|
||||||
|
// 使用stream将查询结果转化为Map,以planId为key,detail为value,取createtime最新的数据
|
||||||
|
existingDetailsMap = existingDetails.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
OmsPayablePaymentDetail::getPaymentPlanId,
|
||||||
|
detail -> detail,
|
||||||
|
// 如果有重复数据,取createtime最新的数据
|
||||||
|
(existing, replacement) -> existing.getCreateTime().compareTo(replacement.getCreateTime()) >= 0 ? existing : replacement
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 遍历所有计划并检查是否有已付款的记录
|
||||||
for (PayableOrderDto payableOrderDto : dto.getPayableOrders()) {
|
for (PayableOrderDto payableOrderDto : dto.getPayableOrders()) {
|
||||||
for (OmsPayablePaymentPlan paymentPlanDto : payableOrderDto.getPaymentPlans()) {
|
for (OmsPayablePaymentPlan paymentPlanDto : payableOrderDto.getPaymentPlans()) {
|
||||||
|
// 检查是否存在已付款的记录
|
||||||
|
OmsPayablePaymentDetail existingDetail = existingDetailsMap.get(paymentPlanDto.getId());
|
||||||
|
if (existingDetail != null) {
|
||||||
|
// 检查是否是已付款状态,如果是则抛出异常
|
||||||
|
if (!OmsPayablePaymentDetail.PayableDetailTypeEnum.REFUND.getCode().equals(existingDetail.getPayableDetailType())) {
|
||||||
|
throw new ServiceException("计划ID为 " + paymentPlanDto.getId() + " 的付款已处理,请刷新页面后重试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OmsPayablePaymentDetail detail = new OmsPayablePaymentDetail();
|
OmsPayablePaymentDetail detail = new OmsPayablePaymentDetail();
|
||||||
detail.setPayableBillId(payableOrderDto.getId());
|
detail.setPayableBillId(payableOrderDto.getId());
|
||||||
detail.setPaymentPlanId(paymentPlanDto.getId());
|
detail.setPaymentPlanId(paymentPlanDto.getId());
|
||||||
|
|
@ -237,57 +284,96 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
omsPayablePaymentDetailService.insertOmsPayablePaymentDetail(detail);
|
omsPayablePaymentDetailService.insertOmsPayablePaymentDetail(detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 更新应付单状态
|
// 3. 更新应付单最新付款id和已付和未付金额
|
||||||
// OmsPayableBill payableBill = omsPayableBillMapper.selectOmsPayableBillById(payableOrderDto.getId());
|
|
||||||
// // 这里可以根据业务逻辑更新状态,例如 "付款中"
|
|
||||||
// // payableBill.setPaymentStatus("1");
|
|
||||||
// omsPayableBillMapper.updateOmsPayableBill(payableBill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 批量更新应付单的付款相关信息
|
||||||
|
SpringUtils.getAopProxy(this).updatePaymentAmount(dto.getPayableOrders().stream().map(PayableOrderDto::getId).collect(Collectors.toList()));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int mergeAndInitiateReceipt(MergedReceiptDataDto dto) {
|
public int mergeAndInitiateReceipt(MergedReceiptDataDto dto) {
|
||||||
// 1. Calculate Tax Totals
|
// 1. Calculate Tax Totals
|
||||||
BigDecimal totalWithoutTax = BigDecimal.ZERO;
|
BigDecimal totalWithoutTax = BigDecimal.ZERO;
|
||||||
Map<Long, OmsPayableBill> billMap = new java.util.HashMap<>();
|
if (CollUtil.isEmpty(dto.getPayableOrders())) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Fetch bills once
|
// Fetch bills once
|
||||||
for (PayableOrderReceiptDto order : dto.getPayableOrders()) {
|
for (PayableOrderReceiptDto order : dto.getPayableOrders()) {
|
||||||
OmsPayableBill bill = omsPayableBillMapper.selectOmsPayableBillById(order.getId());
|
|
||||||
billMap.put(order.getId(), bill);
|
|
||||||
|
|
||||||
for (OmsPayableTicketPlan plan : order.getTicketPlans()) {
|
for (OmsPayableTicketPlan plan : order.getTicketPlans()) {
|
||||||
if (bill.getTotalPriceWithTax() != null && bill.getTotalPriceWithTax().compareTo(BigDecimal.ZERO) != 0) {
|
// 计算每个 plan 的未税金额 = planAmount / (1 + 税率),保留两位小数
|
||||||
BigDecimal ratio = plan.getPlanAmount().divide(bill.getTotalPriceWithTax(), 10, java.math.RoundingMode.HALF_UP);
|
BigDecimal taxRate = order.getTaxRate();
|
||||||
BigDecimal planWithoutTax = bill.getTotalPriceWithoutTax().multiply(ratio).setScale(2, java.math.RoundingMode.HALF_UP);
|
if (taxRate == null || taxRate.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
totalWithoutTax = totalWithoutTax.add(planWithoutTax);
|
// 如果税率为空或小于0,则默认为0
|
||||||
|
taxRate = new BigDecimal(defaultTax);
|
||||||
}
|
}
|
||||||
|
// 计算未税金额 = planAmount / (1 + 税率)
|
||||||
|
BigDecimal divisor = BigDecimal.ONE.add(taxRate);
|
||||||
|
BigDecimal planWithoutTax = plan.getPlanAmount().divide(divisor, 2, java.math.RoundingMode.HALF_UP);
|
||||||
|
totalWithoutTax = totalWithoutTax.add(planWithoutTax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 创建收票单
|
// 2. 创建收票单
|
||||||
OmsTicketBill ticketBill = new OmsTicketBill();
|
OmsTicketBill ticketBill = new OmsTicketBill();
|
||||||
OmsPayableBill firstPayableBill = billMap.get(dto.getPayableOrders().get(0).getId());
|
OmsPayableBill firstPayableBill = omsPayableBillMapper.selectOmsPayableBillById(dto.getPayableOrders().get(0).getId());
|
||||||
ticketBill.setTicketBillType(dto.getTicketBillType());
|
ticketBill.setTicketBillType(dto.getTicketBillType());
|
||||||
|
ticketBill.setVendorTicketTime(dto.getVendorTicketTime());
|
||||||
ticketBill.setVendorCode(firstPayableBill.getVendorCode());
|
ticketBill.setVendorCode(firstPayableBill.getVendorCode());
|
||||||
ticketBill.setVendorName(firstPayableBill.getVendorName());
|
ticketBill.setVendorName(firstPayableBill.getVendorName());
|
||||||
ticketBill.setTicketTime(dto.getTicketTime());
|
ticketBill.setTicketTime(dto.getTicketTime());
|
||||||
ticketBill.setTotalPriceWithTax(dto.getTotalMergeTicketAmount());
|
ticketBill.setTotalPriceWithTax(dto.getTotalMergeTicketAmount());
|
||||||
|
|
||||||
// Set Calculated Tax Info
|
// Set Calculated Tax Info
|
||||||
ticketBill.setTotalPriceWithoutTax(totalWithoutTax);
|
ticketBill.setTotalPriceWithoutTax(totalWithoutTax);
|
||||||
ticketBill.setTaxAmount(dto.getTotalMergeTicketAmount().subtract(totalWithoutTax));
|
ticketBill.setTaxAmount(dto.getTotalMergeTicketAmount().subtract(totalWithoutTax));
|
||||||
|
|
||||||
ticketBill.setTicketBillType(OmsTicketBill.TicketBillTypeEnum.FROM_PAYABLE.getCode());
|
ticketBill.setTicketBillType(OmsTicketBill.TicketBillTypeEnum.FROM_PAYABLE.getCode());
|
||||||
ticketBill.setTicketStatus(OmsTicketBill.TicketStatusEnum.WAIT_TICKET.getCode());
|
ticketBill.setTicketStatus(OmsTicketBill.TicketStatusEnum.WAIT_TICKET.getCode());
|
||||||
omsTicketBillService.insertOmsTicketBill(ticketBill);
|
omsTicketBillService.insertOmsTicketBill(ticketBill);
|
||||||
|
|
||||||
// 3. 创建收票明细
|
// 3. 创建收票明细 - 防止重复收票
|
||||||
|
// 收集所有收票计划ID
|
||||||
|
List<Long> allTicketPlanIds = dto.getPayableOrders().stream()
|
||||||
|
.flatMap(order -> order.getTicketPlans().stream())
|
||||||
|
.map(OmsPayableTicketPlan::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 查询现有的收票明细记录
|
||||||
|
Map<Long, OmsPayableTicketDetail> existingDetailsMap = new java.util.HashMap<>();
|
||||||
|
if (!allTicketPlanIds.isEmpty()) {
|
||||||
|
List<OmsPayableTicketDetail> existingDetails = omsPayableTicketDetailService.selectByTicketPlanIds(allTicketPlanIds);
|
||||||
|
|
||||||
|
// 使用stream将查询结果转化为Map,以planId为key,detail为value,取createtime最新的数据
|
||||||
|
existingDetailsMap = existingDetails.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
OmsPayableTicketDetail::getTicketPlanId,
|
||||||
|
detail -> detail,
|
||||||
|
// 如果有重复数据,取createtime最新的数据
|
||||||
|
(existing, replacement) -> existing.getCreateTime().compareTo(replacement.getCreateTime()) >= 0 ? existing : replacement
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 遍历所有计划并检查是否有已收票的记录
|
||||||
for (PayableOrderReceiptDto payableOrderDto : dto.getPayableOrders()) {
|
for (PayableOrderReceiptDto payableOrderDto : dto.getPayableOrders()) {
|
||||||
for (OmsPayableTicketPlan ticketPlanDto : payableOrderDto.getTicketPlans()) {
|
for (OmsPayableTicketPlan ticketPlanDto : payableOrderDto.getTicketPlans()) {
|
||||||
|
// 检查是否存在已收票的记录
|
||||||
|
OmsPayableTicketDetail existingDetail = existingDetailsMap.get(ticketPlanDto.getId());
|
||||||
|
if (existingDetail != null) {
|
||||||
|
// 检查是否是已收票状态,如果是则抛出异常
|
||||||
|
if (!OmsPayableTicketDetail.PayableDetailTypeEnum.RED_RUSH.getCode().equals(existingDetail.getPayableDetailType())) {
|
||||||
|
throw new ServiceException("计划ID为 " + ticketPlanDto.getId() + " 的收票已处理,请刷新页面后重试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OmsPayableTicketDetail detail = new OmsPayableTicketDetail();
|
OmsPayableTicketDetail detail = new OmsPayableTicketDetail();
|
||||||
detail.setPayableBillId(payableOrderDto.getId());
|
detail.setPayableBillId(payableOrderDto.getId());
|
||||||
detail.setTicketPlanId(ticketPlanDto.getId());
|
detail.setTicketPlanId(ticketPlanDto.getId());
|
||||||
|
|
@ -296,12 +382,88 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
detail.setPaymentAmount(ticketPlanDto.getPlanAmount());
|
detail.setPaymentAmount(ticketPlanDto.getPlanAmount());
|
||||||
detail.setPaymentRate(ticketPlanDto.getPlanRate());
|
detail.setPaymentRate(ticketPlanDto.getPlanRate());
|
||||||
detail.setPaymentTime(ticketPlanDto.getPlanTicketDate());
|
detail.setPaymentTime(ticketPlanDto.getPlanTicketDate());
|
||||||
|
detail.setRemark(ticketPlanDto.getRemark());
|
||||||
detail.setCreateBy(ShiroUtils.getLoginName());
|
detail.setCreateBy(ShiroUtils.getLoginName());
|
||||||
detail.setPayableDetailType(OmsPayableTicketDetail.PayableDetailTypeEnum.TICKET.getCode());
|
detail.setPayableDetailType(OmsPayableTicketDetail.PayableDetailTypeEnum.TICKET.getCode());
|
||||||
omsPayableTicketDetailService.insertOmsPayableTicketDetail(detail);
|
omsPayableTicketDetailService.insertOmsPayableTicketDetail(detail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
|
// 批量更新应付单的收票相关信息
|
||||||
|
return SpringUtils.getAopProxy(this).updateTicketAmount(dto.getPayableOrders().stream().map(PayableOrderReceiptDto::getId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updatePaymentAmount(List<Long> idList) {
|
||||||
|
if (CollUtil.isEmpty(idList)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
OmsPayableBill omsPayableBill = new OmsPayableBill();
|
||||||
|
omsPayableBill.setIdList(idList);
|
||||||
|
List<OmsPayableBill> omsPayableBills = omsPayableBillMapper.selectOmsPayableBillList(omsPayableBill);
|
||||||
|
if (CollUtil.isEmpty(omsPayableBills)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<OmsPayablePaymentDetail> omsPayablePaymentDetails = omsPayablePaymentDetailService.listByPayableBillIdList(idList);
|
||||||
|
Map<Long, Map<String, BigDecimal>> planMap = omsPayablePaymentDetails.stream().collect(Collectors.groupingBy(OmsPayablePaymentDetail::getPayableBillId,
|
||||||
|
Collectors.groupingBy(
|
||||||
|
item -> item.getPaymentStatus() == null ? OmsPaymentBill.PaymentStatusEnum.WAIT_PAYMENT.getCode() : item.getPaymentStatus(),
|
||||||
|
Collectors.reducing(
|
||||||
|
BigDecimal.ZERO,
|
||||||
|
detail -> (detail.getPaymentAmount() != null) ? detail.getPaymentAmount() : BigDecimal.ZERO,
|
||||||
|
BigDecimal::add
|
||||||
|
))));
|
||||||
|
for (OmsPayableBill payableBill : omsPayableBills) {
|
||||||
|
Map<String, BigDecimal> amountMap = planMap.get(payableBill.getId());
|
||||||
|
if (CollUtil.isNotEmpty(amountMap)) {
|
||||||
|
//已付金额 = 已付款金额-退款金额
|
||||||
|
payableBill.setPaidPaymentAmount(amountMap.getOrDefault(OmsPaymentBill.PaymentStatusEnum.PAYMENT.getCode(), BigDecimal.ZERO)
|
||||||
|
.subtract(amountMap.getOrDefault(OmsPaymentBill.PaymentStatusEnum.REFUNDED.getCode(), BigDecimal.ZERO)));
|
||||||
|
//未付金额=总金额-已付金额-付款中金额
|
||||||
|
payableBill.setUnpaidPaymentAmount(payableBill.getTotalPriceWithTax().subtract(payableBill.getPaidPaymentAmount())
|
||||||
|
.subtract(amountMap.getOrDefault(OmsPaymentBill.PaymentStatusEnum.WAIT_PAYMENT.getCode(), BigDecimal.ZERO)));
|
||||||
|
}
|
||||||
|
OmsPayablePaymentPlan payablePaymentPlan = omsPayablePaymentPlanMapper.firstUnPayPlan(payableBill.getId());
|
||||||
|
payableBill.setLastPaymentPlanId(payablePaymentPlan == null ? -1 : payablePaymentPlan.getId());
|
||||||
|
}
|
||||||
|
return omsPayableBillMapper.updateBatchPayableBillPaymentInfo(omsPayableBills);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateTicketAmount(List<Long> idList) {
|
||||||
|
if (CollUtil.isEmpty(idList)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
OmsPayableBill omsPayableBill = new OmsPayableBill();
|
||||||
|
omsPayableBill.setIdList(idList);
|
||||||
|
List<OmsPayableBill> omsPayableBills = omsPayableBillMapper.selectOmsPayableBillList(omsPayableBill);
|
||||||
|
if (CollUtil.isEmpty(omsPayableBills)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
List<OmsPayableTicketDetail> omsPayableTicketDetails = omsPayableTicketDetailService.listByPayableBillIdList(idList);
|
||||||
|
Map<Long, Map<String, BigDecimal>> planMap = omsPayableTicketDetails.stream().collect(Collectors.groupingBy(OmsPayableTicketDetail::getPayableBillId,
|
||||||
|
Collectors.groupingBy(
|
||||||
|
item -> item.getTicketStatus() == null ? OmsTicketBill.TicketStatusEnum.WAIT_TICKET.getCode() : item.getTicketStatus(),
|
||||||
|
Collectors.reducing(
|
||||||
|
BigDecimal.ZERO,
|
||||||
|
detail -> (detail.getPaymentAmount() != null) ? detail.getPaymentAmount() : BigDecimal.ZERO,
|
||||||
|
BigDecimal::add
|
||||||
|
))));
|
||||||
|
for (OmsPayableBill payableBill : omsPayableBills) {
|
||||||
|
Map<String, BigDecimal> amountMap = planMap.get(payableBill.getId());
|
||||||
|
if (CollUtil.isNotEmpty(amountMap)) {
|
||||||
|
//已付金额 = 已付款金额-退款金额
|
||||||
|
payableBill.setReceivedTicketAmount(amountMap.getOrDefault(OmsTicketBill.TicketStatusEnum.TICKET.getCode(), BigDecimal.ZERO)
|
||||||
|
.subtract(amountMap.getOrDefault(OmsPaymentBill.PaymentStatusEnum.REFUNDED.getCode(), BigDecimal.ZERO)));
|
||||||
|
//未付金额=总金额-已付金额-付款中金额
|
||||||
|
payableBill.setUnreceivedTicketAmount(payableBill.getTotalPriceWithTax().subtract(payableBill.getPaidPaymentAmount()
|
||||||
|
.subtract(amountMap.getOrDefault(OmsTicketBill.TicketStatusEnum.WAIT_TICKET.getCode(), BigDecimal.ZERO))));
|
||||||
|
}
|
||||||
|
OmsPayableTicketPlan omsPayableTicketPlan = omsPayableTicketPlanMapper.firstUnPayPlan(payableBill.getId());
|
||||||
|
payableBill.setLastTicketPlanId(omsPayableTicketPlan == null ? -1 : omsPayableTicketPlan.getId());
|
||||||
|
}
|
||||||
|
return omsPayableBillMapper.updateBatchPayableBillTicketInfo(omsPayableBills);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -309,20 +471,20 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
||||||
OmsPayableBill omsPayableBill = selectOmsPayableBillById(id);
|
OmsPayableBill omsPayableBill = selectOmsPayableBillById(id);
|
||||||
List<OmsPayablePaymentDetail> omsPayablePaymentDetails = omsPayablePaymentDetailService.listByPayableBillId(id);
|
List<OmsPayablePaymentDetail> omsPayablePaymentDetails = omsPayablePaymentDetailService.listByPayableBillId(id);
|
||||||
omsPayableBill.setDetailList(omsPayablePaymentDetails);
|
omsPayableBill.setDetailList(omsPayablePaymentDetails);
|
||||||
Map<String, BigDecimal> decimalMap = omsPayablePaymentDetails.stream()
|
// Map<String, BigDecimal> decimalMap = omsPayablePaymentDetails.stream()
|
||||||
.collect(Collectors.groupingBy(
|
// .collect(Collectors.groupingBy(
|
||||||
item->item.getPaymentStatus()==null?OmsPaymentBill.PaymentStatusEnum.WAIT_PAYMENT.getCode(): item.getPaymentStatus(),
|
// item->item.getPaymentStatus()==null?OmsPaymentBill.PaymentStatusEnum.WAIT_PAYMENT.getCode(): item.getPaymentStatus(),
|
||||||
Collectors.reducing(
|
// Collectors.reducing(
|
||||||
BigDecimal.ZERO,
|
// BigDecimal.ZERO,
|
||||||
detail -> (detail.getPaymentAmount() != null) ? detail.getPaymentAmount() : BigDecimal.ZERO,
|
// detail -> (detail.getPaymentAmount() != null) ? detail.getPaymentAmount() : BigDecimal.ZERO,
|
||||||
BigDecimal::add
|
// BigDecimal::add
|
||||||
)
|
// )
|
||||||
));
|
// ));
|
||||||
|
|
||||||
omsPayableBill.setPaidAmount(decimalMap.getOrDefault(OmsPaymentBill.PaymentStatusEnum.PAYMENT.getCode(), BigDecimal.ZERO));
|
// omsPayableBill.setPaidAmount(decimalMap.getOrDefault(OmsPaymentBill.PaymentStatusEnum.PAYMENT.getCode(), BigDecimal.ZERO));
|
||||||
omsPayableBill.setPayingAmount(decimalMap.getOrDefault(OmsPaymentBill.PaymentStatusEnum.WAIT_PAYMENT.getCode(), BigDecimal.ZERO));
|
// omsPayableBill.setPayingAmount(decimalMap.getOrDefault(OmsPaymentBill.PaymentStatusEnum.WAIT_PAYMENT.getCode(), BigDecimal.ZERO));
|
||||||
BigDecimal decimal = omsPayableBill.getTotalPriceWithTax().subtract(omsPayableBill.getPaidAmount()).subtract(omsPayableBill.getPayingAmount());
|
// BigDecimal decimal = omsPayableBill.getTotalPriceWithTax().subtract(omsPayableBill.getPaidAmount()).subtract(omsPayableBill.getPayingAmount());
|
||||||
omsPayableBill.setUnpaidAmount(decimal);
|
// omsPayableBill.setUnpaidAmount(decimal);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,4 +100,9 @@ public class OmsPayablePaymentDetailServiceImpl implements IOmsPayablePaymentDet
|
||||||
return paymentBillPayableDetailDTOS;
|
return paymentBillPayableDetailDTOS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OmsPayablePaymentDetail> selectByPaymentPlanIds(List<Long> paymentPlanIds) {
|
||||||
|
return omsPayablePaymentDetailMapper.selectByPaymentPlanIds(paymentPlanIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.ruoyi.common.utils.ShiroUtils;
|
import com.ruoyi.common.utils.ShiroUtils;
|
||||||
import com.ruoyi.sip.domain.OmsPayablePaymentDetail;
|
import com.ruoyi.sip.domain.*;
|
||||||
import com.ruoyi.sip.domain.OmsPayableTicketPlan;
|
import com.ruoyi.sip.mapper.OmsPayableBillMapper;
|
||||||
import com.ruoyi.sip.service.IOmsPayablePaymentDetailService;
|
import com.ruoyi.sip.service.IOmsPayablePaymentDetailService;
|
||||||
import com.ruoyi.sip.service.IOmsPayableTicketPlanService;
|
import com.ruoyi.sip.service.IOmsPayableTicketPlanService;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
|
@ -19,15 +19,17 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.ruoyi.sip.mapper.OmsPayablePaymentPlanMapper;
|
import com.ruoyi.sip.mapper.OmsPayablePaymentPlanMapper;
|
||||||
import com.ruoyi.sip.domain.OmsPayablePaymentPlan;
|
|
||||||
import com.ruoyi.sip.service.IOmsPayablePaymentPlanService;
|
import com.ruoyi.sip.service.IOmsPayablePaymentPlanService;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class OmsPayablePaymentPlanServiceImpl implements IOmsPayablePaymentPlanService {
|
public class OmsPayablePaymentPlanServiceImpl implements IOmsPayablePaymentPlanService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OmsPayablePaymentPlanMapper omsPayablePaymentPlanMapper;
|
private OmsPayablePaymentPlanMapper omsPayablePaymentPlanMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OmsPayableBillMapper billMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOmsPayablePaymentDetailService omsPayablePaymentDetailService;
|
private IOmsPayablePaymentDetailService omsPayablePaymentDetailService;
|
||||||
|
|
||||||
|
|
@ -81,6 +83,12 @@ public class OmsPayablePaymentPlanServiceImpl implements IOmsPayablePaymentPlanS
|
||||||
for (Long idToDelete : existingPlanIdSet) {
|
for (Long idToDelete : existingPlanIdSet) {
|
||||||
omsPayablePaymentPlanMapper.deleteOmsPayablePaymentPlanById(idToDelete);
|
omsPayablePaymentPlanMapper.deleteOmsPayablePaymentPlanById(idToDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OmsPayablePaymentPlan payablePaymentPlan = omsPayablePaymentPlanMapper.firstUnPayPlan(payableBillId);
|
||||||
|
OmsPayableBill payableBill = new OmsPayableBill();
|
||||||
|
payableBill.setId(payableBillId);
|
||||||
|
payableBill.setLastPaymentPlanId(payablePaymentPlan == null ? -1 : payablePaymentPlan.getId());
|
||||||
|
billMapper.updateOmsPayableBill(payableBill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -152,4 +152,9 @@ public class OmsPayableTicketDetailServiceImpl implements IOmsPayableTicketDetai
|
||||||
public List<OmsPayableTicketDetail> listByPayableBillIdList(List<Long> payableBillId) {
|
public List<OmsPayableTicketDetail> listByPayableBillIdList(List<Long> payableBillId) {
|
||||||
return omsPayableTicketDetailMapper.listByPayableBillIdList(payableBillId);
|
return omsPayableTicketDetailMapper.listByPayableBillIdList(payableBillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OmsPayableTicketDetail> selectByTicketPlanIds(List<Long> ticketPlanIds) {
|
||||||
|
return omsPayableTicketDetailMapper.selectByTicketPlanIds(ticketPlanIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,14 +9,12 @@ import java.util.stream.Collectors;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.ShiroUtils;
|
import com.ruoyi.common.utils.ShiroUtils;
|
||||||
import com.ruoyi.sip.domain.OmsPayablePaymentDetail;
|
import com.ruoyi.sip.domain.*;
|
||||||
import com.ruoyi.sip.domain.OmsPayablePaymentPlan;
|
import com.ruoyi.sip.mapper.OmsPayableBillMapper;
|
||||||
import com.ruoyi.sip.domain.OmsPayableTicketDetail;
|
|
||||||
import com.ruoyi.sip.service.IOmsPayableTicketDetailService;
|
import com.ruoyi.sip.service.IOmsPayableTicketDetailService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.sip.mapper.OmsPayableTicketPlanMapper;
|
import com.ruoyi.sip.mapper.OmsPayableTicketPlanMapper;
|
||||||
import com.ruoyi.sip.domain.OmsPayableTicketPlan;
|
|
||||||
import com.ruoyi.sip.service.IOmsPayableTicketPlanService;
|
import com.ruoyi.sip.service.IOmsPayableTicketPlanService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,6 +29,8 @@ public class OmsPayableTicketPlanServiceImpl implements IOmsPayableTicketPlanSer
|
||||||
private OmsPayableTicketPlanMapper omsPayableTicketPlanMapper;
|
private OmsPayableTicketPlanMapper omsPayableTicketPlanMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOmsPayableTicketDetailService detailService;
|
private IOmsPayableTicketDetailService detailService;
|
||||||
|
@Autowired
|
||||||
|
private OmsPayableBillMapper billMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询应付单收票计划
|
* 查询应付单收票计划
|
||||||
|
|
@ -148,5 +148,11 @@ public class OmsPayableTicketPlanServiceImpl implements IOmsPayableTicketPlanSer
|
||||||
for (Long idToDelete : existingPlanIdSet) {
|
for (Long idToDelete : existingPlanIdSet) {
|
||||||
omsPayableTicketPlanMapper.deleteOmsPayableTicketPlanById(idToDelete);
|
omsPayableTicketPlanMapper.deleteOmsPayableTicketPlanById(idToDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OmsPayableTicketPlan payablePaymentPlan = omsPayableTicketPlanMapper.firstUnPayPlan(payableBillId);
|
||||||
|
OmsPayableBill payableBill = new OmsPayableBill();
|
||||||
|
payableBill.setId(payableBillId);
|
||||||
|
payableBill.setLastTicketPlanId(payablePaymentPlan == null ? -1 : payablePaymentPlan.getId());
|
||||||
|
billMapper.updateOmsPayableBill(payableBill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<resultMap type="OmsPayableBill" id="OmsPayableBillResult">
|
<resultMap type="OmsPayableBill" id="OmsPayableBillResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="payableBillCode" column="payable_bill_code" />
|
<result property="payableBillCode" column="payable_bill_code" />
|
||||||
<result property="estimatedPaymentTime" column="estimated_payment_time" />
|
|
||||||
<result property="vendorCode" column="vendor_code" />
|
<result property="vendorCode" column="vendor_code" />
|
||||||
<result property="orderCode" column="order_code" />
|
<result property="orderCode" column="order_code" />
|
||||||
<result property="inventoryCode" column="inventory_code" />
|
<result property="inventoryCode" column="inventory_code" />
|
||||||
|
|
@ -15,6 +14,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="totalPriceWithTax" column="total_price_with_tax" />
|
<result property="totalPriceWithTax" column="total_price_with_tax" />
|
||||||
<result property="totalPriceWithoutTax" column="total_price_without_tax" />
|
<result property="totalPriceWithoutTax" column="total_price_without_tax" />
|
||||||
<result property="taxAmount" column="tax_amount" />
|
<result property="taxAmount" column="tax_amount" />
|
||||||
|
<result property="lastPaymentPlanId" column="last_payment_plan_id" />
|
||||||
|
<result property="lastTicketPlanId" column="last_ticket_plan_id" />
|
||||||
|
<result property="paidPaymentAmount" column="paid_payment_amount" />
|
||||||
|
<result property="unpaidPaymentAmount" column="unpaid_payment_amount" />
|
||||||
|
<result property="receivedTicketAmount" column="received_ticket_amount" />
|
||||||
|
<result property="unreceivedTicketAmount" column="unreceived_ticket_amount" />
|
||||||
|
<result property="planPaymentDate" column="plan_payment_date" />
|
||||||
|
<result property="planAmount" column="plan_amount" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
|
|
@ -24,13 +31,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectOmsPayableBillVo">
|
<sql id="selectOmsPayableBillVo">
|
||||||
select id, payable_bill_code, estimated_payment_time, vendor_code, order_code, inventory_code, product_type, total_price_with_tax, total_price_without_tax, tax_amount, create_by, create_time, update_by, update_time, remark, del_flag from oms_payable_bill
|
select
|
||||||
</sql>
|
|
||||||
<sql id="selectOmsPayableBillRelationVo">
|
|
||||||
SELECT
|
|
||||||
t1.id,
|
t1.id,
|
||||||
t1.payable_bill_code,
|
t1.payable_bill_code,
|
||||||
t1.estimated_payment_time,
|
|
||||||
t1.vendor_code,
|
t1.vendor_code,
|
||||||
t1.order_code,
|
t1.order_code,
|
||||||
t1.inventory_code,
|
t1.inventory_code,
|
||||||
|
|
@ -38,7 +41,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
t1.total_price_with_tax,
|
t1.total_price_with_tax,
|
||||||
t1.total_price_without_tax,
|
t1.total_price_without_tax,
|
||||||
t1.tax_amount,
|
t1.tax_amount,
|
||||||
|
t1.paid_payment_amount,
|
||||||
|
t1.unpaid_payment_amount,
|
||||||
|
t1.received_ticket_amount,
|
||||||
|
t1.unreceived_ticket_amount,
|
||||||
|
t1.last_payment_plan_id,
|
||||||
|
t1.last_ticket_plan_id,
|
||||||
|
t1.create_by,
|
||||||
|
t1.create_time,
|
||||||
|
t1.update_by,
|
||||||
|
t1.update_time,
|
||||||
|
t1.remark,
|
||||||
|
t1.del_flag
|
||||||
|
from oms_payable_bill t1
|
||||||
|
</sql>
|
||||||
|
<sql id="selectOmsPayableBillRelationVo">
|
||||||
|
SELECT
|
||||||
|
t1.id,
|
||||||
|
t1.payable_bill_code,
|
||||||
|
t1.vendor_code,
|
||||||
|
t1.order_code,
|
||||||
|
t1.inventory_code,
|
||||||
|
t1.product_type,
|
||||||
|
t1.total_price_with_tax,
|
||||||
|
t1.total_price_without_tax,
|
||||||
|
t1.tax_amount,
|
||||||
|
t1.paid_payment_amount,
|
||||||
|
t1.unpaid_payment_amount,
|
||||||
|
t1.received_ticket_amount,
|
||||||
|
t1.unreceived_ticket_amount,
|
||||||
|
t1.last_payment_plan_id,
|
||||||
|
t1.last_ticket_plan_id,
|
||||||
t1.create_by,
|
t1.create_by,
|
||||||
t1.create_time,
|
t1.create_time,
|
||||||
t1.update_by,
|
t1.update_by,
|
||||||
|
|
@ -47,18 +80,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
t1.del_flag ,
|
t1.del_flag ,
|
||||||
t3.project_code,
|
t3.project_code,
|
||||||
t3.project_name,
|
t3.project_name,
|
||||||
t4.vendor_name
|
t4.vendor_name,
|
||||||
|
ppp.plan_payment_date,
|
||||||
|
ppp.plan_amount,
|
||||||
|
t5.plan_ticket_date,
|
||||||
|
t5.plan_amount as plan_ticket_amount
|
||||||
FROM
|
FROM
|
||||||
oms_payable_bill t1
|
oms_payable_bill t1
|
||||||
left join project_order_info t2 on t1.order_code=t2.order_code
|
left join project_order_info t2 on t1.order_code=t2.order_code
|
||||||
left join project_info t3 on t2.project_id=t3.id
|
left join project_info t3 on t2.project_id=t3.id
|
||||||
left join oms_vendor_info t4 on t1.vendor_code=t4.vendor_code
|
left join oms_vendor_info t4 on t1.vendor_code=t4.vendor_code
|
||||||
|
left join oms_payable_payment_plan ppp on t1.last_payment_plan_id = ppp.id
|
||||||
|
left join oms_payable_ticket_plan t5 on t1.last_ticket_plan_id = t5.id
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectOmsPayableBillList" parameterType="OmsPayableBill" resultMap="OmsPayableBillResult">
|
<select id="selectOmsPayableBillList" parameterType="OmsPayableBill" resultMap="OmsPayableBillResult">
|
||||||
<include refid="selectOmsPayableBillRelationVo"/>
|
<include refid="selectOmsPayableBillRelationVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="payableBillCode != null and payableBillCode != ''"> and t1.payable_bill_code like concat( #{payableBillCode},'%') </if>
|
<if test="payableBillCode != null and payableBillCode != ''"> and t1.payable_bill_code like concat( #{payableBillCode},'%') </if>
|
||||||
<if test="estimatedPaymentTime != null "> and t1.estimated_payment_time = #{estimatedPaymentTime}</if>
|
<if test="idList != null and idList.size>0"> and t1.id in <foreach item="item" collection="idList" separator="," open="(" close=")" index="">#{item}</foreach></if>
|
||||||
<if test="vendorCode != null and vendorCode != ''"> and t1.vendor_code = #{vendorCode}</if>
|
<if test="vendorCode != null and vendorCode != ''"> and t1.vendor_code = #{vendorCode}</if>
|
||||||
<if test="vendorName != null and vendorName != ''"> and t4.vendor_name = #{vendorName}</if>
|
<if test="vendorName != null and vendorName != ''"> and t4.vendor_name = #{vendorName}</if>
|
||||||
<if test="projectCode != null and projectCode != ''"> and t3.project_code = #{projectCode}</if>
|
<if test="projectCode != null and projectCode != ''"> and t3.project_code = #{projectCode}</if>
|
||||||
|
|
@ -69,6 +108,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="totalPriceWithTax != null "> and t1.total_price_with_tax = #{totalPriceWithTax}</if>
|
<if test="totalPriceWithTax != null "> and t1.total_price_with_tax = #{totalPriceWithTax}</if>
|
||||||
<if test="totalPriceWithoutTax != null "> and t1.total_price_without_tax = #{totalPriceWithoutTax}</if>
|
<if test="totalPriceWithoutTax != null "> and t1.total_price_without_tax = #{totalPriceWithoutTax}</if>
|
||||||
<if test="taxAmount != null "> and t1.tax_amount = #{taxAmount}</if>
|
<if test="taxAmount != null "> and t1.tax_amount = #{taxAmount}</if>
|
||||||
|
<if test="paidPaymentAmount != null "> and t1.paid_payment_amount = #{paidPaymentAmount}</if>
|
||||||
|
<if test="unpaidPaymentAmount != null "> and t1.unpaid_payment_amount = #{unpaidPaymentAmount}</if>
|
||||||
|
<if test="receivedTicketAmount != null "> and t1.received_ticket_amount = #{receivedTicketAmount}</if>
|
||||||
|
<if test="unreceivedTicketAmount != null "> and t1.unreceived_ticket_amount = #{unreceivedTicketAmount}</if>
|
||||||
|
<if test="lastPaymentPlanId != null"> and t1.last_payment_plan_id = #{lastPaymentPlanId}</if>
|
||||||
|
<if test="lastTicketPlanId != null"> and t1.last_ticket_plan_id = #{lastTicketPlanId}</if>
|
||||||
|
<if test="planPaymentDate != null "> and ppp.plan_payment_date = #{planPaymentDate}</if>
|
||||||
|
<if test="planAmount != null "> and ppp.plan_amount = #{planAmount}</if>
|
||||||
<if test="createTimeStart != null or createTimeEnd != null">
|
<if test="createTimeStart != null or createTimeEnd != null">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="createTimeStart != null and createTimeEnd != null">
|
<when test="createTimeStart != null and createTimeEnd != null">
|
||||||
|
|
@ -83,18 +130,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
</choose>
|
</choose>
|
||||||
</if>
|
</if>
|
||||||
<if test="estimatedPaymentTimeStart != null or estimatedPaymentTimeEnd != null">
|
<if test="planPaymentDateStart != null or planPaymentDateEnd != null">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="estimatedPaymentTimeStart != null and estimatedPaymentTimeEnd != null">
|
<when test="planPaymentDateStart != null and planPaymentDateEnd != null">
|
||||||
and t1.estimated_payment_time between date_format(#{estimatedPaymentTimeStart}, '%Y-%m-%d 00:00:00') and date_format(#{estimatedPaymentTimeEnd}, '%Y-%m-%d 23:59:59')
|
and ppp.plan_payment_date between date_format(#{planPaymentDateStart}, '%Y-%m-%d 00:00:00') and date_format(#{planPaymentDateEnd}, '%Y-%m-%d 23:59:59')
|
||||||
</when>
|
</when>
|
||||||
<when test="estimatedPaymentTimeStart != null">
|
<when test="planPaymentDateStart != null">
|
||||||
and t1.estimated_payment_time <![CDATA[ >= ]]> date_format(#{estimatedPaymentTimeStart}, '%Y-%m-%d 00:00:00')
|
and ppp.plan_payment_date <![CDATA[ >= ]]> date_format(#{planPaymentDateStart}, '%Y-%m-%d 00:00:00')
|
||||||
</when>
|
</when>
|
||||||
<when test="estimatedPaymentTimeEnd != null">
|
<when test="planPaymentDateEnd != null">
|
||||||
and t1.estimated_payment_time <![CDATA[ <= ]]> date_format(#{estimatedPaymentTimeEnd}, '%Y-%m-%d 23:59:59')
|
and ppp.plan_payment_date <![CDATA[ <= ]]> date_format(#{planPaymentDateEnd}, '%Y-%m-%d 23:59:59')
|
||||||
</when>
|
</when>
|
||||||
|
|
||||||
</choose>
|
</choose>
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
|
@ -114,14 +160,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
insert into oms_payable_bill
|
insert into oms_payable_bill
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="payableBillCode != null and payableBillCode != ''">payable_bill_code,</if>
|
<if test="payableBillCode != null and payableBillCode != ''">payable_bill_code,</if>
|
||||||
<if test="estimatedPaymentTime != null">estimated_payment_time,</if>
|
|
||||||
<if test="vendorCode != null">vendor_code,</if>
|
<if test="vendorCode != null">vendor_code,</if>
|
||||||
<if test="orderCode != null">order_code,</if>
|
<if test="orderCode != null">order_code,</if>
|
||||||
<if test="inventoryCode != null">inventory_code,</if>
|
<if test="inventoryCode != null">inventory_code,</if>
|
||||||
<if test="productType != null">product_type,</if>
|
<if test="productType != null">product_type,</if>
|
||||||
|
<if test="productCode != null">product_code,</if>
|
||||||
<if test="totalPriceWithTax != null">total_price_with_tax,</if>
|
<if test="totalPriceWithTax != null">total_price_with_tax,</if>
|
||||||
<if test="totalPriceWithoutTax != null">total_price_without_tax,</if>
|
<if test="totalPriceWithoutTax != null">total_price_without_tax,</if>
|
||||||
<if test="taxAmount != null">tax_amount,</if>
|
<if test="taxAmount != null">tax_amount,</if>
|
||||||
|
<if test="paidPaymentAmount != null">paid_payment_amount,</if>
|
||||||
|
<if test="unpaidPaymentAmount != null">unpaid_payment_amount,</if>
|
||||||
|
<if test="receivedTicketAmount != null">received_ticket_amount,</if>
|
||||||
|
<if test="unreceivedTicketAmount != null">unreceived_ticket_amount,</if>
|
||||||
|
<if test="lastPaymentPlanId != null">last_payment_plan_id,</if>
|
||||||
|
<if test="lastTicketPlanId != null">last_ticket_plan_id,</if>
|
||||||
|
<if test="taxRate != null">tax_rate,</if>
|
||||||
|
|
||||||
|
|
||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
|
|
@ -133,15 +186,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="payableBillCode != null and payableBillCode != ''">#{payableBillCode},</if>
|
<if test="payableBillCode != null and payableBillCode != ''">#{payableBillCode},</if>
|
||||||
<if test="estimatedPaymentTime != null">#{estimatedPaymentTime},</if>
|
|
||||||
<if test="vendorCode != null">#{vendorCode},</if>
|
<if test="vendorCode != null">#{vendorCode},</if>
|
||||||
<if test="orderCode != null">#{orderCode},</if>
|
<if test="orderCode != null">#{orderCode},</if>
|
||||||
<if test="inventoryCode != null">#{inventoryCode},</if>
|
<if test="inventoryCode != null">#{inventoryCode},</if>
|
||||||
<if test="productType != null">#{productType},</if>
|
<if test="productType != null">#{productType},</if>
|
||||||
|
<if test="productCode != null">#{productCode},</if>
|
||||||
<if test="totalPriceWithTax != null">#{totalPriceWithTax},</if>
|
<if test="totalPriceWithTax != null">#{totalPriceWithTax},</if>
|
||||||
<if test="totalPriceWithoutTax != null">#{totalPriceWithoutTax},</if>
|
<if test="totalPriceWithoutTax != null">#{totalPriceWithoutTax},</if>
|
||||||
<if test="taxAmount != null">#{taxAmount},</if>
|
<if test="taxAmount != null">#{taxAmount},</if>
|
||||||
|
<if test="paidPaymentAmount != null">#{paidPaymentAmount},</if>
|
||||||
|
<if test="unpaidPaymentAmount != null">#{unpaidPaymentAmount},</if>
|
||||||
|
<if test="receivedTicketAmount != null">#{receivedTicketAmount},</if>
|
||||||
|
<if test="unreceivedTicketAmount != null">#{unreceivedTicketAmount},</if>
|
||||||
|
<if test="lastPaymentPlanId != null">#{lastPaymentPlanId},</if>
|
||||||
|
<if test="lastTicketPlanId != null">#{lastTicketPlanId},</if>
|
||||||
|
<if test="taxRate != null">#{taxRate},</if>
|
||||||
|
|
||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
|
@ -156,7 +215,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
update oms_payable_bill
|
update oms_payable_bill
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="payableBillCode != null and payableBillCode != ''">payable_bill_code = #{payableBillCode},</if>
|
<if test="payableBillCode != null and payableBillCode != ''">payable_bill_code = #{payableBillCode},</if>
|
||||||
<if test="estimatedPaymentTime != null">estimated_payment_time = #{estimatedPaymentTime},</if>
|
|
||||||
<if test="vendorCode != null">vendor_code = #{vendorCode},</if>
|
<if test="vendorCode != null">vendor_code = #{vendorCode},</if>
|
||||||
<if test="orderCode != null">order_code = #{orderCode},</if>
|
<if test="orderCode != null">order_code = #{orderCode},</if>
|
||||||
<if test="inventoryCode != null">inventory_code = #{inventoryCode},</if>
|
<if test="inventoryCode != null">inventory_code = #{inventoryCode},</if>
|
||||||
|
|
@ -164,6 +222,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="totalPriceWithTax != null">total_price_with_tax = #{totalPriceWithTax},</if>
|
<if test="totalPriceWithTax != null">total_price_with_tax = #{totalPriceWithTax},</if>
|
||||||
<if test="totalPriceWithoutTax != null">total_price_without_tax = #{totalPriceWithoutTax},</if>
|
<if test="totalPriceWithoutTax != null">total_price_without_tax = #{totalPriceWithoutTax},</if>
|
||||||
<if test="taxAmount != null">tax_amount = #{taxAmount},</if>
|
<if test="taxAmount != null">tax_amount = #{taxAmount},</if>
|
||||||
|
<if test="paidPaymentAmount != null">paid_payment_amount = #{paidPaymentAmount},</if>
|
||||||
|
<if test="unpaidPaymentAmount != null">unpaid_payment_amount = #{unpaidPaymentAmount},</if>
|
||||||
|
<if test="receivedTicketAmount != null">received_ticket_amount = #{receivedTicketAmount},</if>
|
||||||
|
<if test="unreceivedTicketAmount != null">unreceived_ticket_amount = #{unreceivedTicketAmount},</if>
|
||||||
|
<if test="lastPaymentPlanId != null">last_payment_plan_id = #{lastPaymentPlanId},</if>
|
||||||
|
<if test="lastTicketPlanId != null">last_ticket_plan_id = #{lastTicketPlanId},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
|
@ -179,10 +243,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteOmsPayableBillByIds" parameterType="String">
|
<delete id="deleteOmsPayableBillByIds" parameterType="String">
|
||||||
delete from oms_payable_bill where id in
|
delete from oms_payable_bill where id in
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<update id="updateBatchPayableBillPaymentInfo">
|
||||||
|
<foreach collection="list" item="item" separator=";">
|
||||||
|
UPDATE oms_payable_bill
|
||||||
|
SET
|
||||||
|
last_payment_plan_id = #{item.lastPaymentPlanId},
|
||||||
|
paid_payment_amount = #{item.paidPaymentAmount},
|
||||||
|
unpaid_payment_amount = #{item.unpaidPaymentAmount},
|
||||||
|
update_time = NOW(),
|
||||||
|
update_by = #{item.updateBy}
|
||||||
|
WHERE id = #{item.id}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
<update id="updateBatchPayableBillTicketInfo">
|
||||||
|
<foreach collection="list" item="item" separator=";">
|
||||||
|
UPDATE oms_payable_bill
|
||||||
|
SET
|
||||||
|
last_ticket_plan_id = #{item.lastTicketPlanId},
|
||||||
|
received_ticket_amount = #{item.receivedTicketAmount},
|
||||||
|
unreceived_ticket_amount = #{item.unreceivedTicketAmount},
|
||||||
|
update_time = NOW(),
|
||||||
|
update_by = #{item.updateBy}
|
||||||
|
WHERE id = #{item.id}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -75,6 +75,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByPaymentPlanIds" resultType="com.ruoyi.sip.domain.OmsPayablePaymentDetail">
|
||||||
|
SELECT
|
||||||
|
t1.id, t1.payment_plan_id, t1.payable_bill_id, t1.payment_time,
|
||||||
|
t1.payment_amount, t1.payment_rate, t1.payment_bill_code, t1.remark,
|
||||||
|
t1.create_time, t1.create_by, t1.update_time, t1.payable_detail_type
|
||||||
|
FROM
|
||||||
|
oms_payable_payment_detail t1
|
||||||
|
WHERE t1.payment_plan_id IN
|
||||||
|
<foreach collection="paymentPlanIds" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
ORDER BY t1.create_time DESC
|
||||||
|
</select>
|
||||||
<select id="listPayableByPaymentCode" resultType="com.ruoyi.sip.domain.dto.PaymentBillPayableDetailDTO">
|
<select id="listPayableByPaymentCode" resultType="com.ruoyi.sip.domain.dto.PaymentBillPayableDetailDTO">
|
||||||
select t1.payment_amount, t2.payable_bill_code, t4.project_name, t4.project_code, t2.total_price_with_tax
|
select t1.payment_amount, t2.payable_bill_code, t4.project_name, t4.project_code, t2.total_price_with_tax
|
||||||
from (SELECT sum(payment_amount) payment_amount,
|
from (SELECT sum(payment_amount) payment_amount,
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectInventoryInfoVo">
|
<sql id="selectInventoryInfoVo">
|
||||||
select t1.id, t1.product_code, t1.product_sn, t1.inventory_status, t1.inner_code, t1.outer_code, t1.warehouse_id, t1.inner_price,
|
select t1.id, t1.product_code, t1.product_sn, t1.inventory_status, t1.inner_code, t1.outer_code, t1.warehouse_id, t1.inner_price,t1.tax_rate,
|
||||||
t1.outer_price, t1.create_by, t1.create_time, t1.update_by, t1.update_time ,
|
t1.outer_price, t1.create_by, t1.create_time, t1.update_by, t1.update_time ,
|
||||||
t2.warehouse_name,t3.description as 'product_desc',t3.model
|
t2.warehouse_name,t3.description as 'product_desc',t3.model
|
||||||
from oms_inventory_info t1
|
from oms_inventory_info t1
|
||||||
|
|
@ -135,10 +135,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="saveBatch">
|
<insert id="saveBatch">
|
||||||
insert into oms_inventory_info (product_code, product_sn, inventory_status, inner_code, outer_code
|
insert into oms_inventory_info (product_code, product_sn, inventory_status, inner_code, outer_code
|
||||||
, warehouse_id, inner_price, outer_price, create_by, create_time, update_by, update_time,payable_bill_code) values
|
, warehouse_id, inner_price, outer_price, create_by, create_time, update_by, update_time,payable_bill_code,tax_rate) values
|
||||||
<foreach item="item" index="index" collection="list" separator=",">
|
<foreach item="item" index="index" collection="list" separator=",">
|
||||||
(#{item.productCode}, #{item.productSn}, #{item.inventoryStatus}, #{item.innerCode}, #{item.outerCode}
|
(#{item.productCode}, #{item.productSn}, #{item.inventoryStatus}, #{item.innerCode}, #{item.outerCode}
|
||||||
, #{item.warehouseId}, #{item.innerPrice}, #{item.outerPrice}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime},#{item.payableBillCode})
|
, #{item.warehouseId}, #{item.innerPrice}, #{item.outerPrice}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime},#{item.payableBillCode},#{item.taxRate})
|
||||||
</foreach>
|
</foreach>
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
inventory_status = VALUES(inventory_status),
|
inventory_status = VALUES(inventory_status),
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<select id="selectOmsPayablePaymentPlanIdsByPayableBillId" parameterType="Long" resultType="Long">
|
<select id="selectOmsPayablePaymentPlanIdsByPayableBillId" parameterType="Long" resultType="Long">
|
||||||
select id from oms_payable_payment_plan where payable_bill_id = #{payableBillId}
|
select id from oms_payable_payment_plan where payable_bill_id = #{payableBillId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="firstUnPayPlan" resultType="com.ruoyi.sip.domain.OmsPayablePaymentPlan">
|
||||||
|
select t1.id,
|
||||||
|
t1.payable_bill_id,
|
||||||
|
t1.plan_payment_date,
|
||||||
|
t1.plan_amount,
|
||||||
|
t1.plan_rate,
|
||||||
|
t1.remark,
|
||||||
|
t1.create_time,
|
||||||
|
t1.create_by,
|
||||||
|
t1.update_time
|
||||||
|
from oms_payable_payment_plan t1
|
||||||
|
left join oms_payable_payment_detail t2 on t1.id = t2.payment_plan_id
|
||||||
|
where t2.id is null and t1.payable_bill_id = #{payableBillId}
|
||||||
|
order by plan_payment_date
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
<select id="listDetailByPayableBillIdList" resultType="com.ruoyi.sip.domain.OmsPayablePaymentPlan">
|
||||||
|
select t1.id,
|
||||||
|
t1.payable_bill_id,
|
||||||
|
t1.plan_payment_date,
|
||||||
|
t1.plan_amount,
|
||||||
|
t1.plan_rate,
|
||||||
|
t1.remark,
|
||||||
|
t1.create_time,
|
||||||
|
t1.create_by,
|
||||||
|
t1.update_time
|
||||||
|
from oms_payable_payment_plan t1
|
||||||
|
left join oms_payable_payment_detail t2 on t1.id = t2.payment_plan_id
|
||||||
|
left join oms_payment_bill t3 on t1.id = t3.id
|
||||||
|
where t1.payable_bill_id in
|
||||||
|
<foreach item="item" index="index" collection="list" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertOmsPayablePaymentPlan" parameterType="OmsPayablePaymentPlan" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertOmsPayablePaymentPlan" parameterType="OmsPayablePaymentPlan" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into oms_payable_payment_plan(
|
insert into oms_payable_payment_plan(
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByTicketPlanIds" resultType="com.ruoyi.sip.domain.OmsPayableTicketDetail">
|
||||||
|
<include refid="selectOmsPayableTicketDetailVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="list != null and list.size > 0">
|
||||||
|
and ticket_plan_id in
|
||||||
|
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectOmsPayableTicketDetailById" parameterType="Long" resultMap="OmsPayableTicketDetailResult">
|
<select id="selectOmsPayableTicketDetailById" parameterType="Long" resultMap="OmsPayableTicketDetailResult">
|
||||||
<include refid="selectOmsPayableTicketDetailVo"/>
|
<include refid="selectOmsPayableTicketDetailVo"/>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<include refid="selectOmsPayableTicketPlanVo"/>
|
<include refid="selectOmsPayableTicketPlanVo"/>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="firstUnPayPlan" resultType="com.ruoyi.sip.domain.OmsPayableTicketPlan">
|
||||||
|
select t1.id, t1.payable_bill_id, t1.plan_ticket_date, t1.plan_amount, t1.plan_rate, t1.create_by, t1.create_time, t1.update_by,
|
||||||
|
t1.update_time
|
||||||
|
from oms_payable_ticket_plan t1
|
||||||
|
left join oms_payable_ticket_detail t2 on t1.id=t2.ticket_plan_id
|
||||||
|
where t2.id is null and t1.payable_bill_id=#{payableBillId}
|
||||||
|
order by t1.plan_ticket_date
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertOmsPayableTicketPlan" parameterType="com.ruoyi.sip.domain.OmsPayableTicketPlan" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertOmsPayableTicketPlan" parameterType="com.ruoyi.sip.domain.OmsPayableTicketPlan" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into oms_payable_ticket_plan
|
insert into oms_payable_ticket_plan
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue