Commit 017a3bf0 authored by chase's avatar chase

fix bug

parent 61b410ff
......@@ -59,6 +59,7 @@ public class SpringContextUtil implements ApplicationContextAware {
public static AdjustmentTableMapper adjustmentTableMapper;
public static TrialBalanceFinalMapper trialBalanceFinalMapper;
public static ProfitLossStatementMapper profitLossStatementMapper;
public static RevenueConfigMapper revenueConfigMapper;
public static RevenueTypeMappingMapper revenueTypeMappingMapper;
public static InvoiceRecordMapper invoiceRecordMapper;
public static CertifiedInvoicesListMapper certifiedInvoicesListMapper;
......@@ -148,6 +149,7 @@ public class SpringContextUtil implements ApplicationContextAware {
invoiceRecordMapper = webApplicationContext.getBean(InvoiceRecordMapper.class);
certifiedInvoicesListMapper = webApplicationContext.getBean(CertifiedInvoicesListMapper.class);
trialBalanceMappingMapper = webApplicationContext.getBean(TrialBalanceMappingMapper.class);
revenueConfigMapper = webApplicationContext.getBean(RevenueConfigMapper.class);
/* map.put("balance_sheet", balanceMapper);
map.put("profit_loss_statement",profitLossStatementMapper);
map.put("cash_flow", cashFlowMapper);
......
......@@ -342,6 +342,17 @@ public class ReportServiceImpl extends BaseService {
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate).
andStatusEqualTo(0);
List<RevenueTypeMapping> mappingList = revenueTypeMappingMapper.selectByExample(mappingExample);
//先清除数据
InvoiceRecord delRecord = new InvoiceRecord();
delRecord.setRevenueCofId(null);
if(!isMergeManualData){
delRecord.setModifyRevenueCofId(null);
}
InvoiceRecordExample delExample = new InvoiceRecordExample();
delExample.createCriteria().andProjectIdEqualTo(projectId)
.andProjectIdEqualTo(projectId).
andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", "")));
invoiceRecordMapper.deleteByExample(delExample);
Map<String, Long> map = new HashMap<>();
for (RevenueTypeMapping mapping : mappingList) {
if (!map.containsKey(mapping.getContent())) {
......@@ -356,10 +367,6 @@ public class ReportServiceImpl extends BaseService {
}
if (map.containsKey(mapping.getContent())) {
InvoiceRecord destRecord = new InvoiceRecord();
//是否保存手工数据源
if(!isMergeManualData){
destRecord.setModifyRevenueCofId(null);
}
destRecord.setRevenueCofId(map.get(mapping.getContent()));
InvoiceRecordExample recordExample = new InvoiceRecordExample();
recordExample.createCriteria().andProjectIdEqualTo(projectId)
......@@ -2331,7 +2338,7 @@ public class ReportServiceImpl extends BaseService {
}
@Autowired
@Resource
private EbitSpreadDataMapper ebitSpreadDataMapper;
public OperationResultDto spreadToDb(RequestParameterDto.EbitParam ebitParam) {
......
......@@ -12,19 +12,17 @@ import pwc.taxtech.atms.constant.enums.EnumOperationType;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import pwc.taxtech.atms.constant.enums.KeyValueConfigResultType;
import pwc.taxtech.atms.dto.vatdto.OutputInvoiceDataSourceDto;
import pwc.taxtech.atms.vat.entity.InvoiceRecord;
import pwc.taxtech.atms.vat.entity.InvoiceRecordExample;
import pwc.taxtech.atms.vat.entity.RevenueTypeMapping;
import pwc.taxtech.atms.vat.entity.RevenueTypeMappingExample;
import pwc.taxtech.atms.vat.entity.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
/**
* 根据收入类型配置查询开票收入开票金额总计
* 根据收入类型配置查询开票收入开票金额总计
*/
public class KPSR extends FunctionBase implements FreeRefFunction {
public KPSR(FormulaContext formulaContext) {
......@@ -40,10 +38,10 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
String revenueTypeName = getStringParam(args[0], ec);//收入类型名称
Integer billType = getIntParam(args[1], ec);//发票类型
Integer amountType = getIntParam(args[2], ec);//金额类型
String formulaExpression = "KPSR(\"" + revenueTypeName + "\","+billType+ ","+amountType+")";
String formulaExpression = "KPSR(\"" + revenueTypeName + "\"," + billType + "," + amountType + ")";
logger.debug(formulaExpression);
List<OutputInvoiceDataSourceDto> dataSource = new ArrayList<>();
double result = assembleData(revenueTypeName,dataSource,billType,amountType,ec);
double result = assembleData(revenueTypeName, dataSource, billType, amountType, ec);
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource), FormulaDataSourceDetailType.OutputInvoiceDataSourceDto, new BigDecimal(result), formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, new BigDecimal(result), dataSoureId, formulaContext.getProjectId());
......@@ -51,9 +49,9 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
}
private double assembleData(String revenueTypeName, List<OutputInvoiceDataSourceDto> contain, Integer billType,Integer amountType,OperationEvaluationContext ec) {
private double assembleData(String revenueTypeName, List<OutputInvoiceDataSourceDto> contain, Integer billType, Integer amountType, OperationEvaluationContext ec) {
String queryDate = formulaContext.getYear()+(formulaContext.getPeriod()<10?("0"+formulaContext.getPeriod()):(formulaContext.getPeriod()+""));
String queryDate = formulaContext.getYear() + (formulaContext.getPeriod() < 10 ? ("0" + formulaContext.getPeriod()) : (formulaContext.getPeriod() + ""));
RevenueTypeMappingExample typeMappingExample = new RevenueTypeMappingExample();
typeMappingExample.createCriteria().andOrgIdEqualTo(formulaContext.getOrganizationId())
.andRevenueTypeNameEqualTo(revenueTypeName).andStartDateLessThanOrEqualTo(queryDate)
......@@ -62,17 +60,43 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
if (CollectionUtils.isEmpty(typeMappingList)) {
return 0.0;
}
List<String> contens = typeMappingList.stream()
.map(o -> o.getContent()).collect(Collectors.toList());
if (CollectionUtils.isEmpty(contens)) {
List<String> revenueTypes = typeMappingList.stream()
.map(o -> o.getRevenueTypeName()).collect(Collectors.toList());
RevenueConfigExample configExample = new RevenueConfigExample();
configExample.createCriteria().andOrgIdEqualTo(formulaContext.getOrganizationId()).andStartDateLessThanOrEqualTo(queryDate)
.andEndDateGreaterThanOrEqualTo(queryDate).andNameIn(revenueTypes);
List<RevenueConfig> configDatas = SpringContextUtil.revenueConfigMapper.selectByExample(configExample);
if (CollectionUtils.isEmpty(configDatas)) {
return 0.0;
}
List<Long> revenueTypeIds = configDatas.stream()
.map(o -> o.getId()).collect(Collectors.toList());
List<InvoiceRecord> billDetails = new ArrayList<>();
InvoiceRecordExample invoiceRecordExample = new InvoiceRecordExample();
InvoiceRecordExample.Criteria c = invoiceRecordExample.createCriteria().andBillingContentIn(contens)
invoiceRecordExample.createCriteria().andRevenueCofIdIn(revenueTypeIds)
.andProjectIdEqualTo(formulaContext.getProjectId())
.andPeriodEqualTo(Integer.valueOf(queryDate))
.andInvoiceTypeEqualTo(InvoiceRecordEnum.InvoiceType.MAPPING.get(billType));
List<InvoiceRecord> billDetails1 = SpringContextUtil.invoiceRecordMapper.selectByExample(invoiceRecordExample);
if(CollectionUtils.isNotEmpty(billDetails1)){
Iterator<InvoiceRecord> iterator = billDetails1.iterator();
while (iterator.hasNext()){
if(iterator.next().getModifyRevenueCofId()!=null){
iterator.remove();
}
}
billDetails.addAll(billDetails1);
}
invoiceRecordExample = new InvoiceRecordExample();
invoiceRecordExample.createCriteria().andModifyRevenueCofIdIn(revenueTypeIds)
.andProjectIdEqualTo(formulaContext.getProjectId())
.andPeriodEqualTo(Integer.valueOf(queryDate))
.andInvoiceTypeEqualTo(InvoiceRecordEnum.InvoiceType.MAPPING.get(billType));
List<InvoiceRecord> billDetails = SpringContextUtil.invoiceRecordMapper.selectByExample(invoiceRecordExample);
List<InvoiceRecord> billDetails2 = SpringContextUtil.invoiceRecordMapper.selectByExample(invoiceRecordExample);
if(CollectionUtils.isNotEmpty(billDetails2)){
billDetails.addAll(billDetails2);
}
for (InvoiceRecord invoiceRecord : billDetails) {
OutputInvoiceDataSourceDto outputInvoiceDataSourceDto = new OutputInvoiceDataSourceDto();
outputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(invoiceRecord.getInvoiceAmount(),
......@@ -91,9 +115,9 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
outputInvoiceDataSourceDto.setOperationType(EnumOperationType.Single.getCode());
contain.add(outputInvoiceDataSourceDto);
}
if(InvoiceRecordEnum.AmountType.INVOICE_AMOUNT.getCode().equals(amountType)){
if (InvoiceRecordEnum.AmountType.INVOICE_AMOUNT.getCode().equals(amountType)) {
return billDetails.stream().mapToDouble(a -> a.getInvoiceAmount().doubleValue()).sum();
}else if (InvoiceRecordEnum.AmountType.TAX_AMOUNT.getCode().equals(amountType)){
} else if (InvoiceRecordEnum.AmountType.TAX_AMOUNT.getCode().equals(amountType)) {
return billDetails.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum();
}
return 0;
......
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