Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add payment documents and keep repeating payment #344

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,20 @@ public Response<String> addOrUpdatePaymentReceipt(AddOrUpdatePaymentDTO addOrUpd
.set(FinancialMain::getUpdateTime, LocalDateTime.now())
.update();

var account = accountService.getById(addOrUpdatePaymentDTO.getPaymentAccountId());
if (account != null) {
var accountBalance = account.getCurrentAmount();
var changeAmount = addOrUpdatePaymentDTO.getActualPaymentAmount();
var beforeChangeAmount = beforeReceipt.stream()
.map(FinancialSub::getSingleAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
accountBalance = accountBalance.add(beforeChangeAmount);
if (changeAmount != null) {
accountBalance = accountBalance.subtract(changeAmount);
}
account.setCurrentAmount(accountBalance);
accountService.updateById(account);
}
// var account = accountService.getById(addOrUpdatePaymentDTO.getPaymentAccountId());
// if (account != null) {
// var accountBalance = account.getCurrentAmount();
// var changeAmount = addOrUpdatePaymentDTO.getActualPaymentAmount();
// var beforeChangeAmount = beforeReceipt.stream()
// .map(FinancialSub::getSingleAmount)
// .reduce(BigDecimal.ZERO, BigDecimal::add);
// accountBalance = accountBalance.add(beforeChangeAmount);
// if (changeAmount != null) {
// accountBalance = accountBalance.subtract(changeAmount);
// }
// account.setCurrentAmount(accountBalance);
// accountService.updateById(account);
// }

if (!updateSubResult || !updateFinancialMain) {
return Response.responseMsg(CollectionPaymentCodeEnum.UPDATE_PAYMENT_RECEIPT_ERROR);
Expand Down Expand Up @@ -338,18 +338,18 @@ public Response<String> addOrUpdatePaymentReceipt(AddOrUpdatePaymentDTO addOrUpd
.collect(Collectors.toList());
var saveSubResult = financialSubService.saveBatch(financialSub);

var account = accountService.getById(addOrUpdatePaymentDTO.getPaymentAccountId());
if (account != null) {
// 更新余额 采购划扣金额
var accountBalance = account.getCurrentAmount();
var changeAmount = addOrUpdatePaymentDTO.getActualPaymentAmount();
if (changeAmount != null) {
accountBalance = accountBalance.subtract(changeAmount);
account.setId(addOrUpdatePaymentDTO.getPaymentAccountId());
account.setCurrentAmount(accountBalance);
accountService.updateById(account);
}
}
// var account = accountService.getById(addOrUpdatePaymentDTO.getPaymentAccountId());
// if (account != null) {
// // 更新余额 采购划扣金额
// var accountBalance = account.getCurrentAmount();
// var changeAmount = addOrUpdatePaymentDTO.getActualPaymentAmount();
// if (changeAmount != null) {
// accountBalance = accountBalance.subtract(changeAmount);
// account.setId(addOrUpdatePaymentDTO.getPaymentAccountId());
// account.setCurrentAmount(accountBalance);
// accountService.updateById(account);
// }
// }

if (!saveResult || !saveSubResult) {
return Response.responseMsg(CollectionPaymentCodeEnum.ADD_PAYMENT_RECEIPT_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,10 @@ public Response<PurchaseStorageDetailVO> getPurchaseStorageDetail(Long id) {
if (id == null) {
return Response.responseMsg(BaseCodeEnum.PARAMETER_NULL);
}
var purchaseMain = getById(id);
var purchaseMain = lambdaQuery()
.eq(ReceiptPurchaseMain::getId, id)
.eq(ReceiptPurchaseMain::getDeleteFlag, CommonConstants.NOT_DELETED)
.one();
var purchasesStorageDetailVO = createPurchaseStorageDetail(purchaseMain);
return Response.responseData(purchasesStorageDetailVO);
}
Expand Down Expand Up @@ -1289,7 +1292,7 @@ public Response<Page<PurchaseArrearsVO>> getPurchaseArrearsPage(QueryPurchaseArr
var operatorName = getUserName(item.getCreateBy());
var financeMainList = paymentReceiptService.lambdaQuery()
.eq(FinancialMain::getRelatedPersonId, item.getSupplierId())
.eq(FinancialMain::getStatus, CommonConstants.NOT_DELETED)
.eq(FinancialMain::getDeleteFlag, CommonConstants.NOT_DELETED)
.list();
var purchaseArrearsVO = PurchaseArrearsVO.builder()
.id(item.getId())
Expand All @@ -1300,19 +1303,27 @@ public Response<Page<PurchaseArrearsVO>> getPurchaseArrearsPage(QueryPurchaseArr
.operatorName(operatorName)
.thisReceiptArrears(item.getArrearsAmount())
.build();


BigDecimal prepaidArrears = BigDecimal.ZERO;

if(!financeMainList.isEmpty()) {
for (FinancialMain financialMain : financeMainList) {
var financeSubList = financialSubService.lambdaQuery()
.eq(FinancialSub::getFinancialMainId, financialMain.getId())
.eq(FinancialSub::getOtherReceipt, item.getReceiptNumber())
.eq(FinancialSub::getDeleteFlag, CommonConstants.NOT_DELETED)
.list();
var receivedArrears = calculateArrearsAmount(financeSubList, FinancialSub::getReceivedPrepaidArrears);
purchaseArrearsVO.setPrepaidArrears(receivedArrears);
purchaseArrearsVO.setPaymentArrears(item.getArrearsAmount().subtract(receivedArrears));
prepaidArrears = prepaidArrears.add(calculateArrearsAmount(financeSubList, FinancialSub::getReceivedPrepaidArrears));
}
}
purchaseArrearsVOList.add(purchaseArrearsVO);
BigDecimal paymentArrears = item.getArrearsAmount().subtract(prepaidArrears);
// Only add the PurchaseArrearsVO to the list if there are remaining arrears
if (paymentArrears.compareTo(BigDecimal.ZERO) > 0) {
purchaseArrearsVO.setPrepaidArrears(prepaidArrears);
purchaseArrearsVO.setPaymentArrears(paymentArrears);
purchaseArrearsVOList.add(purchaseArrearsVO);
}
});
result.setRecords(purchaseArrearsVOList);
result.setTotal(queryResult.getTotal());
Expand Down
2 changes: 1 addition & 1 deletion web/src/api/financial/payment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {defHttp} from '/@/utils/http/axios';
import {defHttp} from '@/utils/http/axios';
import {ErrorMessageMode, SuccessMessageMode} from '/#/axios';
import {BaseDataResp, BaseResp} from "@/api/model/baseModel";
import {
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/lang/en/financial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ export default {
noticeTwo: 'Please select the payment account',
noticeThree: 'The file exceeds the 2MB size limit',
noticeFour: 'Are you sure you want to delete the selected data?',
noticeFive: 'To avoid duplicate addition of the same purchase debt document number, please modify the existing document',
total: 'Total',
inputRemark: 'Please enter the remark',
annex: 'Attachment',
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/lang/zh-CN/financial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ export default {
noticeTwo: '请选择付款账户',
noticeThree: '该文件超过2MB大小限制',
noticeFour: '确定要删除选中的数据?',
noticeFive: '为避免重复添加相同的采购欠款单据号,请修改已有的单据',
total: '合计',
inputRemark: '请输入备注',
annex: '附件',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ import {
tableData,
gridOptions,
getThisPaymentAmount
} from '/@/views/financial/payment/addEditPayment.data';
} from '@/views/financial/payment/addEditPayment.data';
import {getOperatorList} from "@/api/basic/operator";
import {OperatorResp} from "@/api/basic/model/operatorModel";
import {useModal} from "@/components/Modal";
Expand All @@ -184,7 +184,7 @@ import FinancialAccountModal from "@/views/basic/settlement-account/components/F
import {VXETable, VxeGrid, VxeInput, VxeButton, VxeSelect, VxeOption} from 'vxe-table'
import {useMessage} from "@/hooks/web/useMessage";
import { addOrUpdatePayment, getPaymentDetailById} from "@/api/financial/payment"
import {FileData} from '/@/api/retail/model/shipmentsModel';
import {FileData} from '@/api/retail/model/shipmentsModel';
import {getAccountList} from "@/api/financial/account";
import {getSupplierList} from "@/api/basic/supplier";
import XEUtils from "xe-utils";
Expand Down Expand Up @@ -411,6 +411,7 @@ export default defineComponent({
createMessage.warn(t('financial.payment.form.inputDiscountAmount'));
return;
}

const table = xGrid.value
if(table) {
const insertRecords = table.getInsertRecords()
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/purchase/model/addEditModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ interface PurchaseStorageFormState {
paymentLastAmount: number | string;
otherAmount: number;
thisPaymentAmount: number | string;
thisArrearsAmount: number | string;
thisArrearsAmount: number;
remark: string;
status: number | undefined;
warehouseId: number | string;
Expand Down
11 changes: 4 additions & 7 deletions web/src/views/purchase/storage/components/AddEditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export default defineComponent({
purchaseStorageFormState.otherReceipt = data.otherReceipt
purchaseStorageFormState.otherAmount = data.otherAmount
purchaseStorageFormState.thisPaymentAmount = data.thisPaymentAmount
purchaseStorageFormState.thisArrearsAmount = amountSymbol.value + `${XEUtils.commafy(XEUtils.toNumber(data.thisArrearsAmount), {digits: 2})}`
purchaseStorageFormState.thisArrearsAmount = `${XEUtils.commafy(XEUtils.toNumber(data.thisArrearsAmount), {digits: 2})}`
// 判断多账户渲染
if (data.multipleAccountAmounts.length > 0 && data.multipleAccountIds.length > 0) {
manyAccountBtnStatus.value = true
Expand Down Expand Up @@ -992,8 +992,7 @@ export default defineComponent({

watch(getTaxTotalPrice, (newValue) => {
purchaseStorageFormState.paymentLastAmount = newValue
purchaseStorageFormState.thisPaymentAmount = newValue
discountAmountChange()
// purchaseStorageFormState.thisPaymentAmount = newValue
});

function onSearch() {
Expand Down Expand Up @@ -1025,9 +1024,9 @@ export default defineComponent({
const price = getTaxTotalPrice.value;
const discountLastAmount = Number(price.replace(/,/g, '').replace(amountSymbol.value, ''))
const discountAmount = purchaseStorageFormState.paymentAmount
const arrearsAmount = purchaseStorageFormState.thisArrearsAmount
const otherAmount = purchaseStorageFormState.otherAmount
const lastAmount = Number((discountLastAmount - discountAmount));
purchaseStorageFormState.thisArrearsAmount = 0
const lastAmount = Number((discountLastAmount - discountAmount - arrearsAmount));
purchaseStorageFormState.paymentAmount = Number(discountAmount.toFixed(2))
purchaseStorageFormState.paymentLastAmount = amountSymbol.value + `${XEUtils.commafy(XEUtils.toNumber(lastAmount), {digits: 2})}`
purchaseStorageFormState.thisPaymentAmount = amountSymbol.value + `${XEUtils.commafy(XEUtils.toNumber(Number((lastAmount + otherAmount))), {digits: 2})}`
Expand Down Expand Up @@ -1055,9 +1054,7 @@ export default defineComponent({
const otherAmount = purchaseStorageFormState.otherAmount
const thisCollectAmount = purchaseStorageFormState.thisPaymentAmount
const lastAmount = Number((discountLastAmount + otherAmount - thisCollectAmount));

purchaseStorageFormState.thisArrearsAmount = amountSymbol.value + `${XEUtils.commafy(XEUtils.toNumber(lastAmount), {digits: 2})}`

}

const selectAccountChange = (value: number) => {
Expand Down
Loading