加班处理
This commit is contained in:
parent
3737b86341
commit
235f2f9f76
|
|
@ -626,26 +626,28 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
|
|||
QFilter customerFilter = new QFilter("name", QCP.equals, oppunit);
|
||||
//可用状态
|
||||
customerFilter.and(new QFilter("enable",QCP.equals,"1"));
|
||||
DynamicObject[] bd_customer = BusinessDataServiceHelper.load("bd_customer", "id,name,shjh_entry_five",customerFilter.toArray());
|
||||
DynamicObject[] bd_customer = BusinessDataServiceHelper.load("bd_customer", "id,name",customerFilter.toArray());
|
||||
boolean exitCustomerArray = false;
|
||||
if (null != bd_customer ) {
|
||||
if (bd_customer.length==1){
|
||||
exitCustomerArray=true;
|
||||
//if (bd_customer.length==1){
|
||||
|
||||
bill.set("payer", bd_customer[0].getPkValue()); //付款人id
|
||||
bill.set("payernumber", bd_customer[0].getString("number")); //付款人编码
|
||||
bill.set("payername", bd_customer[0].getString("name")); //付款人名称
|
||||
}else if (bd_customer.length>1){
|
||||
for (int i = 0; i < bd_customer.length; i++) {
|
||||
DynamicObjectCollection dynamicObjectCollection = bd_customer[i].getDynamicObjectCollection("shjh_entry_five");
|
||||
if (dynamicObjectCollection.size()!=0){
|
||||
bill.set("payer", bd_customer[i].getPkValue()); //付款人id
|
||||
bill.set("payernumber", bd_customer[i].getString("number")); //付款人编码
|
||||
bill.set("payername", bd_customer[i].getString("name")); //付款人名称
|
||||
exitCustomerArray=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
exitCustomerArray=true;
|
||||
//}
|
||||
//else if (bd_customer.length>1){
|
||||
//for (int i = 0; i < bd_customer.length; i++) {
|
||||
//DynamicObjectCollection dynamicObjectCollection = bd_customer[i].getDynamicObjectCollection("shjh_entry_five");
|
||||
// if (dynamicObjectCollection.size()!=0){
|
||||
// bill.set("payer", bd_customer[i].getPkValue()); //付款人id
|
||||
// bill.set("payernumber", bd_customer[i].getString("number")); //付款人编码
|
||||
// bill.set("payername", bd_customer[i].getString("name")); //付款人名称
|
||||
// exitCustomerArray=true;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
// }
|
||||
}
|
||||
if (!exitCustomerArray){
|
||||
//4.规则生单未配置客户——>默认不确定客户
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ public class RedeemBillUnAuditOperation extends AbstractOperationServicePlugIn i
|
|||
if (valuationentry!=null && valuationentry.size()!=0) {
|
||||
for (DynamicObject dynamicObject : valuationentry) {
|
||||
DynamicObject shdh = dynamicObject.getDynamicObject("shjh_shdh");
|
||||
if (shdh==null){
|
||||
continue;
|
||||
}
|
||||
if (pkValue.compareTo((Long) shdh.getPkValue()) == 0) {
|
||||
valuationentry.remove(dynamicObject);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
// 10. 本月收益(千元)、当月年化收益率%
|
||||
// 11. 本年累计收益(千元)、本年累计年化收益率
|
||||
Long id = row.getLong(REPORT_FIELDS[13]);
|
||||
valuationEntry(accrualDate,buyDate,expireDate2,valueDate,buyAmount,days,basisDays,id,row);
|
||||
BigDecimal redAmount = valuationEntry(accrualDate, buyDate, expireDate2, valueDate, buyAmount, days, basisDays, id, row);
|
||||
|
||||
BigDecimal buyCopies = ReportUtils.getBigDecimalValue(row, REPORT_FIELDS[5]); // 持有份额
|
||||
BigDecimal netWorth = ReportUtils.getBigDecimalValue(row, REPORT_FIELDS[6]); // 购买时单位净值
|
||||
|
|
@ -128,7 +128,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
|
||||
|
||||
// 12. 收益计提 = (持有份额 *月末单位净值 - 购买份额*购买时单位净值) / 1000
|
||||
BigDecimal revenueAmt = countRevenueAmt(valueDate,expireDate2, accrualDate,buyCopies, monthNetWorth, netWorth, row,startBuyCopies);
|
||||
BigDecimal revenueAmt = countRevenueAmt(valueDate,expireDate2, accrualDate,buyCopies, monthNetWorth, netWorth, row,startBuyCopies,redAmount);
|
||||
sumProvisionEarnings=sumProvisionEarnings.add(revenueAmt);
|
||||
|
||||
// 本月收益计算累计
|
||||
|
|
@ -189,8 +189,9 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
* @param days 天数(计提日-计息日)
|
||||
* @param basisDays 计息基准天数
|
||||
* @param id 表单id
|
||||
* @return allRedAmount 计提日期之前赎回金额之和
|
||||
*/
|
||||
private void valuationEntry(Date accrualDate, Date buyDate,Date expireDate,Date valueDate, BigDecimal buyAmount,BigDecimal days,BigDecimal basisDays, Long id, DynamicObject row) {
|
||||
private BigDecimal valuationEntry(Date accrualDate, Date buyDate,Date expireDate,Date valueDate, BigDecimal buyAmount,BigDecimal days,BigDecimal basisDays, Long id, DynamicObject row) {
|
||||
// 初始化所有变量
|
||||
BigDecimal buyCopies = BigDecimal.ZERO;
|
||||
BigDecimal monthIop = BigDecimal.ZERO;
|
||||
|
|
@ -199,6 +200,9 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
BigDecimal monthAnnualizedRate = BigDecimal.ZERO;
|
||||
BigDecimal yearAmount = BigDecimal.ZERO;
|
||||
BigDecimal yearAnnualizedRate = BigDecimal.ZERO;
|
||||
//计提日期之前赎回金额之和(用于收益计提计算)
|
||||
BigDecimal allRedAmount = BigDecimal.ZERO;
|
||||
|
||||
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(id, "cim_finsubscribe");
|
||||
if (dynamicObject != null) {
|
||||
|
|
@ -250,6 +254,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
closestRecord = object;
|
||||
}
|
||||
}
|
||||
allRedAmount=this.getRedAmount(dynamicObjectCollection,closestRecord.getDate("e_valuationdate"));
|
||||
|
||||
// 2. 寻找本月最后一次估值记录(相同日期取赎回日期最大的)
|
||||
if (!valuationDate.after(accrualDate)) {
|
||||
|
|
@ -320,7 +325,9 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
// 计提日期向上最近一次市值-上月最后一次的市值(表体若没有,置0)
|
||||
// 新增逻辑:计息日<计提日<=到期日所在月月底才计算本月收益和收益率
|
||||
if (latestIopRecord != null) {
|
||||
BigDecimal currentMarketValue = latestIopRecord.getBigDecimal("e_iopv").multiply(buyCopies);
|
||||
BigDecimal currentRedAmount = this.getRedAmount(dynamicObjectCollection, latestIopRecord.getDate("e_valuationdate"));
|
||||
|
||||
BigDecimal currentMarketValue = latestIopRecord.getBigDecimal("e_iopv").multiply(buyCopies).add(currentRedAmount);
|
||||
|
||||
// 新增:检查计息日<计提日<=到期日所在月月底
|
||||
boolean isValidPeriod = true;
|
||||
|
|
@ -340,8 +347,11 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
// 只有当上月记录存在时才计算本月收益
|
||||
// ①计提日期若与购买日期不同月,取不到上月最后一次,单元格为0
|
||||
if (lastMonthRecord != null) {
|
||||
BigDecimal lastMonthRedAmount = this.getRedAmount(dynamicObjectCollection, lastMonthRecord.getDate("e_valuationdate"));
|
||||
|
||||
BigDecimal lastMonthMarketValue = lastMonthRecord.getBigDecimal("e_iopv")
|
||||
.multiply(lastMonthRecord.getBigDecimal("e_surpcopies"));
|
||||
.multiply(lastMonthRecord.getBigDecimal("e_surpcopies")).add(lastMonthRedAmount);
|
||||
|
||||
monthAmount = currentMarketValue.subtract(lastMonthMarketValue)
|
||||
.divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP);
|
||||
|
||||
|
|
@ -372,12 +382,16 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
|
||||
// 计算本年累计收益
|
||||
if (latestIopRecord != null) {
|
||||
BigDecimal currentMarketValue = latestIopRecord.getBigDecimal("e_iopv").multiply(buyCopies);
|
||||
BigDecimal currentRedAmount = this.getRedAmount(dynamicObjectCollection, latestIopRecord.getDate("e_valuationdate"));
|
||||
|
||||
BigDecimal currentMarketValue = latestIopRecord.getBigDecimal("e_iopv").multiply(buyCopies).add(currentRedAmount);
|
||||
|
||||
// 只有当上年记录存在时才计算本年累计收益
|
||||
if (lastYearRecord != null) {
|
||||
BigDecimal lastYearRedAmount = this.getRedAmount(dynamicObjectCollection, lastYearRecord.getDate("e_valuationdate"));
|
||||
|
||||
BigDecimal lastYearMarketValue = lastYearRecord.getBigDecimal("e_iopv")
|
||||
.multiply(lastYearRecord.getBigDecimal("e_surpcopies"));
|
||||
.multiply(lastYearRecord.getBigDecimal("e_surpcopies")).add(lastYearRedAmount);
|
||||
|
||||
yearAmount = currentMarketValue.subtract(lastYearMarketValue)
|
||||
.divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP);
|
||||
|
|
@ -419,6 +433,62 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
row.set(DYNAMICS_FIELDS[5], monthAnnualizedRate);
|
||||
row.set(DYNAMICS_FIELDS[6], yearAmount);
|
||||
row.set(DYNAMICS_FIELDS[7], yearAnnualizedRate);
|
||||
|
||||
return allRedAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取填入日期之前的赎回单中的赎回金额之和
|
||||
* @param entry 估值分录
|
||||
* @param date 填入日期
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal getRedAmount(DynamicObjectCollection entry, Date date) {
|
||||
// 1. 按估值日期和赎回日期排序
|
||||
DynamicObjectCollection sortedEntries = new DynamicObjectCollection();
|
||||
sortedEntries.addAll(entry);
|
||||
|
||||
sortedEntries.sort((o1, o2) -> {
|
||||
// 优先按估值日期排序(从小到大)
|
||||
Date valDate1 = o1.getDate("e_valuationdate");
|
||||
Date valDate2 = o2.getDate("e_valuationdate");
|
||||
int compareValDate = valDate1.compareTo(valDate2);
|
||||
if (compareValDate != 0) {
|
||||
return compareValDate;
|
||||
}
|
||||
|
||||
// 估值日期相同时,按赎回日期排序
|
||||
Date redDate1 = o1.getDate("shjh_shrq");
|
||||
Date redDate2 = o2.getDate("shjh_shrq");
|
||||
if (redDate1 == null && redDate2 == null) return 0;
|
||||
if (redDate1 == null) return -1; // null视为较小值
|
||||
if (redDate2 == null) return 1;
|
||||
return redDate1.compareTo(redDate2);
|
||||
});
|
||||
|
||||
// 2. 累加符合条件的赎回金额
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
for (DynamicObject item : sortedEntries) {
|
||||
// 检查是否为赎回单(跳过非赎回条目)
|
||||
DynamicObject shdh = item.getDynamicObject("shjh_shdh");
|
||||
if (shdh == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检查估值日期是否 ≤ 目标日期
|
||||
Date valDate = item.getDate("e_valuationdate");
|
||||
if (valDate != null && valDate.compareTo(date) <= 0) {
|
||||
Object pkValue = shdh.getPkValue();
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(pkValue, "cim_redeem");
|
||||
BigDecimal amount = dynamicObject.getBigDecimal("amount"); // 赎回金额字段名
|
||||
BigDecimal realrevenue = dynamicObject.getBigDecimal("revenueamount"); // 实际收益字段名
|
||||
if (amount != null) {
|
||||
sum = sum.add(amount).add(realrevenue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -568,7 +638,8 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
BigDecimal monthNetWorth,
|
||||
BigDecimal netWorth,
|
||||
DynamicObject row,
|
||||
BigDecimal startBuyCopies
|
||||
BigDecimal startBuyCopies,
|
||||
BigDecimal redAmount
|
||||
) {
|
||||
if (expireDate==null){
|
||||
expireDate=accrualDate;
|
||||
|
|
@ -580,6 +651,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
|
|||
if (buyCopies != null && monthNetWorth != null && netWorth != null && startBuyCopies != null) {
|
||||
// 计算:(持有份额 * 月末单位净值 - 购买份额 * 购买时单位净值) / 1000
|
||||
revenue = buyCopies.multiply(monthNetWorth)
|
||||
.add(redAmount)
|
||||
.subtract(startBuyCopies.multiply(netWorth))
|
||||
.divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue