Commit bb9da620 authored by zhkwei's avatar zhkwei

1、固资导入;2、固资损失计算;3、汇率记录条数;4、调整日记账导入模板及bug;5、总分机构分配表小部分优化

parent c033ce6b
...@@ -362,7 +362,7 @@ public class AssetListServiceImpl extends BaseService { ...@@ -362,7 +362,7 @@ public class AssetListServiceImpl extends BaseService {
//获取财务原值---计算方法:原值+原值调整值,暂时不考虑调整值 //获取财务原值---计算方法:原值+原值调整值,暂时不考虑调整值
citAsset.setAccountAcquisitionValue(acquisitionValue); citAsset.setAccountAcquisitionValue(acquisitionValue);
//获取财务每月折旧额----(原值-残值额)/折旧期限 //获取财务每月折旧额----(原值-残值额)/折旧期限
citAsset.setAccountMonthDepreciationAmount(acquisitionValue.subtract(residualRate).divide(new BigDecimal(depreciationPeriod), 2)); citAsset.setAccountMonthDepreciationAmount((acquisitionValue.subtract(residualRate)).divide(new BigDecimal(depreciationPeriod), 2));
//获取财务累计折旧额,接下来计算需要用到,所以赋给一个对象 //获取财务累计折旧额,接下来计算需要用到,所以赋给一个对象
value = CitCommonUtil.getValue(rowData.getCell(25)); value = CitCommonUtil.getValue(rowData.getCell(25));
...@@ -480,7 +480,7 @@ public class AssetListServiceImpl extends BaseService { ...@@ -480,7 +480,7 @@ public class AssetListServiceImpl extends BaseService {
switch(enumCitAssetType){ switch(enumCitAssetType){
case FixedAssets: case FixedAssets:
//获取税务折旧期限 //获取税务折旧期限
citAsset.setTaxDepreciationPeriod(Math.max(citAsset.getDepreciationPeriod(),assetDetailGroup.getGroupYear())); citAsset.setTaxDepreciationPeriod(Math.max(citAsset.getDepreciationPeriod(),assetDetailGroup.getGroupYear()*12));
//把购入日期放入到Calendar //把购入日期放入到Calendar
cal.setTime(citAsset.getBuyDate()); cal.setTime(citAsset.getBuyDate());
...@@ -524,7 +524,7 @@ public class AssetListServiceImpl extends BaseService { ...@@ -524,7 +524,7 @@ public class AssetListServiceImpl extends BaseService {
case InvisibleAssets: case InvisibleAssets:
//获取税务折旧期限 //获取税务折旧期限
citAsset.setTaxDepreciationPeriod(Math.max(citAsset.getDepreciationPeriod(),assetDetailGroup.getGroupYear())); citAsset.setTaxDepreciationPeriod(Math.max(citAsset.getDepreciationPeriod(),assetDetailGroup.getGroupYear()*12));
//把购入日期放入到Calendar //把购入日期放入到Calendar
cal.setTime(citAsset.getBuyDate()); cal.setTime(citAsset.getBuyDate());
...@@ -546,7 +546,7 @@ public class AssetListServiceImpl extends BaseService { ...@@ -546,7 +546,7 @@ public class AssetListServiceImpl extends BaseService {
//获取本年折旧期间 ,截至本年累计折旧期间-截至去年累计折旧期间 //获取本年折旧期间 ,截至本年累计折旧期间-截至去年累计折旧期间
citAsset.setTaxYearDepreciationPeriod(citAsset.getTaxToCurrentYearDepreciationPeriod()-citAsset.getTaxToLastYearDepreciationPeriod()); citAsset.setTaxYearDepreciationPeriod(citAsset.getTaxToCurrentYearDepreciationPeriod()-citAsset.getTaxToLastYearDepreciationPeriod());
//获取税务每月折旧额,(原值-残值)/税法折旧期间 //获取税务每月折旧额,(原值-残值)/税法折旧期间
citAsset.setTaxMonthDepreciationAmount(citAsset.getAcquisitionValue().subtract(citAsset.getResidualRate()).divide(new BigDecimal(assetGroupResult.getTaxDepreciationPeriod()), 2)); citAsset.setTaxMonthDepreciationAmount((citAsset.getAcquisitionValue().subtract(citAsset.getResidualRate())).divide(new BigDecimal(citAsset.getTaxDepreciationPeriod()), 2));
//获取税务截止本年累计折旧额, 本年折旧期间* 每月折旧额 //获取税务截止本年累计折旧额, 本年折旧期间* 每月折旧额
citAsset.setTaxToCurrentYearDepreciationAmount(citAsset.getTaxMonthDepreciationAmount().multiply(new BigDecimal(citAsset.getTaxToCurrentYearDepreciationPeriod()))); citAsset.setTaxToCurrentYearDepreciationAmount(citAsset.getTaxMonthDepreciationAmount().multiply(new BigDecimal(citAsset.getTaxToCurrentYearDepreciationPeriod())));
//获取税务本年折旧额, 截至本年累计折旧期间*每月折旧额 //获取税务本年折旧额, 截至本年累计折旧期间*每月折旧额
......
...@@ -201,6 +201,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -201,6 +201,7 @@ public class CitImportExcelServiceImpl extends BaseService {
if(rowData == null){ if(rowData == null){
citDataImportLogError.setErrorMsg("数据错误,第"+(rowNum+1)+"整行为空"); citDataImportLogError.setErrorMsg("数据错误,第"+(rowNum+1)+"整行为空");
citDataImportLogList.add(citDataImportLogError); citDataImportLogList.add(citDataImportLogError);
continue;
} }
//拼接日记账调整版的实体 //拼接日记账调整版的实体
CitJournalEntryAdjust citJournal = new CitJournalEntryAdjust(); CitJournalEntryAdjust citJournal = new CitJournalEntryAdjust();
......
...@@ -1495,7 +1495,7 @@ public class CitReportServiceImpl extends BaseService { ...@@ -1495,7 +1495,7 @@ public class CitReportServiceImpl extends BaseService {
} }
/** /**
* 生成总分机构分配表 * 生成总分机构分配表,从生成的报表中取数
*/ */
public CitDistributionDto generateTotalBranchOrgDisTable(String projectId) { public CitDistributionDto generateTotalBranchOrgDisTable(String projectId) {
...@@ -1694,6 +1694,146 @@ public class CitReportServiceImpl extends BaseService { ...@@ -1694,6 +1694,146 @@ public class CitReportServiceImpl extends BaseService {
return citDistributionDto; return citDistributionDto;
} }
/**
* 生成总分机构分配表,从根源上取数
*/
public CitDistributionDto geneTotalBranchOrgDT(String projectId) {
CitDistributionDto citDistributionDto = new CitDistributionDto();
Project project = projectMapper.selectByPrimaryKey(projectId);
//判断是不是总机构,若机构的parentId为空则代表为父机构
Organization organization = organizationMapper.selectByPrimaryKey(project.getOrganizationId());
if(organization.getParentId() == null){
//此时代表该机构为总机构,需要生成总分机构分配表,
// 1、生成之前先删除之前生成的数据
CitDistributionExample citDistributionExample = new CitDistributionExample();
citDistributionExample.createCriteria().andProjectIdEqualTo(projectId);
citDistributionMapper.deleteByExample(citDistributionExample);
//获取当前卡片所在期间(就是年数)
Integer period = project.getYear();
//2生成总分机构分配表 start
//2.1 查出所有所有分支机构
OrganizationExample example = new OrganizationExample();
example.createCriteria().andCodeLike(project.getCode().substring(0, project.getCode().length() - 2)+"%");
List<Organization> organizations = organizationMapper.selectByExample(example);
//2、取出各个分支机构的三项因素,并算出各个三项因素的合计
//比较变量,其余值和该值进行比较,判断其余变量是否为0
BigDecimal compareVariable = new BigDecimal(0.000000);
//营业收入合计变量
BigDecimal totalBusinessIncome = new BigDecimal(0.000000);
//职工薪酬合计变量
BigDecimal totalEmployeeRemuneration = new BigDecimal(0.000000);
//资产总额合计变量
BigDecimal totalTotalAssets = new BigDecimal(0.000000);
//分配所得税额合计变量
BigDecimal totalDistributionAmount = new BigDecimal(0.000000);
//第六行G列的值
BigDecimal sixRowGCouValue = new BigDecimal(0.000000);
List<CitDistribution> citDistributionList = new ArrayList<>();
for (Organization org : organizations) {
//2.1 查出该机构该期间对应的卡片
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andOrganizationIdEqualTo(org.getId()).andYearEqualTo(period);
List<Project> projects = projectMapper.selectByExample(projectExample);
if (projects == null || projects.size() == 0) {
continue;
}
CitDistribution citDistribution = new CitDistribution();
citDistribution.setId(idService.nextId());
citDistribution.setOrganizationId(org.getId());
citDistribution.setPeriod(period);
citDistribution.setProjectId(project.getId());
citDistribution.setOrgName(org.getName());
citDistribution.setTaxPayerNumber(org.getTaxPayerNumber());
citDistribution.setCode(org.getCode());
//2.2 获取该机构该期间的营业收入--A101010《一版企业收入明细表》的营业收入金额C4抓取
// TODO 获取该机构该期间的营业收入
CitTbamExample citTbamExample = new CitTbamExample();
citTbamExample.createCriteria().andAttributeIn(Arrays.asList(attributeArr)).andProjectIdEqualTo(projects.get(0).getId());
List<CitTbam> citTbams = citTbamMapper.selectByExample(citTbamExample);
BigDecimal businessIncome = new BigDecimal(0.000000);
for (CitTbam citTbam : citTbams) {
businessIncome.add(citTbam.getEndingBalance());
}
totalBusinessIncome.add(businessIncome);
citDistribution.setBusinessIncome(businessIncome);
//2.3 获取该机构该期间的职工薪酬--WP008职工薪酬表的“职工薪酬”的小计项D20抓取,系统原有的方法
BigDecimal wp008CellValue = reportAnalysisService.getCellValue(projects.get(0).getId(), 0, "CIT.WP008", 20, 4);
citDistribution.setEmployeeRemuneration(wp008CellValue);
totalEmployeeRemuneration.add(wp008CellValue);
//判断当前循环的机构是不是总机构,若是总机构要查找出A200000的15栏
if (org.getCode().equals(project.getCode())){
BigDecimal a200000CellValue = reportAnalysisService.getCellValue(projects.get(0).getId(), 0, "CIT.A200000", 25, 3);
sixRowGCouValue.add(a200000CellValue);
}
CitBalanceSheetPrcAdjustExample citBsExample = new CitBalanceSheetPrcAdjustExample();
citBsExample.createCriteria().andProjectIdEqualTo(projects.get(0).getId()).andItemNameEqualTo("非流动资产合计");
List<CitBalanceSheetPrcAdjust> citBalanceSheetPrcAdjusts = citBsPrcAdjustMapper.selectByExample(citBsExample);
citDistribution.setTotalAssets(citBalanceSheetPrcAdjusts == null||citBalanceSheetPrcAdjusts.size()==0 ? new BigDecimal(0.000000):citBalanceSheetPrcAdjusts.get(0).getBegBal());
totalTotalAssets.add(citDistribution.getTotalAssets());
citDistributionList.add(citDistribution);
}
//计算各个机构的分配比例及分配税额
for (CitDistribution citDistribution : citDistributionList) {
//计算分配比例
citDistribution.setDistributionRatio(citDistribution.getBusinessIncome().
divide(totalBusinessIncome.compareTo(compareVariable)==0?new BigDecimal(1):totalBusinessIncome).multiply(new BigDecimal("0.35")).
add(citDistribution.getEmployeeRemuneration().divide(totalEmployeeRemuneration.compareTo(compareVariable)==0?new BigDecimal(1):totalEmployeeRemuneration).
multiply(new BigDecimal("0.35"))).
add(citDistribution.getTotalAssets().divide(totalTotalAssets.compareTo(compareVariable)==0?new BigDecimal(1):totalTotalAssets).multiply(new BigDecimal("0.30"))));
//拼写分配比例的公式
StringBuilder sb = new StringBuilder();
sb.append(citDistribution.getBusinessIncome());
sb.append("/");
sb.append(totalBusinessIncome);
sb.append("*0.35");
sb.append("+");
sb.append(citDistribution.getEmployeeRemuneration());
sb.append("/");
sb.append(totalEmployeeRemuneration);
sb.append("*0.35");
sb.append("+");
sb.append(citDistribution.getTotalAssets());
sb.append("/");
sb.append(totalTotalAssets);
sb.append("*0.30");
citDistribution.setDistributionRatioFormula(citDistribution.getBusinessIncome().toString());
//计算分配税额
citDistribution.setDistributionAmount(sixRowGCouValue.multiply(citDistribution.getDistributionRatio()));
totalDistributionAmount.add(citDistribution.getDistributionAmount());
// TODO 拼写分配税额的计算公式
}
citDistributionList.stream().forEach(citDistribution -> {
int insert = citDistributionMapper.insertSelective(citDistribution);
});
citDistributionDto.setTotalBusinessIncome(totalBusinessIncome);
citDistributionDto.setTotalEmployeeRemuneration(totalEmployeeRemuneration);
citDistributionDto.setTotalTotalAssets(totalTotalAssets);
}
return citDistributionDto;
}
/**
* 报表导出及上传保存所用
* @param reportIds
* @param projectId
* @param period
* @return
*/
public Workbook generateReportData(List<Long> reportIds, String projectId, Integer period) { public Workbook generateReportData(List<Long> reportIds, String projectId, Integer period) {
PeriodReportExample reportExample = new PeriodReportExample(); PeriodReportExample reportExample = new PeriodReportExample();
reportExample.createCriteria().andIdIn(reportIds); reportExample.createCriteria().andIdIn(reportIds);
......
...@@ -101,6 +101,8 @@ public class DataImportService extends BaseService { ...@@ -101,6 +101,8 @@ public class DataImportService extends BaseService {
private ProjectMapper projectMapper; private ProjectMapper projectMapper;
@Autowired @Autowired
private OrganizationServiceImpl organizationService; private OrganizationServiceImpl organizationService;
@Autowired
private OrganizationAccountingRateMapper organizationAccountingRateMapper;
private static String ebsCallUrl; private static String ebsCallUrl;
...@@ -2261,7 +2263,7 @@ public class DataImportService extends BaseService { ...@@ -2261,7 +2263,7 @@ public class DataImportService extends BaseService {
tmpOrgList.forEach(o -> { tmpOrgList.forEach(o -> {
try { try {
Callable callEbs = new CallEbsThread(type, o, ebsCallUrl, dataImportLogMapper, authUserHelper, Callable callEbs = new CallEbsThread(type, o, ebsCallUrl, dataImportLogMapper, authUserHelper,
idService, dtsTokenService, period, effectiveDateFrom, effectiveDateTo, operator); idService, dtsTokenService, period, effectiveDateFrom, effectiveDateTo, operator,organizationAccountingRateMapper);
executorService.submit(callEbs); executorService.submit(callEbs);
// resList.add(future); // resList.add(future);
} catch (RejectedExecutionException rje) { } catch (RejectedExecutionException rje) {
...@@ -2382,9 +2384,12 @@ public class DataImportService extends BaseService { ...@@ -2382,9 +2384,12 @@ public class DataImportService extends BaseService {
private String effectiveDateTo; private String effectiveDateTo;
private String operator; private String operator;
private OrganizationAccountingRateMapper organizationAccountingRateMapper;
CallEbsThread(int type, Organization org, String ebsCallUrl, DataImportLogMapper dataImportLogMapper, CallEbsThread(int type, Organization org, String ebsCallUrl, DataImportLogMapper dataImportLogMapper,
AuthUserHelper authUserHelper, DistributedIdService idService, DtsTokenService dtsTokenService, AuthUserHelper authUserHelper, DistributedIdService idService, DtsTokenService dtsTokenService,
String period, String effectiveDateFrom, String effectiveDateTo, String operator) { String period, String effectiveDateFrom, String effectiveDateTo, String operator,
OrganizationAccountingRateMapper organizationAccountingRateMapper) {
this.type = type; this.type = type;
this.org = org; this.org = org;
this.period = period; this.period = period;
...@@ -2393,6 +2398,7 @@ public class DataImportService extends BaseService { ...@@ -2393,6 +2398,7 @@ public class DataImportService extends BaseService {
this.dtsTokenService = dtsTokenService; this.dtsTokenService = dtsTokenService;
this.idService = idService; this.idService = idService;
this.dataImportLogMapper = dataImportLogMapper; this.dataImportLogMapper = dataImportLogMapper;
this.organizationAccountingRateMapper = organizationAccountingRateMapper;
this.effectiveDateFrom = effectiveDateFrom; this.effectiveDateFrom = effectiveDateFrom;
this.effectiveDateTo = effectiveDateTo; this.effectiveDateTo = effectiveDateTo;
this.operator = operator; this.operator = operator;
...@@ -2494,6 +2500,16 @@ public class DataImportService extends BaseService { ...@@ -2494,6 +2500,16 @@ public class DataImportService extends BaseService {
} else { } else {
if (EbsExtractTypeConstant.JE == type) { if (EbsExtractTypeConstant.JE == type) {
resp.setCompanyCode(null != resp.getSegment1() ? resp.getSegment1() : ""); resp.setCompanyCode(null != resp.getSegment1() ? resp.getSegment1() : "");
}else if(EbsExtractTypeConstant.RATE == type){
//只有汇率表是同步进行操作,所以在得到response之前已经进行数据插入及记录的更新,
// 在此进行记录条数的设置
logger.info("此时操作汇率表");
OrganizationAccountingRateExample example = new OrganizationAccountingRateExample();
//期间
example.createCriteria().andPeriodEqualTo(convertPeriodStr2Int(period)).andTaskIdEqualTo(String.valueOf(taskId));
List<OrganizationAccountingRate> itemList = organizationAccountingRateMapper.selectByExample(example);
logger.info("查询的汇率条数:"+itemList.size());
log.setRecordSize(itemList.size());
} }
log.setId(taskId); log.setId(taskId);
log.setImportResult(true); log.setImportResult(true);
...@@ -2509,7 +2525,16 @@ public class DataImportService extends BaseService { ...@@ -2509,7 +2525,16 @@ public class DataImportService extends BaseService {
} }
return 1; return 1;
} }
/**
* 期间格式转换为原始的int类型
* @param periodStr
* @return
*/
private Integer convertPeriodStr2Int(String periodStr){
periodStr=StringUtils.replace(periodStr, "-", "");
Integer period=Integer.parseInt(periodStr);
return period;
}
} }
} }
...@@ -453,7 +453,7 @@ ...@@ -453,7 +453,7 @@
accounted_dr, accounted_cr, entered_dr, entered_cr, cf_item, attribute1, attribute2, attribute3, attribute4, attribute5, accounted_dr, accounted_cr, entered_dr, entered_cr, cf_item, attribute1, attribute2, attribute3, attribute4, attribute5,
attribute6, attribute7, attribute8, attribute9, attribute10, attribute11, attribute12, attribute13, attribute14, attribute15, attribute6, attribute7, attribute8, attribute9, attribute10, attribute11, attribute12, attribute13, attribute14, attribute15,
attribute16, created_by, created_date, late_updated_by, late_updated_date, create_time, update_time, is_select attribute16, created_by, created_date, late_updated_by, late_updated_date, create_time, update_time, is_select
from journal_entry where tms_period like CONCAT('%' ,#{record.period},'%') from journal_entry where tms_period like CONCAT(#{record.period},'%')
<if test="orgList != null and orgList.size > 0"> <if test="orgList != null and orgList.size > 0">
AND organization_id in AND organization_id in
<foreach item="item" index="index" collection="orgList" open="(" separator="," close=")"> <foreach item="item" index="index" collection="orgList" open="(" separator="," close=")">
......
...@@ -290,8 +290,8 @@ ...@@ -290,8 +290,8 @@
width: 100 width: 100
}, },
{ {
caption: $translate.instant('PerMonthDepreciationAmount'), caption: $translate.instant('TaxMonthDepreciationAmount'),
dataField: "perMonthDepreciationAmount", dataField: "taxMonthDepreciationAmount",
format: {type: 'fixedPoint', precision: 2}, format: {type: 'fixedPoint', precision: 2},
width: 100 width: 100
}, },
......
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