Commit 82c2f74b by kangxiaoshan

分摊金额处理

parent c2eee1e4
......@@ -458,7 +458,7 @@ public class ContractController {
.append(c.getEndDate())
.append(c.getIntervalUseDays())
.append("\"").append(df.format(c.getIntervaIncomeShare() * 1.0 / 100)).append("\"")
.append("\"").append(df.format(c.getAdjustmentFund())).append("\"")
.append("\"").append(df.format(c.getAdjustmentFund() * 1.0 / 100)).append("\"")
.append("\"").append(df.format(c.getIncomeShareAll() * 1.0 / 100)).append("\"")
.append("\r\n");
}
......
......@@ -98,15 +98,15 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value = "select contract_code,my_body_code,sale,platform from contract where contract_code in ?1",nativeQuery = true)
List<Object[]> findByContractCode(List<String> codesList);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time <= ?2 and platform=?3",nativeQuery = true)
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3",nativeQuery = true)
List<Contract> findShareContranctByDate(String startDate, String endDate, String platform);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time <= ?2 and platform=?3 and my_body_code = ?4",nativeQuery = true)
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and my_body_code = ?4",nativeQuery = true)
List<Contract> findShareContranctByDate(String startDate, String endDate, String platform, String bodyCode);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time <= ?2 and platform=?3 and (my_body_name like %?5% or customer_body like %?5% or contract_code like %?5%)",nativeQuery = true)
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and (my_body_name like %?5% or customer_body like %?5% or contract_code like %?5%)",nativeQuery = true)
List<Contract> findShareContranctByDateSerche(String startDate, String endDate, String platform, String serchName);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time <= ?2 and platform=?3 and my_body_code = ?4 and (my_body_name like %?5% or customer_body like %?5% or contract_code like %?5%)",nativeQuery = true)
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and my_body_code = ?4 and (my_body_name like %?5% or customer_body like %?5% or contract_code like %?5%)",nativeQuery = true)
List<Contract> findShareContranctByDate(String startDate, String endDate, String platform, String bodyCode, String serchName);
}
......@@ -513,6 +513,10 @@ public class ContractServiceImpl implements ContractService {
// adiAccountService.updateAccount(resource);
// }
this.calculateShareIncome(resource);
resource = contractRepository.save(resource);
this.saveContractRelations(resource, resource.getId());
......@@ -520,6 +524,20 @@ public class ContractServiceImpl implements ContractService {
return resource;
}
public void calculateShareIncome(Contract resource){
DateTime formStart = new DateTime(resource.getStartDate());
DateTime contractStart = new DateTime(resource.getStartDate());
DateTime contractEnd = new DateTime(resource.getEndDate());
if (formStart.getMonthOfYear() != new DateTime().getMonthOfYear()) {
// 自动计算分摊调整金
//当录入时间与合同开始时间不在一个月时。自动生成调分摊输入调整金。
//分摊收入调整金 = 合同金额 * 6% / 合同总天数 *[录入日期前一月最后一日(含) - 合同开始日期]
int day1 = Days.daysBetween(contractStart, contractEnd).getDays();
int day2 = Days.daysBetween(contractStart, new DateTime().plusMonths(-1).dayOfMonth().withMaximumValue()).getDays();
resource.setAdjustmentFund(resource.getMoney() * 6 / day1 * day2 ); // 此处为 *100的结果
}
}
private void saveIncrementFlow(Contract resource, Long extraFlow) {
if ("main".equals(resource.getType())) {
......@@ -775,6 +793,8 @@ public class ContractServiceImpl implements ContractService {
}
}
this.calculateShareIncome(resource);
resource.setId(contract.getId());
return contractRepository.save(resource);
......@@ -2405,7 +2425,7 @@ public class ContractServiceImpl implements ContractService {
v.setAdjustmentFund(0L);
}
//分摊总收入
v.setIncomeShareAll(intervalIncome + v.getAdjustmentFund() * 100);
v.setIncomeShareAll(intervalIncome + v.getAdjustmentFund());
});
......
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