付款申请单已审核 重新添加发票

This commit is contained in:
程小伟 2025-05-08 10:17:08 +08:00
parent d830cc43ad
commit 113f2a4e47
2 changed files with 64 additions and 39 deletions

View File

@ -13,7 +13,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
public class customPaymentApplyEditUI extends PaymentApplyEditUI {
public class CustomPaymentApplyEditUI extends PaymentApplyEditUI {
public void closedCallBack(ClosedCallBackEvent event) {
super.closedCallBack(event);
String actionId = event.getActionId();

View File

@ -33,39 +33,52 @@ public class SupplementInvoiceBillPlugin extends PaymentApplyEditUI {
private static final Log log = LogFactory.getLog(SupplementInvoiceBillPlugin.class);
@Override
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
super.beforeDoOperation(args);
FormOperate operate = (FormOperate)args.getSource();
String key = operate.getOperateKey();//获取操作码
log.info("SupplementInvoiceBillPlugin:操作码:"+key);
if(StringUtil.equals("supplementinvoice", key)) {//候补发票
log.info("SupplementInvoiceBillPlugin:点击候补发票");
this.beforeNewSubEntry(args);
String billId = this.getModel().getDataEntity().getPkValue().toString();
log.info("SupplementInvoiceBillPlugin:主键值:"+billId);
if (!billId.equals("0") && "A".equals(this.getModel().getValue("billstatus"))){
log.info("SupplementInvoiceBillPlugin:单据暂存,走父类方法");
super.beforeDoOperation(args);
} else if (!billId.equals("0") &&"C".equals(this.getModel().getValue("billstatus"))){
log.info("SupplementInvoiceBillPlugin:单据已审核,走子类方法");
FormOperate operate = (FormOperate)args.getSource();
String key = operate.getOperateKey();//获取操作码
log.info("SupplementInvoiceBillPlugin:操作码:"+key);
if(StringUtil.equals("supplementinvoice", key)) {//候补发票
log.info("SupplementInvoiceBillPlugin:点击候补发票");
this.beforeNewSubEntry1(args);
}
}
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
log.info("SupplementInvoiceBillPlugin:发生变动的字段:"+e.getProperty().getName());
String billId = this.getModel().getDataEntity().getPkValue().toString();
log.info("SupplementInvoiceBillPlugin:主键名:"+billId);
if (!billId.equals("0") && "C".equals(this.getModel().getValue("billstatus"))){//单据为已审核情况下
log.info("SupplementInvoiceBillPlugin:主键值:"+billId);
if (!billId.equals("0") && "A".equals(this.getModel().getValue("billstatus"))){
super.propertyChanged(e);
} else if (!billId.equals("0") &&"C".equals(this.getModel().getValue("billstatus"))){
String key = e.getProperty().getName();
// int rowIndex = e.getChangeSet()[0].getRowIndex();
log.info("SupplementInvoiceBillPlugin:发生变动的字段:"+key);
if(StringUtil.equals("applyinvoftaxamt", key)) {
log.info("SupplementInvoiceBillPlugin:发票申请金额发生变动,与合同的申请金额进行比较");
this.compareApplyInvoftaxamt();
this.compareApplyInvoftaxamt1();
}
}
}
private void compareApplyInvoftaxamt() {
private void compareApplyInvoftaxamt1() {
int rowIndex = this.getModel().getEntryCurrentRowIndex("entryentity");
DynamicObject rowEntity = this.getModel().getEntryRowEntity("entryentity", rowIndex);//获取对应行的单据体
BigDecimal applyoftaxamount = rowEntity.getBigDecimal("applyoftaxamount");//获取单据体对应的 本次应付金额字段
BigDecimal totalAmount = this.getSum("subentryentity", "applyinvoftaxamt");//算出子单据申请金额总和
BigDecimal totalAmount = this.getSum1("subentryentity", "applyinvoftaxamt");//算出子单据申请金额总和
if(applyoftaxamount.compareTo(totalAmount)!=0){
this.getView().showTipNotification(
"合同付款信息 第"+(rowIndex+1)+"行的 本次申请金额\n" +
@ -73,7 +86,7 @@ public class SupplementInvoiceBillPlugin extends PaymentApplyEditUI {
}
}
protected void beforeNewSubEntry(BeforeDoOperationEventArgs args) {
protected void beforeNewSubEntry1(BeforeDoOperationEventArgs args) {
String billId = this.getModel().getDataEntity().getPkValue().toString();
log.info("SupplementInvoiceBillPlugin:主键值:"+billId);
if (!billId.equals("0") && "C".equals(this.getModel().getValue("billstatus"))) {//单据状态是否为审核
@ -84,9 +97,12 @@ public class SupplementInvoiceBillPlugin extends PaymentApplyEditUI {
if (rows.length != 1) {//只能选择一条
this.getView().showMessage(ResManager.loadKDString("必须选中一条合同付款信息记录。", "PaymentApplyEditUI_2", "ec-contract-formplugin", new Object[0]));
args.setCancel(true);
}else if(!this.hasInvoice(rows[0])) {//没有对应的发票进项发票候补
}else if(this.hasInvoice1(rows[0])){
this.getView().showMessage(ResManager.loadKDString("发票已导入,无需候补。", "PaymentApplyEditUI_2", "ec-contract-formplugin", new Object[0]));
args.setCancel(true);
}else if(!this.hasInvoice1(rows[0])) {//没有对应的发票进项发票候补
log.info("SupplementInvoiceBillPlugin:单据已审核,已选择一条合同付款信息记录,没有对应的发票,可以进项发票候补");
this.showInvoice("subentryentity");
this.showInvoice1("subentryentity");
}
} else {
@ -94,7 +110,7 @@ public class SupplementInvoiceBillPlugin extends PaymentApplyEditUI {
args.setCancel(true);
}
}
private void showInvoice(String entryType) {
private void showInvoice1(String entryType) {
log.info("SupplementInvoiceBillPlugin:在进项发票基础资料中进项筛选");
Object currencyId = this.getModel().getValue("currency_id");
long orgId = ((DynamicObject)this.getModel().getValue("org")).getLong("id");
@ -137,16 +153,24 @@ public class SupplementInvoiceBillPlugin extends PaymentApplyEditUI {
@Override
public void closedCallBack(ClosedCallBackEvent event) {
super.closedCallBack(event);
String actionId = event.getActionId();//获取回调标识
Object returnData = event.getReturnData();//获取子页面返回的数据
log.info("SupplementInvoiceBillPlugin:获取回调标识:"+actionId);
if (actionId.equals("subentryentity") && returnData != null) {
this.invoiceCloseCallBack(event);
String billId = this.getModel().getDataEntity().getPkValue().toString();
log.info("SupplementInvoiceBillPlugin:主键值:"+billId);
if (!billId.equals("0") && "A".equals(this.getModel().getValue("billstatus"))){
super.closedCallBack(event);
} else if (!billId.equals("0") &&"C".equals(this.getModel().getValue("billstatus"))){
String actionId = event.getActionId();//获取回调标识
Object returnData = event.getReturnData();//获取子页面返回的数据
log.info("SupplementInvoiceBillPlugin:获取回调标识:"+actionId);
if (actionId.equals("subentryentity") && returnData != null) {
this.invoiceCloseCallBack1(event);
}
}
}
protected void invoiceCloseCallBack(ClosedCallBackEvent event) {
protected void invoiceCloseCallBack1(ClosedCallBackEvent event) {
ListSelectedRowCollection rows = (ListSelectedRowCollection)event.getReturnData();
DynamicObject[] invArr = new DynamicObject[rows.size()];
int index = 0;
@ -177,36 +201,36 @@ public class SupplementInvoiceBillPlugin extends PaymentApplyEditUI {
log.info("SupplementInvoiceBillPlugin:发票保存");
SaveServiceHelper.save(invArr);//发票保存
this.getView().invokeOperation("invoicesave");
this.setEnableByInvoice();
this.setEnableByInvoice1();
}
protected void setEnableByInvoice() {
protected void setEnableByInvoice1() {
int entryRowCount = this.getModel().getEntryRowCount("entryentity");
log.info("SupplementInvoiceBillPlugin:有发票,合同记录锁定 thisapplyoftax thisapplyamout 字段");
for(int i = 0; i < entryRowCount; ++i) {//有发票锁定 "thisapplyoftax", "thisapplyamount" 字段
this.getView().setEnable(!this.hasInvoice(i), i, new String[]{"thisapplyoftax", "thisapplyamount"});
this.getView().setEnable(!this.hasInvoice1(i), i, new String[]{"thisapplyoftax", "thisapplyamount"});
}
}
protected boolean hasInvoice(int rowIndex) {
protected boolean hasInvoice1(int rowIndex) {
DynamicObject rowEntity = this.getModel().getEntryRowEntity("entryentity", rowIndex);//获取对应的单据体
DynamicObjectCollection subEntries = rowEntity.getDynamicObjectCollection("subentryentity");//获取单据体对应的子单据体
return subEntries != null && !subEntries.isEmpty();//子单据体不为null且有数据
}
protected void setApplyAmtByInvoice(String subColumnId, String contractColumnId, int rowIndex) {
BigDecimal totalAmount = this.getSum("subentryentity", subColumnId);
// this.getModel().setValue(contractColumnId, totalAmount, rowIndex);
}
// protected void setApplyAmtByInvoice(String subColumnId, String contractColumnId, int rowIndex) {
// BigDecimal totalAmount = this.getSum("subentryentity", subColumnId);
//// this.getModel().setValue(contractColumnId, totalAmount, rowIndex);
// }
protected void setApplyAmtByInvoice(int rowIndex) {
this.setApplyAmtByInvoice("applyinvoftaxamt", "applyoftaxamount", rowIndex);
// this.setApplyAmtByInvoice("applyinvamt", "applyamount", rowIndex);
// this.setApplyAmtByInvoice("applyinvtax", "applytaxamount", rowIndex);
}
// protected void setApplyAmtByInvoice(int rowIndex) {
// this.setApplyAmtByInvoice("applyinvoftaxamt", "applyoftaxamount", rowIndex);
//// this.setApplyAmtByInvoice("applyinvamt", "applyamount", rowIndex);
//// this.setApplyAmtByInvoice("applyinvtax", "applytaxamount", rowIndex);
// }
protected BigDecimal getSum(String entryId, String columnId) {
protected BigDecimal getSum1(String entryId, String columnId) {
int rowCount = this.getModel().getEntryRowCount(entryId);
BigDecimal totalAmount = BigDecimal.ZERO;