Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Biz.Finances.V2.0
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶然
Kivii.Biz.Finances.V2.0
Commits
81fa1495
Commit
81fa1495
authored
Jun 14, 2022
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化了合并申请的接口
parent
18b0c433
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
20 deletions
+15
-20
RestfulInvoiceApply.Apply.cs
Src/Transforms/RestfulInvoiceApply.Apply.cs
+15
-20
No files found.
Src/Transforms/RestfulInvoiceApply.Apply.cs
View file @
81fa1495
...
...
@@ -336,25 +336,20 @@ namespace Kivii.Finances.Transforms
public
List
<
Guid
>
Kvids
{
get
;
set
;
}
public
InvoiceApplyDetail
Detail
{
get
;
set
;
}
public
List
<
InvoiceApplyDetail
>
Details
{
get
;
set
;
}
//发票开具最大额度限制 默认10万
public
decimal
Limit
{
get
;
set
;
}
=
100000
;
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
(
Detail
==
null
&&
Details
.
IsNullOrEmpty
()).
ThrowIfTrue
(
"Need Detail Or Details!"
);
if
(
Details
.
IsNullOrEmpty
())
Details
=
new
List
<
InvoiceApplyDetail
>();
if
(
Detail
!=
null
)
Details
.
Add
(
Detail
);
if
(
Kvids
==
null
||
Kvids
.
Count
<=
0
)
throw
new
Exception
(
"请先选择申请条目!"
);
Item
.
ThrowIfNull
(
"申请内容不能为空!"
);
Item
.
Details
.
ThrowIfNullOrEmpty
(
"缺少申请明细信息!"
);
if
(
Item
.
OperateType
!=
InvoiceApplyType
.
Payment
)
throw
new
Exception
(
"合并开票只针对收款刷卡现金申请!"
);
if
(
Kvids
==
null
||
Kvids
.
Count
<=
0
)
throw
new
Exception
(
"请先选择申请条目!"
);
if
(
Details
.
Exists
(
o
=>
o
.
GoodsFullName
.
IsNullOrEmpty
()))
throw
new
Exception
(
"明细名称存在空值!"
);
if
(
Details
.
Exists
(
o
=>
o
.
TaxRate
<
0
)
||
Details
.
Exists
(
o
=>
o
.
TaxRate
>
1
))
throw
new
Exception
(
"存在明细税率设置范围不在0-1之间!"
);
if
(
Details
.
Exists
(
o
=>
o
.
Quantity
<=
0
))
throw
new
Exception
(
"请填写数量!"
);
var
group
=
Details
.
GroupBy
(
o
=>
o
.
GoodsId
);
if
(
Item
.
Details
.
Exists
(
o
=>
o
.
GoodsFullName
.
IsNullOrEmpty
()))
throw
new
Exception
(
"明细名称存在空值!"
);
if
(
Item
.
Details
.
Exists
(
o
=>
o
.
TaxRate
<
0
)
||
Item
.
Details
.
Exists
(
o
=>
o
.
TaxRate
>
1
))
throw
new
Exception
(
"存在明细税率设置范围不在0-1之间!"
);
if
(
Item
.
Details
.
Exists
(
o
=>
o
.
Quantity
<=
0
))
throw
new
Exception
(
"请填写数量!"
);
var
group
=
Item
.
Details
.
GroupBy
(
o
=>
o
.
GoodsId
);
foreach
(
var
kv
in
group
)
{
var
sum
=
kv
.
Sum
(
o
=>
o
.
Amount
);
...
...
@@ -368,22 +363,22 @@ namespace Kivii.Finances.Transforms
if
(
applys
.
Count
<
2
)
throw
new
Exception
(
"请选择两条以上的申请进行合并!"
);
//if (applys.Exists(o => o.Type != "VATS")) throw new Exception("普票暂时无法合并开票");
if
(
applys
.
Exists
(
o
=>
o
.
PayerName
!=
Item
.
PayerName
))
throw
new
Exception
(
"合并申请抬头不一致!"
);
if
(
!
applys
.
Exists
(
o
=>
o
.
OperateType
!=
InvoiceApplyType
.
Payment
))
throw
new
Exception
(
"合并开票只针对收款刷卡现金申请!"
);
if
(
applys
.
Exists
(
o
=>
o
.
OperateType
!=
InvoiceApplyType
.
Payment
))
throw
new
Exception
(
"合并开票只针对收款刷卡现金申请!"
);
if
(
applys
.
Exists
(
o
=>
o
.
OperateType
==
InvoiceApplyType
.
Payment
))
Item
.
OperateType
=
InvoiceApplyType
.
Payment
;
var
groups
=
applys
.
GroupBy
(
o
=>
new
{
o
.
PayerName
,
o
.
PayerTaxNumber
});
if
(
groups
.
Count
()
!=
1
)
throw
new
Exception
(
"合并申请抬头不一致!"
);
if
(
applys
.
Exists
(
o
=>
o
.
Status
>
(
int
)
InvoiceApplyStatus
.
FinancialExecute
))
throw
new
Exception
(
"请勿重复申请开票!"
);
if
(
applys
.
Exists
(
o
=>
o
.
Status
<
(
int
)
InvoiceApplyStatus
.
ProcessAdoption
))
throw
new
Exception
(
"此申请还在审批中..."
);
if
(
applys
.
Sum
(
o
=>
o
.
Amount
)
!=
Item
.
Amount
)
throw
new
Exception
(
"合并金额与申请金额不一致!"
);
if
(
Item
.
Amount
!=
Details
.
Sum
(
o
=>
o
.
Amount
))
throw
new
Exception
(
"总金额和明细总额不一致!"
);
if
(
Item
.
Amount
!=
Item
.
Details
.
Sum
(
o
=>
o
.
Amount
))
throw
new
Exception
(
"总金额和明细总额不一致!"
);
var
remark
=
$"
[总:
{
Item
.
Amount
}
元]"
;
var
summary
=
$"申请合并:
[总:
{
Item
.
Amount
}
元]"
;
foreach
(
var
item
in
applys
)
{
remark
+=
$"[
{
item
.
OwnerName
}
:
{
item
.
Amount
}
元]"
;
summary
+=
$"[
{
item
.
OwnerName
}
:
{
item
.
Amount
}
元]"
;
}
#
region
计算
(
不根据前端传来
)
foreach
(
var
detail
in
Details
)
foreach
(
var
detail
in
Item
.
Details
)
{
detail
.
AmountUntaxed
=
Math
.
Round
(
detail
.
Amount
/
(
1
+
detail
.
TaxRate
),
2
);
detail
.
AmountTax
=
detail
.
Amount
-
detail
.
AmountUntaxed
;
...
...
@@ -410,8 +405,8 @@ namespace Kivii.Finances.Transforms
newApply
.
Amount
=
applys
.
Sum
(
o
=>
o
.
Amount
);
//newApply.AmountUsed = applys.Sum(o => o.AmountUsed);
newApply
.
Status
=
(
int
)
InvoiceApplyStatus
.
FinancialApproval
;
newApply
.
Summary
=
Item
.
S
ummary
;
newApply
.
Remark
=
r
emark
;
newApply
.
Summary
=
s
ummary
;
newApply
.
Remark
=
Item
.
R
emark
;
newApply
.
Metadata
[
"PayeeOperatorName"
]
=
Item
.
Metadata
.
ContainsKey
(
"PayeeOperatorName"
)
?
Item
.
Metadata
[
"PayeeOperatorName"
]
:
KiviiContext
.
CurrentMember
.
FullName
;
newApply
.
Metadata
[
"ReviewerName"
]
=
Item
.
Metadata
.
ContainsKey
(
"ReviewerName"
)
?
Item
.
Metadata
[
"ReviewerName"
]
:
KiviiContext
.
CurrentMember
.
FullName
;
conn
.
Insert
(
newApply
);
...
...
@@ -419,7 +414,7 @@ namespace Kivii.Finances.Transforms
#
endregion
#
region
ApplyDetail
入库
foreach
(
var
detail
in
Details
)
foreach
(
var
detail
in
Item
.
Details
)
{
detail
.
ApplyKvid
=
newInvoiceApplyKvid
;
conn
.
Insert
(
detail
);
...
...
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