理财报表位数改动、千元去除
This commit is contained in:
		
							parent
							
								
									a8479c0e56
								
							
						
					
					
						commit
						df0dc5116c
					
				|  | @ -45,19 +45,17 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|     public void beforeQuery(ReportQueryParam queryParam) { | ||||
|         super.beforeQuery(queryParam); | ||||
|         ReportList reportList = getControl("reportlistap"); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[0], "预计收益(千元)", ReportColumn.TYPE_DECIMAL , String.valueOf(8)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[0], "预计收益", ReportColumn.TYPE_DECIMAL , String.valueOf(2)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[1], "计提日", ReportColumn.TYPE_DATE })); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[2], "天数", ReportColumn.TYPE_BIGINT })); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[3], "收益计提(千元)", ReportColumn.TYPE_DECIMAL , String.valueOf(8)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[4], "本月收益(千元)", ReportColumn.TYPE_DECIMAL , String.valueOf(8)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[5], "当月年化收益率(%)", ReportColumn.TYPE_DECIMAL , String.valueOf(8)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[6], "本年累计收益(千元)", ReportColumn.TYPE_DECIMAL , String.valueOf(8)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[7], "本年累计年化收益率(%)", ReportColumn.TYPE_DECIMAL , String.valueOf(8)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[8], "实际收益", ReportColumn.TYPE_DECIMAL , String.valueOf(8)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[9], "实际总收益率(%)", ReportColumn.TYPE_DECIMAL , String.valueOf(8)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[3], "收益计提", ReportColumn.TYPE_DECIMAL , String.valueOf(2)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[4], "本月收益", ReportColumn.TYPE_DECIMAL , String.valueOf(2)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[5], "当月年化收益率(%)", ReportColumn.TYPE_DECIMAL , String.valueOf(2)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[6], "本年累计收益", ReportColumn.TYPE_DECIMAL , String.valueOf(2)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[7], "本年累计年化收益率(%)", ReportColumn.TYPE_DECIMAL , String.valueOf(2)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[8], "实际收益", ReportColumn.TYPE_DECIMAL , String.valueOf(2)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[9], "实际总收益率(%)", ReportColumn.TYPE_DECIMAL , String.valueOf(2)})); | ||||
|         reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[10], "是否已到期", ReportColumn.TYPE_TEXT })); | ||||
|         //reportList.getColumns().add(ReportUtils.createReportColumn(new String [] { DYNAMICS_FIELDS[11], "金额(千元)", ReportColumn.TYPE_DECIMAL , String.valueOf(8)})); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|  | @ -78,13 +76,14 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|         BigDecimal sumYearEarnings =BigDecimal.ZERO;//本年收益汇总 | ||||
|         BigDecimal sumActualEarnings =BigDecimal.ZERO;//实际收益汇总 | ||||
| 
 | ||||
| 
 | ||||
|         while (iterator.hasNext()) { | ||||
|             DynamicObject row = iterator.next(); | ||||
|             //1.金额(千元)设置 | ||||
|             //1.金额设置 | ||||
|             BigDecimal amount = ReportUtils.getBigDecimalValue(row, REPORT_FIELDS[4]); // 原始金额(元) | ||||
|             BigDecimal buyAmount = amount.divide(new BigDecimal(1000), 8, RoundingMode.HALF_UP);//购买金额(千元) | ||||
|             row.set(REPORT_FIELDS[4],buyAmount); | ||||
|             row.set(REPORT_FIELDS[4],amount.setScale(2, RoundingMode.HALF_UP)); | ||||
| 
 | ||||
|             BigDecimal newAmount = ReportUtils.getBigDecimalValue(row, REPORT_FIELDS[17]); // 金额(元) | ||||
|             row.set(REPORT_FIELDS[17],newAmount.setScale(2, RoundingMode.HALF_UP)); | ||||
| 
 | ||||
|             BigDecimal netWorth = ReportUtils.getBigDecimalValue(row, REPORT_FIELDS[6]); // 购买时单位净值 | ||||
|             Date buyDate = row.getDate(REPORT_FIELDS[7]); // 购买日 | ||||
|  | @ -110,7 +109,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|             // 5.计息基准天数 | ||||
|             BigDecimal basisDays = computeBasisDays(basis); | ||||
| 
 | ||||
|             // 6. 预计收益 = 产品期限 * 金额(千元) * 预计业绩比较基准 / 365 | ||||
|             // 6. 预计收益 = 产品期限 * 金额 * 预计业绩比较基准 / 365 | ||||
|             BigDecimal proRevenue = countProRevenue(expectedRate, term, amount, row,basisDays); | ||||
|             sumProjectedEarnings=sumProjectedEarnings.add(proRevenue); | ||||
| 
 | ||||
|  | @ -118,10 +117,10 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|             // 7. 持有份额 = 计提日期向上最近持有份额 | ||||
|             // 8. 月末单位净值 = 计提日期向上最近一次的净值 | ||||
|             // 9. 月末净值报告日 = 计提日期向上最近一次的估值日期 | ||||
|             // 10. 本月收益(千元)、当月年化收益率% | ||||
|             // 11. 本年累计收益(千元)、本年累计年化收益率 | ||||
|             // 10. 本月收益、当月年化收益率% | ||||
|             // 11. 本年累计收益、本年累计年化收益率 | ||||
|             Long id = row.getLong(REPORT_FIELDS[13]); | ||||
|             BigDecimal allRedProductAmount = valuationEntry(accrualDate, buyDate, expireDate2, valueDate, buyAmount, days, basisDays, id, row,netWorth,startBuyCopies); | ||||
|             BigDecimal allRedProductAmount = valuationEntry(accrualDate, buyDate, expireDate2, valueDate, amount, days, basisDays, id, row,netWorth,startBuyCopies); | ||||
| 
 | ||||
|             BigDecimal buyCopies = ReportUtils.getBigDecimalValue(row, REPORT_FIELDS[5]); // 持有份额 | ||||
|             BigDecimal monthNetWorth = ReportUtils.getBigDecimalValue(row, REPORT_FIELDS[11]); // 月末单位净值 | ||||
|  | @ -142,27 +141,14 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|             //实际总收益率=实际收益/金额 | ||||
|             BigDecimal actualEarnings = ReportUtils.getBigDecimalValue(row, DYNAMICS_FIELDS[8]); | ||||
|             row.set(DYNAMICS_FIELDS[9],actualEarnings | ||||
|                     .divide(buyAmount,4, RoundingMode.HALF_UP) | ||||
|                     .divide(amount,4, RoundingMode.HALF_UP) | ||||
|                     .multiply(BigDecimal.valueOf(100))); | ||||
|             sumActualEarnings=sumActualEarnings.add(actualEarnings); | ||||
| 
 | ||||
|             //小计行合计 | ||||
| //            if (row.getString(REPORT_FIELDS[0]).contains("-小计")){ | ||||
| //                row.set(DYNAMICS_FIELDS[0],sumProjectedEarnings); | ||||
| //                row.set(DYNAMICS_FIELDS[3],sumProvisionEarnings); | ||||
| //                row.set(DYNAMICS_FIELDS[4],sumMonthEarnings); | ||||
| //                row.set(DYNAMICS_FIELDS[6],sumYearEarnings); | ||||
| //                //赋值后归0,重新参与合计 | ||||
| //                sumProjectedEarnings=BigDecimal.ZERO; | ||||
| //                sumProvisionEarnings=BigDecimal.ZERO; | ||||
| //                sumMonthEarnings=BigDecimal.ZERO; | ||||
| //                sumYearEarnings=BigDecimal.ZERO; | ||||
| //            } | ||||
| 
 | ||||
| 
 | ||||
|         } | ||||
| 
 | ||||
|         //小计行处理 | ||||
|         //ReportUtils.changeRowData(rowData,REPORT_FIELDS[0]); | ||||
|         //过滤 | ||||
|         ReportUtils.removeRowData(rowData,REPORT_FIELDS[9],DYNAMICS_FIELDS[1]); | ||||
|         //排序 | ||||
|  | @ -179,11 +165,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|         sumConfig.add(new String[]{DYNAMICS_FIELDS[6], DYNAMICS_FIELDS[6]}); // shjh_yearrevenueamt | ||||
|         sumConfig.add(new String[]{DYNAMICS_FIELDS[8], DYNAMICS_FIELDS[8]}); // shjh_actualearnings | ||||
|         sumConfig.add(new String[]{REPORT_FIELDS[17], REPORT_FIELDS[17]}); // shjh_actualearnings | ||||
| 
 | ||||
|         ReportUtils.addTotalRowData(rowData,REPORT_FIELDS[0],"小计","合计",sumConfig); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -342,10 +324,10 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
| 
 | ||||
|                     //计提日最近估值记录获取——(赎回金额+实际收益)* 所有赎回单 | ||||
|                     allRedAmount=this.getRealRevenueAmount(dynamicObjectCollection,closestRecord.getDate("e_valuationdate")); | ||||
|                     row.set(DYNAMICS_FIELDS[8], allRedAmount.divide(BigDecimal.valueOf(1000),8, RoundingMode.HALF_UP)); // 实际收益 | ||||
|                     row.set(DYNAMICS_FIELDS[8], allRedAmount); // 实际收益 | ||||
|                     //计提日最近估值记录获取——(1-赎回份额/赎回日剩余份额)* 所有赎回单 | ||||
|                     allRedProductAmount=this.getRedProductAmount(dynamicObjectCollection,closestRecord.getDate("e_valuationdate")); | ||||
|                     //计算金额(千元) | ||||
|                     //计算金额 | ||||
|                     row.set(REPORT_FIELDS[17],allRedProductAmount.multiply(buyAmount).setScale(8, RoundingMode.HALF_UP)); | ||||
|                 } | ||||
| 
 | ||||
|  | @ -386,8 +368,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|                             BigDecimal lastMonthMarketValue = lastMonthRecord.getBigDecimal("e_iopv") | ||||
|                                     .multiply(lastMonthRecord.getBigDecimal("e_surpcopies")).add(lastMonthRedAmount); | ||||
| 
 | ||||
|                             monthAmount = currentMarketValue.subtract(lastMonthMarketValue) | ||||
|                                     .divide(new BigDecimal(1000), 8, RoundingMode.HALF_UP); | ||||
|                             monthAmount = currentMarketValue.subtract(lastMonthMarketValue); | ||||
| 
 | ||||
|                             // 计算当月年化收益率 | ||||
|                             // 本月收益/(购买金额*(赎回比之积))*100*12 | ||||
|  | @ -401,8 +382,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|                         } else if (accrualYear == buyYear && accrualMonth == buyMonth) { | ||||
|                             // 特殊处理:计提月与购买月相同时,使用购买金额作为上月市值 | ||||
|                             // ②如果计提日期和购买日同月,"上月最后一次的市值行"取购买金额 | ||||
|                             monthAmount = currentMarketValue.subtract(buyAmount.multiply(new BigDecimal(1000))) | ||||
|                                     .divide(new BigDecimal(1000), 8, RoundingMode.HALF_UP); | ||||
|                             monthAmount = currentMarketValue.subtract(buyAmount); | ||||
| 
 | ||||
|                             if (buyAmount.compareTo(BigDecimal.ZERO) != 0) { | ||||
|                                 //本月收益/购买金额*100*12 | ||||
|  | @ -428,8 +408,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|                         BigDecimal lastYearMarketValue = lastYearRecord.getBigDecimal("e_iopv") | ||||
|                                 .multiply(lastYearRecord.getBigDecimal("e_surpcopies")).add(lastYearRedAmount); | ||||
| 
 | ||||
|                         yearAmount = currentMarketValue.subtract(lastYearMarketValue) | ||||
|                                 .divide(new BigDecimal(1000), 8, RoundingMode.HALF_UP); | ||||
|                         yearAmount = currentMarketValue.subtract(lastYearMarketValue); | ||||
| 
 | ||||
|                         //本年累计年化收益率=(本年累计总收益额/(金额*(赎回比之积)))/(计提日期到-年初日期)*计息基准天数 | ||||
|                         if (buyAmount.compareTo(BigDecimal.ZERO) != 0 && BigDecimal.valueOf(daysFromJan1).compareTo(BigDecimal.ZERO) != 0 ) { | ||||
|  | @ -445,8 +424,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|                         // 天数:(计提日期到-计息日) | ||||
| 
 | ||||
|                         if (buyAmount.compareTo(BigDecimal.ZERO) != 0 ) { | ||||
|                             yearAmount = currentMarketValue.subtract(buyAmount.multiply(new BigDecimal(1000))) | ||||
|                                     .divide(new BigDecimal(1000), 8, RoundingMode.HALF_UP); | ||||
|                             yearAmount = currentMarketValue.subtract(buyAmount); | ||||
| 
 | ||||
|                             if (days.compareTo(BigDecimal.ZERO) !=0 ){ | ||||
|                                 yearAnnualizedRate = yearAmount | ||||
|  | @ -462,8 +440,6 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         //计算实际收益 | ||||
|         //countActRevenueAmt(buyCopies, monthIop, netWorth, row,startBuyCopies,allRedAmount); | ||||
|         // 设置结果 | ||||
|         row.set(REPORT_FIELDS[5], buyCopies); | ||||
|         row.set(REPORT_FIELDS[11], monthIop); | ||||
|  | @ -712,19 +688,10 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|         String day = "0"; // 默认值设为0 | ||||
|         Date endDate = (expireDate != null) ? expireDate : accrualDate; | ||||
| 
 | ||||
| //        BigDecimal actualEarnings = BigDecimal.ZERO; | ||||
|         Long id = row.getLong(REPORT_FIELDS[13]); // id | ||||
|         DynamicObject[] load = BusinessDataServiceHelper.load("cim_redeem", "id,redeemdate,lastmodifytime,realrevenue", | ||||
|                 (new QFilter("sourcebillid", QCP.equals, id)).toArray()); | ||||
| 
 | ||||
|         // 计算实际收益 | ||||
| //        if (load != null && load.length != 0) { | ||||
| //            for (DynamicObject dynamicObject : load) { | ||||
| //                BigDecimal realrevenue = dynamicObject.getBigDecimal("realrevenue"); | ||||
| //                actualEarnings = actualEarnings.add(realrevenue); | ||||
| //            } | ||||
| //        } | ||||
| 
 | ||||
|         if (valueDate != null) { | ||||
|             String status = row.getString(REPORT_FIELDS[14]); // 状态 | ||||
|             if (status.equals("subscribe_end")) { | ||||
|  | @ -762,7 +729,6 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|         row.set(DYNAMICS_FIELDS[10], isExpired); // 是否到期 | ||||
| 
 | ||||
|         row.set(REPORT_FIELDS[3], day); // 产品期限天数 | ||||
|         //row.set(DYNAMICS_FIELDS[8], actualEarnings); // 实际收益 | ||||
| 
 | ||||
|         return day; | ||||
|     } | ||||
|  | @ -776,7 +742,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 预计收益 = 产品期限 * 金额(千元) * 预计业绩比较基准 / 365 | ||||
|      * 预计收益 = 产品期限 * 金额 * 预计业绩比较基准 / 365 | ||||
|      * @param expectedRate 预计业绩比较基准(%) | ||||
|      * @param day 总天数 | ||||
|      * @param amount 投资金额 | ||||
|  | @ -786,7 +752,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
| 
 | ||||
|         BigDecimal projectRevenue = BigDecimal.ZERO; | ||||
|         if (expectedRate != null) { | ||||
|             projectRevenue = new BigDecimal(day).multiply(amount.divide(new BigDecimal(1000), 10, RoundingMode.HALF_UP)) | ||||
|             projectRevenue = new BigDecimal(day).multiply(amount) | ||||
|                     .multiply(expectedRate.divide(new BigDecimal(100), 10, RoundingMode.HALF_UP)) | ||||
|                     .divide(basisDay, 8, RoundingMode.HALF_UP); | ||||
|             row.set(DYNAMICS_FIELDS[0], projectRevenue); | ||||
|  | @ -819,10 +785,9 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
| 
 | ||||
|         // 检查所有参数是否非空 | ||||
|         if (buyCopies != null && monthNetWorth != null && netWorth != null && startBuyCopies != null) { | ||||
|             // 计算:(持有份额 * 月末单位净值+(所有赎回单金额+实际收益) - 购买份额 * 购买时单位净值) / 1000 | ||||
|             // 计算:持有份额 * 月末单位净值+(所有赎回单金额+实际收益) - 购买份额 * 购买时单位净值 | ||||
|             revenue = buyCopies.multiply(monthNetWorth) | ||||
|                     .subtract(startBuyCopies.multiply(netWorth).multiply(allRedProductAmount)) | ||||
|                     .divide(new BigDecimal(1000), 8, RoundingMode.HALF_UP); | ||||
|                     .subtract(startBuyCopies.multiply(netWorth).multiply(allRedProductAmount)); | ||||
| 
 | ||||
|             // 设置到表格行 | ||||
|             boolean isValidPeriod = !valueDate.after(accrualDate) && !accrualDate.after(expireDate); | ||||
|  | @ -838,37 +803,6 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|         return revenue; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 实际收益 = (持有份额 * 月末单位净值+(赎回单赎回金额、实际收益之和) - 购买份额 * 购买时单位净值) / 1000 | ||||
|      * @param buyCopies 持有份额(当前份额) | ||||
|      * @param monthNetWorth 月末单位净值(当前净值) | ||||
|      * @param netWorth 购买时单位净值(初始净值) | ||||
|      * @param row 表格行数据 | ||||
|      * @param startBuyCopies 购买份额(初始份额) | ||||
|      * @return 计算后的收益金额(保留2位小数) | ||||
|      */ | ||||
|     private void countActRevenueAmt( | ||||
|                                        BigDecimal buyCopies, | ||||
|                                        BigDecimal monthNetWorth, | ||||
|                                        BigDecimal netWorth, | ||||
|                                        DynamicObject row, | ||||
|                                        BigDecimal startBuyCopies, | ||||
|                                        BigDecimal redAmount | ||||
|     ) { | ||||
| 
 | ||||
|         BigDecimal revenue = BigDecimal.ZERO; | ||||
| 
 | ||||
|         // 检查所有参数是否非空 | ||||
|         if (buyCopies != null && monthNetWorth != null && netWorth != null && startBuyCopies != null) { | ||||
|             // 计算:(持有份额 * 月末单位净值+(所有赎回单金额+实际收益) - 购买份额 * 购买时单位净值) / 1000 | ||||
|             revenue = buyCopies.multiply(monthNetWorth) | ||||
|                     .add(redAmount) | ||||
|                     .subtract(startBuyCopies.multiply(netWorth)) | ||||
|                     .divide(new BigDecimal(1000), 8, RoundingMode.HALF_UP); | ||||
|             row.set(DYNAMICS_FIELDS[8], revenue); // 实际收益 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     // 辅助方法:比较赎回日期 | ||||
|     private boolean isRedeemDateLater(Date newRedeemDate, Date existingRedeemDate) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue