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
44603696
Commit
44603696
authored
Jul 14, 2022
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级发票更新接口 支持更新税率
parent
4f50c4a3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
4 deletions
+41
-4
Invoice.cs
Src/Entities/Invoice.cs
+1
-1
InvoiceDetail.cs
Src/Entities/InvoiceDetail.cs
+1
-1
RestfulInvoice.cs
Src/Transforms/RestfulInvoice.cs
+39
-2
No files found.
Src/Entities/Invoice.cs
View file @
44603696
...
...
@@ -152,7 +152,7 @@ namespace Kivii.Finances.Entities
#
region
金额和税
[
ApiMember
(
Description
=
"发票税率"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
DecimalLength
(
5
,
4
),
Default
(
0
)]
public
decimal
TaxRate
{
get
;
set
;
}
...
...
Src/Entities/InvoiceDetail.cs
View file @
44603696
...
...
@@ -67,7 +67,7 @@ namespace Kivii.Finances.Entities
public
decimal
QuantityUnitPriceUntaxed
{
get
;
set
;
}
[
ApiMember
(
Description
=
"税率"
)]
[
I
gnoreUpdate
,
I
nternalSetter
]
[
InternalSetter
]
[
DecimalLength
(
5
,
2
),
Required
]
public
decimal
TaxRate
{
get
;
set
;
}
...
...
Src/Transforms/RestfulInvoice.cs
View file @
44603696
...
...
@@ -121,7 +121,7 @@ namespace Kivii.Finances.Transforms
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
(
"无法更新发票金额!"
);
Item
.
AmountUntaxed
=
Math
.
Round
(
Item
.
Amount
/
(
1
+
exist
.
TaxRate
),
2
);
Item
.
AmountUntaxed
=
Math
.
Round
(
Item
.
Amount
/
(
1
+
Item
.
TaxRate
),
2
);
Item
.
AddOnlyProperties
(
o
=>
o
.
AmountUntaxed
);
Item
.
AmountTax
=
Item
.
Amount
-
Item
.
AmountUntaxed
;
Item
.
AddOnlyProperties
(
o
=>
o
.
AmountTax
);
...
...
@@ -131,7 +131,7 @@ namespace Kivii.Finances.Transforms
else
detail
.
GoodsFullName
=
"检测费"
;
detail
.
Kvid
=
Guid
.
NewGuid
();
detail
.
InvoiceKvid
=
exist
.
Kvid
;
detail
.
TaxRate
=
exist
.
TaxRate
;
detail
.
TaxRate
=
Item
.
TaxRate
;
detail
.
Amount
=
Item
.
Amount
;
detail
.
AmountUntaxed
=
Item
.
AmountUntaxed
;
detail
.
AmountTax
=
Item
.
AmountTax
;
...
...
@@ -156,6 +156,43 @@ namespace Kivii.Finances.Transforms
throw
ex
;
}
}
else
if
(
Item
.
OnlyPropertiesIsExist
(
o
=>
o
.
TaxRate
))
{
(
Item
.
TaxRate
<
0
||
Item
.
TaxRate
>
1
).
ThrowIfTrue
(
"发票税率取值不合法!"
);
var
details
=
conn
.
Select
<
InvoiceDetail
>(
o
=>
o
.
InvoiceKvid
==
Item
.
Kvid
);
Item
.
AmountUntaxed
=
Math
.
Round
(
exist
.
Amount
/
(
1
+
Item
.
TaxRate
),
2
);
Item
.
AddOnlyProperties
(
o
=>
o
.
AmountUntaxed
);
Item
.
AmountTax
=
exist
.
Amount
-
Item
.
AmountUntaxed
;
Item
.
AddOnlyProperties
(
o
=>
o
.
AmountTax
);
foreach
(
var
detail
in
details
)
{
detail
.
TaxRate
=
Item
.
TaxRate
;
detail
.
AddOnlyProperties
(
o
=>
o
.
TaxRate
);
detail
.
AmountUntaxed
=
Math
.
Round
(
detail
.
Amount
/
(
1
+
detail
.
TaxRate
),
2
);
detail
.
AddOnlyProperties
(
o
=>
o
.
AmountUntaxed
);
detail
.
AmountTax
=
detail
.
Amount
-
detail
.
AmountUntaxed
;
detail
.
AddOnlyProperties
(
o
=>
o
.
AmountTax
);
detail
.
QuantityUnitPriceUntaxed
=
Math
.
Round
(
detail
.
AmountUntaxed
/
detail
.
Quantity
,
2
);
detail
.
AddOnlyProperties
(
o
=>
o
.
QuantityUnitPriceUntaxed
);
}
var
trans
=
conn
.
OpenTransaction
();
try
{
conn
.
UpdateOnly
(
Item
);
foreach
(
var
item
in
details
)
{
conn
.
UpdateOnly
(
item
);
}
trans
.
Commit
();
}
catch
(
Exception
ex
)
{
trans
.
Rollback
();
throw
ex
;
}
}
else
conn
.
UpdateOnly
(
Item
);
rtns
.
Results
.
Add
(
Item
);
return
rtns
;
...
...
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