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
64a26bb1
Commit
64a26bb1
authored
Jul 28, 2022
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化发票更新接口
parent
190cc324
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
RestfulInvoice.cs
Src/Transforms/RestfulInvoice.cs
+15
-0
No files found.
Src/Transforms/RestfulInvoice.cs
View file @
64a26bb1
...
...
@@ -115,12 +115,27 @@ namespace Kivii.Finances.Transforms
exist
.
ThrowIfNull
(
"未找到要更新的发票信息!"
);
if
(
exist
.
Type
.
ToLower
()
==
"relation"
)
throw
new
Exception
(
"不支持的数据类型,无法更新!"
);
if
(
Item
.
OffsetKvid
!=
Guid
.
Empty
)
throw
new
Exception
(
"无法更新已作废发票!"
);
if
(
Item
.
SerialNumber
==
exist
.
SerialNumber
)
Item
.
RemoveOnlyProperties
(
o
=>
o
.
SerialNumber
);
if
(
Item
.
OnlyPropertiesIsExist
(
o
=>
o
.
SerialNumber
))
{
var
nodes
=
conn
.
Select
<
Invoice
>(
o
=>
o
.
RootKvid
==
Item
.
Kvid
&&
o
.
RootKvid
!=
o
.
Kvid
);
if
(!
nodes
.
IsNullOrEmpty
())
{
foreach
(
var
node
in
nodes
)
{
node
.
SerialNumber
=
node
.
SerialNumber
.
Replace
(
exist
.
SerialNumber
,
Item
.
SerialNumber
);
node
.
AddOnlyProperties
(
o
=>
o
.
SerialNumber
);
conn
.
UpdateOnly
(
node
);
}
}
}
if
(
Item
.
Amount
==
exist
.
Amount
)
Item
.
RemoveOnlyProperties
(
o
=>
o
.
Amount
);
if
(
Item
.
OnlyPropertiesIsExist
(
o
=>
o
.
Amount
))
{
if
(
Item
.
Amount
<=
0
)
throw
new
Exception
(
"发票金额不能小于等于0!"
);
var
details
=
conn
.
Select
<
InvoiceDetail
>(
o
=>
o
.
InvoiceKvid
==
Item
.
Kvid
);
if
(
exist
.
AmountPayment
>
0
)
throw
new
Exception
(
"无法更新发票金额!"
);
if
(
exist
.
AmountUsed
>
0
)
throw
new
Exception
(
"无法更新发票金额!"
);
Item
.
AmountUntaxed
=
Math
.
Round
(
Item
.
Amount
/
(
1
+
Item
.
TaxRate
),
2
);
Item
.
AddOnlyProperties
(
o
=>
o
.
AmountUntaxed
);
Item
.
AmountTax
=
Item
.
Amount
-
Item
.
AmountUntaxed
;
...
...
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