158 lines
8.6 KiB
Java
158 lines
8.6 KiB
Java
package shkd.repc.rebm.formplugin;
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
import kd.bos.dataentity.utils.StringUtils;
|
|
import kd.bos.entity.datamodel.IEntryOperate;
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
import kd.bos.entity.report.CellStyle;
|
|
import kd.bos.form.control.AbstractGrid;
|
|
import kd.bos.form.control.EntryGrid;
|
|
import kd.repc.rebm.common.util.crlutil.CrlUtil;
|
|
import kd.repc.rebm.formplugin.bill.BidBustalk4REBMEditUI;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.text.DecimalFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class BidBustalk4REBMEditUIExtends extends BidBustalk4REBMEditUI {
|
|
|
|
@Override
|
|
public void propertyChanged(PropertyChangedArgs arg0) {
|
|
DynamicObject dataEntity = this.getModel().getDataEntity();
|
|
DynamicObject bidProject = dataEntity.getDynamicObject("bidproject");
|
|
boolean isEnableList = bidProject.getBoolean("isenablelist");
|
|
if (!isEnableList) {
|
|
super.propertyChanged(arg0);
|
|
ChangeData cd = arg0.getChangeSet()[0];
|
|
Object newVal = cd.getNewValue();
|
|
Object oldVal = cd.getOldValue();
|
|
String fieldKey = arg0.getProperty().getName();
|
|
if (StringUtils.equals("new_price", fieldKey) || StringUtils.equals("taxrate", fieldKey)) {
|
|
if (newVal != null && newVal.equals(oldVal)) {
|
|
return;
|
|
}
|
|
|
|
DynamicObject bustalk = this.getModel().getDataEntity(true);
|
|
EntryGrid sectionEntryGrid = (EntryGrid)this.getView().getControl("bidsection");
|
|
AbstractGrid.GridState sectionEntryState = sectionEntryGrid.getEntryState();
|
|
int sectionEntryFocusRow = sectionEntryState.getFocusRow();
|
|
EntryGrid supplierEntryGrid = (EntryGrid)this.getView().getControl("supplierentry");
|
|
AbstractGrid.GridState supplierEntryState = supplierEntryGrid.getEntryState();
|
|
int supplierEntryFocusRow = supplierEntryState.getFocusRow();
|
|
DynamicObject sectionEntryRow = (DynamicObject)bustalk.getDynamicObjectCollection("bidsection").get(sectionEntryFocusRow);
|
|
if (supplierEntryFocusRow > -1) {
|
|
this.getView().updateView("supplierentry");
|
|
DynamicObject supplierEntryRow = (DynamicObject)sectionEntryRow.getDynamicObjectCollection("supplierentry").get(supplierEntryFocusRow);
|
|
BigDecimal finalprice = supplierEntryRow.getBigDecimal("new_price");
|
|
if (StringUtils.equals("new_price", fieldKey)) {
|
|
finalprice = (BigDecimal)newVal;
|
|
}
|
|
|
|
BigDecimal finaltaxrate = supplierEntryRow.getBigDecimal("taxrate").divide(new BigDecimal(100));
|
|
BigDecimal upprice = supplierEntryRow.getBigDecimal("up_price");
|
|
BigDecimal finaltax = BigDecimal.ZERO;
|
|
BigDecimal finalnotTaxTenderPrice = BigDecimal.ZERO;
|
|
BigDecimal decline1;
|
|
if (finaltaxrate.compareTo(BigDecimal.ZERO) > 0 && finalprice.compareTo(BigDecimal.ZERO) > 0) {
|
|
decline1 = finalprice.multiply(finaltaxrate);
|
|
BigDecimal addNumbner = finaltaxrate.add(new BigDecimal(1));
|
|
finaltax = decline1.divide(addNumbner, 2, 4);
|
|
finalnotTaxTenderPrice = finalprice.subtract(finaltax);
|
|
supplierEntryRow.set("pricevat", finaltax);
|
|
if (upprice.compareTo(BigDecimal.ZERO) == 1) {
|
|
BigDecimal decline = finalprice.subtract(upprice).divide(upprice, 4, 4);
|
|
supplierEntryRow.set("decline", decline);
|
|
List<CellStyle> styles = new ArrayList();
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
String declineStr = df.format(decline.multiply(new BigDecimal("100")));
|
|
declineStr = declineStr.replaceAll("-", "");
|
|
CellStyle style = new CellStyle();
|
|
style.setRow(supplierEntryFocusRow);
|
|
style.setFieldKey("decline_back");
|
|
if (decline.compareTo(BigDecimal.ZERO) == 1) {
|
|
supplierEntryRow.set("decline_back", declineStr + "% ↑");
|
|
style.setForeColor("#18BC71");
|
|
} else if (decline.compareTo(BigDecimal.ZERO) == -1) {
|
|
supplierEntryRow.set("decline_back", declineStr + "% ↓");
|
|
style.setForeColor("#FD6C6A");
|
|
} else {
|
|
supplierEntryRow.set("decline_back", "0.00%");
|
|
style.setForeColor("#000");
|
|
}
|
|
|
|
supplierEntryGrid.setCellStyle(styles);
|
|
}
|
|
|
|
this.getModel().setValue("bus_exceptvat", finalnotTaxTenderPrice, supplierEntryFocusRow);
|
|
this.getView().updateView("supplierentry");
|
|
} else if (finaltaxrate.compareTo(BigDecimal.ZERO) == 0) {
|
|
if (upprice.compareTo(BigDecimal.ZERO) == 1) {
|
|
decline1 = finalprice.subtract(upprice).divide(upprice, 4, 4);
|
|
supplierEntryRow.set("decline", decline1);
|
|
List<CellStyle> styles = new ArrayList();
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
String declineStr = df.format(decline1.multiply(new BigDecimal("100")));
|
|
declineStr = declineStr.replaceAll("-", "");
|
|
CellStyle style = new CellStyle();
|
|
style.setRow(supplierEntryFocusRow);
|
|
style.setFieldKey("decline_back");
|
|
if (decline1.compareTo(BigDecimal.ZERO) == 1) {
|
|
supplierEntryRow.set("decline_back", declineStr + "% ↑");
|
|
style.setForeColor("#18BC71");
|
|
} else if (decline1.compareTo(BigDecimal.ZERO) == -1) {
|
|
supplierEntryRow.set("decline_back", declineStr + "% ↓");
|
|
style.setForeColor("#FD6C6A");
|
|
} else {
|
|
supplierEntryRow.set("decline_back", "0.00%");
|
|
style.setForeColor("#000");
|
|
}
|
|
|
|
supplierEntryGrid.setCellStyle(styles);
|
|
}
|
|
|
|
this.getModel().setValue("bus_exceptvat", finalprice, supplierEntryFocusRow);
|
|
this.getView().updateView("supplierentry");
|
|
}
|
|
}
|
|
}
|
|
|
|
EntryGrid grid = (EntryGrid)this.getView().getControl("supplierentry");
|
|
IEntryOperate operate = grid.getModel();
|
|
DynamicObjectCollection supllierEntry = operate.getEntryEntity("supplierentry");
|
|
this.changeEntryFieldColor(grid, supllierEntry);
|
|
}
|
|
}
|
|
|
|
private void changeEntryFieldColor(EntryGrid grid, DynamicObjectCollection supllierEntry) {
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
List<CellStyle> styles = new ArrayList();
|
|
|
|
for(int j = 0; j < supllierEntry.size(); ++j) {
|
|
DynamicObject entry = (DynamicObject)supllierEntry.get(j);
|
|
BigDecimal decline = entry.getBigDecimal("decline");
|
|
String declineStr = df.format(decline.multiply(new BigDecimal("100")));
|
|
declineStr = declineStr.replaceAll("-", "");
|
|
CellStyle style = new CellStyle();
|
|
style.setRow(j);
|
|
style.setFieldKey("decline_back");
|
|
if (decline.compareTo(BigDecimal.ZERO) == 1) {
|
|
this.getModel().setValue("decline_back", declineStr + "% ↑", j);
|
|
style.setForeColor("#18BC71");
|
|
} else if (decline.compareTo(BigDecimal.ZERO) == -1) {
|
|
this.getModel().setValue("decline_back", declineStr + "% ↓", j);
|
|
style.setForeColor("#FD6C6A");
|
|
} else {
|
|
this.getModel().setValue("decline_back", "0.00%", j);
|
|
style.setForeColor("#000");
|
|
}
|
|
|
|
styles.add(style);
|
|
}
|
|
|
|
grid.setCellStyle(styles);
|
|
}
|
|
}
|