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
35cdcea9
Commit
35cdcea9
authored
Apr 21, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
d4a8fe80
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
134 additions
and
0 deletions
+134
-0
xgg-saas-merchant/app/base/controller/impl/saas/invoice2Ctl.js
+0
-0
xgg-saas-merchant/app/base/controller/impl/saas/invoiceCtl.js
+134
-0
No files found.
xgg-saas-merchant/app/base/controller/impl/saas/invoice2Ctl.js
0 → 100644
View file @
35cdcea9
This diff is collapsed.
Click to expand it.
xgg-saas-merchant/app/base/controller/impl/saas/invoiceCtl.js
View file @
35cdcea9
...
...
@@ -193,6 +193,140 @@ class InvoiceCtl extends CtlBase {
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
// 功能1 确定个体户开票
async
confirmInvoice
(
params
,
pobj2
,
req
)
{
let
invoice_type
=
params
.
invoice_type
;
let
msg
=
error
.
message
;
if
(
msg
.
startsWith
(
"bpo-validation-error:"
))
{
return
system
.
getResult
(
null
,
msg
.
replace
(
"bpo-validation-error:"
,
""
));
}
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
try
{
return
await
this
.
invoiceSve
.
invoiceOrder
(
params
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
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
;
if
(
!
items
||
items
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"该发票缺少交易信息,请联系平台查看原因"
);
}
let
bmMap
=
{};
let
creditCodes
=
[];
for
(
let
item
of
items
)
{
let
creditCode
=
item
.
credit_code
;
let
list
=
bmMap
[
creditCode
]
||
[];
list
.
push
(
item
);
bmMap
[
creditCode
]
=
list
;
creditCodes
.
push
(
creditCode
);
}
let
businessmenMap
=
await
this
.
orderSve
.
mapByCreditCodes
({
creditCodes
:
creditCodes
});
businessmenMap
=
businessmenMap
.
data
;
let
invoiceList
=
[];
let
calcParams
=
[];
for
(
let
creditCode
in
bmMap
)
{
let
businessmen
=
businessmenMap
[
creditCode
];
let
itemList
=
bmMap
[
creditCode
];
let
amount
=
0
;
for
(
let
item
of
itemList
)
{
amount
=
amount
+
Number
(
item
.
amt
||
0
);
}
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
.
isBank
,
"is_bank_name"
:
businessmen
.
isBank
?
"已开户"
:
"未开户"
,
"invoice_amount"
:
system
.
y2f
(
amount
),
"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
// 计算税金
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
(
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
(
invoiceCalc
.
service_amount
);
invoice
.
personal_invoice_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
personal_invoice_tax
));
invoice
.
additional_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
additional_tax
));
invoice
.
service_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
service_amount
));
invoice
.
value_added_tax
=
system
.
toFloat
(
Number
(
invoiceCalc
.
value_added_tax
));
}
return
system
.
getResultSuccess
({
tax
:
{
additional_tax_total
:
system
.
toFloat
(
additional_tax_total
),
personal_invoice_tax_total
:
system
.
toFloat
(
personal_invoice_tax_total
),
value_added_tax_total
:
system
.
toFloat
(
value_added_tax_total
),
service_tax_total
:
system
.
toFloat
(
service_tax_total
),
},
invoiceList
:
invoiceList
});
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
}
module
.
exports
=
InvoiceCtl
;
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