Commit f29456e6 by kangxiaoshan

处理指定合同分摊收入

parent d8b76c16
......@@ -140,6 +140,10 @@
</option>
</method>
</configuration>
<list>
<item itemvalue="Application.ShareIncomeServiceImpl" />
<item itemvalue="Tomcat Server.tomcat" />
</list>
<recent_temporary>
<list>
<item itemvalue="Application.ShareIncomeServiceImpl" />
......@@ -197,6 +201,10 @@
<workItem from="1595210254869" duration="331000" />
<workItem from="1595249283758" duration="1012000" />
<workItem from="1595296992575" duration="2571000" />
<workItem from="1595411015947" duration="2361000" />
<workItem from="1595423418178" duration="5133000" />
<workItem from="1595834892104" duration="1472000" />
<workItem from="1595989766739" duration="9839000" />
</task>
<servers />
</component>
......@@ -231,78 +239,78 @@
</option>
</component>
<component name="WindowStateProjectService">
<state x="438" y="66" key="#xdebugger.evaluate" timestamp="1595064059991">
<state x="352" y="132" key="#xdebugger.evaluate" timestamp="1596003888437">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state x="438" y="66" key="#xdebugger.evaluate/0.0.1366.728@0.0.1366.728" timestamp="1595064059991" />
<state width="454" height="438" key="DebuggerActiveHint" timestamp="1595063945975">
<state x="352" y="132" key="#xdebugger.evaluate/0.0.1366.728@0.0.1366.728" timestamp="1596003888437" />
<state width="461" height="438" key="DebuggerActiveHint" timestamp="1596003841176">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="454" height="438" key="DebuggerActiveHint/0.0.1366.728@0.0.1366.728" timestamp="1595063945975" />
<state width="1111" height="308" key="GridCell.Tab.0.bottom" timestamp="1595299506737">
<state width="461" height="438" key="DebuggerActiveHint/0.0.1366.728@0.0.1366.728" timestamp="1596003841176" />
<state width="1111" height="308" key="GridCell.Tab.0.bottom" timestamp="1596005108491">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.0.bottom/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.0.center" timestamp="1595299506737">
<state width="1111" height="308" key="GridCell.Tab.0.bottom/0.0.1366.728@0.0.1366.728" timestamp="1596005108491" />
<state width="1111" height="308" key="GridCell.Tab.0.center" timestamp="1596005108491">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.0.left" timestamp="1595299506736">
<state width="1111" height="308" key="GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728" timestamp="1596005108491" />
<state width="1111" height="308" key="GridCell.Tab.0.left" timestamp="1596005108491">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728" timestamp="1595299506736" />
<state width="1111" height="308" key="GridCell.Tab.0.right" timestamp="1595299506737">
<state width="1111" height="308" key="GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728" timestamp="1596005108491" />
<state width="1111" height="308" key="GridCell.Tab.0.right" timestamp="1596005108491">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.1.bottom" timestamp="1595299506737">
<state width="1111" height="308" key="GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728" timestamp="1596005108491" />
<state width="1111" height="308" key="GridCell.Tab.1.bottom" timestamp="1596005108492">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.1.bottom/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.1.center" timestamp="1595299506737">
<state width="1111" height="308" key="GridCell.Tab.1.bottom/0.0.1366.728@0.0.1366.728" timestamp="1596005108492" />
<state width="1111" height="308" key="GridCell.Tab.1.center" timestamp="1596005108491">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.1.center/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.1.left" timestamp="1595299506737">
<state width="1111" height="308" key="GridCell.Tab.1.center/0.0.1366.728@0.0.1366.728" timestamp="1596005108491" />
<state width="1111" height="308" key="GridCell.Tab.1.left" timestamp="1596005108491">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.1.left/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.1.right" timestamp="1595299506737">
<state width="1111" height="308" key="GridCell.Tab.1.left/0.0.1366.728@0.0.1366.728" timestamp="1596005108491" />
<state width="1111" height="308" key="GridCell.Tab.1.right" timestamp="1596005108491">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.1.right/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.2.bottom" timestamp="1595299506738">
<state width="1111" height="308" key="GridCell.Tab.1.right/0.0.1366.728@0.0.1366.728" timestamp="1596005108491" />
<state width="1111" height="308" key="GridCell.Tab.2.bottom" timestamp="1596005108300">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.2.bottom/0.0.1366.728@0.0.1366.728" timestamp="1595299506738" />
<state width="1111" height="308" key="GridCell.Tab.2.center" timestamp="1595299506737">
<state width="1111" height="308" key="GridCell.Tab.2.bottom/0.0.1366.728@0.0.1366.728" timestamp="1596005108300" />
<state width="1111" height="308" key="GridCell.Tab.2.center" timestamp="1596005108300">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.2.center/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.2.left" timestamp="1595299506737">
<state width="1111" height="308" key="GridCell.Tab.2.center/0.0.1366.728@0.0.1366.728" timestamp="1596005108300" />
<state width="1111" height="308" key="GridCell.Tab.2.left" timestamp="1596005108300">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.2.left/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.2.right" timestamp="1595299506737">
<state width="1111" height="308" key="GridCell.Tab.2.left/0.0.1366.728@0.0.1366.728" timestamp="1596005108300" />
<state width="1111" height="308" key="GridCell.Tab.2.right" timestamp="1596005108300">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.2.right/0.0.1366.728@0.0.1366.728" timestamp="1595299506737" />
<state width="1111" height="308" key="GridCell.Tab.3.bottom" timestamp="1595299506738">
<state width="1111" height="308" key="GridCell.Tab.2.right/0.0.1366.728@0.0.1366.728" timestamp="1596005108300" />
<state width="1111" height="308" key="GridCell.Tab.3.bottom" timestamp="1596005108300">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.3.bottom/0.0.1366.728@0.0.1366.728" timestamp="1595299506738" />
<state width="1111" height="308" key="GridCell.Tab.3.center" timestamp="1595299506738">
<state width="1111" height="308" key="GridCell.Tab.3.bottom/0.0.1366.728@0.0.1366.728" timestamp="1596005108300" />
<state width="1111" height="308" key="GridCell.Tab.3.center" timestamp="1596005108300">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.3.center/0.0.1366.728@0.0.1366.728" timestamp="1595299506738" />
<state width="1111" height="308" key="GridCell.Tab.3.left" timestamp="1595299506738">
<state width="1111" height="308" key="GridCell.Tab.3.center/0.0.1366.728@0.0.1366.728" timestamp="1596005108300" />
<state width="1111" height="308" key="GridCell.Tab.3.left" timestamp="1596005108300">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.3.left/0.0.1366.728@0.0.1366.728" timestamp="1595299506738" />
<state width="1111" height="308" key="GridCell.Tab.3.right" timestamp="1595299506738">
<state width="1111" height="308" key="GridCell.Tab.3.left/0.0.1366.728@0.0.1366.728" timestamp="1596005108300" />
<state width="1111" height="308" key="GridCell.Tab.3.right" timestamp="1596005108300">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.3.right/0.0.1366.728@0.0.1366.728" timestamp="1595299506738" />
<state width="1111" height="308" key="GridCell.Tab.3.right/0.0.1366.728@0.0.1366.728" timestamp="1596005108300" />
<state width="1111" height="308" key="GridCell.Tab.6.bottom" timestamp="1595298613992">
<screen x="0" y="0" width="1366" height="728" />
</state>
......@@ -335,6 +343,14 @@
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1111" height="308" key="GridCell.Tab.7.right/0.0.1366.728@0.0.1366.728" timestamp="1595298613394" />
<state width="498" height="446" key="SwitcherDM" timestamp="1595411365033">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="498" height="446" key="SwitcherDM/0.0.1366.728@0.0.1366.728" timestamp="1595411365033" />
<state width="691" height="364" key="XDebugger.FullValuePopup" timestamp="1595471656041">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="691" height="364" key="XDebugger.FullValuePopup/0.0.1366.728@0.0.1366.728" timestamp="1595471656041" />
<state x="225" y="100" key="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory$2" timestamp="1595063525107">
<screen x="0" y="0" width="1366" height="728" />
</state>
......
package common.service.impl;
import com.amazonaws.services.dynamodbv2.xspec.B;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import common.model.*;
import common.repository.AuthRepository;
import common.repository.ContractBodyRepository;
......@@ -118,7 +119,6 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
usePart[0] = usePart[0].compareTo(usePart[1]) >= 0 ? usePart[1] : usePart[0];
/*DateTime[][] mainTimes = new DateTime[][]{selected, contractPart, usePart};*/
contract.setIntervalUseDays(getDayRange(contractPart[0], usePart[1]) + 1);
......@@ -128,8 +128,6 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
int contractAllDay = getDayRange(contractPart[0], contractPart[1]) + 1;//合同总天数
//处理精度
/*Long dayShareIncome = new BigDecimal(excludTax * 1.0 / contractAllDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();//每日分摊收入(值扩大100倍)*/
BigDecimal dayShareIncome = new BigDecimal(excludTax * 1.0 / contractAllDay);
......@@ -145,6 +143,12 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
return;
}
//特殊合同处理
Contract specilContract = this.specilContract(contract, dayShareIncome, contractPart, usePart, selected);
if (specilContract != null) {
return;
}
//晚录合同处理
DateTime create = new DateTime(new DateTime(contract.getCreateTime()).toString("yyyy-MM-dd")); //录入时间点
DateTime[] creatPoints = new DateTime[]{
......@@ -156,6 +160,65 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
}
private Contract specilContract(Contract contract, BigDecimal dayShareIncome, DateTime[] contractPart, DateTime[] usePart, DateTime[] selected) {
if (!"QQ-ADI-20190729-57".equals(contract.getContractCode())) {
return null;
}
/*19年不含税金额:24268.88
已摊销天数:161
20不含税金额:31202.8181132075
未摊销天数:205
合同日期2019.7.24-2020.7.23,
合同编号:QQ-ADI-20190729-57*/
DateTime[] middlePoiont = new DateTime[]{new DateTime("2019-12-31"), new DateTime("2020-01-01")};
int daysIncom = getDayRange(usePart[0], usePart[1]) + 1;
BigDecimal dayShare = null;
if (checkTwoTime(usePart[0], middlePoiont[0]) && checkTwoTime(middlePoiont[1], usePart[1])) {
//跨年选择 处理方式待定
contract.setIntervaIncomeShare(0L);
contract.setIncomeExcludingTax(0L);
contract.setAdjustmentFund(0L);
contract.setIncomeShareAll(contract.getIntervaIncomeShare());
return contract;
} else if (checkTwoTime(usePart[1], middlePoiont[0])) {
//按19年处理
dayShare = new BigDecimal(24268.88 * 100 * 1.0 / 161);
contract.setIncomeExcludingTax(new BigDecimal(24268.88 * 100).longValue());
} else {
//按20年处理
dayShare = new BigDecimal(31202.8181132075).multiply(new BigDecimal(100))
.divide(new BigDecimal(205), 15, BigDecimal.ROUND_HALF_UP);
contract.setIncomeExcludingTax(new BigDecimal(31202.8181132075).multiply(new BigDecimal(100))
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
}
contract.setIntervaIncomeShare(shareMultiply(dayShare, new BigDecimal(daysIncom), 0));
/*if (usePart[1].equals(middlePoiont[0])) {
//包含19年最后一日
long last = contract.getIncomeExcludingTax() - dayShare.setScale(0, BigDecimal.ROUND_HALF_UP).longValue() * 160;
contract.setIntervaIncomeShare(shareMultiply(dayShare, new BigDecimal(daysIncom - 1), 0) + last);
} else if (checkTwoTime(middlePoiont[1], usePart[1])) {
// 20 年包含合同最后一日
long last = contract.getIncomeExcludingTax() - dayShare.setScale(0, BigDecimal.ROUND_HALF_UP).longValue() * 204;
contract.setIntervaIncomeShare(shareMultiply(dayShare, new BigDecimal(daysIncom - 1), 0) + last);
}*/
contract.setAdjustmentFund(0L);
contract.setIncomeShareAll(contract.getIntervaIncomeShare());
return contract;
}
private void afterContract(Contract contract, int contractAllDay, BigDecimal dayShareIncome,
DateTime[] contractPart, DateTime[] usePart, DateTime[] selected, DateTime[] creatPoints) {
......@@ -163,7 +226,6 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
//时间范围内用于计算分摊金额的天数
int daysIncom = getDayRange(usePart[0], usePart[1]) + 1;
//区间分摊总收入
// contract.setIntervaIncomeShare(dayShareIncome * daysIncom);
contract.setIntervaIncomeShare(shareMultiply(dayShareIncome, new BigDecimal(daysIncom), 0));
Long adjustmentFund = 0L;//调整金
......@@ -186,6 +248,7 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
contract.setIncomeShareAll(contract.getIntervaIncomeShare());
isLater = false;
} else if (selected[1].isBefore(creatPoints[1])) {
//录入月1号之前 调整金为 0 分摊为 0
contract.setIntervaIncomeShare(0L);
......@@ -198,10 +261,8 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
//所选时间范围内的分摊收入(录入月1号 即creatPoints[1] 开始计算)
DateTime useStart = creatPoints[1].compareTo(selected[0]) >= 0 ? creatPoints[1] : selected[0];
daysIncom = getDayRange(useStart, usePart[1]) + 1;
/*contract.setIntervaIncomeShare(dayShareIncome * daysIncom);//时间范围内分摊金*/
contract.setIntervaIncomeShare(shareMultiply(dayShareIncome, new BigDecimal(daysIncom), 0));
/*adjustmentFund = (getDayRange(contractPart[0], creatPoints[1].plusDays(-1)) + 1) * dayShareIncome;*/
contract.setIntervaIncomeShare(shareMultiply(dayShareIncome, new BigDecimal(daysIncom), 0));
adjustmentFund = shareMultiply(dayShareIncome, new BigDecimal(getDayRange(contractPart[0], creatPoints[1].plusDays(-1)) + 1), 0);
if (checkTwoTime(selected[0], creatPoints[1]) && checkTwoTime(creatPoints[1], selected[1])) {
......@@ -216,14 +277,11 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
//最后一日分摊金计算处理
Long lastDay;
if (isLater) {
/*lastDay = contract.getIncomeExcludingTax() - adjustmentFund
- dayShareIncome * getDayRange(creatPoints[1], contractPart[1]);*/
lastDay = contract.getIncomeExcludingTax() - adjustmentFund
- shareMultiply(dayShareIncome, new BigDecimal(getDayRange(creatPoints[1], contractPart[1])), 0);
} else {
/*lastDay = contract.getIncomeExcludingTax() - adjustmentFund
- dayShareIncome * getDayRange(contractPart[0], contractPart[1]);*/
lastDay = contract.getIncomeExcludingTax() - adjustmentFund
- shareMultiply(dayShareIncome, new BigDecimal(getDayRange(contractPart[0], contractPart[1])), 0);
}
......@@ -303,10 +361,7 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
// 合同终止日 或 作废日
DateTime cancelDate = new DateTime(contractChange.getDs());
/*Long adjustmentFund = (getDayRange(contractPart[0], cancelDate) + 1) * dayShareIncome * (-1);*/
Long adjustmentFund = shareMultiply(new BigDecimal((getDayRange(contractPart[0], cancelDate) + 1) * -1), dayShareIncome, 0);
DateTime usedEnd = usePart[1].compareTo(cancelDate) <= 0 ? usePart[1] : cancelDate;
int daysIncom = Days.daysBetween(usePart[0], usedEnd).getDays() + 1;
......@@ -314,14 +369,9 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
contract.setIntervalUseDays(getDayRange(contractPart[0], usedEnd) + 1);
//区间分摊总收入
/*contract.setIntervaIncomeShare(dayShareIncome * daysIncom);*/
contract.setIntervaIncomeShare(shareMultiply(dayShareIncome, new BigDecimal(daysIncom), 0));
/*boolean fullRange = getDayRange(selected[0], selected[1])
>= Days.daysBetween(contractPart[0], cancelDate).getDays() ? true : false;
if (fullRange) {
contract.setAdjustmentFund(-1 * contract.getIntervaIncomeShare());
} else */
if (checkTwoTime(selected[0], cancelDate) && checkTwoTime(cancelDate, selected[1])) {
contract.setAdjustmentFund(adjustmentFund);
} else {
......@@ -353,18 +403,12 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
public static void main(String[] args) {
/* Long aa = new BigDecimal(1000 * 100 / 1.06).setScale(2, BigDecimal.ROUND_HALF_UP).longValue();
Long bb = new BigDecimal(1000 / 1.06)
.setScale(2, BigDecimal.ROUND_HALF_UP)
.multiply(new BigDecimal(100L)).longValue();
System.out.println(aa);
System.out.println(bb);*/
//252.3890909090909
System.out.println(new BigDecimal(38867.92 * 1.0 / 154).doubleValue());
//2019.7.24-2020.7.23
DateTime[] middlePoiont = new DateTime[]{new DateTime("2019-12-31"), new DateTime("2020-01-01")};
DateTime[] middlePoiont2 = new DateTime[]{new DateTime("2019-07-24"), new DateTime("2020-07-23")};
System.out.println(Days.daysBetween(middlePoiont2[1], middlePoiont2[0]).getDays());
System.out.println(Days.daysBetween(middlePoiont2[1], middlePoiont[0]).getDays());
System.out.println(Days.daysBetween(middlePoiont[1], middlePoiont2[0]).getDays());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment