Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
183097be
Commit
183097be
authored
Apr 09, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dd
parent
e1265812
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
59 deletions
+69
-59
xgg-admin/app/base/service/impl/invoice/invoiceSve.js
+69
-59
No files found.
xgg-admin/app/base/service/impl/invoice/invoiceSve.js
View file @
183097be
...
...
@@ -249,7 +249,8 @@ class InvoiceService extends ServiceBase {
receiveTel
:
_invoicesummaryinfo
.
businessmen_mobile
,
receiveAddress
:
_invoicesummaryinfo
.
businessmen_addr
,
receiveTaxIdentificationNumber
:
_invoicesummaryinfo
.
businessmen_credit_code
,
province
:
PROVINCE_CODE_MAP
[
_invoicesummaryinfo
.
province
],
// province: PROVINCE_CODE_MAP[_invoicesummaryinfo.province],
province
:
_invoicesummaryinfo
.
province
,
receiveAccountName
:
""
,
//xxxx
sourceClient
:
"0"
,
//票据来源
createDate
:
moment
(
_invoicesummaryinfo
.
created_at
).
format
(
"YYYY-MM-DD HH:ss:mm"
),
//创建时间
...
...
@@ -278,66 +279,75 @@ class InvoiceService extends ServiceBase {
if
(
!
this
.
INVOICE_TYPE
.
includes
(
this
.
trim
(
params
.
invoice_type
))){
return
system
.
getResult
(
null
,
`参数错误,发票类型不存在`
);
}
//取出个体工商户信息
var
businessRes
=
await
this
.
businessmenSve
.
queryObusinessmenByCreditCode
({
credit_code
:
this
.
trim
(
params
.
credit_code
)
});
if
(
businessRes
.
status
!=
0
&&
!
businessRes
.
data
)
{
return
system
.
getResult
(
null
,
`个体户不存在`
);
}
let
businessmenBean
=
businessRes
.
data
;
if
(
!
businessmenBean
.
sign_time
)
{
return
system
.
getResult
(
null
,
`个体户未签约`
);
}
try
{
//取出个体工商户信息
var
businessRes
=
await
this
.
businessmenSve
.
queryObusinessmenByCreditCode
({
credit_code
:
this
.
trim
(
params
.
credit_code
)
});
if
(
businessRes
.
status
!=
0
&&
!
businessRes
.
data
)
{
return
system
.
getResult
(
null
,
`个体户不存在`
);
}
let
businessmenBean
=
businessRes
.
data
;
if
(
!
businessmenBean
.
sign_time
)
{
return
system
.
getResult
(
null
,
`个体户未签约`
);
}
//增值税累计类型 1按月 2按季度 add_value_up_type
//个税累计类型 1按月累计 2按季度累计 tax_up_type
let
accumulatedAmountParams
=
{
add_value_up_type
:
businessmenBean
.
add_value_up_type
,
tax_up_type
:
businessmenBean
.
tax_up_type
,
credit_code
:
this
.
trim
(
params
.
credit_code
),
invoiced_time
:
this
.
trim
(
params
.
invoiced_time
)
};
//取出累计开票金额
var
invoiceRes
=
await
this
.
callms
(
"invoice"
,
"accumulatedAmount"
,
accumulatedAmountParams
);
if
(
!
invoiceRes
||
invoiceRes
.
status
!=
0
||
!
invoiceRes
.
data
)
{
return
system
.
getResult
(
null
,
`系统错误`
);
//增值税累计类型 1按月 2按季度 add_value_up_type
//个税累计类型 1按月累计 2按季度累计 tax_up_type
let
accumulatedAmountParams
=
{
add_value_up_type
:
businessmenBean
.
add_value_up_type
,
tax_up_type
:
businessmenBean
.
tax_up_type
,
credit_code
:
this
.
trim
(
params
.
credit_code
),
invoiced_time
:
this
.
trim
(
params
.
invoiced_time
)
};
//取出累计开票金额
var
invoiceRes
=
await
this
.
callms
(
"invoice"
,
"accumulatedAmount"
,
accumulatedAmountParams
);
if
(
!
invoiceRes
||
invoiceRes
.
status
!=
0
||
!
invoiceRes
.
data
)
{
return
system
.
getResult
(
null
,
`系统错误`
);
}
let
additional_tax_total
=
invoiceRes
.
data
.
addValueRes
.
additional_tax_total
,
//附加税累计总和
value_added_tax_total
=
invoiceRes
.
data
.
addValueRes
.
value_added_tax_total
,
//增值税累计总和
invoice_amount_total
=
invoiceRes
.
data
.
addValueRes
.
invoice_amount_total
;
//增值税累计价税总和 (计算不对)
let
personal_invoice_tax_total
=
invoiceRes
.
data
.
taxValueRes
.
personal_invoice_tax_total
;
//个税累计总和
personal_invoice_amount_total
=
invoiceRes
.
data
.
taxValueRes
.
personal_invoice_amount_total
;
//个税价税累计总和 (计算不对)
//**********************************************************一下是计算个税********************************************************************************************** */
let
apettemp
=
Decimal
(
1
).
plus
(
Decimal
.
div
(
businessmenBean
.
tax_rate
,
100
));
//此参数 在计算附加税和增值税 复用
//累计不含税价(个税)
let
accumulatedPriceExcludingTax
=
Decimal
.
div
(
personal_invoice_amount_total
,
apettemp
);
let
aptemp
=
new
Decimal
(
1
).
sub
(
Decimal
.
div
(
businessmenBean
.
cost_rate
,
100
));
//累计利润
let
accumulatedProfit
=
new
Decimal
(
accumulatedPriceExcludingTax
).
mul
(
aptemp
);
//计算梯度的增值税附加税个税 的税率 {rate,qcd,zengzhiRate,fujiaRate}
let
rateRes
=
this
.
findTaxAndQCD
(
accumulatedProfit
,
params
.
invoice_type
,
businessmenBean
);
//个税 = 累计利润*个税税率-速算扣除数-该月/季度 累计缴纳的个税
let
personal_invoice_tax
=
new
Decimal
(
accumulatedProfit
).
mul
(
rateRes
.
rate
).
sub
(
rateRes
.
qcd
).
sub
(
personal_invoice_tax_total
).
toFixed
(
2
);
//***********************************************************一下是计算附加税和增值税******************************************************************************** */
//累计不含税价(个税)
let
accumulatedPriceExcludingTax
=
Decimal
.
div
(
invoice_amount_total
,
apettemp
);
//计算梯度的增值税附加税个税 的税率 {rate,qcd,zengzhiRate,fujiaRate}
let
AVRateRes
=
this
.
findTaxAndQCD
(
accumulatedPriceExcludingTax
,
params
.
invoice_type
,
businessmenBean
);
//增值税税 = 累计不含税价*增值税-该月累计缴纳的增值税
let
value_added_tax
=
new
Decimal
(
invoice_amount_total
).
mul
(
AVRateRes
.
zengzhiRate
).
sub
(
value_added_tax_total
).
toFixed
(
2
);
//附加税 =增值税*附加税
let
additional_tax
=
new
Decimal
(
invoice_amount_total
).
mul
(
AVRateRes
.
zengzhiRate
).
toFixed
(
2
);
//************************************************************一下是计算服务费************************************* */
let
service_rate
=
new
Decimal
(
businessmenBean
).
div
(
100
);
let
service_amount
=
new
Decimal
(
this
.
trim
(
params
.
invoice_amount
)).
mul
(
businessmenBean
.
service_rate
);
return
system
.
getResult
(
personal_invoice_tax
,
value_added_tax
,
additional_tax
,
service_amount
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
let
additional_tax_total
=
invoiceRes
.
data
.
addValueRes
.
additional_tax_total
,
//附加税累计总和
value_added_tax_total
=
invoiceRes
.
data
.
addValueRes
.
value_added_tax_total
,
//增值税累计总和
invoice_amount_total
=
invoiceRes
.
data
.
addValueRes
.
invoice_amount_total
;
//增值税累计价税总和 (计算不对)
let
personal_invoice_tax_total
=
invoiceRes
.
data
.
taxValueRes
.
personal_invoice_tax_total
;
//个税累计总和
personal_invoice_amount_total
=
invoiceRes
.
data
.
taxValueRes
.
personal_invoice_amount_total
;
//个税价税累计总和 (计算不对)
//**********************************************************一下是计算个税********************************************************************************************** */
let
apettemp
=
Decimal
(
1
).
plus
(
Decimal
.
div
(
businessmenBean
.
tax_rate
,
100
));
//此参数 在计算附加税和增值税 复用
//累计不含税价(个税)
let
accumulatedPriceExcludingTax
=
Decimal
.
div
(
personal_invoice_amount_total
,
apettemp
);
let
aptemp
=
new
Decimal
(
1
).
sub
(
Decimal
.
div
(
businessmenBean
.
cost_rate
,
100
));
//累计利润
let
accumulatedProfit
=
new
Decimal
(
accumulatedPriceExcludingTax
).
mul
(
aptemp
);
//计算梯度的增值税附加税个税 的税率 {rate,qcd,zengzhiRate,fujiaRate}
let
rateRes
=
this
.
findTaxAndQCD
(
accumulatedProfit
,
params
.
invoice_type
,
businessmenBean
);
//个税 = 累计利润*个税税率-速算扣除数-该月/季度 累计缴纳的个税
let
personal_invoice_tax
=
new
Decimal
(
accumulatedProfit
).
mul
(
rateRes
.
rate
).
sub
(
rateRes
.
qcd
).
sub
(
personal_invoice_tax_total
).
toFixed
(
2
);
//***********************************************************一下是计算附加税和增值税******************************************************************************** */
//累计不含税价(个税)
let
accumulatedPriceExcludingTax
=
Decimal
.
div
(
invoice_amount_total
,
apettemp
);
console
.
log
(
invoiceRes
);
return
system
.
getResultSuccess
();
}
...
...
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