|
|
|
@ -3,6 +3,7 @@ package zcgj.zcdev.zcdev.pr.plugin.form;
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
|
import kd.bos.dataentity.utils.StringUtils;
|
|
|
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
|
|
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
|
|
|
import kd.bos.form.CloseCallBack;
|
|
|
|
|
import kd.bos.form.ShowFormHelper;
|
|
|
|
|
import kd.bos.list.ListShowParameter;
|
|
|
|
@ -20,25 +21,20 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onThisQtyChanged(ChangeData changeData) {
|
|
|
|
|
BigDecimal qty = this.defaultZeroBigDecimal((BigDecimal)changeData.getNewValue());
|
|
|
|
|
BigDecimal qty = this.defaultZeroBigDecimal((BigDecimal) changeData.getNewValue());
|
|
|
|
|
int rowIndex = changeData.getRowIndex();
|
|
|
|
|
int parentRowIndex = changeData.getParentRowIndex();
|
|
|
|
|
BigDecimal totalqty = (BigDecimal)this.getModel().getValue("totalqty", rowIndex, parentRowIndex);
|
|
|
|
|
BigDecimal preQty = (BigDecimal)this.getModel().getValue("preqty", rowIndex, parentRowIndex);
|
|
|
|
|
BigDecimal totalqty = (BigDecimal) this.getModel().getValue("totalqty", rowIndex, parentRowIndex);
|
|
|
|
|
BigDecimal preQty = (BigDecimal) this.getModel().getValue("preqty", rowIndex, parentRowIndex);
|
|
|
|
|
BigDecimal balanceQty = totalqty.subtract(preQty);
|
|
|
|
|
if (qty.compareTo(balanceQty) > 0) {
|
|
|
|
|
// this.getView().showMessage(String.format(ResManager.loadKDString("本期计量数量不能超过%s(总数量-期初累计计量数量)。", "ContractMeasureBillEditPlugin_4", "ec-contract-formplugin", new Object[0]), balanceQty.intValue()));
|
|
|
|
|
// this.getModel().setValue("thisqty", BigDecimal.ZERO, rowIndex, parentRowIndex);
|
|
|
|
|
} else {
|
|
|
|
|
this.getModel().setValue("lstqty", preQty.add(qty), rowIndex, parentRowIndex);
|
|
|
|
|
BigDecimal taxPrice = (BigDecimal)this.getModel().getValue("curtaxprice", rowIndex, parentRowIndex);
|
|
|
|
|
BigDecimal amount = taxPrice.multiply(qty);
|
|
|
|
|
this.getModel().setValue("thisoftaxmount", amount, rowIndex, parentRowIndex);
|
|
|
|
|
if (this.isInContract()) {
|
|
|
|
|
this.countPercent(rowIndex, parentRowIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.getModel().setValue("lstqty", preQty.add(qty), rowIndex, parentRowIndex);
|
|
|
|
|
BigDecimal taxPrice = (BigDecimal) this.getModel().getValue("curtaxprice", rowIndex, parentRowIndex);
|
|
|
|
|
BigDecimal amount = taxPrice.multiply(qty);
|
|
|
|
|
this.getModel().setValue("thisoftaxmount", amount, rowIndex, parentRowIndex);
|
|
|
|
|
if (this.isInContract()) {
|
|
|
|
|
this.countPercent(rowIndex, parentRowIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -52,8 +48,8 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd
|
|
|
|
|
List<Object> listingIds = new ArrayList();
|
|
|
|
|
|
|
|
|
|
int rowIndex;
|
|
|
|
|
for(rowIndex = 0; rowIndex < rowCount; ++rowIndex) {
|
|
|
|
|
DynamicObject listing = (DynamicObject)this.getModel().getValue("listing", rowIndex);
|
|
|
|
|
for (rowIndex = 0; rowIndex < rowCount; ++rowIndex) {
|
|
|
|
|
DynamicObject listing = (DynamicObject) this.getModel().getValue("listing", rowIndex);
|
|
|
|
|
if (listing != null) {
|
|
|
|
|
// listingIds.add(listing.getPkValue());
|
|
|
|
|
}
|
|
|
|
@ -61,9 +57,9 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd
|
|
|
|
|
|
|
|
|
|
qFilters.add(new QFilter("id", "not in", listingIds));
|
|
|
|
|
rowIndex = this.getModel().getEntryCurrentRowIndex("listmodelentry");
|
|
|
|
|
String listModelId = (String)this.getModel().getValue("listmodelid", rowIndex);
|
|
|
|
|
String listModelId = (String) this.getModel().getValue("listmodelid", rowIndex);
|
|
|
|
|
qFilters.add(new QFilter("listingmodel", "=", StringUtils.isNotBlank(listModelId) ? Long.parseLong(listModelId) : 0L));
|
|
|
|
|
DynamicObject contract = (DynamicObject)this.getModel().getValue("contract");
|
|
|
|
|
DynamicObject contract = (DynamicObject) this.getModel().getValue("contract");
|
|
|
|
|
if (contract != null) {
|
|
|
|
|
qFilters.add(new QFilter("contractid", "=", contract.getLong("id")));
|
|
|
|
|
}
|
|
|
|
@ -101,6 +97,7 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd
|
|
|
|
|
this.getView().showForm(param);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Long> getUnitprojectIds(DynamicObject project) {
|
|
|
|
|
List<Long> result = null;
|
|
|
|
|
DynamicObject orgObj = this.getModel().getDataEntity().getDynamicObject("org");
|
|
|
|
@ -118,4 +115,71 @@ public class InContractMeasurementBillEditPlugin extends InContractMeasureBillEd
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void propertyChanged(PropertyChangedArgs e) {
|
|
|
|
|
super.propertyChanged(e);
|
|
|
|
|
String name = e.getProperty().getName();
|
|
|
|
|
ChangeData changeData = e.getChangeSet()[0];
|
|
|
|
|
int rowIndex = changeData.getRowIndex();
|
|
|
|
|
int parentRowIndex = changeData.getParentRowIndex();
|
|
|
|
|
BigDecimal curtaxprice = BigDecimal.ZERO;//当前含税单价
|
|
|
|
|
BigDecimal currentprice = BigDecimal.ZERO;//当前单价
|
|
|
|
|
BigDecimal qty = BigDecimal.ZERO;//数量
|
|
|
|
|
BigDecimal entrytaxrate = BigDecimal.ZERO;//税率
|
|
|
|
|
BigDecimal taxrate = entrytaxrate.divide(new BigDecimal(100));
|
|
|
|
|
if (parentRowIndex+rowIndex>=0){
|
|
|
|
|
Object curtaxpriceobj = this.getModel().getValue("curtaxprice", rowIndex, parentRowIndex);
|
|
|
|
|
if (curtaxpriceobj != null) {
|
|
|
|
|
curtaxprice = (BigDecimal) curtaxpriceobj;
|
|
|
|
|
}
|
|
|
|
|
Object currentpriceobj = this.getModel().getValue("currentprice", rowIndex, parentRowIndex);
|
|
|
|
|
if (currentpriceobj != null) {
|
|
|
|
|
currentprice = (BigDecimal) currentpriceobj;
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
Object totalqtyibj = this.getModel().getValue("totalqty", rowIndex, parentRowIndex);
|
|
|
|
|
if (totalqtyibj != null) {
|
|
|
|
|
qty = (BigDecimal) totalqtyibj;
|
|
|
|
|
}
|
|
|
|
|
Object entrytaxrateobj = this.getModel().getValue("entrytaxrate", rowIndex, parentRowIndex);
|
|
|
|
|
if (entrytaxrateobj != null) {
|
|
|
|
|
entrytaxrate = (BigDecimal) entrytaxrateobj;
|
|
|
|
|
}
|
|
|
|
|
if (name.equals("curtaxprice") && curtaxprice.compareTo(new BigDecimal(0))>0) {
|
|
|
|
|
BigDecimal divide = currentprice.divide(taxrate.add(new BigDecimal(1)));//当前单价
|
|
|
|
|
BigDecimal multiply = divide.multiply(qty);//当前金额
|
|
|
|
|
BigDecimal multiply1 = curtaxprice.multiply(qty);//当前价税合计
|
|
|
|
|
BigDecimal subtract = multiply1.subtract(multiply);//当前税额
|
|
|
|
|
this.getModel().setValue("currentprice",divide, rowIndex, parentRowIndex);//当前单价
|
|
|
|
|
this.getModel().setValue("currentamt", multiply,rowIndex, parentRowIndex);//当前金额
|
|
|
|
|
this.getModel().setValue("currenttaxamt", subtract,rowIndex, parentRowIndex);//当前税额
|
|
|
|
|
this.getModel().setValue("currentoftax", multiply1,rowIndex, parentRowIndex);//当前价税合计
|
|
|
|
|
} else if (name.equals("currentprice")&¤tprice.compareTo(new BigDecimal(0))>0) {
|
|
|
|
|
BigDecimal divide = curtaxprice.multiply(taxrate.add(new BigDecimal(1)));//当前含税单价
|
|
|
|
|
BigDecimal multiply = curtaxprice.multiply(qty);//当前金额
|
|
|
|
|
BigDecimal multiply1 = divide.multiply(qty);//当前价税合计
|
|
|
|
|
BigDecimal subtract = multiply1.subtract(multiply);//当前税额
|
|
|
|
|
this.getModel().setValue("curtaxprice",divide, rowIndex, parentRowIndex);//当前含税单价
|
|
|
|
|
this.getModel().setValue("currentamt", multiply,rowIndex, parentRowIndex);//当前金额
|
|
|
|
|
this.getModel().setValue("currenttaxamt",multiply1, rowIndex, parentRowIndex);//当前税额
|
|
|
|
|
this.getModel().setValue("currentoftax",subtract, rowIndex, parentRowIndex);//当前价税合计
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void updateAmount(ChangeData changeData) {
|
|
|
|
|
// int rowIndex = changeData.getRowIndex();
|
|
|
|
|
// int parentRowIndex = changeData.getParentRowIndex();
|
|
|
|
|
// BigDecimal curtaxrate = (BigDecimal)this.getModel().getValue("curtaxprice", rowIndex,parentRowIndex);//当前含税单价
|
|
|
|
|
// BigDecimal curtaxprice = (BigDecimal)this.getModel().getValue("currentprice", rowIndex,parentRowIndex);//当前单价
|
|
|
|
|
// BigDecimal qty = (BigDecimal)this.getModel().getValue("totalqty", rowIndex,parentRowIndex);//数量
|
|
|
|
|
//
|
|
|
|
|
// this.getModel().setValue("curtaxprice", rowIndex,parentRowIndex);//当前金额
|
|
|
|
|
// this.getModel().setValue("currentprice", rowIndex,parentRowIndex);//当前税额
|
|
|
|
|
// this.getModel().setValue("currentamt", rowIndex,parentRowIndex);//当前金额
|
|
|
|
|
// this.getModel().setValue("currenttaxamt", rowIndex,parentRowIndex);//当前税额
|
|
|
|
|
// this.getModel().setValue("currentoftax", rowIndex,parentRowIndex);//当前价税合计
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|