Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
18ffb5bf
Commit
18ffb5bf
authored
Jul 16, 2018
by
frank.xa.zhang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_frank' into dev
parents
b44cc9f0
eb5daca4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
678 additions
and
102 deletions
+678
-102
SpringContextUtil.java
.../java/pwc/taxtech/atms/common/util/SpringContextUtil.java
+7
-0
Constant.java
...api/src/main/java/pwc/taxtech/atms/constant/Constant.java
+28
-0
EnumOperationType.java
...va/pwc/taxtech/atms/constant/enums/EnumOperationType.java
+18
-0
FormulaDataSourceDetailType.java
...tech/atms/constant/enums/FormulaDataSourceDetailType.java
+4
-1
DataSourceDto.java
.../main/java/pwc/taxtech/atms/dto/vatdto/DataSourceDto.java
+1
-1
InputInvoiceDataSourceDto.java
...wc/taxtech/atms/dto/vatdto/InputInvoiceDataSourceDto.java
+26
-0
OutputInvoiceDataSourceDto.java
...c/taxtech/atms/dto/vatdto/OutputInvoiceDataSourceDto.java
+31
-0
OutputVATInvoiceDto.java
...java/pwc/taxtech/atms/dto/vatdto/OutputVATInvoiceDto.java
+10
-0
OutputVATInvoiceMapper.java
...java/pwc/taxtech/atms/vat/dao/OutputVATInvoiceMapper.java
+4
-0
PeriodTaxRuleSettingMapper.java
.../pwc/taxtech/atms/vat/dao/PeriodTaxRuleSettingMapper.java
+4
-0
InputVatInvoiceDao.java
...java/pwc/taxtech/atms/vat/dao/dao/InputVatInvoiceDao.java
+44
-0
ReportGeneratorImpl.java
...wc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
+3
-7
FSJZ.java
.../taxtech/atms/vat/service/impl/report/functions/FSJZ.java
+11
-89
FunctionBase.java
.../atms/vat/service/impl/report/functions/FunctionBase.java
+85
-4
GZSD.java
.../taxtech/atms/vat/service/impl/report/functions/GZSD.java
+106
-0
JXFP.java
.../taxtech/atms/vat/service/impl/report/functions/JXFP.java
+167
-0
XXFP.java
.../taxtech/atms/vat/service/impl/report/functions/XXFP.java
+129
-0
OutputVATInvoiceMapper.xml
...urces/pwc/taxtech/atms/vat/dao/OutputVATInvoiceMapper.xml
+0
-0
PeriodTaxRuleSettingMapper.xml
...s/pwc/taxtech/atms/vat/dao/PeriodTaxRuleSettingMapper.xml
+0
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/common/util/SpringContextUtil.java
View file @
18ffb5bf
...
...
@@ -9,6 +9,7 @@ import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import
pwc.taxtech.atms.dao.dao.ProjectDao
;
import
pwc.taxtech.atms.service.impl.DistributedIDService
;
import
pwc.taxtech.atms.vat.dao.*
;
import
pwc.taxtech.atms.vat.dao.dao.InputVatInvoiceDao
;
import
pwc.taxtech.atms.vat.dao.dao.VatEnterpriseAccountDao
;
//用来获取spring托管的bean
...
...
@@ -35,6 +36,9 @@ public class SpringContextUtil implements ApplicationContextAware {
public
static
VatEnterpriseAccountDao
vatEnterpriseAccountDao
;
public
static
VatEnterpriseAccountMapper
vatEnterpriseAccountMapper
;
public
static
BalanceStdManualMapper
balanceStdManualMapper
;
public
static
OutputVATInvoiceMapper
outputVATInvoiceMapper
;
public
static
PeriodTaxRuleSettingMapper
periodTaxRuleSettingMapper
;
public
static
InputVatInvoiceDao
inputVatInvoiceDao
;
/**
...
...
@@ -69,5 +73,8 @@ public class SpringContextUtil implements ApplicationContextAware {
vatEnterpriseAccountDao
=
webApplicationContext
.
getBean
(
VatEnterpriseAccountDao
.
class
);
vatEnterpriseAccountMapper
=
webApplicationContext
.
getBean
(
VatEnterpriseAccountMapper
.
class
);
balanceStdManualMapper
=
webApplicationContext
.
getBean
(
BalanceStdManualMapper
.
class
);
outputVATInvoiceMapper
=
webApplicationContext
.
getBean
(
OutputVATInvoiceMapper
.
class
);
periodTaxRuleSettingMapper
=
webApplicationContext
.
getBean
(
PeriodTaxRuleSettingMapper
.
class
);
inputVatInvoiceDao
=
webApplicationContext
.
getBean
(
InputVatInvoiceDao
.
class
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/constant/Constant.java
View file @
18ffb5bf
...
...
@@ -42,4 +42,31 @@ public final class Constant {
public
static
final
String
IMAGE_FORMART_
=
"png"
;
public
static
final
String
EMPTY
=
""
;
public
static
class
DataSourceName
{
public
static
final
String
KeyValueDataSource
=
"KeyValueDataSource"
;
public
static
final
String
InputInvoiceDataSource
=
"IncomeDataSource"
;
public
static
final
String
InputDetailInvoiceDataSource
=
"IncomeDetailDataSource"
;
public
static
final
String
OutputInvoiceDataSource
=
"OutputInvoiceDataSource"
;
public
static
final
String
VoucherDataSource
=
"VoucherDataSource"
;
public
static
final
String
ReportDataSource
=
"ReportDataSource"
;
public
static
final
String
ConditionDataSource
=
"ConditionDataSource"
;
public
static
final
String
MinConditionDataSource
=
"MinConditionDataSource"
;
public
static
final
String
MaxConditionDataSource
=
"MaxConditionDataSource"
;
public
static
final
String
SAPDataSource
=
"SAPDataSource"
;
public
static
final
String
LandSellDataSource
=
"LandSellDataSource"
;
public
static
final
String
UnbilledDataSource
=
"UnbilledDataSource"
;
public
static
final
String
AssetListDataSource
=
"AssetListDataSource"
;
}
public
static
class
IsDefault
{
public
static
final
short
Yes
=
1
;
public
static
final
short
No
=
0
;
}
public
static
class
InputInvoiceCertificationResult
{
public
static
String
CheckPass
=
"勾选认证"
;
public
static
String
ScanPass
=
"扫描认证"
;
public
static
String
NotPass
=
"未认证"
;
}
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/constant/enums/EnumOperationType.java
0 → 100644
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
constant
.
enums
;
public
enum
EnumOperationType
{
Single
(
0
),
Add
(
1
),
Sub
(
2
),
Mul
(
3
),
Div
(
4
);
private
Integer
code
;
EnumOperationType
(
Integer
code
)
{
this
.
code
=
code
;
}
public
Integer
getCode
()
{
return
code
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/constant/enums/FormulaDataSourceDetailType.java
View file @
18ffb5bf
...
...
@@ -2,7 +2,10 @@ package pwc.taxtech.atms.constant.enums;
public
enum
FormulaDataSourceDetailType
{
BSPLFormulaDataSourceDto
(
1
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
BSPLFormulaDataSourceDto
.
class
);
BSPLFormulaDataSourceDto
(
1
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
BSPLFormulaDataSourceDto
.
class
),
FormulaDataSourceDto
(
2
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
FormulaDataSourceDto
.
class
),
InputInvoiceDataSourceDto
(
3
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
FormulaDataSourceDto
.
class
),
OutputInvoiceDataSourceDto
(
4
,
pwc
.
taxtech
.
atms
.
dto
.
vatdto
.
OutputInvoiceDataSourceDto
.
class
);
private
Integer
code
;
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/DataSourceDto.java
View file @
18ffb5bf
...
...
@@ -24,7 +24,7 @@ public class DataSourceDto {
// 1: Formula, 2: Voucher, 3: OutputInvoice, 4: InputInvoice, 5: CustomInvoice, 6: KeyIn, 7: RelatedModel, 8: SapDaily
Integer
dataSourceType
;
BigDecimal
amount
;
private
BigDecimal
amount
;
String
description
;
// 1: +, 2: -, 3: *, 4: /
...
...
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/InputInvoiceDataSourceDto.java
0 → 100644
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
lombok.Getter
;
import
lombok.Setter
;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceType
;
import
java.math.BigDecimal
;
import
java.util.Date
;
@Setter
@Getter
public
class
InputInvoiceDataSourceDto
extends
FormulaDataSourceDto
{
public
InputInvoiceDataSourceDto
()
{
super
();
this
.
setType
(
FormulaDataSourceType
.
InputInvoice
.
getCode
());
}
public
int
Period
;
public
Date
certificationDate
;
public
String
sellerTaxNumber
;
public
String
invoiceCode
;
public
String
invoiceNumber
;
public
BigDecimal
taxAmount
;
public
int
invoiceType
;
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/OutputInvoiceDataSourceDto.java
0 → 100644
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
lombok.Getter
;
import
lombok.Setter
;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceType
;
import
java.math.BigDecimal
;
import
java.util.Date
;
@Getter
@Setter
public
class
OutputInvoiceDataSourceDto
extends
FormulaDataSourceDto
{
public
OutputInvoiceDataSourceDto
()
{
super
();
this
.
setType
(
FormulaDataSourceType
.
OutputInvoice
.
getCode
());
}
private
Long
id
;
private
int
period
;
private
Date
invoiceDate
;
private
String
buyerName
;
private
String
invoiceCode
;
private
String
invoiceNumber
;
private
BigDecimal
taxRate
;
private
BigDecimal
taxAmount
;
private
Integer
invoiceType
;
private
String
dataSourceId
;
//数据源名称
private
String
dataSourceName
;
}
atms-api/src/main/java/pwc/taxtech/atms/dto/vatdto/OutputVATInvoiceDto.java
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
dto
.
vatdto
;
import
lombok.Getter
;
import
lombok.Setter
;
import
pwc.taxtech.atms.vat.entity.OutputVATInvoice
;
import
pwc.taxtech.atms.vat.entity.OutputVATInvoiceItem
;
@Getter
@Setter
public
class
OutputVATInvoiceDto
{
private
String
invoiceID
;
private
OutputVATInvoice
invoice
;
private
OutputVATInvoiceItem
invoiceItem
;
}
atms-api/src/main/java/pwc/taxtech/atms/vat/dao/OutputVATInvoiceMapper.java
View file @
18ffb5bf
...
...
@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.session.RowBounds
;
import
pwc.taxtech.atms.MyVatMapper
;
import
pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceDto
;
import
pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceInfoDto
;
import
pwc.taxtech.atms.dto.vatdto.QueryOutputDto
;
import
pwc.taxtech.atms.vat.entity.OutputVATInvoice
;
...
...
@@ -181,4 +182,6 @@ public interface OutputVATInvoiceMapper extends MyVatMapper {
" AND o.PeriodID = #{period}"
+
" "
)
List
<
OutputVATInvoiceInfoDto
>
queryOutputDetailWithItem
(
Integer
period
);
List
<
OutputVATInvoiceDto
>
getVatInvoiceWithItems
(
String
dbName
);
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/vat/dao/PeriodTaxRuleSettingMapper.java
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
vat
.
dao
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.session.RowBounds
;
...
...
@@ -105,4 +106,6 @@ public interface PeriodTaxRuleSettingMapper extends MyVatMapper {
* @mbg.generated
*/
int
updateByPrimaryKey
(
PeriodTaxRuleSetting
record
);
List
<
PeriodTaxRuleSetting
>
getTaxRuleSetting
(
@Param
(
"organizationId"
)
String
organizationId
,
@Param
(
"taxName"
)
String
taxName
,
@Param
(
"period"
)
int
period
);
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/vat/dao/dao/InputVatInvoiceDao.java
0 → 100644
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
vat
.
dao
.
dao
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
pwc.taxtech.atms.vat.dao.InputVATInvoiceMapper
;
import
pwc.taxtech.atms.vat.entity.InputVATInvoice
;
import
pwc.taxtech.atms.vat.entity.InputVATInvoiceExample
;
import
java.util.List
;
@Service
public
class
InputVatInvoiceDao
{
@Autowired
InputVATInvoiceMapper
inputVATInvoiceMapper
;
public
List
<
InputVATInvoice
>
getInputVATInvoice
(
Integer
period
,
Integer
invoiceType
,
String
checkPass
,
String
scanPass
,
String
notPass
)
{
InputVATInvoiceExample
example
=
new
InputVATInvoiceExample
();
InputVATInvoiceExample
.
Criteria
criteria
=
example
.
createCriteria
();
InputVATInvoiceExample
.
Criteria
criteria1
=
example
.
createCriteria
();
if
(
period
!=
null
)
{
criteria
.
andPeriodIDEqualTo
(
period
);
criteria1
.
andPeriodIDEqualTo
(
period
);
}
if
(
invoiceType
!=
null
)
{
criteria
.
andInvoiceTypeEqualTo
(
invoiceType
);
criteria1
.
andInvoiceTypeEqualTo
(
invoiceType
);
}
if
(
StringUtils
.
isNotBlank
(
notPass
)){
criteria
.
andCertificationResultEqualTo
(
notPass
);
criteria1
.
andCertificationResultEqualTo
(
notPass
);
}
else
if
(
StringUtils
.
isNotBlank
(
checkPass
)&&
StringUtils
.
isNotBlank
(
scanPass
)){
criteria
.
andCertificationResultEqualTo
(
checkPass
);
criteria
.
andCertificationResultEqualTo
(
scanPass
);
example
.
or
(
criteria1
);
}
return
inputVATInvoiceMapper
.
selectByExample
(
example
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/ReportGeneratorImpl.java
View file @
18ffb5bf
...
...
@@ -26,11 +26,7 @@ import pwc.taxtech.atms.dto.vatdto.PeriodCellTemplateConfigExtendDto;
import
pwc.taxtech.atms.entitiy.Project
;
import
pwc.taxtech.atms.vat.entity.*
;
import
pwc.taxtech.atms.vat.service.ReportGenerator
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.BB
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FSJZ
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.ND
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.SGSR
;
import
pwc.taxtech.atms.vat.service.impl.report.functions.*
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
...
...
@@ -281,9 +277,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
* @param workbook 工作簿
*/
private
void
addFunctionsToWorkbook
(
Workbook
workbook
,
FormulaContext
formulaContext
)
{
String
[]
functionNames
=
{
"SGSR"
,
"FSJZ"
,
"ND"
,
"BB"
};
String
[]
functionNames
=
{
"SGSR"
,
"FSJZ"
,
"ND"
,
"BB"
,
"XXFP"
};
FreeRefFunction
[]
functionImpls
=
{
new
SGSR
(
formulaContext
),
new
FSJZ
(
formulaContext
),
new
ND
(
formulaContext
),
new
BB
(
formulaContext
)};
new
BB
(
formulaContext
)
,
new
XXFP
(
formulaContext
)
};
UDFFinder
udfs
=
new
DefaultUDFFinder
(
functionNames
,
functionImpls
);
UDFFinder
udfToolpack
=
new
AggregatingUDFFinder
(
udfs
);
workbook
.
addToolPack
(
udfToolpack
);
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/FSJZ.java
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
com.alibaba.fastjson.JSON
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.eval.NumberEval
;
import
org.apache.poi.ss.formula.eval.ValueEval
;
...
...
@@ -9,8 +8,10 @@ import pwc.taxtech.atms.common.util.SpringContextUtil;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType
;
import
pwc.taxtech.atms.constant.enums.KeyValueConfigResultType
;
import
pwc.taxtech.atms.dto.vatdto.BSPLFormulaDataSourceDto
;
import
pwc.taxtech.atms.dto.vatdto.FormulaDataSourceDto
;
import
pwc.taxtech.atms.vat.entity.*
;
import
pwc.taxtech.atms.vat.entity.Balance
;
import
pwc.taxtech.atms.vat.entity.BalanceStdManual
;
import
pwc.taxtech.atms.vat.entity.VatEnterpriseAccount
;
import
pwc.taxtech.atms.vat.entity.VatStandardAccount
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
...
...
@@ -90,7 +91,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
}
BigDecimal
val
=
new
BigDecimal
(
0
);
List
<
FormulaDataSourceDto
>
formulaDataSourceDtoList
=
new
ArrayList
<>();
List
<
Object
>
formulaDataSourceDtoList
=
new
ArrayList
<>();
if
(
balanceStdManual
!=
null
)
{
List
<
VatEnterpriseAccount
>
vatEnterpriseAccountList
=
SpringContextUtil
.
vatEnterpriseAccountMapper
...
...
@@ -132,49 +133,9 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
}
//todo: sava data
//save datasource
DataSource
dataSource
=
new
DataSource
();
Long
dataSourceID
=
SpringContextUtil
.
distributedIDService
.
nextId
();
dataSource
.
setId
(
dataSourceID
);
dataSource
.
setType
(
1
);
dataSource
.
setName
(
"ReportDataSource"
);
dataSource
.
setAmount
(
val
);
dataSource
.
setDescription
(
""
);
dataSource
.
setCreateBy
(
"Admin"
);
dataSource
.
setUpdateBy
(
"Admin"
);
dataSource
.
setCreateTime
(
creatime
);
dataSource
.
setUpdateTime
(
creatime
);
dataSource
.
setRowIndex
(
ec
.
getRowIndex
());
dataSource
.
setColumnIndex
(
ec
.
getColumnIndex
());
dataSource
.
setRowName
(
""
);
dataSource
.
setColumnName
(
""
);
SpringContextUtil
.
dataSourceMapper
.
insertSelective
(
dataSource
);
for
(
FormulaDataSourceDto
aFormulaDataSourceDtoList
:
formulaDataSourceDtoList
)
{
BSPLFormulaDataSourceDto
bsplFormulaDataSourceDto
=
((
BSPLFormulaDataSourceDto
)
aFormulaDataSourceDtoList
);
DataSourceDetail
dataSourceDetail
=
new
DataSourceDetail
();
dataSourceDetail
.
setId
(
SpringContextUtil
.
distributedIDService
.
nextId
());
dataSourceDetail
.
setDataSourceId
(
dataSourceID
);
dataSourceDetail
.
setDataSourceType
(
FormulaDataSourceDetailType
.
BSPLFormulaDataSourceDto
.
getCode
());
dataSourceDetail
.
setItemValue
(
JSON
.
toJSONString
(
bsplFormulaDataSourceDto
));
SpringContextUtil
.
dataSourceDetailMapper
.
insertSelective
(
dataSourceDetail
);
}
Long
dataSourceID
=
saveDataSource
(
ec
,
formulaDataSourceDtoList
,
FormulaDataSourceDetailType
.
BSPLFormulaDataSourceDto
,
val
);
//save formulablock
Long
cellTemplateID
=
getCellTemplateID
(
period
,
ec
);
PeriodFormulaBlock
periodFormulaBlock
=
new
PeriodFormulaBlock
();
periodFormulaBlock
.
setId
(
SpringContextUtil
.
distributedIDService
.
nextId
());
periodFormulaBlock
.
setPeriod
(
period
);
periodFormulaBlock
.
setReportId
(
0L
);
periodFormulaBlock
.
setCellTemplateId
(
cellTemplateID
);
periodFormulaBlock
.
setFormulaExpression
(
formulaExpression
);
periodFormulaBlock
.
setData
(
val
.
toString
());
periodFormulaBlock
.
setDataSourceId
(
dataSourceID
);
periodFormulaBlock
.
setCreateBy
(
"Admin"
);
periodFormulaBlock
.
setCreateTime
(
creatime
);
periodFormulaBlock
.
setUpdateBy
(
"Admin"
);
periodFormulaBlock
.
setUpdateTime
(
creatime
);
SpringContextUtil
.
periodFormulaBlockMapper
.
insertSelective
(
periodFormulaBlock
);
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
val
,
dataSourceID
);
return
new
NumberEval
(
val
.
doubleValue
());
}
else
{
...
...
@@ -196,7 +157,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
}
BigDecimal
val
=
new
BigDecimal
(
0
);
List
<
FormulaDataSourceDto
>
dsList
=
new
ArrayList
<>();
List
<
Object
>
dsList
=
new
ArrayList
<>();
if
(
balance
!=
null
)
{
if
(
period
==
99
)
{
val
=
new
BigDecimal
(((
balance
.
getYearDebitNet
()
!=
null
?
balance
.
getYearDebitNet
()
:
0
).
doubleValue
()
...
...
@@ -232,51 +193,12 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
?
FormulaHelper
.
roundValue
(
val
,
KeyValueConfigResultType
.
Accounting
,
null
,
formulaContext
)
:
new
BigDecimal
(
0
);
}
//todo: sava data
//save datasource
DataSource
dataSource
=
new
DataSource
();
Long
dataSourceID
=
SpringContextUtil
.
distributedIDService
.
nextId
();
dataSource
.
setId
(
dataSourceID
);
dataSource
.
setType
(
1
);
dataSource
.
setName
(
"ReportDataSource"
);
dataSource
.
setAmount
(
val
);
dataSource
.
setDescription
(
""
);
dataSource
.
setCreateBy
(
"Admin"
);
dataSource
.
setUpdateBy
(
"Admin"
);
dataSource
.
setCreateTime
(
creatime
);
dataSource
.
setUpdateTime
(
creatime
);
dataSource
.
setRowIndex
(
ec
.
getRowIndex
());
dataSource
.
setColumnIndex
(
ec
.
getColumnIndex
());
dataSource
.
setRowName
(
""
);
dataSource
.
setColumnName
(
""
);
SpringContextUtil
.
dataSourceMapper
.
insertSelective
(
dataSource
);
for
(
FormulaDataSourceDto
aFormulaDataSourceDtoList
:
dsList
)
{
BSPLFormulaDataSourceDto
bsplFormulaDataSourceDto
=
((
BSPLFormulaDataSourceDto
)
aFormulaDataSourceDtoList
);
DataSourceDetail
dataSourceDetail
=
new
DataSourceDetail
();
dataSourceDetail
.
setId
(
SpringContextUtil
.
distributedIDService
.
nextId
());
dataSourceDetail
.
setDataSourceId
(
dataSourceID
);
dataSourceDetail
.
setDataSourceType
(
FormulaDataSourceDetailType
.
BSPLFormulaDataSourceDto
.
getCode
());
dataSourceDetail
.
setItemValue
(
JSON
.
toJSONString
(
bsplFormulaDataSourceDto
));
SpringContextUtil
.
dataSourceDetailMapper
.
insertSelective
(
dataSourceDetail
);
}
Long
dataSourceID
=
saveDataSource
(
ec
,
dsList
,
FormulaDataSourceDetailType
.
BSPLFormulaDataSourceDto
,
val
);
//save formulablock
Long
cellTemplateID
=
getCellTemplateID
(
period
,
ec
);
PeriodFormulaBlock
periodFormulaBlock
=
new
PeriodFormulaBlock
();
periodFormulaBlock
.
setId
(
SpringContextUtil
.
distributedIDService
.
nextId
());
periodFormulaBlock
.
setPeriod
(
period
);
periodFormulaBlock
.
setReportId
(
0L
);
//todo:update reportID when report data generated
periodFormulaBlock
.
setCellTemplateId
(
cellTemplateID
);
periodFormulaBlock
.
setFormulaExpression
(
formulaExpression
);
periodFormulaBlock
.
setData
(
val
.
toString
());
periodFormulaBlock
.
setDataSourceId
(
dataSourceID
);
periodFormulaBlock
.
setCreateBy
(
"Admin"
);
periodFormulaBlock
.
setCreateTime
(
creatime
);
periodFormulaBlock
.
setUpdateBy
(
"Admin"
);
periodFormulaBlock
.
setUpdateTime
(
creatime
);
SpringContextUtil
.
periodFormulaBlockMapper
.
insertSelective
(
periodFormulaBlock
);
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
val
,
dataSourceID
);
return
new
NumberEval
(
val
.
doubleValue
());
}
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/FunctionBase.java
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
com.alibaba.fastjson.JSON
;
import
org.apache.poi.ss.formula.OperationEvaluationContext
;
import
org.apache.poi.ss.formula.eval.EvaluationException
;
import
org.apache.poi.ss.formula.eval.OperandResolver
;
import
org.apache.poi.ss.formula.eval.ValueEval
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
pwc.taxtech.atms.common.util.SpringContextUtil
;
import
pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType
;
import
pwc.taxtech.atms.vat.entity.DataSource
;
import
pwc.taxtech.atms.vat.entity.DataSourceDetail
;
import
pwc.taxtech.atms.vat.entity.PeriodFormulaBlock
;
import
pwc.taxtech.atms.vat.service.impl.FormulaAgent
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
public
class
FunctionBase
{
protected
final
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
protected
FormulaContext
formulaContext
;
final
FormulaAgent
agent
;
public
FunctionBase
(
FormulaContext
formulaContext
){
public
FunctionBase
(
FormulaContext
formulaContext
)
{
this
.
formulaContext
=
formulaContext
;
this
.
agent
=
formulaContext
.
getFormulaAgent
();
}
...
...
@@ -43,9 +53,9 @@ public class FunctionBase {
}
}
public
Long
getCellTemplateID
(
int
period
,
OperationEvaluationContext
ec
){
return
FormulaHelper
.
getCellTemplateIDWithTemplateCodeAndColumnIndexAndRowIndex
(
ec
.
getWorkbook
().
getSheetName
(
ec
.
getSheetIndex
()),
ec
.
getColumnIndex
(),
ec
.
getRowIndex
(),
period
,
formulaContext
);
public
Long
getCellTemplateID
(
int
period
,
OperationEvaluationContext
ec
)
{
return
FormulaHelper
.
getCellTemplateIDWithTemplateCodeAndColumnIndexAndRowIndex
(
ec
.
getWorkbook
().
getSheetName
(
ec
.
getSheetIndex
()),
ec
.
getColumnIndex
(),
ec
.
getRowIndex
(),
period
,
formulaContext
);
}
public
int
getYear
(
int
parameterYear
)
{
...
...
@@ -58,4 +68,75 @@ public class FunctionBase {
}
}
public
int
getPeriod
(
int
parameterPeriod
,
int
[]
yearOffset
)
{
if
(
yearOffset
.
length
==
0
)
{
yearOffset
=
new
int
[
10
];
}
yearOffset
[
0
]
=
0
;
if
(
parameterPeriod
==
-
99
)
{
return
parameterPeriod
;
}
else
if
(
parameterPeriod
<=
-
1
)
{
int
period
=
parameterPeriod
+
formulaContext
.
getPeriod
();
while
(
period
<=
0
)
{
yearOffset
[
0
]--;
period
+=
12
;
}
return
period
;
}
else
if
(
parameterPeriod
==
0
)
{
return
formulaContext
.
getPeriod
();
}
else
{
return
parameterPeriod
;
}
}
public
Long
saveDataSource
(
OperationEvaluationContext
ec
,
List
<
Object
>
dataSourceList
,
FormulaDataSourceDetailType
formulaDataSourceDetailType
,
BigDecimal
val
)
{
Date
creatime
=
new
Date
();
DataSource
dataSource
=
new
DataSource
();
Long
dataSourceID
=
SpringContextUtil
.
distributedIDService
.
nextId
();
dataSource
.
setId
(
dataSourceID
);
dataSource
.
setType
(
1
);
dataSource
.
setName
(
"ReportDataSource"
);
dataSource
.
setAmount
(
val
);
dataSource
.
setDescription
(
""
);
dataSource
.
setCreateBy
(
"Admin"
);
dataSource
.
setUpdateBy
(
"Admin"
);
dataSource
.
setCreateTime
(
creatime
);
dataSource
.
setUpdateTime
(
creatime
);
dataSource
.
setRowIndex
(
ec
.
getRowIndex
());
dataSource
.
setColumnIndex
(
ec
.
getColumnIndex
());
dataSource
.
setRowName
(
""
);
dataSource
.
setColumnName
(
""
);
SpringContextUtil
.
dataSourceMapper
.
insertSelective
(
dataSource
);
for
(
Object
obj
:
dataSourceList
)
{
DataSourceDetail
dataSourceDetail
=
new
DataSourceDetail
();
dataSourceDetail
.
setId
(
SpringContextUtil
.
distributedIDService
.
nextId
());
dataSourceDetail
.
setDataSourceId
(
dataSourceID
);
dataSourceDetail
.
setDataSourceType
(
formulaDataSourceDetailType
.
getCode
());
dataSourceDetail
.
setItemValue
(
JSON
.
toJSONString
(
obj
));
SpringContextUtil
.
dataSourceDetailMapper
.
insertSelective
(
dataSourceDetail
);
}
return
dataSourceID
;
}
public
void
saveFormulaBlock
(
int
period
,
OperationEvaluationContext
ec
,
String
formulaExpression
,
BigDecimal
val
,
Long
dataSourceID
)
{
Long
cellTemplateID
=
getCellTemplateID
(
period
,
ec
);
Date
creatime
=
new
Date
();
PeriodFormulaBlock
periodFormulaBlock
=
new
PeriodFormulaBlock
();
periodFormulaBlock
.
setId
(
SpringContextUtil
.
distributedIDService
.
nextId
());
periodFormulaBlock
.
setPeriod
(
period
);
periodFormulaBlock
.
setReportId
(
0L
);
periodFormulaBlock
.
setCellTemplateId
(
cellTemplateID
);
periodFormulaBlock
.
setFormulaExpression
(
formulaExpression
);
periodFormulaBlock
.
setData
(
val
.
toString
());
periodFormulaBlock
.
setDataSourceId
(
dataSourceID
);
periodFormulaBlock
.
setCreateBy
(
"Admin"
);
periodFormulaBlock
.
setCreateTime
(
creatime
);
periodFormulaBlock
.
setUpdateBy
(
"Admin"
);
periodFormulaBlock
.
setUpdateTime
(
creatime
);
SpringContextUtil
.
periodFormulaBlockMapper
.
insertSelective
(
periodFormulaBlock
);
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/GZSD.java
0 → 100644
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
org.apache.commons.lang3.StringUtils
;
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.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.FormulaDataSourceType
;
import
pwc.taxtech.atms.constant.enums.KeyValueConfigResultType
;
import
pwc.taxtech.atms.dto.vatdto.FormulaDataSourceDto
;
import
pwc.taxtech.atms.vat.entity.PeriodTaxRuleSetting
;
import
java.math.BigDecimal
;
import
java.text.NumberFormat
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Optional
;
/// <summary>
/// 名称:rule engine 中取值(规则设定)
/// 功能:附加税报表中参数取值
/// 备注:申报表取值时首先判断机构是否是特殊情况,及机构名称是否出现在特殊情况中,若没有出现在特殊情况中,则取默认税率和税基;
/// </summary>
/// <param name="taxCategory">税(费)种——“1”城市维护建设税;“2” 教育费附加;“3”地方教育附加;“4”印花税;“5”水利基金;</param>
/// <param name="resultType">“0”一般计税依据(税基),“1” 税率;</param>
/// <returns></returns>
public
class
GZSD
extends
FunctionBase
implements
FreeRefFunction
{
public
GZSD
(
FormulaContext
formulaContext
)
{
super
(
formulaContext
);
}
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
if
(
args
.
length
<
2
)
{
return
null
;
}
Integer
taxCategory
=
getIntParam
(
args
[
0
],
ec
);
Integer
resultType
=
getIntParam
(
args
[
1
],
ec
);
String
formulaExpression
=
"GZSD("
+
taxCategory
+
","
+
resultType
+
")"
;
logger
.
debug
(
formulaExpression
);
String
taxName
=
StringUtils
.
EMPTY
;
switch
(
taxCategory
)
{
case
1
:
taxName
=
"城市维护建设税"
;
break
;
case
2
:
taxName
=
"教育费附加"
;
break
;
case
3
:
taxName
=
"地方教育费附加"
;
break
;
case
4
:
taxName
=
"印花税"
;
break
;
case
5
:
taxName
=
"水利基金"
;
break
;
default
:
break
;
}
List
<
PeriodTaxRuleSetting
>
taxRuleSettings
=
SpringContextUtil
.
periodTaxRuleSettingMapper
.
getTaxRuleSetting
(
formulaContext
.
getOrganizationID
(),
taxName
,
formulaContext
.
getPeriod
());
Optional
<
PeriodTaxRuleSetting
>
matchedRule
=
taxRuleSettings
.
stream
().
filter
(
a
->
a
.
getIsDefault
()
!=
Constant
.
IsDefault
.
Yes
).
findFirst
();
if
(!
matchedRule
.
isPresent
())
{
matchedRule
=
Optional
.
ofNullable
(
taxRuleSettings
.
get
(
0
));
if
(
matchedRule
.
isPresent
())
{
return
null
;
}
}
if
(
resultType
==
1
)
{
BigDecimal
val
=
FormulaHelper
.
roundValue
(
matchedRule
.
get
().
getTaxRate
(),
KeyValueConfigResultType
.
Percentage
,
null
,
formulaContext
);
NumberFormat
nf
=
NumberFormat
.
getPercentInstance
();
nf
.
setMaximumFractionDigits
(
2
);
List
<
FormulaDataSourceDto
>
dataSourceDtoList
=
new
ArrayList
<>();
FormulaDataSourceDto
formulaDataSourceDto
=
new
FormulaDataSourceDto
();
formulaDataSourceDto
.
setOperationType
(
EnumOperationType
.
Single
.
getCode
());
formulaDataSourceDto
.
setType
(
FormulaDataSourceType
.
Other
.
getCode
());
formulaDataSourceDto
.
setResultType
(
KeyValueConfigResultType
.
Percentage
.
getCode
());
formulaDataSourceDto
.
setAmount
(
matchedRule
.
get
().
getTaxRate
());
formulaDataSourceDto
.
setName
(
nf
.
format
(
matchedRule
.
get
().
getTaxRate
()));
dataSourceDtoList
.
add
(
formulaDataSourceDto
);
Long
dataSourceId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSourceDtoList
),
FormulaDataSourceDetailType
.
FormulaDataSourceDto
,
val
);
saveFormulaBlock
(
formulaContext
.
getPeriod
(),
ec
,
formulaExpression
,
val
,
dataSourceId
);
return
new
NumberEval
(
val
.
doubleValue
());
}
else
{
//todo: @本期应(实)纳税额 ,@GDZC.BQ.QMYE 这种类型的数据,重新计算,按照keyvalue的配置
//return new NumberEval(matchedRule.get().getTaxBase());
}
return
null
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/JXFP.java
0 → 100644
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
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.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.InputVATInvoice
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/// <summary>
/// 名称:本期/前期认证相符且本期申报抵扣
/// 功能:从导入进项发票明细清单取数
/// 备注:取值表格:进项明细清单
/// 条件字段:
/// 认证期间:"0"当期,"-99"前期(当月之前所有月份,不含当月),"99"所有认证期间
/// 发票类型:“1”增值税专票,“2”货运发票,“3”机动车发票,“4”农产品发票,“5”其他发票(包括空值);
/// 认证结果(认证通过,认证未通过,未认证)
/// 取值字段:金额,税额,份数
/// 在导入进项发票时会去检查是否有重复导入发票现象,不允许重复导入,从而杜绝重复抵扣。
/// </summary>
/// <param name="certificationPeriod">认证期间:“0”当期(当月),“-99”前期(当月之前所有月份,不含当月),"99"所有认证期间</param>
/// <param name="invoiceType">“1”增值税专票,“2”货运发票,“3”机动车发票,“4”农产品发票,“5”其他发票(包括空值)</param>
/// <param name="authenticationType">认证结果:“1”认证通过;“0”认证未通过;“2”未认证</param>
/// <param name="resultType">计算取值:“0”金额;“1”税额;“2”份数;</param>
/// <param name="period">会计期间——“0”当期,1-12为自然月</param>
/// <returns></returns>
public
class
JXFP
extends
FunctionBase
implements
FreeRefFunction
{
public
JXFP
(
FormulaContext
formulaContext
)
{
super
(
formulaContext
);
}
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
if
(
args
.
length
<
5
)
{
return
null
;
}
int
certificationPeriod
=
getIntParam
(
args
[
0
],
ec
);
int
invoiceType
=
getIntParam
(
args
[
1
],
ec
);
int
authenticationType
=
getIntParam
(
args
[
2
],
ec
);
int
resultType
=
getIntParam
(
args
[
3
],
ec
);
int
period
=
getIntParam
(
args
[
3
],
ec
);
String
formulaExpression
=
"JXFP("
+
certificationPeriod
+
","
+
invoiceType
+
","
+
authenticationType
+
","
+
resultType
+
","
+
period
+
")"
;
logger
.
debug
(
formulaExpression
);
int
[]
yearOffset
=
{};
certificationPeriod
=
getPeriod
(
certificationPeriod
,
yearOffset
);
if
(
yearOffset
[
0
]
<
0
)
{
return
null
;
}
period
=
getPeriod
(
period
,
yearOffset
);
if
(
yearOffset
[
0
]
<
0
)
{
return
null
;
}
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
formulaContext
.
getYear
(),
1
,
1
);
Date
startDate
=
calendar
.
getTime
();
calendar
.
add
(
Calendar
.
YEAR
,
1
);
Date
endDate
=
calendar
.
getTime
();
List
<
InputVATInvoice
>
inputVATInvoices
;
if
(
authenticationType
==
1
&&
formulaContext
.
getIsYear
())
{
inputVATInvoices
=
SpringContextUtil
.
inputVatInvoiceDao
.
getInputVATInvoice
(
null
,
invoiceType
,
Constant
.
InputInvoiceCertificationResult
.
CheckPass
,
Constant
.
InputInvoiceCertificationResult
.
ScanPass
,
null
);
}
else
if
(
authenticationType
==
1
)
{
inputVATInvoices
=
SpringContextUtil
.
inputVatInvoiceDao
.
getInputVATInvoice
(
period
,
invoiceType
,
Constant
.
InputInvoiceCertificationResult
.
CheckPass
,
Constant
.
InputInvoiceCertificationResult
.
ScanPass
,
null
);
}
// 认证未通过与未认证暂认为是同一个意思
else
if
((
authenticationType
==
1
||
authenticationType
==
2
)
&&
formulaContext
.
getIsYear
())
{
inputVATInvoices
=
SpringContextUtil
.
inputVatInvoiceDao
.
getInputVATInvoice
(
null
,
invoiceType
,
null
,
null
,
Constant
.
InputInvoiceCertificationResult
.
NotPass
);
}
// 认证未通过与未认证暂认为是同一个意思
else
if
(
authenticationType
==
0
||
authenticationType
==
2
)
{
inputVATInvoices
=
SpringContextUtil
.
inputVatInvoiceDao
.
getInputVATInvoice
(
period
,
invoiceType
,
null
,
null
,
Constant
.
InputInvoiceCertificationResult
.
NotPass
);
}
else
{
return
null
;
}
if
(
certificationPeriod
!=
-
99
&&
certificationPeriod
!=
99
&&
(
certificationPeriod
<
1
||
certificationPeriod
>
12
))
{
return
null
;
}
else
if
(!
formulaContext
.
getIsYear
())
{
if
(
certificationPeriod
==
-
99
)
{
calendar
.
set
(
formulaContext
.
getYear
(),
formulaContext
.
getPeriod
(),
1
);
endDate
=
calendar
.
getTime
();
Date
finalEndDate
=
endDate
;
inputVATInvoices
=
inputVATInvoices
.
stream
()
.
filter
(
a
->
a
.
getCertificationDate
().
before
(
finalEndDate
))
.
collect
(
Collectors
.
toList
());
}
else
if
(
certificationPeriod
!=
99
)
{
calendar
.
set
(
formulaContext
.
getYear
(),
certificationPeriod
,
1
);
startDate
=
calendar
.
getTime
();
calendar
.
set
(
formulaContext
.
getYear
(),
certificationPeriod
,
1
);
calendar
.
add
(
Calendar
.
MONTH
,
1
);
endDate
=
calendar
.
getTime
();
Date
finalEndDate1
=
endDate
;
Date
finalStartDate
=
startDate
;
inputVATInvoices
=
inputVATInvoices
.
stream
()
.
filter
(
a
->
a
.
getCertificationDate
().
after
(
finalStartDate
)
&&
a
.
getCertificationDate
().
before
(
finalEndDate1
))
.
collect
(
Collectors
.
toList
());
}
}
List
<
InputInvoiceDataSourceDto
>
dataSource
=
new
ArrayList
();
for
(
InputVATInvoice
x
:
inputVATInvoices
)
{
InputInvoiceDataSourceDto
inputInvoiceDataSourceDto
=
new
InputInvoiceDataSourceDto
();
inputInvoiceDataSourceDto
.
setAmount
(
FormulaHelper
.
roundValue
(
x
.
getAmount
(),
KeyValueConfigResultType
.
Accounting
,
null
,
formulaContext
));
inputInvoiceDataSourceDto
.
setResultType
(
KeyValueConfigResultType
.
Accounting
.
getCode
());
inputInvoiceDataSourceDto
.
setTaxAmount
(
FormulaHelper
.
roundValue
(
x
.
getTaxAmount
(),
KeyValueConfigResultType
.
Accounting
,
null
,
formulaContext
));
inputInvoiceDataSourceDto
.
setCertificationDate
(
x
.
getCertificationDate
());
inputInvoiceDataSourceDto
.
setInvoiceCode
(
x
.
getInvoiceCode
());
inputInvoiceDataSourceDto
.
setInvoiceNumber
(
x
.
getInvoiceNumber
());
inputInvoiceDataSourceDto
.
setInvoiceType
(
x
.
getInvoiceType
());
inputInvoiceDataSourceDto
.
setPeriod
(
x
.
getPeriodID
());
inputInvoiceDataSourceDto
.
setSellerTaxNumber
(
x
.
getSellerTaxNumber
());
inputInvoiceDataSourceDto
.
setName
(
Constant
.
DataSourceName
.
InputDetailInvoiceDataSource
);
inputInvoiceDataSourceDto
.
setOperationType
(
EnumOperationType
.
Single
.
getCode
());
dataSource
.
add
(
inputInvoiceDataSourceDto
);
}
dataSource
=
dataSource
.
stream
()
.
sorted
(
Comparator
.
comparing
(
InputInvoiceDataSourceDto:
:
getCertificationDate
)
.
thenComparing
(
InputInvoiceDataSourceDto:
:
getInvoiceCode
)
.
thenComparing
(
InputInvoiceDataSourceDto:
:
getInvoiceNumber
))
.
collect
(
Collectors
.
toList
());
if
(
resultType
==
0
)
{
double
val
=
dataSource
.
stream
().
mapToDouble
(
a
->
a
.
getAmount
().
doubleValue
()).
sum
();
Long
dataSourceId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
InputInvoiceDataSourceDto
,
BigDecimal
.
valueOf
(
val
));
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
BigDecimal
.
valueOf
(
val
),
dataSourceId
);
return
new
NumberEval
(
val
);
}
else
if
(
resultType
==
1
)
{
double
val
=
dataSource
.
stream
().
mapToDouble
(
a
->
a
.
getTaxAmount
().
doubleValue
()).
sum
();
Long
dataSourceId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
InputInvoiceDataSourceDto
,
BigDecimal
.
valueOf
(
val
));
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
BigDecimal
.
valueOf
(
val
),
dataSourceId
);
return
new
NumberEval
(
val
);
}
else
if
(
resultType
==
2
)
{
double
val
=
dataSource
.
size
();
Long
dataSourceId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
InputInvoiceDataSourceDto
,
BigDecimal
.
valueOf
(
val
));
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
BigDecimal
.
valueOf
(
val
),
dataSourceId
);
return
new
NumberEval
(
val
);
}
return
null
;
}
}
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/report/functions/XXFP.java
0 → 100644
View file @
18ffb5bf
package
pwc
.
taxtech
.
atms
.
vat
.
service
.
impl
.
report
.
functions
;
import
org.apache.commons.lang3.StringUtils
;
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.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.OutputInvoiceDataSourceDto
;
import
pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceDto
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/// <summary>
/// 名称:销项发票
/// 功能:从发票取数,一般取发票金额或税额汇总数
/// </summary>
/// <param name="taxRate">税率取值为17%,13%,11%,6%,5%, 3%,1.5%,若所有税率都取则为99</param>
/// <param name="invoiceType">发票类型——两种取值结果“1”专用发票和“0”除专用发票以外其他发票,若所有发票都取则为99</param>
/// <param name="amountType">取值——两种取值结果“金额”0和“税额”1</param>
/// <param name="period">会计期间(开票日期)——三种取值结果 “-1”指上期,“0”当期,“99”当前累计(从期初到目前)</param>
/// <returns></returns>
public
class
XXFP
extends
FunctionBase
implements
FreeRefFunction
{
public
XXFP
(
FormulaContext
formulaContext
)
{
super
(
formulaContext
);
}
@Override
public
ValueEval
evaluate
(
ValueEval
[]
args
,
OperationEvaluationContext
ec
)
{
if
(
args
.
length
<
4
)
{
return
null
;
}
String
taxRate
=
getStringParam
(
args
[
0
],
ec
);
int
invoiceType
=
getIntParam
(
args
[
1
],
ec
);
int
amountType
=
getIntParam
(
args
[
2
],
ec
);
int
period
=
getIntParam
(
args
[
3
],
ec
);
String
formulaExpression
=
"XXFP(\""
+
taxRate
+
"\","
+
invoiceType
+
","
+
amountType
+
","
+
period
+
")"
;
logger
.
debug
(
formulaExpression
);
Integer
curYear
=
formulaContext
.
getYear
();
int
[]
yearOffset
=
{};
period
=
getPeriod
(
period
,
yearOffset
);
curYear
=
curYear
+
yearOffset
[
0
];
BigDecimal
taxRateVal
=
new
BigDecimal
(
"-1"
);
if
(!
taxRate
.
endsWith
(
"%"
))
{
if
(
taxRate
.
equals
(
"99"
))
{
taxRateVal
=
new
BigDecimal
(
"99"
);
}
else
{
return
null
;
}
}
else
{
taxRate
=
StringUtils
.
removeEnd
(
taxRate
,
"%"
);
try
{
taxRateVal
=
BigDecimal
.
valueOf
(
Double
.
parseDouble
(
taxRate
));
}
catch
(
NumberFormatException
ex
)
{
return
null
;
}
taxRateVal
=
taxRateVal
.
divide
(
new
BigDecimal
(
"100"
),
2
,
BigDecimal
.
ROUND_HALF_UP
);
//保留两位小数,然后四舍五入
}
String
dbName
=
SpringContextUtil
.
projectDao
.
getDbNameWithYearAndOrgID
(
formulaContext
.
getOrganizationID
(),
curYear
);
List
<
OutputVATInvoiceDto
>
outputInvoice
=
SpringContextUtil
.
outputVATInvoiceMapper
.
getVatInvoiceWithItems
(
dbName
);
if
(
invoiceType
!=
99
)
{
outputInvoice
=
outputInvoice
.
stream
()
.
filter
(
a
->
a
.
getInvoice
().
getInvoiceType
()
==
invoiceType
)
.
collect
(
Collectors
.
toList
());
}
if
(
taxRateVal
.
compareTo
(
new
BigDecimal
(
"99"
))
!=
0
)
{
BigDecimal
finalTaxRateVal
=
taxRateVal
;
outputInvoice
=
outputInvoice
.
stream
()
.
filter
(
a
->
a
.
getInvoiceItem
().
getTaxRate
().
compareTo
(
finalTaxRateVal
)
==
0
)
.
collect
(
Collectors
.
toList
());
}
if
(
period
!=
99
)
{
int
finalPeriod
=
period
;
outputInvoice
=
outputInvoice
.
stream
().
filter
(
a
->
a
.
getInvoice
().
getPeriodID
().
equals
(
finalPeriod
)).
collect
(
Collectors
.
toList
());
}
List
<
OutputInvoiceDataSourceDto
>
dataSource
=
new
ArrayList
();
for
(
OutputVATInvoiceDto
x
:
outputInvoice
)
{
OutputInvoiceDataSourceDto
outputInvoiceDataSourceDto
=
new
OutputInvoiceDataSourceDto
();
outputInvoiceDataSourceDto
.
setAmount
(
FormulaHelper
.
roundValue
(
x
.
getInvoiceItem
().
getAmount
(),
KeyValueConfigResultType
.
Accounting
,
null
,
formulaContext
));
outputInvoiceDataSourceDto
.
setResultType
(
KeyValueConfigResultType
.
Accounting
.
getCode
());
outputInvoiceDataSourceDto
.
setTaxAmount
(
FormulaHelper
.
roundValue
(
x
.
getInvoiceItem
().
getAmount
(),
KeyValueConfigResultType
.
Accounting
,
null
,
formulaContext
));
outputInvoiceDataSourceDto
.
setTaxRate
(
x
.
getInvoiceItem
().
getTaxRate
());
outputInvoiceDataSourceDto
.
setBuyerName
(
x
.
getInvoice
().
getBuyerName
());
outputInvoiceDataSourceDto
.
setInvoiceCode
(
x
.
getInvoice
().
getClassCode
());
outputInvoiceDataSourceDto
.
setInvoiceNumber
(
x
.
getInvoice
().
getInvoiceNumber
());
outputInvoiceDataSourceDto
.
setInvoiceDate
(
x
.
getInvoice
().
getInvoiceDate
());
outputInvoiceDataSourceDto
.
setInvoiceType
(
x
.
getInvoice
().
getInvoiceType
());
outputInvoiceDataSourceDto
.
setPeriod
(
x
.
getInvoice
().
getPeriodID
());
outputInvoiceDataSourceDto
.
setName
(
Constant
.
DataSourceName
.
OutputInvoiceDataSource
);
outputInvoiceDataSourceDto
.
setOperationType
(
EnumOperationType
.
Single
.
getCode
());
dataSource
.
add
(
outputInvoiceDataSourceDto
);
}
if
(
amountType
==
0
)
{
double
val
=
dataSource
.
stream
().
mapToDouble
(
a
->
a
.
getAmount
().
doubleValue
()).
sum
();
Long
dataSoureId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
OutputInvoiceDataSourceDto
,
new
BigDecimal
(
val
));
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
new
BigDecimal
(
val
),
dataSoureId
);
return
new
NumberEval
(
val
);
}
else
if
(
amountType
==
1
)
{
double
val
=
dataSource
.
stream
().
mapToDouble
(
a
->
a
.
getTaxAmount
().
doubleValue
()).
sum
();
Long
dataSoureId
=
saveDataSource
(
ec
,
Collections
.
singletonList
(
dataSource
),
FormulaDataSourceDetailType
.
OutputInvoiceDataSourceDto
,
new
BigDecimal
(
val
));
saveFormulaBlock
(
period
,
ec
,
formulaExpression
,
new
BigDecimal
(
val
),
dataSoureId
);
return
new
NumberEval
(
val
);
}
return
null
;
}
}
atms-api/src/main/resources/pwc/taxtech/atms/vat/dao/OutputVATInvoiceMapper.xml
View file @
18ffb5bf
This diff is collapsed.
Click to expand it.
atms-api/src/main/resources/pwc/taxtech/atms/vat/dao/PeriodTaxRuleSettingMapper.xml
View file @
18ffb5bf
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment