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
010c42d8
Commit
010c42d8
authored
Apr 13, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
8d4b6562
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
41 deletions
+54
-41
xgg-saas-platform/app/base/controller/impl/saas/invoiceCtl.js
+54
-41
No files found.
xgg-saas-platform/app/base/controller/impl/saas/invoiceCtl.js
View file @
010c42d8
...
...
@@ -84,13 +84,14 @@ class InvoiceCtl extends CtlBase {
async
platformInvoiceInfo
(
params
,
pobj2
,
req
)
{
try
{
let
id
=
params
.
id
;
let
invoice_type
=
params
.
invoice_type
;
let
apply
=
await
this
.
saasinvoiceSve
.
invoiceapplyById
(
params
);
if
(
!
apply
.
data
||
!
apply
.
data
.
id
)
{
return
system
.
getResult
(
null
,
"发票申请不存在"
);
}
// apply = apply.data;
let
result
=
await
this
.
buildTradeInvoice
(
id
);
let
result
=
await
this
.
buildTradeInvoice
(
params
);
return
system
.
getResultSuccess
(
result
);
}
catch
(
error
)
{
let
msg
=
error
.
message
;
...
...
@@ -101,7 +102,9 @@ class InvoiceCtl extends CtlBase {
}
}
async
buildTradeInvoice
(
invoiceId
)
{
async
buildTradeInvoice
(
params
)
{
let
invoiceId
=
params
.
id
;
let
invoice_type
=
params
.
invoice_type
;
// 查交易
let
items
=
await
this
.
tradeSve
.
itemByInvoiceId
({
saas_invoice_id
:
invoiceId
});
items
=
items
.
data
;
...
...
@@ -121,10 +124,8 @@ class InvoiceCtl extends CtlBase {
businessmenMap
=
businessmenMap
.
data
;
let
invoiceList
=
[];
let
additional_tax_total
=
0
;
let
personal_invoice_tax_total
=
0
;
let
value_added_tax_total
=
0
;
let
service_tax_total
=
0
;
let
calcParams
=
[];
for
(
let
creditCode
in
bmMap
)
{
let
businessmen
=
businessmenMap
[
creditCode
];
let
itemList
=
bmMap
[
creditCode
];
...
...
@@ -132,59 +133,71 @@ class InvoiceCtl extends CtlBase {
for
(
let
item
of
itemList
)
{
amount
=
amount
+
Number
(
item
.
amt
||
0
);
}
// TODO 总统计算 begin
let
notifyApi
=
settings
.
outApi
().
deliverNotifyApi
;
let
data
=
{
"credit_code"
:
creditCode
,
"invoiced_time"
:
moment
(
pobj
.
invoiced_time
).
format
(
"YYYY-MM-DD hh:mm:ss"
),
"invoice_type"
:
pobj
.
invoice_type
,
"invoice_amount"
:
pobj
.
invoice_amount
};
// 推送订单到交付平台
let
url
=
settings
.
deliverSysApi
().
calcInvoice
;
let
res
=
await
axios
({
method
:
'post'
,
url
:
url
,
data
:
data
calcParams
.
push
({
"credit_code"
:
creditCode
,
"invoiced_time"
:
moment
().
format
(
"YYYY-MM-DD hh:mm:ss"
),
"invoice_type"
:
invoice_type
,
"invoice_amount"
:
amount
});
if
(
!
res
||
!
res
.
data
||
res
.
status
!=
0
){
return
system
.
getResult
(
null
,
`试算错误`
);
}
let
data
=
res
.
data
;
let
invoiceCalc
=
{
"personal_invoice_tax"
:
data
.
personal_invoice_tax
,
"additional_tax"
:
data
.
additional_tax
,
"service_tax"
:
data
.
service_tax
,
"value_added_tax"
:
data
.
value_added_tax
,
}
// TODO 总统计算 end
additional_tax_total
=
additional_tax_total
+
Number
(
invoiceCalc
.
additional_tax
);
personal_invoice_tax_total
=
personal_invoice_tax_total
+
Number
(
invoiceCalc
.
personal_invoice_tax
);
value_added_tax_total
=
value_added_tax_total
+
Number
(
invoiceCalc
.
value_added_tax
);
service_tax_total
=
service_tax_total
+
Number
(
invoiceCalc
.
service_tax
);
invoiceList
.
push
({
"name"
:
businessmen
.
name
,
"credit_code"
:
creditCode
,
"is_bank"
:
businessmen
.
isBank
,
"invoice_amount"
:
amount
,
"personal_invoice_tax"
:
Number
(
invoiceCalc
.
personal_invoice_tax
)
,
"additional_tax"
:
Number
(
invoiceCalc
.
additional_tax
)
,
"service_tax"
:
Number
(
invoiceCalc
.
service_tax
)
,
"value_added_tax"
:
Number
(
invoiceCalc
.
value_added_tax
)
,
"personal_invoice_tax"
:
0
,
"additional_tax"
:
0
,
"service_tax"
:
0
,
"value_added_tax"
:
0
,
"unit"
:
""
,
"quantity"
:
""
,
"price"
:
""
,
"remark"
:
""
});
}
let
additional_tax_total
=
0
;
let
personal_invoice_tax_total
=
0
;
let
value_added_tax_total
=
0
;
let
service_tax_total
=
0
;
// TODO 总统计算 begin
// 计算税金
let
url
=
settings
.
deliverSysApi
().
calcInvoice
;
let
res
=
await
axios
({
method
:
'post'
,
url
:
url
,
data
:
calcParams
});
if
(
!
res
||
!
res
.
data
||
res
.
status
!=
0
){
return
system
.
getResult
(
null
,
`试算错误`
);
}
let
calcList
=
res
.
data
;
let
calcMap
=
{};
for
(
let
c
of
calcList
)
{
calcMap
[
c
.
credit_code
]
=
c
;
}
for
(
let
invoice
of
invoiceList
)
{
let
invoiceCalc
=
calcMap
[
invoice
.
credit_code
];
additional_tax_total
=
additional_tax_total
+
Number
(
invoiceCalc
.
additional_tax
);
personal_invoice_tax_total
=
personal_invoice_tax_total
+
Number
(
invoiceCalc
.
personal_invoice_tax
);
value_added_tax_total
=
value_added_tax_total
+
Number
(
invoiceCalc
.
value_added_tax
);
service_tax_total
=
service_tax_total
+
Number
(
invoiceCalc
.
service_tax
);
invoice
.
personal_invoice_tax
=
Number
(
invoiceCalc
.
personal_invoice_tax
);
invoice
.
additional_tax
=
Number
(
invoiceCalc
.
additional_tax
);
invoice
.
service_tax
=
Number
(
invoiceCalc
.
service_tax
);
invoice
.
value_added_tax
=
Number
(
invoiceCalc
.
value_added_tax
);
}
return
{
tax
:
{
additional_tax_total
:
additional_tax_total
,
personal_invoice_tax_total
:
personal_invoice_tax_total
,
value_added_tax_total
:
value_added_tax_total
,
service_tax_total
:
service_tax_total
,
},
invoiceList
:
invoiceList
}
...
...
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