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
2218a692
Commit
2218a692
authored
Feb 23, 2024
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增创建空账单接口
parent
df2d17cb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
18 deletions
+57
-18
BillExtension.cs
Src/Extensions/BillExtension.cs
+20
-18
RestfulBill.cs
Src/Transforms/RestfulBill.cs
+37
-0
No files found.
Src/Extensions/BillExtension.cs
View file @
2218a692
...
...
@@ -38,10 +38,10 @@ namespace Kivii.Finances
return
offsetBillDetail
;
}
public
static
Bill
Accept
(
this
Bill
bill
,
List
<
Settlement
>
settlements
,
IDbConnection
conn
=
null
)
public
static
Bill
Accept
(
this
Bill
bill
,
List
<
Settlement
>
settlements
=
null
,
IDbConnection
conn
=
null
)
{
bill
.
ThrowIfNull
(
"账单不能为空!"
);
settlements
.
ThrowIfNullOrEmpty
(
"结算不能为空!"
);
//
settlements.ThrowIfNullOrEmpty("结算不能为空!");
var
rtns
=
new
Bill
();
...
...
@@ -65,24 +65,27 @@ namespace Kivii.Finances
rtns
.
OwnerName
=
KiviiContext
.
CurrentMember
.
DepartmentName
;
conn
.
Insert
(
rtns
);
foreach
(
var
settlement
in
settlements
)
if
(!
settlements
.
IsNullOrEmpty
()
)
{
var
billDetail
=
new
BillDetail
();
billDetail
.
BillKvid
=
billKvid
;
foreach
(
var
settlement
in
settlements
)
{
var
billDetail
=
new
BillDetail
();
billDetail
.
BillKvid
=
billKvid
;
billDetail
.
BizId
=
settlement
.
SerialNumber
;
billDetail
.
BizType
=
typeof
(
Settlement
).
FullName
;
billDetail
.
BizKvid
=
settlement
.
Kvid
;
billDetail
.
BizId
=
settlement
.
SerialNumber
;
billDetail
.
BizType
=
typeof
(
Settlement
).
FullName
;
billDetail
.
BizKvid
=
settlement
.
Kvid
;
billDetail
.
Type
=
settlement
.
Type
;
billDetail
.
Amount
=
settlement
.
Amount
;
billDetail
.
Currency
=
settlement
.
Currency
;
billDetail
.
Summary
=
settlement
.
Summary
;
billDetail
.
Remark
=
settlement
.
Remark
;
billDetail
.
OperateTime
=
DateTime
.
Now
;
billDetail
.
OperatorKvid
=
KiviiContext
.
CurrentMember
.
Kvid
;
billDetail
.
OperatorName
=
KiviiContext
.
CurrentMember
.
FullName
;
conn
.
Insert
(
billDetail
);
billDetail
.
Type
=
settlement
.
Type
;
billDetail
.
Amount
=
settlement
.
Amount
;
billDetail
.
Currency
=
settlement
.
Currency
;
billDetail
.
Summary
=
settlement
.
Summary
;
billDetail
.
Remark
=
settlement
.
Remark
;
billDetail
.
OperateTime
=
DateTime
.
Now
;
billDetail
.
OperatorKvid
=
KiviiContext
.
CurrentMember
.
Kvid
;
billDetail
.
OperatorName
=
KiviiContext
.
CurrentMember
.
FullName
;
conn
.
Insert
(
billDetail
);
}
}
trans
?.
Commit
();
return
rtns
;
...
...
@@ -92,7 +95,6 @@ namespace Kivii.Finances
trans
?.
Rollback
();
throw
ex
;
}
}
...
...
Src/Transforms/RestfulBill.cs
View file @
2218a692
...
...
@@ -197,4 +197,41 @@ namespace Kivii.Finances.Transforms
return
rtns
;
}
}
[
Api
(
Description
=
"创建空账单"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
BillCreateEx
:
RestfulExecution
<
Bill
>
{
public
Bill
Item
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
if
(
Item
.
PayerName
.
IsNullOrEmpty
()
||
Item
.
PayeeName
.
IsNullOrEmpty
())
throw
new
Exception
(
"收付双方不能为空!"
);
if
(
Item
.
Currency
==
CurrencyUnit
.
Unsupported
)
throw
new
Exception
(
"未传入货币单位!"
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Bill
>();
conn
.
InitEntityType
<
Bill
>();
conn
.
InitEntityType
<
BillDetail
>();
if
(
Item
.
Amount
<=
0
)
throw
new
Exception
(
"账单金额不能小于0!"
);
var
rtns
=
new
RestfulCreateResponse
<
Bill
>();
rtns
.
Results
=
new
List
<
Bill
>();
//var trans = conn.OpenTransaction();
try
{
var
bill
=
Item
.
Accept
(
null
,
conn
);
bill
.
RemoveAllOnlyProperties
();
rtns
.
Results
.
Add
(
bill
);
//trans.Commit();
}
catch
(
Exception
ex
)
{
//trans.Rollback();
throw
ex
;
}
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