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
c008a2fd
Commit
c008a2fd
authored
Jun 06, 2022
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增发票修改接口
parent
2330aac9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
15 deletions
+86
-15
Invoice.cs
Src/Entities/Invoice.cs
+16
-15
RestfulInvoice.cs
Src/Transforms/RestfulInvoice.cs
+69
-0
RestfulInvoiceApply.Apply.cs
Src/Transforms/RestfulInvoiceApply.Apply.cs
+1
-0
No files found.
Src/Entities/Invoice.cs
View file @
c008a2fd
...
...
@@ -61,17 +61,18 @@ namespace Kivii.Finances.Entities
#
endregion
#
region
收付双方
Payer
付款单位
,
贷方
Payee
收款单位
,
借方
全禁止更新
[
IgnoreUpdate
]
[
InternalSetter
]
[
DefaultEmptyGuid
]
public
Guid
PayerKvid
{
get
;
set
;
}
[
ApiMember
(
Description
=
"付款单位,贷方"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
100
),
Required
]
public
string
PayerName
{
get
;
set
;
}
[
ApiMember
(
Description
=
"付方税号,收票方税号"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
100
)]
public
string
PayerTaxNumber
{
get
;
set
;
}
...
...
@@ -84,46 +85,46 @@ namespace Kivii.Finances.Entities
public
string
PayerPhone
{
get
;
set
;
}
[
ApiMember
(
Description
=
"付款账户名称,指开户银行"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
200
),
Default
(
""
)]
public
string
PayerRegisteredBank
{
get
;
set
;
}
[
ApiMember
(
Description
=
"付款账户卡号"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
100
),
Default
(
""
)]
public
string
PayerBankAccount
{
get
;
set
;
}
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
DefaultEmptyGuid
]
public
Guid
PayeeKvid
{
get
;
set
;
}
[
ApiMember
(
Description
=
"收款单位,借方"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
100
),
Required
]
public
string
PayeeName
{
get
;
set
;
}
[
ApiMember
(
Description
=
"收方税号,开票方税号"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
100
),
Required
]
public
string
PayeeTaxNumber
{
get
;
set
;
}
[
ApiMember
(
Description
=
"公司地址"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
200
),
Default
(
""
)]
public
string
PayeeCompanyAddress
{
get
;
set
;
}
[
ApiMember
(
Description
=
"电话号码"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
50
),
Default
(
""
)]
public
string
PayeePhone
{
get
;
set
;
}
[
ApiMember
(
Description
=
"收款账户名称,指开户银行"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
200
),
Default
(
""
)]
public
string
PayeeRegisteredBank
{
get
;
set
;
}
[
ApiMember
(
Description
=
"收款账户卡号"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
100
),
Default
(
""
)]
public
string
PayeeBankAccount
{
get
;
set
;
}
#
endregion
...
...
@@ -161,7 +162,7 @@ namespace Kivii.Finances.Entities
public
decimal
AmountPayment
{
get
;
set
;
}
[
ApiMember
(
Description
=
"含税金额,合同或订单中使用的金额"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
DecimalLength
(
15
,
2
),
Default
(
0
)]
public
decimal
Amount
{
get
;
set
;
}
...
...
@@ -198,7 +199,7 @@ namespace Kivii.Finances.Entities
#
region
文本
摘要
备注
[
ApiMember
(
Description
=
"摘要,最大500字"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
StringLength
(
500
),
Default
(
""
)]
public
string
Summary
{
get
;
set
;
}
...
...
@@ -210,7 +211,7 @@ namespace Kivii.Finances.Entities
#
region
操作相关
Organization
Creator
Updater
Operator
OperateTime
全禁止更新
[
ApiMember
(
Description
=
"操作日期"
)]
[
I
gnoreUpdate
]
[
I
nternalSetter
]
[
Required
]
public
DateTime
OperateTime
{
get
;
set
;
}
...
...
Src/Transforms/RestfulInvoice.cs
View file @
c008a2fd
...
...
@@ -94,6 +94,74 @@ namespace Kivii.Finances.Transforms
}
[
Api
(
Description
=
"发票更新"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
InvoiceUpdateEx
:
RestfulExecution
<
Invoice
>
{
public
Invoice
Item
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
Item
.
ThrowIfNull
(
"请传入要更新的信息!"
);
Item
.
Kvid
.
ThrowIfEmpty
(
"缺少更新Kvid!"
);
Item
.
RemoveOnlyProperties
(
o
=>
o
.
AmountPayment
);
Item
.
RemoveOnlyProperties
(
o
=>
o
.
RootKvid
);
Item
.
RemoveOnlyProperties
(
o
=>
o
.
AmountUntaxed
);
Item
.
RemoveOnlyProperties
(
o
=>
o
.
AmountTax
);
var
rtns
=
new
RestfulUpdateResponse
<
Invoice
>();
rtns
.
Results
=
new
List
<
Invoice
>();
if
(
Item
.
GetOnlyProperties
().
IsNullOrEmpty
())
return
rtns
;
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Invoice
>();
var
exist
=
conn
.
SingleById
<
Invoice
>(
Item
.
Kvid
);
exist
.
ThrowIfNull
(
"未找到要更新的发票信息!"
);
if
(
exist
.
Type
.
ToLower
()
==
"relation"
)
throw
new
Exception
(
"不支持的数据类型,无法更新!"
);
if
(
Item
.
OffsetKvid
!=
Guid
.
Empty
)
throw
new
Exception
(
"无法更新已作废发票!"
);
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
(
"无法更新发票金额!"
);
Item
.
AmountUntaxed
=
Math
.
Round
(
Item
.
Amount
/
(
1
+
exist
.
TaxRate
),
2
);
Item
.
AddOnlyProperties
(
o
=>
o
.
AmountUntaxed
);
Item
.
AmountTax
=
Item
.
Amount
-
Item
.
AmountUntaxed
;
Item
.
AddOnlyProperties
(
o
=>
o
.
AmountTax
);
var
detail
=
new
InvoiceDetail
();
if
(!
details
.
IsNullOrEmpty
())
detail
.
PopulateInstance
(
details
[
0
]);
else
detail
.
GoodsFullName
=
"检测费"
;
detail
.
Kvid
=
Guid
.
NewGuid
();
detail
.
InvoiceKvid
=
exist
.
Kvid
;
detail
.
TaxRate
=
exist
.
TaxRate
;
detail
.
Amount
=
Item
.
Amount
;
detail
.
AmountUntaxed
=
Item
.
AmountUntaxed
;
detail
.
AmountTax
=
Item
.
AmountTax
;
detail
.
QuantityUnitPrice
=
Math
.
Round
(
detail
.
Amount
/
detail
.
Quantity
,
2
);
detail
.
QuantityUnitPriceUntaxed
=
Math
.
Round
(
detail
.
AmountUntaxed
/
detail
.
Quantity
,
2
);
detail
.
Remark
=
"手改修改发票金额,生成记录"
;
var
trans
=
conn
.
OpenTransaction
();
try
{
conn
.
UpdateOnly
(
Item
);
conn
.
Insert
(
detail
);
var
updateDetails
=
conn
.
From
<
InvoiceDetail
>();
updateDetails
=
updateDetails
.
Update
(
o
=>
o
.
Status
);
updateDetails
=
updateDetails
.
Where
(
o
=>
Sql
.
In
(
o
.
Kvid
,
details
.
ConvertAll
(
p
=>
p
.
Kvid
)));
conn
.
UpdateOnly
<
InvoiceDetail
>(
new
InvoiceDetail
{
Status
=
-
1
},
updateDetails
);
trans
.
Commit
();
}
catch
(
Exception
ex
)
{
trans
.
Rollback
();
throw
ex
;
}
}
else
conn
.
UpdateOnly
(
Item
);
rtns
.
Results
.
Add
(
Item
);
return
rtns
;
}
}
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
InvoiceRead
:
RestfulRead
<
Invoice
>
{
...
...
@@ -239,6 +307,7 @@ namespace Kivii.Finances.Transforms
detail
.
AmountUntaxed
=
invoice
.
AmountUntaxed
;
detail
.
Amount
=
invoice
.
Amount
;
detail
.
AmountTax
=
invoice
.
AmountTax
;
detail
.
QuantityUnitPrice
=
Math
.
Round
(
detail
.
Amount
/
detail
.
Quantity
,
2
);
detail
.
QuantityUnitPriceUntaxed
=
Math
.
Round
(
detail
.
AmountUntaxed
/
detail
.
Quantity
,
2
);
insertInvoiceDetails
.
Add
(
detail
);
}
...
...
Src/Transforms/RestfulInvoiceApply.Apply.cs
View file @
c008a2fd
...
...
@@ -652,6 +652,7 @@ namespace Kivii.Finances.Transforms
detail
.
AmountUntaxed
=
invoice
.
AmountUntaxed
;
detail
.
Amount
=
invoice
.
Amount
;
detail
.
AmountTax
=
invoice
.
AmountTax
;
detail
.
QuantityUnitPrice
=
Math
.
Round
(
detail
.
Amount
/
detail
.
Quantity
,
2
);
detail
.
QuantityUnitPriceUntaxed
=
Math
.
Round
(
detail
.
AmountUntaxed
/
detail
.
Quantity
,
2
);
insertInvoiceDetails
.
Add
(
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