Commit 128e337d authored by zhkwei's avatar zhkwei

1、总分机构分配比例;2、发票记录导出模板;

parent a6abc899
......@@ -85,7 +85,7 @@ public class CitReportController {
try{
apiResultDto.setCode(1);
apiResultDto.setMessage("生成成功");
apiResultDto.setData(citReportService.generateTotalBranchOrgDisTable(citDistributionDto.getProjectId()));
apiResultDto.setData(citReportService.geneTotalBranchOrgDT(citDistributionDto.getProjectId()));
return apiResultDto;
}catch(Exception e){
e.printStackTrace();
......
......@@ -67,7 +67,11 @@ public class CitReportServiceImpl extends BaseService {
"JXFP", "PSUM", "DFFS", "JFFS", "WPSR", "WPNAME", "WPTYPE", "SUM2", "RSUMIF", "QMYE", "ZC","YT"};
//生成总分机构分配表时取营业收入时所要用的条件
private final static String[] attributeArr = {"主营业务收入-销售商品收入","主营业务收入-提供劳务收入","其他业务收入-其他"};
private final static String[] inComeAttributeArr = {"主营业务收入-销售商品收入","主营业务收入-提供劳务收入","主营业务收入-建造合同收入",
"主营业务收入-让渡资产使用权收入","其他业务收入-其他","其他业务收入-销售材料收入","其他业务收入-出租固定资产收入",
"其他业务收入-出租无形资产收入","其他业务收入-出租包装物和商品收入","其他业务收入-其他"};
//生成总分机构分配表时取营业收入时所要用的条件
private final static String[] salariesAttributeArr = {"职工薪酬"};
@Autowired
private ReportGeneratorImpl reportGenerator;
......@@ -1497,7 +1501,7 @@ public class CitReportServiceImpl extends BaseService {
}
/**
* 生成总分机构分配表,从生成的报表中取数
* 生成总分机构分配表,从生成的报表中取数----原始版本,暂时不用
*/
public CitDistributionDto generateTotalBranchOrgDisTable(String projectId) {
......@@ -1554,7 +1558,7 @@ public class CitReportServiceImpl extends BaseService {
//2.2 获取该机构该期间的营业收入--A101010《一版企业收入明细表》的营业收入金额C4抓取
// TODO 获取该机构该期间的营业收入
CitTbamExample citTbamExample = new CitTbamExample();
citTbamExample.createCriteria().andAttributeIn(Arrays.asList(attributeArr)).andProjectIdEqualTo(projects.get(0).getId());
citTbamExample.createCriteria().andAttributeIn(Arrays.asList(inComeAttributeArr)).andProjectIdEqualTo(projects.get(0).getId());
List<CitTbam> citTbams = citTbamMapper.selectByExample(citTbamExample);
BigDecimal businessIncome = new BigDecimal(0.000000);
for (CitTbam citTbam : citTbams) {
......@@ -1715,12 +1719,12 @@ public class CitReportServiceImpl extends BaseService {
citDistributionMapper.deleteByExample(citDistributionExample);
//获取当前卡片所在期间(就是年数)
Integer period = project.getYear();
//2生成总分机构分配表 start
//2.1 查出所有所有分支机构
//2生成总分机构分配表 start
//2.1 查所有分支机构
OrganizationExample example = new OrganizationExample();
example.createCriteria().andCodeLike(project.getCode().substring(0, project.getCode().length() - 2)+"%");
example.createCriteria().andParentIdEqualTo(organization.getId());
List<Organization> organizations = organizationMapper.selectByExample(example);
//2、取出各个分支机构的三项因素,并算出各个三项因素的合计
//2.2、取出各个分支机构的三项因素,并算出各个三项因素的合计
//比较变量,其余值和该值进行比较,判断其余变量是否为0
BigDecimal compareVariable = new BigDecimal(0.000000);
//营业收入合计变量
......@@ -1732,11 +1736,9 @@ public class CitReportServiceImpl extends BaseService {
//分配所得税额合计变量
BigDecimal totalDistributionAmount = new BigDecimal(0.000000);
//第六行G列的值
BigDecimal sixRowGCouValue = new BigDecimal(0.000000);
List<CitDistribution> citDistributionList = new ArrayList<>();
for (Organization org : organizations) {
//2.1 查出该机构该期间对应的卡片
//2.2.1 查出该机构该期间对应的卡片
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andOrganizationIdEqualTo(org.getId()).andYearEqualTo(period);
List<Project> projects = projectMapper.selectByExample(projectExample);
......@@ -1753,45 +1755,55 @@ public class CitReportServiceImpl extends BaseService {
citDistribution.setTaxPayerNumber(org.getTaxPayerNumber());
citDistribution.setCode(org.getCode());
//2.2 获取该机构该期间的营业收入--A101010《一版企业收入明细表》的营业收入金额C4抓取
// TODO 获取该机构该期间的营业收入
//2.2.2 获取该机构该期间的营业收入--查询出该机构的营业收入
CitTbamExample citTbamExample = new CitTbamExample();
citTbamExample.createCriteria().andAttributeIn(Arrays.asList(attributeArr)).andProjectIdEqualTo(projects.get(0).getId());
List<CitTbam> citTbams = citTbamMapper.selectByExample(citTbamExample);
citTbamExample.createCriteria().andAttributeIn(Arrays.asList(inComeAttributeArr)).andProjectIdEqualTo(projects.get(0).getId());
List<CitTbam> incomeCitTbams = citTbamMapper.selectByExample(citTbamExample);
BigDecimal businessIncome = new BigDecimal(0.000000);
for (CitTbam citTbam : citTbams) {
businessIncome.add(citTbam.getEndingBalance());
for (CitTbam citTbam : incomeCitTbams) {
//因底稿WP003单元格的计算是取负的,所以此处用减
businessIncome = businessIncome.subtract(citTbam.getEndingBalance());
}
totalBusinessIncome.add(businessIncome);
totalBusinessIncome = 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);
//2.2.3 获取该机构该期间的职工薪酬--查询出该机构的职工薪酬
citTbamExample.clear();
citTbamExample.createCriteria().andAttributeIn(Arrays.asList(salariesAttributeArr)).andProjectIdEqualTo(projects.get(0).getId());
List<CitTbam> salariesCitTbams = citTbamMapper.selectByExample(citTbamExample);
BigDecimal employeeRemuneration = new BigDecimal(0.000000);
for (CitTbam citTbam : salariesCitTbams) {
employeeRemuneration = employeeRemuneration.add(citTbam.getEndingBalance());
}
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());
totalEmployeeRemuneration = totalEmployeeRemuneration.add(employeeRemuneration);
citDistribution.setEmployeeRemuneration(employeeRemuneration);
//2.2.4 获取该机构相对应的资产负债表---A202000的 资产总额取负债表的BB("BS101","B",35,12,-1) 意思是取去年12月年底的数,一年取一次上年的。
BigDecimal totalAssets = reportAnalysisService.getCellValue(projects.get(0).getId(), 12, "BS101", 35, 2);
totalTotalAssets = totalTotalAssets.add(totalAssets);
citDistribution.setTotalAssets(totalAssets);
citDistributionList.add(citDistribution);
}
//计算各个机构的分配比例及分配税额
//判断三项因素的总额是否为0,若为0,参与除法运算时赋值为1
BigDecimal totalBusinessIncomeTemp = totalBusinessIncome.compareTo(compareVariable)==0?new BigDecimal("1"):totalBusinessIncome;
BigDecimal totalEmployeeRemunerationTemp = totalEmployeeRemuneration.compareTo(compareVariable)==0?new BigDecimal("1"):totalEmployeeRemuneration;
BigDecimal totalTotalAssetsTemp = totalTotalAssets.compareTo(compareVariable)==0?new BigDecimal("1"):totalTotalAssets;
//2.3 计算各个机构的分配比例
for (CitDistribution citDistribution : citDistributionList) {
//计算分配比例
BigDecimal decimal = citDistribution.getBusinessIncome().divide(totalBusinessIncomeTemp,4).multiply(new BigDecimal("0.35"));
BigDecimal multiply = citDistribution.getEmployeeRemuneration().divide(totalEmployeeRemunerationTemp,4).multiply(new BigDecimal("0.35"));
BigDecimal multiply1 = citDistribution.getTotalAssets().divide(totalTotalAssetsTemp,4).multiply(new BigDecimal("0.30"));
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).
divide(totalBusinessIncomeTemp,4).multiply(new BigDecimal("0.35")).
add(citDistribution.getEmployeeRemuneration().divide(totalEmployeeRemunerationTemp,4).
multiply(new BigDecimal("0.35"))).
add(citDistribution.getTotalAssets().divide(totalTotalAssets.compareTo(compareVariable)==0?new BigDecimal(1):totalTotalAssets).multiply(new BigDecimal("0.30"))));
add(citDistribution.getTotalAssets().divide(totalTotalAssetsTemp,4).multiply(new BigDecimal("0.30"))));
//拼写分配比例的公式
StringBuilder sb = new StringBuilder();
sb.append(citDistribution.getBusinessIncome());
......@@ -1810,10 +1822,6 @@ public class CitReportServiceImpl extends BaseService {
sb.append("*0.30");
citDistribution.setDistributionRatioFormula(citDistribution.getBusinessIncome().toString());
//计算分配税额
citDistribution.setDistributionAmount(sixRowGCouValue.multiply(citDistribution.getDistributionRatio()));
totalDistributionAmount.add(citDistribution.getDistributionAmount());
// TODO 拼写分配税额的计算公式
}
citDistributionList.stream().forEach(citDistribution -> {
......
......@@ -180,11 +180,15 @@
$scope.startCalculateData = function () {
citReportService.generateDistributionTable($scope.queryParams).success(function (data) {
$scope.totalBusinessIncome = data.data.totalBusinessIncome;
$scope.totalEmployeeRemuneration = data.data.totalEmployeeRemuneration;
$scope.totalTotalAssets = data.data.totalTotalAssets;
loadJournalEntryDataFromDB();
if (data.code != 0) {
$scope.totalBusinessIncome = data.data.totalBusinessIncome;
$scope.totalEmployeeRemuneration = data.data.totalEmployeeRemuneration;
$scope.totalTotalAssets = data.data.totalTotalAssets;
loadJournalEntryDataFromDB();
SweetAlert.success($translate.instant('ImportSuccess'))
} else {
SweetAlert.error($translate.instant('PleaseContactAdministrator'));
}
// if(status===204){
// SweetAlert.warning("没有数据可以下载");
// return;
......@@ -264,7 +268,7 @@
{
caption: $translate.instant('DistributionRatio'),
dataField: "distributionRatio",
format: {type: 'fixedPoint', precision: 2},
format: {type: 'percent', precision: 2},
width: 200
}
],
......
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