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
4ac9df7b
Commit
4ac9df7b
authored
Mar 09, 2022
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增统计相关接口
parent
c5c35d0e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
8 deletions
+156
-8
Kivii.Biz.Finances.V2.0.csproj
Src/Kivii.Biz.Finances.V2.0.csproj
+1
-0
RestfulInvoice.cs
Src/Transforms/RestfulInvoice.cs
+6
-2
RestfulPay.cs
Src/Transforms/RestfulPay.cs
+7
-6
RestfulStatistic.cs
Src/Transforms/RestfulStatistic.cs
+142
-0
No files found.
Src/Kivii.Biz.Finances.V2.0.csproj
View file @
4ac9df7b
...
...
@@ -95,6 +95,7 @@
<Compile
Include=
"Transforms\RestfulPayment.UnBiz.Refund.cs"
/>
<Compile
Include=
"Transforms\RestfulSettlement.cs"
/>
<Compile
Include=
"Transforms\RestfulSettlement.Offset.cs"
/>
<Compile
Include=
"Transforms\RestfulStatistic.cs"
/>
</ItemGroup>
<ItemGroup>
<None
Include=
"packages.config"
/>
...
...
Src/Transforms/RestfulInvoice.cs
View file @
4ac9df7b
...
...
@@ -214,8 +214,12 @@ namespace Kivii.Finances.Transforms
invoice
.
Remark
=
info
.
Remark
;
invoice
.
Metadata
=
new
Dictionary
<
string
,
string
>();
invoice
.
Metadata
[
"PayeeOperatorName"
]
=
info
.
Metadata
.
ContainsKey
(
"PayeeOperatorName"
)
?
info
.
Metadata
[
"PayeeOperatorName"
]
:
""
;
invoice
.
Metadata
[
"ReviewerName"
]
=
info
.
Metadata
.
ContainsKey
(
"ReviewerName"
)
?
info
.
Metadata
[
"ReviewerName"
]
:
""
;
if
(!
info
.
Metadata
.
IsNullOrEmpty
())
{
invoice
.
Metadata
=
info
.
Metadata
;
invoice
.
Metadata
[
"PayeeOperatorName"
]
=
info
.
Metadata
.
ContainsKey
(
"PayeeOperatorName"
)
?
info
.
Metadata
[
"PayeeOperatorName"
]
:
""
;
invoice
.
Metadata
[
"ReviewerName"
]
=
info
.
Metadata
.
ContainsKey
(
"ReviewerName"
)
?
info
.
Metadata
[
"ReviewerName"
]
:
""
;
}
insertInvoices
.
Add
(
invoice
);
foreach
(
var
infoDetail
in
info
.
Details
)
...
...
Src/Transforms/RestfulPay.cs
View file @
4ac9df7b
...
...
@@ -33,7 +33,8 @@ namespace Kivii.Finances.Transforms
settlements
.
ThrowIfNullOrEmpty
(
"未找到结算单!"
);
if
(
settlements
.
Count
!=
SettlementKvids
.
Count
)
throw
new
Exception
(
"所选结算项与实际结算项不符合!"
);
if
(
settlements
.
Exists
(
o
=>
o
.
OffsetKvid
!=
Guid
.
Empty
))
throw
new
Exception
(
"所选结算项存在已作废项!"
);
if
(
settlements
.
Exists
(
o
=>
o
.
AmountPayment
>=
o
.
Amount
))
throw
new
Exception
(
"所选结算项存在已付款登记!"
);
if
(
settlements
.
Sum
(
o
=>
o
.
AmountPayment
)
>=
settlements
.
Sum
(
o
=>
o
.
Amount
))
throw
new
Exception
(
"所选结算项存在已付款登记!"
);
//if (settlements.Exists(o => o.AmountPayment >= o.Amount)) throw new Exception("所选结算项存在已付款登记!");
(
settlements
.
ConvertAll
(
o
=>
o
.
Currency
).
Distinct
().
ToList
().
Count
!=
1
).
ThrowIfTrue
(
"存在不相符的货币单位!"
);
var
currency
=
settlements
.
ConvertAll
(
o
=>
o
.
Currency
).
Distinct
().
ToList
()[
0
];
(
currency
==
CurrencyUnit
.
Unsupported
).
ThrowIfTrue
(
"不支持的货币单位!"
);
...
...
@@ -48,7 +49,7 @@ namespace Kivii.Finances.Transforms
var
accountBiz
=
currency
.
GetBizAccount
();
//conn.Single<Account>(o => o.OwnerKvid == KiviiContext.CurrentMember.OrganizationKvid && o.Type == AccountType.Biz && o.Currency == Item.Currency);
accountBiz
.
ThrowIfNull
(
$"未能正确获取系统
{
currency
}
业务账户!请联系管理员!"
);
if
(
PayingMethods
.
Count
==
1
)
//单笔付款登记
{
var
payingMethod
=
PayingMethods
[
0
];
...
...
@@ -83,7 +84,7 @@ namespace Kivii.Finances.Transforms
#
region
同步更新泛型
Settlement
表中数据
foreach
(
var
item
in
settlements
)
{
conn
.
UpdateOnly
(
item
);
//更新了AmountPayment
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了AmountPayment
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
if
(
_realMethod
==
null
)
...
...
@@ -138,7 +139,7 @@ namespace Kivii.Finances.Transforms
#
region
同步更新泛型
Settlement
表中数据
foreach
(
var
item
in
settlements
)
{
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
if
(
_realMethod
==
null
)
...
...
@@ -191,7 +192,7 @@ namespace Kivii.Finances.Transforms
#
region
同步更新泛型
Settlement
表中数据
foreach
(
var
item
in
settlements
)
{
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
if
(
_realMethod
==
null
)
...
...
@@ -325,7 +326,7 @@ namespace Kivii.Finances.Transforms
#
region
同步更新泛型
Settlement
表中数据
foreach
(
var
item
in
settlements
)
{
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
if
(
_realMethod
==
null
)
...
...
Src/Transforms/RestfulStatistic.cs
0 → 100644
View file @
4ac9df7b
using
Kivii.Finances.Entities
;
using
Kivii.Linq
;
using
Kivii.Web
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Kivii.Finances.Transforms
{
[
Api
(
Description
=
"发票统计"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
InvoiceStatistic
:
RestfulExecution
<
Invoice
>
{
#
region
QueryArgs
public
virtual
int
?
Skip
{
get
;
set
;
}
public
virtual
int
?
Take
{
get
;
set
;
}
public
virtual
string
OrderBy
{
get
;
set
;
}
public
string
OrderByDesc
{
get
;
set
;
}
public
virtual
string
Include
{
get
;
set
;
}
public
virtual
string
Fields
{
get
;
set
;
}
public
string
QueryKeys
{
get
;
set
;
}
public
string
QueryValues
{
get
;
set
;
}
#
endregion
public
DateTime
BeginTime
{
get
;
set
;
}
public
DateTime
EndTime
{
get
;
set
;
}
public
bool
Offseted
{
get
;
set
;
}
/// <summary>
/// 用于查询借票是否到账使用
/// </summary>
public
bool
?
Payed
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
int
monthDay
=
DateTime
.
DaysInMonth
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
);
if
(
BeginTime
==
DateTime
.
MinValue
)
BeginTime
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
1
);
if
(
EndTime
==
DateTime
.
MinValue
)
EndTime
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
monthDay
);
BeginTime
=
DateTime
.
Parse
(
BeginTime
.
ToString
(
"yyyy-MM-dd"
));
EndTime
=
DateTime
.
Parse
(
EndTime
.
ToString
(
"yyyy-MM-dd"
));
if
(
EndTime
<
BeginTime
)
throw
new
Exception
(
"查询结束日期不可小于开始日期!"
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Invoice
>();
var
dynamicParams
=
Request
.
GetRequestParams
();
var
autoQuery
=
Request
.
TryResolve
<
IAutoQueryDb
>();
autoQuery
.
IncludeTotal
=
true
;
var
request
=
new
RestfulQuery
<
Invoice
>();
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Where
(
o
=>
o
.
RootKvid
==
o
.
Kvid
);
if
(
Offseted
)
//只查作废或者红字的发票
{
sqlExpress
.
And
(
o
=>
o
.
OperateTime
>=
BeginTime
&&
o
.
OperateTime
<
EndTime
&&
o
.
Amount
<
0
);
}
else
{
//查当月的全部发票(包含当月到账的借票)
sqlExpress
.
And
(
o
=>
((
o
.
OperateTime
>=
BeginTime
&&
o
.
OperateTime
<
EndTime
)
||
(
o
.
PayedTime
.
Value
>=
BeginTime
&&
o
.
PayedTime
.
Value
<
EndTime
&&
o
.
OperateTime
<
BeginTime
)));
if
(
Payed
!=
null
&&
Payed
.
Value
)
sqlExpress
.
And
(
o
=>
o
.
AmountPayment
==
o
.
Amount
);
if
(
Payed
!=
null
&&
!
Payed
.
Value
)
sqlExpress
.
And
(
o
=>
o
.
AmountPayment
<
o
.
Amount
);
}
var
rtns
=
autoQuery
.
Execute
(
Request
,
conn
,
request
,
sqlExpress
);
return
rtns
;
}
}
[
Api
(
Description
=
"结算统计"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
SettlementStatistics
:
RestfulExecution
<
Settlement
>
{
#
region
QueryArgs
public
virtual
int
?
Skip
{
get
;
set
;
}
public
virtual
int
?
Take
{
get
;
set
;
}
public
virtual
string
OrderBy
{
get
;
set
;
}
public
string
OrderByDesc
{
get
;
set
;
}
public
virtual
string
Include
{
get
;
set
;
}
public
virtual
string
Fields
{
get
;
set
;
}
public
string
QueryKeys
{
get
;
set
;
}
public
string
QueryValues
{
get
;
set
;
}
#
endregion
public
DateTime
BeginTime
{
get
;
set
;
}
public
DateTime
EndTime
{
get
;
set
;
}
public
bool
?
Payed
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
int
monthDay
=
DateTime
.
DaysInMonth
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
);
if
(
BeginTime
==
DateTime
.
MinValue
)
BeginTime
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
1
);
if
(
EndTime
==
DateTime
.
MinValue
)
EndTime
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
monthDay
);
BeginTime
=
DateTime
.
Parse
(
BeginTime
.
ToString
(
"yyyy-MM-dd"
));
EndTime
=
DateTime
.
Parse
(
EndTime
.
ToString
(
"yyyy-MM-dd"
));
if
(
EndTime
<
BeginTime
)
throw
new
Exception
(
"查询结束日期不可小于开始日期!"
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Settlement
>();
var
dynamicParams
=
Request
.
GetRequestParams
();
var
autoQuery
=
Request
.
TryResolve
<
IAutoQueryDb
>();
autoQuery
.
IncludeTotal
=
true
;
var
request
=
new
RestfulQuery
<
Settlement
>();
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
//sqlExpress.Where(o => o.OffsetKvid == Guid.Empty);
if
(
Payed
!=
null
)
{
if
(
Payed
.
Value
)
sqlExpress
.
And
(
o
=>
o
.
Amount
==
o
.
AmountPayment
);
else
sqlExpress
.
And
(
o
=>
o
.
Amount
>
o
.
AmountPayment
);
}
sqlExpress
.
And
(
o
=>
o
.
CreateTime
>=
BeginTime
&&
o
.
CreateTime
<
EndTime
);
var
rtns
=
autoQuery
.
Execute
(
Request
,
conn
,
request
,
sqlExpress
);
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