fix:
1.销售出库单提交,客户有信保逾期或者欠条没核销不能提交,获取到逾期金额和欠条金额
This commit is contained in:
parent
3f03c787b3
commit
6af58fd314
@ -24,7 +24,7 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
@Override
|
||||
public void validate() {
|
||||
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||
for(ExtendedDataEntity dataEntitie : dataEntities){
|
||||
for (ExtendedDataEntity dataEntitie : dataEntities) {
|
||||
// arrearsAmtValidator(dataEntitie);
|
||||
if (specialApplicationShipment(dataEntitie)) continue;
|
||||
hasArrearsValidator(dataEntitie);
|
||||
@ -36,6 +36,7 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
|
||||
/**
|
||||
* 最后一笔出库的时候,判断出库金额是否和合同金额相等
|
||||
*
|
||||
* @param dataEntitie
|
||||
*/
|
||||
private void checkAmountAligned(ExtendedDataEntity dataEntitie) {
|
||||
@ -147,10 +148,10 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
/**
|
||||
* 校验当前客户是否有信保逾期
|
||||
* 信保限额申请单分录的应收款日期1小于当前时间并且有欠款金额
|
||||
*
|
||||
* @param entry
|
||||
*/
|
||||
private void creditInsuranceOverdueVerification(ExtendedDataEntity entry)
|
||||
{
|
||||
private void creditInsuranceOverdueVerification(ExtendedDataEntity entry) {
|
||||
DynamicObject dataEntity = entry.getDataEntity();
|
||||
dataEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(), dataEntity.getDynamicObjectType().getName());
|
||||
DynamicObject customer = dataEntity.getDynamicObject("yem_customer");
|
||||
@ -161,9 +162,11 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
DynamicObject method = TotalUtil.getSettlementMethod(shippingdetails);
|
||||
DynamicObject company = dataEntity.getDynamicObject("yem_company.yem_erporg");
|
||||
String swiftCode = TotalUtil.getSwiftCode(shippingdetails);
|
||||
BigDecimal yemArrearsamtapply = shippingdetails.getBigDecimal("yem_arrearsamtapply");
|
||||
DynamicObject creditLine = TotalUtil.getCsrCreditLine(customer, method, company, swiftCode);
|
||||
if (creditLine == null) return;
|
||||
DynamicObjectCollection collection = creditLine.getDynamicObjectCollection("yem_im_info");
|
||||
BigDecimal amountoweds = BigDecimal.ZERO;
|
||||
for (DynamicObject dynamicObject : collection) {
|
||||
// 应收款日期1
|
||||
Date paydate = dynamicObject.getDate("yem_paydate1");
|
||||
@ -171,9 +174,22 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
Date now = new Date();
|
||||
if (paydate == null) continue;
|
||||
if (amountowed.compareTo(BigDecimal.ZERO) > 0 && paydate.before(now)) {
|
||||
this.addErrorMessage(entry, String.format("客户 %s 信保逾期,请确认!", customer.getString("name")));
|
||||
amountoweds = amountowed.add(amountoweds);
|
||||
}
|
||||
}
|
||||
String string = "";
|
||||
if (amountoweds.compareTo(BigDecimal.ZERO) > 0 || yemArrearsamtapply.compareTo(BigDecimal.ZERO) > 0) {
|
||||
string = "客户" + customer.getString("name") + "信保逾期,";
|
||||
}
|
||||
if (amountoweds.compareTo(BigDecimal.ZERO) > 0) {
|
||||
string = string + "欠款金额:" + amountoweds;
|
||||
} else if (yemArrearsamtapply.compareTo(BigDecimal.ZERO) > 0) {
|
||||
string = string + "欠条金额:" + yemArrearsamtapply;
|
||||
}
|
||||
if (!string.isEmpty()) {
|
||||
string = string+",请确认!";
|
||||
}
|
||||
this.addErrorMessage(entry ,string);
|
||||
}
|
||||
|
||||
|
||||
@ -184,22 +200,22 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
* return
|
||||
* @time 2023/11/9 14:57
|
||||
*/
|
||||
public void arrearsAmtValidator(ExtendedDataEntity dataEntitie){
|
||||
public void arrearsAmtValidator(ExtendedDataEntity dataEntitie) {
|
||||
DynamicObject dataEntity = dataEntitie.getDataEntity();
|
||||
long id = dataEntity.getLong("id");
|
||||
String coreBillType = dataEntity.getString("yem_corebilltype");
|
||||
long coreBillId = dataEntity.getLong("yem_corebillid");
|
||||
if(YEM.isNotEmpty(coreBillType) && YEM.isNotEmpty(coreBillId)){
|
||||
DynamicObject saleOrder = BusinessDataServiceHelper.loadSingle(coreBillId,coreBillType);
|
||||
if (YEM.isNotEmpty(coreBillType) && YEM.isNotEmpty(coreBillId)) {
|
||||
DynamicObject saleOrder = BusinessDataServiceHelper.loadSingle(coreBillId, coreBillType);
|
||||
BigDecimal rapRate = PaymentControlUtil.getRapRate(saleOrder);
|
||||
BigDecimal collection = PaymentControlUtil.getCollection(coreBillId);//A 合同的所有收款
|
||||
BigDecimal contractPayment = PaymentControlUtil.getAdvancePayment(PaymentControlUtil.getContractPayment(saleOrder),rapRate);//B 合同的预收款
|
||||
BigDecimal deliverPayment = PaymentControlUtil.getBalancePayment(PaymentControlUtil.getDeliverPayment(id, coreBillType, coreBillId),rapRate);//C 提交、审核的历史发货尾款
|
||||
BigDecimal translateDeliverPayment = PaymentControlUtil.getBalancePayment(PaymentControlUtil.getTranslateDeliverPayment(dataEntity),rapRate);//D 本次发货尾款
|
||||
BigDecimal contractPayment = PaymentControlUtil.getAdvancePayment(PaymentControlUtil.getContractPayment(saleOrder), rapRate);//B 合同的预收款
|
||||
BigDecimal deliverPayment = PaymentControlUtil.getBalancePayment(PaymentControlUtil.getDeliverPayment(id, coreBillType, coreBillId), rapRate);//C 提交、审核的历史发货尾款
|
||||
BigDecimal translateDeliverPayment = PaymentControlUtil.getBalancePayment(PaymentControlUtil.getTranslateDeliverPayment(dataEntity), rapRate);//D 本次发货尾款
|
||||
BigDecimal arrearsAmt = collection.subtract(contractPayment).subtract(deliverPayment).subtract(translateDeliverPayment).setScale(2, RoundingMode.HALF_UP);
|
||||
if(arrearsAmt.compareTo(BigDecimal.ZERO) < 0){
|
||||
if (arrearsAmt.compareTo(BigDecimal.ZERO) < 0) {
|
||||
BigDecimal fAbs = arrearsAmt.abs().setScale(2, RoundingMode.HALF_UP);
|
||||
this.addErrorMessage(dataEntitie,String.format("截止当前,本发货通知单存在欠款,欠款金额为%s,不允许提交,请收款齐全后重试!",fAbs));
|
||||
this.addErrorMessage(dataEntitie, String.format("截止当前,本发货通知单存在欠款,欠款金额为%s,不允许提交,请收款齐全后重试!", fAbs));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,7 +229,7 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
* @time 2023/11/13 15:13
|
||||
*/
|
||||
|
||||
public void isStorageTrans(ExtendedDataEntity dataEntitie){
|
||||
public void isStorageTrans(ExtendedDataEntity dataEntitie) {
|
||||
DynamicObject dataEntity = dataEntitie.getDataEntity();
|
||||
List<Long> entryIds = new ArrayList();
|
||||
DynamicObjectCollection materialInfos = dataEntity.getDynamicObjectCollection("yem_es_materialinfo");
|
||||
@ -223,20 +239,20 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
entryIds.add(sourceEntryId);
|
||||
}
|
||||
|
||||
Map<Long, Map<String,BigDecimal>> allMap = new HashMap<>();
|
||||
Map<Long, Map<String, BigDecimal>> allMap = new HashMap<>();
|
||||
DynamicObject[] shippingDetails = BusinessDataServiceHelper.load("yem_shippingdetails", "yem_es_materialinfo.yem_storageqty,yem_es_materialinfo.yem_deliveryqty",
|
||||
new QFilter[]{new QFilter("yem_es_materialinfo.id", QCP.in, entryIds)});
|
||||
for(DynamicObject shippingDetail : shippingDetails){
|
||||
for (DynamicObject shippingDetail : shippingDetails) {
|
||||
DynamicObjectCollection shippingMaterialInfos = shippingDetail.getDynamicObjectCollection("yem_es_materialinfo");
|
||||
for(DynamicObject shippingMaterialInfo : shippingMaterialInfos){
|
||||
for (DynamicObject shippingMaterialInfo : shippingMaterialInfos) {
|
||||
long materialInfoId = shippingMaterialInfo.getLong("id");
|
||||
if(entryIds.contains(materialInfoId)){
|
||||
if (entryIds.contains(materialInfoId)) {
|
||||
HashMap<String, BigDecimal> map = new HashMap<>();
|
||||
BigDecimal storageQty = shippingMaterialInfo.getBigDecimal("yem_storageqty");
|
||||
BigDecimal deliveryQty = shippingMaterialInfo.getBigDecimal("yem_deliveryqty");
|
||||
map.put("storageQty",storageQty);
|
||||
map.put("deliveryQty",deliveryQty);
|
||||
allMap.put(materialInfoId,map);
|
||||
map.put("storageQty", storageQty);
|
||||
map.put("deliveryQty", deliveryQty);
|
||||
allMap.put(materialInfoId, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -244,11 +260,11 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
DynamicObject materialInfo = materialInfos.get(i);
|
||||
long sourceEntryId = materialInfo.getLong("yem_sourceentryid");
|
||||
Map<String, BigDecimal> map = allMap.get(sourceEntryId);
|
||||
if(YEM.isNotEmpty(map)){
|
||||
if (YEM.isNotEmpty(map)) {
|
||||
BigDecimal storageQty = map.get("storageQty");
|
||||
BigDecimal deliveryQty = map.get("deliveryQty");
|
||||
if(deliveryQty.compareTo(storageQty) > 0){
|
||||
this.addErrorMessage(dataEntitie,String.format("发货通知单明细信息第%s行还未进行储运,请下推订舱通知单后,在提交发货通知单!",i + 1));
|
||||
if (deliveryQty.compareTo(storageQty) > 0) {
|
||||
this.addErrorMessage(dataEntitie, String.format("发货通知单明细信息第%s行还未进行储运,请下推订舱通知单后,在提交发货通知单!", i + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -256,10 +272,10 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
|
||||
/**
|
||||
* 1、销售出库对应的合同(非本次发运明细单)--欠条是否有核销掉
|
||||
*
|
||||
* @param dataEntities
|
||||
*/
|
||||
private void hasArrearsValidator(ExtendedDataEntity dataEntities)
|
||||
{
|
||||
private void hasArrearsValidator(ExtendedDataEntity dataEntities) {
|
||||
// 销售出库单
|
||||
DynamicObject dataEntity = dataEntities.getDataEntity();
|
||||
long shipDetailId = dataEntity.getLong("yem_sourcebillid");
|
||||
@ -298,12 +314,13 @@ public class DeliverNoticeSubmitValidator extends AbstractValidator {
|
||||
}
|
||||
}
|
||||
if (totalArrearsAmt.compareTo(BigDecimal.ZERO) > 0) {
|
||||
this.addErrorMessage(dataEntities, String.format("合同 %s 下还有未核销的欠条:%s,未核销金额为 %s,请核销后再提交!", contractnum, Arrays.toString(billno.toArray()),totalArrearsAmt.setScale(2, RoundingMode.HALF_UP)));
|
||||
this.addErrorMessage(dataEntities, String.format("合同 %s 下还有未核销的欠条:%s,未核销金额为 %s,请核销后再提交!", contractnum, Arrays.toString(billno.toArray()), totalArrearsAmt.setScale(2, RoundingMode.HALF_UP)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售出库提交时,如果有已审核的发货特殊申请,不需要校验是否信保预期,是否由未核销掉的欠条,否则需要核销;
|
||||
*
|
||||
* @param dataEntitie
|
||||
* @return
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user