Commit e65d41e8 authored by chase's avatar chase

fix bug

parent 7fc003a6
......@@ -61,7 +61,7 @@ public class SpringContextUtil implements ApplicationContextAware {
public static ProfitLossStatementMapper profitLossStatementMapper;
public static RevenueTypeMappingMapper revenueTypeMappingMapper;
public static InvoiceRecordMapper invoiceRecordMapper;
public static CertifiedInvoicesListMapper certifiedInvoicesListMapper;
......@@ -146,7 +146,7 @@ public class SpringContextUtil implements ApplicationContextAware {
balanceSheetMapper = webApplicationContext.getBean(BalanceSheetMapper.class);
revenueTypeMappingMapper = webApplicationContext.getBean(RevenueTypeMappingMapper.class);
invoiceRecordMapper = webApplicationContext.getBean(InvoiceRecordMapper.class);
certifiedInvoicesListMapper = webApplicationContext.getBean(CertifiedInvoicesListMapper.class);
/* map.put("balance_sheet", balanceMapper);
map.put("profit_loss_statement",profitLossStatementMapper);
map.put("cash_flow", cashFlowMapper);
......
......@@ -6,12 +6,9 @@ import org.springframework.stereotype.Service;
import pwc.taxtech.atms.invoice.InputInvoiceMapper;
import pwc.taxtech.atms.vat.entity.InputInvoice;
import pwc.taxtech.atms.vat.entity.InputInvoiceExample;
import pwc.taxtech.atms.vat.entity.InputVatInvoice;
import pwc.taxtech.atms.vat.entity.InputVatInvoiceExample;
import java.util.Calendar;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class InputInvoiceDao {
......@@ -25,16 +22,19 @@ public class InputInvoiceDao {
if (period != null) {
Calendar date = Calendar.getInstance();
String year = String.valueOf(date.get(Calendar.YEAR));
//认证期间
criteria.andRZSQEqualTo(year + (period > 9 ? period.toString() : "0" + period.toString()));
}
if (invoiceType != null) {
//发票类型
criteria.andFPLXEqualTo(String.valueOf(invoiceType));
// criteria1.andFPLXEqualTo(String.valueOf(invoiceType));
}
if (StringUtils.isNotBlank(notPass)) {
String unPass = "2";
//认证结果
criteria.andRZJGEqualTo(unPass);
// criteria1.andRZJGEqualTo(unPass);
} else if (StringUtils.isNotBlank(checkPass) && StringUtils.isNotBlank(scanPass)) {
......@@ -43,6 +43,7 @@ public class InputInvoiceDao {
// criteria1.andRZJGEqualTo(pass);
// example.or(criteria1);
}
//发票状态
criteria.andFPZTNotEqualTo("1"); // 过滤作废状态
// List<InputInvoice> list = inputInvoiceMapper.selectByExample(example).stream().filter(x -> {
......
......@@ -132,7 +132,10 @@ public class ReportServiceImpl extends BaseService {
private HttpFileService httpFileService;
@Autowired
DidiFileUploadService didiFileUploadService;
@Resource
TrialBalanceFinalMapper trialBalanceFinalMapper;
@Autowired
FormulaAgent agent;
public OperationResultDto<List<ReportDto>> getFilterReportTemplate(String projectId, EnumServiceType serviceType, Integer periodParam) {
OperationResultDto<List<ReportDto>> result = new OperationResultDto<>();
CommonUtils.copyProperties(getReportTemplate(projectId, serviceType, periodParam), result);
......@@ -297,11 +300,30 @@ public class ReportServiceImpl extends BaseService {
List<Long> exceptTemplateIds = templateMapper.getIdsForExceptTemplate();
//根据收入类型映射生成开票记录关联数据
assembleInvoiceRecord(projectId,period);
//生成trial_balance_final数据
assembleTrialBalanceFinal(projectId,period);
clearPeriodData(projectId, period, exceptTemplateIds, isMergeManualData);
copyTemplateAndConfigFromAdmin(projectId, templates, period);
setStatus(job, STATUS_END);
periodJobMapper.updateByPrimaryKey(job);
}
public void assembleTrialBalanceFinal(String projectId,Integer period){
Project project = projectMapper.selectByPrimaryKey(projectId);
MyAsserts.assertNotNull(project, Exceptions.NOT_FOUND_REPORT_EXCEPTION);
String queryPeriod = project.getYear()+""+(period<10?("0"+period):(period+""));
Project lastProject = agent.getFixedProject(projectId, project.getYear());
String lastPeriod = "0";
if(lastProject!=null){
if(project.getId().equals(lastProject.getId())){
lastPeriod = project.getYear()+""+(period-1<10?("0"+(period-1)):((period-1)+""));
}else {
lastPeriod = lastProject.getYear()+"12";
}
}
// trialBalanceFinalMapper.generateFinalData(project.getId(),Integer.valueOf(queryPeriod),
// lastProject!=null?lastProject.getId():"0",Integer.getInteger(lastPeriod));
}
public void assembleInvoiceRecord(String projectId,Integer period){
Project project = projectMapper.selectByPrimaryKey(projectId);
......
......@@ -4,24 +4,19 @@ import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.Constant;
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.InputInvoiceDataSourceDto;
import pwc.taxtech.atms.vat.entity.InputInvoice;
import pwc.taxtech.atms.vat.entity.CertifiedInvoicesList;
import pwc.taxtech.atms.vat.entity.CertifiedInvoicesListExample;
import java.math.BigDecimal;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/// <summary>
......@@ -84,24 +79,24 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
calendar.add(Calendar.YEAR, 1);
Date endDate = calendar.getTime();
List<InputInvoice> inputInvoices;
List<CertifiedInvoicesList> inputInvoices;
if (authenticationType == 1 && formulaContext.getIsYear()) {
inputInvoices = SpringContextUtil.inputInvoiceDao.getInputInvoice(null, invoiceType,
inputInvoices = getInvoice(null, invoiceType,
Constant.InputInvoiceCertificationResult.CheckPass, Constant.InputInvoiceCertificationResult.ScanPass,
null);
} else if (authenticationType == 1) {
inputInvoices = SpringContextUtil.inputInvoiceDao.getInputInvoice(period, invoiceType,
inputInvoices =getInvoice(period, invoiceType,
Constant.InputInvoiceCertificationResult.CheckPass, Constant.InputInvoiceCertificationResult.ScanPass,
null);
}
// 认证未通过与未认证暂认为是同一个意思
else if (authenticationType == 2 && formulaContext.getIsYear()) {
inputInvoices = SpringContextUtil.inputInvoiceDao.getInputInvoice(null, invoiceType,
inputInvoices = getInvoice(null, invoiceType,
null, null, Constant.InputInvoiceCertificationResult.NotPass);
}
// 认证未通过与未认证暂认为是同一个意思
else if (authenticationType == 0 || authenticationType == 2) {
inputInvoices = SpringContextUtil.inputInvoiceDao.getInputInvoice(period, invoiceType, null,
inputInvoices =getInvoice(period, invoiceType, null,
null, Constant.InputInvoiceCertificationResult.NotPass);
} else {
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal("0.0"), 0L, formulaContext.getProjectId());
......@@ -118,7 +113,7 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
endDate = calendar.getTime();
Date finalEndDate = endDate;
inputInvoices = inputInvoices.stream()
.filter(a -> DateUtils.strToDate(a.getRZSJ()).before(finalEndDate))
.filter(a -> a.getCertifiedDate().before(finalEndDate))
.collect(Collectors.toList());
} else if (certificationPeriod != 99) {
calendar.set(formulaContext.getYear(), certificationPeriod - 1, 1);
......@@ -129,26 +124,26 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
Date finalEndDate1 = endDate;
Date finalStartDate = startDate;
inputInvoices = inputInvoices.stream()
.filter(a -> strToDate(a.getRZSQ()).after(finalStartDate)
&& strToDate(a.getRZSQ()).before(finalEndDate1))
.filter(a -> a.getCertifiedDate().after(finalStartDate)
&& a.getCertifiedDate().before(finalEndDate1))
.collect(Collectors.toList());
}
}
List<InputInvoiceDataSourceDto> dataSource = new ArrayList<>();
for (InputInvoice x : inputInvoices) {
for (CertifiedInvoicesList x : inputInvoices) {
InputInvoiceDataSourceDto inputInvoiceDataSourceDto = new InputInvoiceDataSourceDto();
inputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(new BigDecimal(x.getHJJE()), KeyValueConfigResultType.Accounting,
inputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(x.getAmount(), KeyValueConfigResultType.Accounting,
null, formulaContext));
inputInvoiceDataSourceDto.setResultType(KeyValueConfigResultType.Accounting.getCode());
inputInvoiceDataSourceDto.setTaxAmount(FormulaHelper.roundValue(new BigDecimal(x.getHJSE()), KeyValueConfigResultType.Accounting,
inputInvoiceDataSourceDto.setTaxAmount(FormulaHelper.roundValue(x.getTaxAmount(), KeyValueConfigResultType.Accounting,
null, formulaContext));
inputInvoiceDataSourceDto.setCertificationDate(DateUtils.strToDate(x.getRZSJ()));
inputInvoiceDataSourceDto.setInvoiceCode(x.getFPDM());
inputInvoiceDataSourceDto.setInvoiceNumber(x.getFPHM());
inputInvoiceDataSourceDto.setInvoiceType(Integer.parseInt(x.getFPLX()));
inputInvoiceDataSourceDto.setCertificationDate(x.getCertifiedDate());
inputInvoiceDataSourceDto.setInvoiceCode(x.getInvoiceCode());
inputInvoiceDataSourceDto.setInvoiceNumber(x.getInvoiceNum());
inputInvoiceDataSourceDto.setInvoiceType(Integer.parseInt(x.getInvoiceType()));
inputInvoiceDataSourceDto.setPeriod(period);
inputInvoiceDataSourceDto.setSellerTaxNumber(x.getXFSH());
inputInvoiceDataSourceDto.setSellerTaxNumber(x.getSalesTaxNum());
inputInvoiceDataSourceDto.setName(Constant.DataSourceName.InputDetailInvoiceDataSource);
inputInvoiceDataSourceDto.setOperationType(EnumOperationType.Single.getCode());
dataSource.add(inputInvoiceDataSourceDto);
......@@ -199,4 +194,40 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
return strtodate;
}
public List<CertifiedInvoicesList> getInvoice(Integer period, String invoiceType, String checkPass, String scanPass, String notPass) {
CertifiedInvoicesListExample example = new CertifiedInvoicesListExample();
CertifiedInvoicesListExample.Criteria criteria = example.createCriteria();
if (period != null) {
Calendar date = Calendar.getInstance();
String year = String.valueOf(date.get(Calendar.YEAR));
//认证期间
criteria.andPeriodEqualTo(Integer.valueOf(year + (period > 9 ? period.toString() : "0" + period.toString())));
}
if (invoiceType != null) {
//发票类型
criteria.andInvoiceTypeEqualTo(String.valueOf(invoiceType));
// criteria1.andFPLXEqualTo(String.valueOf(invoiceType));
}
// if (StringUtils.isNotBlank(notPass)) {
// String unPass = "2";
// //认证结果
// criteria.andRZJGEqualTo(unPass);
//// criteria1.andRZJGEqualTo(unPass);
// } else if (StringUtils.isNotBlank(checkPass) && StringUtils.isNotBlank(scanPass)) {
// String pass = "1";
// criteria.andRZJGEqualTo(pass);
//// criteria1.andRZJGEqualTo(pass);
//// example.or(criteria1);
// }
//发票状态
criteria.andInvoiceTypeEqualTo("1"); // 过滤作废状态
// List<InputInvoice> list = inputInvoiceMapper.selectByExample(example).stream().filter(x -> {
// return x.getRZSQ().endsWith("-" + (period.intValue() > 9 ? period.toString() : "0" + period.toString()));
// }).collect(Collectors.toList());
return SpringContextUtil.certifiedInvoicesListMapper.selectByExample(example);
}
}
......@@ -121,4 +121,9 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
@Param("projectId") String projectId,
@Param("period") Integer period,
@Param("queryDate") String queryDate);
int generateFinalData(@Param("projectId") String projectId,
@Param("period") Integer period,
@Param("lastProjectId") String lastProjectId,
@Param("lastPeriod") Integer lastPeriod);
}
\ No newline at end of file
......@@ -74,5 +74,125 @@
order by detail.emptyCode
</select>
<insert id="generateFinalData" >
insert
into trial_balance_final
select balance.id,
balance.organization_id,
balance.project_id,
balance.date,
balance.source,
balance.tms_period,
balance.period,
balance.ledger_id,
balance.ledger_name,
balance.currency_code,
balance.status,
balance.category,
balance.account_category,
balance.acct_code1,
balance.acct_name1,
balance.acct_name2,
balance.acct_name3,
balance.segment1,
balance.segment2,
balance.segment3,
balance.segment4,
balance.segment5,
balance.segment6,
balance.segment7,
balance.segment8,
balance.segment9,
balance.segment10,
balance.segment1_name,
balance.segment2_name,
balance.segment3_name,
balance.segment4_name,
balance.segment5_name,
balance.segment6_name,
balance.segment7_name,
balance.segment8_name,
balance.segment9_name,
balance.segment10_name,
balance.beg_bal,
balance.period_dr,
balance.period_cr,
balance.end_bal,
balance.qtd_dr,
balance.qtd_cr,
balance.ytd_dr,
balance.ytd_cr,
balance.beg_bal_beq,
balance.period_dr_beq + if(adjustment.period_dr_beq is null, 0, adjustment.period_dr_beq) -
if(last_adjustment.period_dr_beq is null, 0, last_adjustment.period_dr_beq),
balance.period_cr_beq + if(adjustment.period_cr_beq is null, 0, adjustment.period_cr_beq) -
if(last_adjustment.period_cr_beq is null, 0, last_adjustment.period_cr_beq),
balance.end_bal_beq + if(adjustment.end_bal_beq is null, 0, adjustment.end_bal_beq) -
if(last_adjustment.end_bal_beq is null, 0, last_adjustment.end_bal_beq),
balance.qtd_dr_beq,
balance.qtd_cr_beq,
balance.ytd_dr_beq,
balance.ytd_cr_beq,
sysdate(),
sysdate()
from trial_balance balance
left join
adjustment_table adjustment
on
balance.project_id = adjustment.project_id
and
balance.period = adjustment.period
and
balance.segment1 = adjustment.segment1
and
balance.segment2 = adjustment.segment2
and
balance.segment3 = adjustment.segment3
and
balance.segment4 = adjustment.segment4
and
balance.segment5 = adjustment.segment5
and
balance.segment6 = adjustment.segment6
and
balance.segment7 = adjustment.segment7
and
balance.segment8 = adjustment.segment8
and
balance.segment9 = adjustment.segment9
and
balance.segment10 = adjustment.segment10
left join
(
select *
from adjustment_table
where project_id = #{lastProjectId}
and period = #{lastPeriod}
) last_adjustment
on
balance.segment1 = last_adjustment.segment1
and
balance.segment2 = last_adjustment.segment2
and
balance.segment3 = last_adjustment.segment3
and
balance.segment4 = last_adjustment.segment4
and
balance.segment5 = last_adjustment.segment5
and
balance.segment6 = last_adjustment.segment6
and
balance.segment7 = last_adjustment.segment7
and
balance.segment8 = last_adjustment.segment8
and
balance.segment9 = last_adjustment.segment9
and
balance.segment10 = last_adjustment.segment10
where balance.project_id = #{projectId}
and balance.period = #{perioid}
</insert>
</mapper>
\ No newline at end of file
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