资金计划申请科目余额取数插件
This commit is contained in:
parent
5432763ef9
commit
0b0568f108
|
|
@ -10,6 +10,8 @@ import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.dataentity.entity.MulBasedataDynamicObjectCollection;
|
import kd.bos.dataentity.entity.MulBasedataDynamicObjectCollection;
|
||||||
import kd.bos.entity.datamodel.events.ChangeData;
|
import kd.bos.entity.datamodel.events.ChangeData;
|
||||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||||
|
import kd.bos.logging.Log;
|
||||||
|
import kd.bos.logging.LogFactory;
|
||||||
import kd.bos.openapi.common.result.OpenApiResult;
|
import kd.bos.openapi.common.result.OpenApiResult;
|
||||||
import kd.bos.openapi.common.util.OpenApiSdkUtil;
|
import kd.bos.openapi.common.util.OpenApiSdkUtil;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
|
|
@ -30,6 +32,8 @@ import java.util.*;
|
||||||
* 资金计划申请科目余额取数插件
|
* 资金计划申请科目余额取数插件
|
||||||
*/
|
*/
|
||||||
public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn implements Plugin {
|
public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn implements Plugin {
|
||||||
|
public static final Log log = LogFactory.getLog(FundingplanapplyAccountBalancePlugin.class);
|
||||||
|
|
||||||
String[] selectorsArray = new String[]{"beginlocal", "endlocal", "yeardebitfor", "yearcreditfor", "debitlocal", "creditlocal"};
|
String[] selectorsArray = new String[]{"beginlocal", "endlocal", "yeardebitfor", "yearcreditfor", "debitlocal", "creditlocal"};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -51,12 +55,14 @@ public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn imp
|
||||||
MulBasedataDynamicObjectCollection customs = (MulBasedataDynamicObjectCollection ) changeData.getNewValue();
|
MulBasedataDynamicObjectCollection customs = (MulBasedataDynamicObjectCollection ) changeData.getNewValue();
|
||||||
if(customs!=null && !customs.isEmpty()){
|
if(customs!=null && !customs.isEmpty()){
|
||||||
customerBalance(rowIndex,customs);
|
customerBalance(rowIndex,customs);
|
||||||
|
customerBalancePrev(rowIndex,customs);
|
||||||
}
|
}
|
||||||
}else if(name.equals("zcgj_out_supplier") ){
|
}else if(name.equals("zcgj_out_supplier") ){
|
||||||
int rowIndex = changeData.getRowIndex();
|
int rowIndex = changeData.getRowIndex();
|
||||||
MulBasedataDynamicObjectCollection suppliers = (MulBasedataDynamicObjectCollection ) changeData.getNewValue();
|
MulBasedataDynamicObjectCollection suppliers = (MulBasedataDynamicObjectCollection ) changeData.getNewValue();
|
||||||
if(suppliers!=null && !suppliers.isEmpty()){
|
if(suppliers!=null && !suppliers.isEmpty()){
|
||||||
supplierBalance(rowIndex,suppliers);
|
supplierBalance(rowIndex,suppliers);
|
||||||
|
supplierBalancePrev(rowIndex,suppliers);
|
||||||
}
|
}
|
||||||
}else if(name.equals("zcgj_period") ){
|
}else if(name.equals("zcgj_period") ){
|
||||||
|
|
||||||
|
|
@ -66,6 +72,7 @@ public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn imp
|
||||||
if(dynamicObjectCollectionObj != null){
|
if(dynamicObjectCollectionObj != null){
|
||||||
if(!dynamicObjectCollectionObj.isEmpty()){
|
if(!dynamicObjectCollectionObj.isEmpty()){
|
||||||
customerBalance(i,dynamicObjectCollectionObj);
|
customerBalance(i,dynamicObjectCollectionObj);
|
||||||
|
customerBalancePrev(i,dynamicObjectCollectionObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -76,6 +83,7 @@ public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn imp
|
||||||
if(dynamicObjectCollectionObj != null){
|
if(dynamicObjectCollectionObj != null){
|
||||||
if(!dynamicObjectCollectionObj.isEmpty()){
|
if(!dynamicObjectCollectionObj.isEmpty()){
|
||||||
supplierBalance(i,dynamicObjectCollectionObj);
|
supplierBalance(i,dynamicObjectCollectionObj);
|
||||||
|
supplierBalancePrev(i,dynamicObjectCollectionObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -101,6 +109,7 @@ public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn imp
|
||||||
this.getView().showErrorNotification("请选择期间!");
|
this.getView().showErrorNotification("请选择期间!");
|
||||||
}else{
|
}else{
|
||||||
balanceQueryParamApi.setPeriodNumber(period.getString("number")); //
|
balanceQueryParamApi.setPeriodNumber(period.getString("number")); //
|
||||||
|
|
||||||
List<String> groupBy = new ArrayList<>();
|
List<String> groupBy = new ArrayList<>();
|
||||||
|
|
||||||
Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
|
Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
|
||||||
|
|
@ -145,8 +154,8 @@ public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn imp
|
||||||
BigDecimal beginningbalanceofyear =totalendlocal.subtract(totayeardebitfor).add(totalyearcreditfor);
|
BigDecimal beginningbalanceofyear =totalendlocal.subtract(totayeardebitfor).add(totalyearcreditfor);
|
||||||
dynamicObject.set("zcgj_iinitialreceivable",beginningbalanceofyear);//年初余额取科目余额表年初数
|
dynamicObject.set("zcgj_iinitialreceivable",beginningbalanceofyear);//年初余额取科目余额表年初数
|
||||||
dynamicObject.set("zcgj_monthbeginreceivable",totalbeginlocal);//月初应收余额
|
dynamicObject.set("zcgj_monthbeginreceivable",totalbeginlocal);//月初应收余额
|
||||||
dynamicObject.set("zcgj_ytdoutputvalue",totayeardebitfor);//本年累计结算-借方
|
//dynamicObject.set("zcgj_ytdoutputvalue",totayeardebitfor);//本年累计结算-借方
|
||||||
dynamicObject.set("zcgj_ytdpaymentreceived",totalyearcreditfor);//本年累计回款-贷方
|
//dynamicObject.set("zcgj_ytdpaymentreceived",totalyearcreditfor);//本年累计回款-贷方
|
||||||
this.getView().updateView("zcgj_infundproject_entry");
|
this.getView().updateView("zcgj_infundproject_entry");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -157,6 +166,100 @@ public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn imp
|
||||||
DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
||||||
dynamicObject.set("zcgj_iinitialreceivable",BigDecimal.ZERO);//年初余额取科目余额表年初数
|
dynamicObject.set("zcgj_iinitialreceivable",BigDecimal.ZERO);//年初余额取科目余额表年初数
|
||||||
dynamicObject.set("zcgj_monthbeginreceivable",BigDecimal.ZERO);//年初余额取科目余额表年初数
|
dynamicObject.set("zcgj_monthbeginreceivable",BigDecimal.ZERO);//年初余额取科目余额表年初数
|
||||||
|
//dynamicObject.set("zcgj_ytdoutputvalue",BigDecimal.ZERO);//本年累计结算-借方
|
||||||
|
//dynamicObject.set("zcgj_ytdpaymentreceived",BigDecimal.ZERO);//本年累计回款-贷方
|
||||||
|
this.getView().updateView("zcgj_infundproject_entry");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void customerBalancePrev(int rowIndex, DynamicObjectCollection customs){
|
||||||
|
if(customs!=null){
|
||||||
|
DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_org");
|
||||||
|
if(org == null){
|
||||||
|
//this.getView().showErrorNotification("请选择所属组织!");
|
||||||
|
}else{
|
||||||
|
BalanceQueryParamApi balanceQueryParamApi = new BalanceQueryParamApi();
|
||||||
|
balanceQueryParamApi.setSelectors(Arrays.asList(selectorsArray));
|
||||||
|
balanceQueryParamApi.setOrgNumber(org.getString("number"));
|
||||||
|
balanceQueryParamApi.setBookTypeNumber("100002"); //账簿类型
|
||||||
|
balanceQueryParamApi.setAccountTableNumber("0003");//科目表
|
||||||
|
|
||||||
|
DynamicObject period = (DynamicObject)this.getModel().getValue("zcgj_period");
|
||||||
|
if(period == null){
|
||||||
|
//this.getView().showErrMessage("请选择期间!");
|
||||||
|
this.getView().showErrorNotification("请选择期间!");
|
||||||
|
}else{
|
||||||
|
|
||||||
|
int year = Integer.parseInt(period.getString("number").substring(0, 4));
|
||||||
|
int month = Integer.parseInt(period.getString("number").substring(4, 6));
|
||||||
|
if (month == 1) {//如果当前期间为1月时,不取上月数据,当前数据为0
|
||||||
|
//year -= 1;
|
||||||
|
//month = 12;
|
||||||
|
DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_infundproject_entry");
|
||||||
|
DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
||||||
|
dynamicObject.set("zcgj_ytdoutputvalue",BigDecimal.ZERO);//本年累计结算-借方
|
||||||
|
dynamicObject.set("zcgj_ytdpaymentreceived",BigDecimal.ZERO);//本年累计回款-贷方
|
||||||
|
this.getView().updateView("zcgj_infundproject_entry");
|
||||||
|
} else {
|
||||||
|
month -= 1;
|
||||||
|
|
||||||
|
String prevPeriod = String.format("%04d%02d", year, month);//获取上月会计期间
|
||||||
|
balanceQueryParamApi.setPeriodNumber(prevPeriod); //
|
||||||
|
|
||||||
|
List<String> groupBy = new ArrayList<>();
|
||||||
|
|
||||||
|
Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
|
||||||
|
List<Map<String, String>> li = new ArrayList<>();
|
||||||
|
for (DynamicObject custom : customs) {
|
||||||
|
Map<String, String> map1 = new HashMap<>();
|
||||||
|
DynamicObject basedataObj = custom.getDynamicObject("fbasedataid");
|
||||||
|
DynamicObject customer = BusinessDataServiceHelper.loadSingle( basedataObj.getPkValue(), "bd_customer");
|
||||||
|
map1.put("0001", customer.getString("number"));
|
||||||
|
li.add(map1);
|
||||||
|
}
|
||||||
|
accountAssgrp.put("1122", li);
|
||||||
|
balanceQueryParamApi.setAccountAssgrp(accountAssgrp);
|
||||||
|
groupBy.add("0001");
|
||||||
|
groupBy.add("account");
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String json = gson.toJson(balanceQueryParamApi);
|
||||||
|
Map<String, Object> params = gson.fromJson(json,
|
||||||
|
new TypeToken<Map<String, Object>>() {
|
||||||
|
}.getType());
|
||||||
|
OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/gl/getBalanceApi", params);
|
||||||
|
|
||||||
|
if (balanceData.isStatus()) {
|
||||||
|
String data = (String) balanceData.getData();
|
||||||
|
Type listType = new TypeToken<List<AccountRecord>>() {
|
||||||
|
}.getType();
|
||||||
|
List<AccountRecord> records = gson.fromJson(data, listType);
|
||||||
|
|
||||||
|
BigDecimal totalbeginlocal = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalendlocal = BigDecimal.ZERO;
|
||||||
|
BigDecimal totayeardebitfor = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalyearcreditfor = BigDecimal.ZERO;
|
||||||
|
for (AccountRecord record : records) {
|
||||||
|
totalbeginlocal = totalbeginlocal.add(record.getBeginlocal());//期初本位币金额
|
||||||
|
totalendlocal = totalendlocal.add(record.getEndlocal());//期初本位币金额
|
||||||
|
totayeardebitfor = totayeardebitfor.add(record.getYeardebitfor());//yeardebitfor
|
||||||
|
totalyearcreditfor = totalyearcreditfor.add(record.getYearcreditfor());//yearcreditfor
|
||||||
|
}
|
||||||
|
DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_infundproject_entry");
|
||||||
|
DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
||||||
|
//年初余额 = 期末余额-本年累计借方+本年累计贷方
|
||||||
|
BigDecimal beginningbalanceofyear =totalendlocal.subtract(totayeardebitfor).add(totalyearcreditfor);
|
||||||
|
dynamicObject.set("zcgj_ytdoutputvalue",totayeardebitfor);//本年累计结算-借方
|
||||||
|
dynamicObject.set("zcgj_ytdpaymentreceived",totalyearcreditfor);//本年累计回款-贷方
|
||||||
|
this.getView().updateView("zcgj_infundproject_entry");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_infundproject_entry");
|
||||||
|
DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
||||||
dynamicObject.set("zcgj_ytdoutputvalue",BigDecimal.ZERO);//本年累计结算-借方
|
dynamicObject.set("zcgj_ytdoutputvalue",BigDecimal.ZERO);//本年累计结算-借方
|
||||||
dynamicObject.set("zcgj_ytdpaymentreceived",BigDecimal.ZERO);//本年累计回款-贷方
|
dynamicObject.set("zcgj_ytdpaymentreceived",BigDecimal.ZERO);//本年累计回款-贷方
|
||||||
this.getView().updateView("zcgj_infundproject_entry");
|
this.getView().updateView("zcgj_infundproject_entry");
|
||||||
|
|
@ -225,8 +328,8 @@ public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn imp
|
||||||
BigDecimal beginningbalanceofyear =totalendlocal.subtract(totalyearcreditfor).add(totayeardebitfor);
|
BigDecimal beginningbalanceofyear =totalendlocal.subtract(totalyearcreditfor).add(totayeardebitfor);
|
||||||
dynamicObject.set("zcgj_openingpayable",beginningbalanceofyear);//年初余额取科目余额表年初数
|
dynamicObject.set("zcgj_openingpayable",beginningbalanceofyear);//年初余额取科目余额表年初数
|
||||||
dynamicObject.set("zcgj_monthbeginpayable",totalbeginlocal);//月初应付余额
|
dynamicObject.set("zcgj_monthbeginpayable",totalbeginlocal);//月初应付余额
|
||||||
dynamicObject.set("zcgj_ytdtotalpayment",totayeardebitfor);//本年累计付款-借方
|
// dynamicObject.set("zcgj_ytdtotalpayment",totayeardebitfor);//本年累计付款-借方
|
||||||
dynamicObject.set("zcgj_ytdnetsettlement",totalyearcreditfor);//本年累计结算-贷方
|
// dynamicObject.set("zcgj_ytdnetsettlement",totalyearcreditfor);//本年累计结算-贷方
|
||||||
this.getView().updateView("zcgj_outfundproject_entry");
|
this.getView().updateView("zcgj_outfundproject_entry");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -236,12 +339,186 @@ public class FundingplanapplyAccountBalancePlugin extends AbstractBillPlugIn imp
|
||||||
DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
||||||
dynamicObject.set("zcgj_openingpayable",BigDecimal.ZERO);//年初余额取科目余额表年初数
|
dynamicObject.set("zcgj_openingpayable",BigDecimal.ZERO);//年初余额取科目余额表年初数
|
||||||
dynamicObject.set("zcgj_monthbeginpayable",BigDecimal.ZERO);//年初余额取科目余额表年初数
|
dynamicObject.set("zcgj_monthbeginpayable",BigDecimal.ZERO);//年初余额取科目余额表年初数
|
||||||
|
//dynamicObject.set("zcgj_ytdnetsettlement",BigDecimal.ZERO);//本年累计结算-借方
|
||||||
|
//dynamicObject.set("zcgj_ytdtotalpayment",BigDecimal.ZERO);//本年累计付款-贷方
|
||||||
|
this.getView().updateView("zcgj_outfundproject_entry");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void supplierBalancePrev(int rowIndex, DynamicObjectCollection suppliers){
|
||||||
|
if(suppliers!=null){
|
||||||
|
DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_org");
|
||||||
|
if(org == null){
|
||||||
|
//this.getView().showErrorNotification("请选择所属组织!");
|
||||||
|
}else{
|
||||||
|
BalanceQueryParamApi balanceQueryParamApi = new BalanceQueryParamApi();
|
||||||
|
balanceQueryParamApi.setSelectors(Arrays.asList(selectorsArray));
|
||||||
|
balanceQueryParamApi.setOrgNumber(org.getString("number"));
|
||||||
|
balanceQueryParamApi.setBookTypeNumber("100002"); //账簿类型
|
||||||
|
balanceQueryParamApi.setAccountTableNumber("0003");//科目表
|
||||||
|
|
||||||
|
DynamicObject period = (DynamicObject)this.getModel().getValue("zcgj_period");
|
||||||
|
if(period == null){
|
||||||
|
//this.getView().showErrMessage("请选择期间!");
|
||||||
|
this.getView().showErrorNotification("请选择期间!");
|
||||||
|
}else{
|
||||||
|
int year = Integer.parseInt(period.getString("number").substring(0, 4));
|
||||||
|
int month = Integer.parseInt(period.getString("number").substring(4, 6));
|
||||||
|
if (month == 1) {
|
||||||
|
//year -= 1;
|
||||||
|
//month = 12;
|
||||||
|
DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_outfundproject_entry");
|
||||||
|
DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
||||||
|
dynamicObject.set("zcgj_ytdnetsettlement",BigDecimal.ZERO);//本年累计结算-借方
|
||||||
|
dynamicObject.set("zcgj_ytdtotalpayment",BigDecimal.ZERO);//本年累计付款-贷方
|
||||||
|
this.getView().updateView("zcgj_outfundproject_entry");
|
||||||
|
} else {
|
||||||
|
month -= 1;
|
||||||
|
|
||||||
|
String prevPeriod = String.format("%04d%02d", year, month);//获取上月会计期间
|
||||||
|
|
||||||
|
balanceQueryParamApi.setPeriodNumber(prevPeriod); //
|
||||||
|
List<String> groupBy = new ArrayList<>();
|
||||||
|
|
||||||
|
Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
|
||||||
|
List<Map<String, String>> li = new ArrayList<>();
|
||||||
|
for (DynamicObject supplier : suppliers) {
|
||||||
|
Map<String, String> map1 = new HashMap<>();
|
||||||
|
DynamicObject basedataObj = supplier.getDynamicObject("fbasedataid");
|
||||||
|
DynamicObject customer = BusinessDataServiceHelper.loadSingle( basedataObj.getPkValue(), "bd_supplier");
|
||||||
|
map1.put("0005", customer.getString("number"));
|
||||||
|
li.add(map1);
|
||||||
|
}
|
||||||
|
accountAssgrp.put("2202", li);
|
||||||
|
balanceQueryParamApi.setAccountAssgrp(accountAssgrp);
|
||||||
|
groupBy.add("0005");
|
||||||
|
groupBy.add("account");
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String json = gson.toJson(balanceQueryParamApi);
|
||||||
|
Map<String, Object> params = gson.fromJson(json,
|
||||||
|
new TypeToken<Map<String, Object>>() {
|
||||||
|
}.getType());
|
||||||
|
OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/gl/getBalanceApi", params);
|
||||||
|
|
||||||
|
if (balanceData.isStatus()) {
|
||||||
|
String data = (String) balanceData.getData();
|
||||||
|
Type listType = new TypeToken<List<AccountRecord>>() {
|
||||||
|
}.getType();
|
||||||
|
List<AccountRecord> records = gson.fromJson(data, listType);
|
||||||
|
|
||||||
|
BigDecimal totalbeginlocal = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalendlocal = BigDecimal.ZERO;
|
||||||
|
BigDecimal totayeardebitfor = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalyearcreditfor = BigDecimal.ZERO;
|
||||||
|
for (AccountRecord record : records) {
|
||||||
|
totalbeginlocal = totalbeginlocal.add(record.getBeginlocal());//期初本位币金额
|
||||||
|
totalendlocal = totalendlocal.add(record.getEndlocal());//期初本位币金额
|
||||||
|
totayeardebitfor = totayeardebitfor.add(record.getYeardebitfor());//yeardebitfor
|
||||||
|
totalyearcreditfor = totalyearcreditfor.add(record.getYearcreditfor());//yearcreditfor
|
||||||
|
}
|
||||||
|
DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_outfundproject_entry");
|
||||||
|
DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
||||||
|
//年初余额 = 期末余额-本年累计借方+本年累计贷方
|
||||||
|
BigDecimal beginningbalanceofyear =totalendlocal.subtract(totalyearcreditfor).add(totayeardebitfor);
|
||||||
|
BigDecimal yufu1123 = supplierBalance1123(rowIndex, suppliers);
|
||||||
|
log.info("FundingplanapplyAccountBalancePlugin:获取1123预付款:"+yufu1123);
|
||||||
|
//本年累计付款需要加上预付余额
|
||||||
|
totayeardebitfor = totayeardebitfor.add(yufu1123);
|
||||||
|
dynamicObject.set("zcgj_ytdtotalpayment",totayeardebitfor);//本年累计付款-借方
|
||||||
|
dynamicObject.set("zcgj_ytdnetsettlement",totalyearcreditfor);//本年累计结算-贷方
|
||||||
|
this.getView().updateView("zcgj_outfundproject_entry");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_outfundproject_entry");
|
||||||
|
DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
||||||
dynamicObject.set("zcgj_ytdnetsettlement",BigDecimal.ZERO);//本年累计结算-借方
|
dynamicObject.set("zcgj_ytdnetsettlement",BigDecimal.ZERO);//本年累计结算-借方
|
||||||
dynamicObject.set("zcgj_ytdtotalpayment",BigDecimal.ZERO);//本年累计付款-贷方
|
dynamicObject.set("zcgj_ytdtotalpayment",BigDecimal.ZERO);//本年累计付款-贷方
|
||||||
this.getView().updateView("zcgj_outfundproject_entry");
|
this.getView().updateView("zcgj_outfundproject_entry");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//取预付余额
|
||||||
|
public BigDecimal supplierBalance1123(int rowIndex, DynamicObjectCollection suppliers){
|
||||||
|
if(suppliers!=null){
|
||||||
|
DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_org");
|
||||||
|
if(org == null){
|
||||||
|
//this.getView().showErrorNotification("请选择所属组织!");
|
||||||
|
}else{
|
||||||
|
BalanceQueryParamApi balanceQueryParamApi = new BalanceQueryParamApi();
|
||||||
|
balanceQueryParamApi.setSelectors(Arrays.asList(selectorsArray));
|
||||||
|
balanceQueryParamApi.setOrgNumber(org.getString("number"));
|
||||||
|
balanceQueryParamApi.setBookTypeNumber("100002"); //账簿类型
|
||||||
|
balanceQueryParamApi.setAccountTableNumber("0003");//科目表
|
||||||
|
|
||||||
|
DynamicObject period = (DynamicObject)this.getModel().getValue("zcgj_period");
|
||||||
|
if(period == null){
|
||||||
|
//this.getView().showErrMessage("请选择期间!");
|
||||||
|
this.getView().showErrorNotification("请选择期间!");
|
||||||
|
}else{
|
||||||
|
|
||||||
|
balanceQueryParamApi.setPeriodNumber(period.getString("number")); //
|
||||||
|
List<String> groupBy = new ArrayList<>();
|
||||||
|
|
||||||
|
Map<String, List<Map<String, String>>> accountAssgrp = new HashMap<>();
|
||||||
|
List<Map<String, String>> li = new ArrayList<>();
|
||||||
|
for (DynamicObject supplier : suppliers) {
|
||||||
|
Map<String, String> map1 = new HashMap<>();
|
||||||
|
DynamicObject basedataObj = supplier.getDynamicObject("fbasedataid");
|
||||||
|
DynamicObject customer = BusinessDataServiceHelper.loadSingle( basedataObj.getPkValue(), "bd_supplier");
|
||||||
|
map1.put("0005", customer.getString("number"));
|
||||||
|
li.add(map1);
|
||||||
|
}
|
||||||
|
accountAssgrp.put("1123", li);
|
||||||
|
balanceQueryParamApi.setAccountAssgrp(accountAssgrp);
|
||||||
|
groupBy.add("0005");
|
||||||
|
groupBy.add("account");
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String json = gson.toJson(balanceQueryParamApi);
|
||||||
|
log.info("FundingplanapplyAccountBalancePlugin:1123查询参数:"+json);
|
||||||
|
Map<String, Object> params = gson.fromJson(json,
|
||||||
|
new TypeToken<Map<String, Object>>() {
|
||||||
|
}.getType());
|
||||||
|
OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/gl/getBalanceApi", params);
|
||||||
|
|
||||||
|
if (balanceData.isStatus()) {
|
||||||
|
String data = (String) balanceData.getData();
|
||||||
|
Type listType = new TypeToken<List<AccountRecord>>() {
|
||||||
|
}.getType();
|
||||||
|
List<AccountRecord> records = gson.fromJson(data, listType);
|
||||||
|
|
||||||
|
BigDecimal totalbeginlocal = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalendlocal = BigDecimal.ZERO;
|
||||||
|
BigDecimal totayeardebitfor = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalyearcreditfor = BigDecimal.ZERO;
|
||||||
|
for (AccountRecord record : records) {
|
||||||
|
totalbeginlocal = totalbeginlocal.add(record.getBeginlocal());//期初本位币金额
|
||||||
|
totalendlocal = totalendlocal.add(record.getEndlocal());//期末本位币金额
|
||||||
|
totayeardebitfor = totayeardebitfor.add(record.getYeardebitfor());//yeardebitfor
|
||||||
|
totalyearcreditfor = totalyearcreditfor.add(record.getYearcreditfor());//yearcreditfor
|
||||||
|
}
|
||||||
|
// DynamicObjectCollection zcgjFinApprovedAmount = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_outfundproject_entry");
|
||||||
|
// DynamicObject dynamicObject = zcgjFinApprovedAmount.get(rowIndex);
|
||||||
|
//年初余额 = 期末余额-本年累计借方+本年累计贷方
|
||||||
|
int month = Integer.parseInt(period.getString("number").substring(4, 6));
|
||||||
|
if (month == 1) {//果1月时取年初余额
|
||||||
|
BigDecimal beginningbalanceofyear =totalendlocal.subtract(totalyearcreditfor).add(totayeardebitfor);
|
||||||
|
return beginningbalanceofyear;
|
||||||
|
} else {//取期初余额
|
||||||
|
return totalbeginlocal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
//公司资金往来
|
//公司资金往来
|
||||||
public void fundplyentry(){
|
public void fundplyentry(){
|
||||||
fundplyentryXJ();//现金
|
fundplyentryXJ();//现金
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue