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
874eb57a
Commit
874eb57a
authored
Apr 22, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
c0b188d5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
38 deletions
+46
-38
xgg-saas-platform/app/base/controller/impl/saas/invoiceCtl.js
+46
-38
No files found.
xgg-saas-platform/app/base/controller/impl/saas/invoiceCtl.js
View file @
874eb57a
...
...
@@ -4,6 +4,7 @@ const validation = system.getObject("util.validation");
var
moment
=
require
(
'moment'
);
const
settings
=
require
(
"../../../../config/settings"
);
const
axios
=
require
(
"axios"
);
class
InvoiceCtl
extends
CtlBase
{
constructor
()
{
super
();
...
...
@@ -145,19 +146,21 @@ class InvoiceCtl extends CtlBase {
amount
=
amount
+
Number
(
item
.
amt
||
0
);
}
let
service_tax
=
parseFloat
((
Number
(
amount
)
*
Number
(
invoice_service_rate
)
/
100
).
toFixed
(
2
));
calcParams
.
push
({
"credit_code"
:
creditCode
,
"invoiced_time"
:
moment
().
format
(
"YYYY-MM-DD hh:mm:ss"
),
"invoice_type"
:
invoice_type
,
"invoice_amount"
:
amount
});
if
(
businessmen
.
is_bank
)
{
calcParams
.
push
({
"credit_code"
:
creditCode
,
"invoiced_time"
:
moment
().
format
(
"YYYY-MM-DD hh:mm:ss"
),
"invoice_type"
:
invoice_type
,
"invoice_amount"
:
amount
});
}
// TODO 总统计算 end
invoiceList
.
push
({
"name"
:
businessmen
.
name
,
"credit_code"
:
creditCode
,
"is_bank"
:
businessmen
.
is
B
ank
,
"is_bank_name"
:
businessmen
.
is
B
ank
?
"已开户"
:
"未开户"
,
"is_bank"
:
businessmen
.
is
_b
ank
,
"is_bank_name"
:
businessmen
.
is
_b
ank
?
"已开户"
:
"未开户"
,
"invoice_amount"
:
system
.
f2y
(
amount
),
"personal_invoice_tax"
:
0
,
"additional_tax"
:
0
,
...
...
@@ -178,41 +181,46 @@ class InvoiceCtl extends CtlBase {
// TODO 总统计算 begin
// 计算税金
try
{
let
url
=
settings
.
deliverSysApi
().
calcInvoice
;
let
res
=
await
axios
({
method
:
'post'
,
url
:
url
,
data
:
calcParams
});
if
(
!
res
||
!
res
.
data
||
res
.
data
.
status
!=
0
||
res
.
data
.
data
.
length
==
0
){
return
system
.
getResult
(
null
,
`试算错误`
);
}
let
calcList
=
res
.
data
.
data
;
let
calcMap
=
{};
let
errors
=
[];
for
(
let
c
of
calcList
)
{
calcMap
[
c
.
credit_code
]
=
c
;
if
(
c
.
error
)
{
errors
.
push
(
`
${
c
.
msg
}
【
${
c
.
credit_code
}
】`
);
if
(
calcParams
.
length
>
0
)
{
let
url
=
settings
.
deliverSysApi
().
calcInvoice
;
let
res
=
await
axios
({
method
:
'post'
,
url
:
url
,
data
:
calcParams
});
if
(
!
res
||
!
res
.
data
||
res
.
data
.
status
!=
0
||
res
.
data
.
data
.
length
==
0
)
{
return
system
.
getResult
(
null
,
`试算错误`
);
}
let
calcList
=
res
.
data
.
data
;
let
errors
=
[];
for
(
let
c
of
calcList
)
{
calcMap
[
c
.
credit_code
]
=
c
;
if
(
c
.
error
)
{
errors
.
push
(
`
${
c
.
msg
}
【
${
c
.
credit_code
}
】`
);
}
}
}
if
(
errors
.
length
>
0
)
{
return
system
.
getResult
(
null
,
errors
.
join
(
"、"
));
if
(
errors
.
length
>
0
)
{
return
system
.
getResult
(
null
,
errors
.
join
(
"、"
));
}
}
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
(
invoice
.
service_tax
);
invoice
.
personal_invoice_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
personal_invoice_tax
));
invoice
.
additional_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
additional_tax
));
invoice
.
value_added_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
value_added_tax
));
let
businessmen
=
businessmenMap
[
invoice
.
credit_code
];
if
(
!
businessmen
.
is_bank
)
{
service_tax_total
=
service_tax_total
+
Number
(
invoice
.
service_tax
);
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
);
invoice
.
personal_invoice_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
personal_invoice_tax
));
invoice
.
additional_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
additional_tax
));
invoice
.
value_added_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
value_added_tax
));
}
}
return
system
.
getResultSuccess
({
...
...
@@ -226,7 +234,7 @@ class InvoiceCtl extends CtlBase {
});
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误`
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
...
...
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