Commit 08e321eb authored by chase's avatar chase

修改税金计算表

parent df9f5f52
...@@ -60,7 +60,7 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -60,7 +60,7 @@ public class SpringContextUtil implements ApplicationContextAware {
public static TrialBalanceFinalMapper trialBalanceFinalMapper; public static TrialBalanceFinalMapper trialBalanceFinalMapper;
public static ProfitLossStatementMapper profitLossStatementMapper; public static ProfitLossStatementMapper profitLossStatementMapper;
public static RevenueTypeMappingMapper revenueTypeMappingMapper; public static RevenueTypeMappingMapper revenueTypeMappingMapper;
public static BillDetailMapper billDetailMapper; public static InvoiceRecordMapper invoiceRecordMapper;
...@@ -145,7 +145,7 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -145,7 +145,7 @@ public class SpringContextUtil implements ApplicationContextAware {
balanceSheetMapper = webApplicationContext.getBean(BalanceSheetMapper.class); balanceSheetMapper = webApplicationContext.getBean(BalanceSheetMapper.class);
revenueTypeMappingMapper = webApplicationContext.getBean(RevenueTypeMappingMapper.class); revenueTypeMappingMapper = webApplicationContext.getBean(RevenueTypeMappingMapper.class);
billDetailMapper = webApplicationContext.getBean(BillDetailMapper.class); invoiceRecordMapper = webApplicationContext.getBean(InvoiceRecordMapper.class);
/* map.put("balance_sheet", balanceMapper); /* map.put("balance_sheet", balanceMapper);
map.put("profit_loss_statement",profitLossStatementMapper); map.put("profit_loss_statement",profitLossStatementMapper);
......
...@@ -3,19 +3,19 @@ package pwc.taxtech.atms.constant.enums; ...@@ -3,19 +3,19 @@ package pwc.taxtech.atms.constant.enums;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class BillDetailEnum { public class InvoiceRecordEnum {
/** /**
* 发票类型 * 发票类型
*/ */
public enum BillType { public enum InvoiceType {
ORDINARY(1, "增值税普票"), ORDINARY(1, "增值税普票"),
SPECIAL(2, "增值税专票"); SPECIAL(2, "增值税专票");
private Integer code; private Integer code;
private String name; private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>(); public static final Map<Integer, String> MAPPING = new HashMap<>();
BillType(Integer code, String name) { InvoiceType(Integer code, String name) {
this.code = code; this.code = code;
this.name = name; this.name = name;
} }
...@@ -29,11 +29,40 @@ public class BillDetailEnum { ...@@ -29,11 +29,40 @@ public class BillDetailEnum {
} }
static { static {
for (BillDetailEnum.BillType billType : BillDetailEnum.BillType.values()) { for (InvoiceRecordEnum.InvoiceType invoiceType : InvoiceRecordEnum.InvoiceType.values()) {
MAPPING.put(billType.getCode(), billType.getName()); MAPPING.put(invoiceType.getCode(), invoiceType.getName());
} }
} }
} }
/**
* 金额类型
*/
public enum AmountType {
INVOICE_AMOUNT(1, "开票金额"),
TAX_AMOUNT(2, "税额");
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
AmountType(Integer code, String name) {
this.code = code;
this.name = name;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
static {
for (InvoiceRecordEnum.AmountType amountType : InvoiceRecordEnum.AmountType.values()) {
MAPPING.put(amountType.getCode(), amountType.getName());
}
}
}
} }
...@@ -8,18 +8,19 @@ public class TaxesCalculateReportEnum { ...@@ -8,18 +8,19 @@ public class TaxesCalculateReportEnum {
public enum Column { public enum Column {
Column_1(0, "序号"), Column_1(0, "序号"),
Column_2(1, "收入类型名称"), Column_2(1, "税金项目"),
Column_3(2, "税金项目"), Column_3(2, "期间"),
Column_4(3, "期间"), Column_4(3, "账载收入-明细"),
Column_5(4, "账载收入-明细"), Column_5(4, "销项开票收入数-专票"),
Column_6(5, "销项开票收入数-专票"), Column_6(5, "销项开票税额-专票"),
Column_7(6, "销项开票收入数-普票"), Column_7(6, "销项开票收入数-普票"),
Column_8(7, "计税基数(应税收入)"), Column_8(7, "销项开票税额-普票"),
Column_9(8, "税率"), Column_9(8, "计税基数 (应税收入)"),
Column_10(9, "税额(元)"), Column_10(9, "税率"),
Column_11(10, "收入类别"), Column_11(10, "税额(元)"),
Column_12(11, "计税方式"), Column_12(11, "收入类别"),
Column_13(12, "备注") Column_13(12, "计税方式"),
Column_14(13, "备注")
; ;
private Integer index; private Integer index;
private String name; private String name;
......
...@@ -5,16 +5,15 @@ import org.apache.poi.ss.formula.OperationEvaluationContext; ...@@ -5,16 +5,15 @@ import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.NumberEval; import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction; 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.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.Constant; import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.BillDetailEnum; import pwc.taxtech.atms.constant.enums.InvoiceRecordEnum;
import pwc.taxtech.atms.constant.enums.EnumOperationType; import pwc.taxtech.atms.constant.enums.EnumOperationType;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType; import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import pwc.taxtech.atms.constant.enums.KeyValueConfigResultType; import pwc.taxtech.atms.constant.enums.KeyValueConfigResultType;
import pwc.taxtech.atms.dto.vatdto.OutputInvoiceDataSourceDto; import pwc.taxtech.atms.dto.vatdto.OutputInvoiceDataSourceDto;
import pwc.taxtech.atms.vat.entity.BillDetail; import pwc.taxtech.atms.vat.entity.InvoiceRecord;
import pwc.taxtech.atms.vat.entity.BillDetailExample; import pwc.taxtech.atms.vat.entity.InvoiceRecordExample;
import pwc.taxtech.atms.vat.entity.RevenueTypeMapping; import pwc.taxtech.atms.vat.entity.RevenueTypeMapping;
import pwc.taxtech.atms.vat.entity.RevenueTypeMappingExample; import pwc.taxtech.atms.vat.entity.RevenueTypeMappingExample;
...@@ -34,16 +33,17 @@ public class KPSR extends FunctionBase implements FreeRefFunction { ...@@ -34,16 +33,17 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
@Override @Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) { public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length < 2) { if (args.length < 3) {
return null; return null;
} }
String revenueTypeName = getStringParam(args[0], ec);//收入类型名称 String revenueTypeName = getStringParam(args[0], ec);//收入类型名称
Integer billType = getIntParam(args[1], ec);//发票类型 Integer billType = getIntParam(args[1], ec);//发票类型
String formulaExpression = "KPSR(\"" + revenueTypeName + "\","+billType+")"; Integer amountType = getIntParam(args[2], ec);//金额类型
String formulaExpression = "KPSR(\"" + revenueTypeName + "\","+billType+ ","+amountType+")";
logger.debug(formulaExpression); logger.debug(formulaExpression);
List<OutputInvoiceDataSourceDto> dataSource = new ArrayList<>(); List<OutputInvoiceDataSourceDto> dataSource = new ArrayList<>();
double result = assembleData(revenueTypeName,dataSource,billType,ec); double result = assembleData(revenueTypeName,dataSource,billType,amountType,ec);
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource), FormulaDataSourceDetailType.OutputInvoiceDataSourceDto, new BigDecimal(result), formulaContext.getPeriod(), Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource), FormulaDataSourceDetailType.OutputInvoiceDataSourceDto, new BigDecimal(result), formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId()); formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, new BigDecimal(result), dataSoureId, formulaContext.getProjectId()); saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, new BigDecimal(result), dataSoureId, formulaContext.getProjectId());
...@@ -51,7 +51,7 @@ public class KPSR extends FunctionBase implements FreeRefFunction { ...@@ -51,7 +51,7 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
} }
private double assembleData(String revenueTypeName, List<OutputInvoiceDataSourceDto> contain, Integer billType,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(); RevenueTypeMappingExample typeMappingExample = new RevenueTypeMappingExample();
...@@ -67,30 +67,36 @@ public class KPSR extends FunctionBase implements FreeRefFunction { ...@@ -67,30 +67,36 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
if (CollectionUtils.isEmpty(contens)) { if (CollectionUtils.isEmpty(contens)) {
return 0.0; return 0.0;
} }
BillDetailExample billDetailExample = new BillDetailExample(); InvoiceRecordExample invoiceRecordExample = new InvoiceRecordExample();
BillDetailExample.Criteria c = billDetailExample.createCriteria().andBillContentIn(contens).andProjectIdEqualTo(formulaContext.getProjectId()) InvoiceRecordExample.Criteria c = invoiceRecordExample.createCriteria().andBillingContentIn(contens)
.andProjectIdEqualTo(formulaContext.getProjectId())
.andPeriodEqualTo(Integer.valueOf(queryDate)) .andPeriodEqualTo(Integer.valueOf(queryDate))
.andBillTypeEqualTo(BillDetailEnum.BillType.MAPPING.get(billType)); .andInvoiceTypeEqualTo(InvoiceRecordEnum.InvoiceType.MAPPING.get(billType));
List<BillDetail> billDetails = SpringContextUtil.billDetailMapper.selectByExample(billDetailExample); List<InvoiceRecord> billDetails = SpringContextUtil.invoiceRecordMapper.selectByExample(invoiceRecordExample);
for (BillDetail billDetail : billDetails) { for (InvoiceRecord invoiceRecord : billDetails) {
OutputInvoiceDataSourceDto outputInvoiceDataSourceDto = new OutputInvoiceDataSourceDto(); OutputInvoiceDataSourceDto outputInvoiceDataSourceDto = new OutputInvoiceDataSourceDto();
outputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(billDetail.getBillAmount(), outputInvoiceDataSourceDto.setAmount(FormulaHelper.roundValue(invoiceRecord.getInvoiceAmount(),
KeyValueConfigResultType.Accounting, null, formulaContext)); KeyValueConfigResultType.Accounting, null, formulaContext));
outputInvoiceDataSourceDto.setResultType(KeyValueConfigResultType.Accounting.getCode()); outputInvoiceDataSourceDto.setResultType(KeyValueConfigResultType.Accounting.getCode());
outputInvoiceDataSourceDto.setTaxAmount(FormulaHelper.roundValue(billDetail.getTaxAmount(), outputInvoiceDataSourceDto.setTaxAmount(FormulaHelper.roundValue(invoiceRecord.getTaxAmount(),
KeyValueConfigResultType.Accounting, null, formulaContext)); KeyValueConfigResultType.Accounting, null, formulaContext));
outputInvoiceDataSourceDto.setTaxRate(billDetail.getTaxRate()); outputInvoiceDataSourceDto.setTaxRate(invoiceRecord.getTaxRate());
outputInvoiceDataSourceDto.setBuyerName(billDetail.getCustomer()); outputInvoiceDataSourceDto.setBuyerName(invoiceRecord.getCustomerCompanyName());
outputInvoiceDataSourceDto.setInvoiceCode(billDetail.getBillCode()); outputInvoiceDataSourceDto.setInvoiceCode(invoiceRecord.getInvoiceCode());
outputInvoiceDataSourceDto.setInvoiceNumber(billDetail.getBillNo()); outputInvoiceDataSourceDto.setInvoiceNumber(invoiceRecord.getInvoiceNum());
outputInvoiceDataSourceDto.setInvoiceDate(DateUtils.strToDate(billDetail.getBillDate())); outputInvoiceDataSourceDto.setInvoiceDate(invoiceRecord.getBillingDate());
outputInvoiceDataSourceDto.setInvoiceType(billType); outputInvoiceDataSourceDto.setInvoiceType(billType);
outputInvoiceDataSourceDto.setPeriod(formulaContext.getPeriod()); outputInvoiceDataSourceDto.setPeriod(formulaContext.getPeriod());
outputInvoiceDataSourceDto.setName(Constant.DataSourceName.OutputInvoiceDataSource); outputInvoiceDataSourceDto.setName(Constant.DataSourceName.OutputInvoiceDataSource);
outputInvoiceDataSourceDto.setOperationType(EnumOperationType.Single.getCode()); outputInvoiceDataSourceDto.setOperationType(EnumOperationType.Single.getCode());
contain.add(outputInvoiceDataSourceDto); contain.add(outputInvoiceDataSourceDto);
} }
return billDetails.stream().mapToDouble(a -> a.getBillAmount().doubleValue()).sum(); 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)){
return billDetails.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum();
}
return 0;
} }
......
...@@ -642,6 +642,9 @@ ...@@ -642,6 +642,9 @@
|| $scope.selectedTabIndex === enums.formulaDataSourceType.InputInvoiceDetail || $scope.selectedTabIndex === enums.formulaDataSourceType.InputInvoiceDetail
|| $scope.selectedTabIndex === enums.formulaDataSourceType.OutputInvoice || $scope.selectedTabIndex === enums.formulaDataSourceType.OutputInvoice
|| $scope.selectedTabIndex === enums.formulaDataSourceType.InvoiceFilter) { || $scope.selectedTabIndex === enums.formulaDataSourceType.InvoiceFilter) {
if(new Number($scope.detail.cellTemplateId)<0){
$("#dataGridFooterSummary").html("");
}else{
evalVal = _.reduce($scope.detail.dataGridSource, function (memo, x) { evalVal = _.reduce($scope.detail.dataGridSource, function (memo, x) {
if(x.money){ if(x.money){
return memo + x.money; return memo + x.money;
...@@ -667,6 +670,7 @@ ...@@ -667,6 +670,7 @@
+ evalVal.formatAmount(precition) + '&nbsp;&nbsp;&nbsp;&nbsp;' + $translate.instant('TaxAmount') + evalVal.formatAmount(precition) + '&nbsp;&nbsp;&nbsp;&nbsp;' + $translate.instant('TaxAmount')
+ ':&nbsp;&nbsp;&nbsp;&nbsp;' + evalTaxVal.formatAmount(precition)); + ':&nbsp;&nbsp;&nbsp;&nbsp;' + evalTaxVal.formatAmount(precition));
} }
}
else if ($scope.selectedTabIndex === enums.formulaDataSourceType.Voucher) { else if ($scope.selectedTabIndex === enums.formulaDataSourceType.Voucher) {
evalVal = _.reduce($scope.detail.dataGridSource, function (memo, x) { evalVal = _.reduce($scope.detail.dataGridSource, function (memo, x) {
return memo + x.debit - x.credit; return memo + x.debit - x.credit;
......
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