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
fed5068e
Commit
fed5068e
authored
Feb 18, 2023
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Payment新增Assign类型
parent
f19140a5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
86 additions
and
20 deletions
+86
-20
Payment.cs
Src/Entities/Payment.cs
+5
-0
InvoiceApplyExtension.cs
Src/Extensions/InvoiceApplyExtension.cs
+1
-1
PayExtension.cs
Src/Extensions/PayExtension.cs
+1
-1
PaymentExtension.cs
Src/Extensions/PaymentExtension.cs
+0
-0
RestfulInvoice.cs
Src/Transforms/RestfulInvoice.cs
+3
-3
RestfulInvoiceApply.Apply.cs
Src/Transforms/RestfulInvoiceApply.Apply.cs
+26
-3
RestfulPay.cs
Src/Transforms/RestfulPay.cs
+15
-3
RestfulPayment.Account.cs
Src/Transforms/RestfulPayment.Account.cs
+2
-1
RestfulPayment.Split.cs
Src/Transforms/RestfulPayment.Split.cs
+0
-0
RestfulPayment.cs
Src/Transforms/RestfulPayment.cs
+29
-6
RestfulSettlement.Offset.cs
Src/Transforms/RestfulSettlement.Offset.cs
+1
-1
RestfulPayment.Statistic.cs
Src/Transforms/Statistics/RestfulPayment.Statistic.cs
+3
-1
No files found.
Src/Entities/Payment.cs
View file @
fed5068e
...
...
@@ -236,6 +236,11 @@ namespace Kivii.Finances.Entities
Split
,
/// <summary>
/// 拆分后分配,用于内部拆分后指派分配到其他部门,此类型的父级是Split,同时此类型职能与Split相同,可用于收款登记和转账
/// </summary>
Assign
,
/// <summary>
/// 非业务使用
/// </summary>
UnBiz
,
...
...
Src/Extensions/InvoiceApplyExtension.cs
View file @
fed5068e
...
...
@@ -38,7 +38,7 @@ namespace Kivii.Finances
{
payments
.
ThrowIfNullOrEmpty
(
"要关联的Payments不能为空!"
);
invoices
.
ThrowIfNullOrEmpty
(
"要关联的Invoices不能为空!"
);
(
payments
.
Exists
(
o
=>
o
.
Type
!=
PaymentType
.
Bank
&&
o
.
Type
!=
PaymentType
.
AliPay
&&
o
.
Type
!=
PaymentType
.
Cash
&&
o
.
Type
!=
PaymentType
.
Pos
&&
o
.
Type
!=
PaymentType
.
Split
&&
o
.
Type
!=
PaymentType
.
WeChat
)).
ThrowIfTrue
(
"请选择正确收款进行关联"
);
(
payments
.
Exists
(
o
=>
o
.
Type
!=
PaymentType
.
Bank
&&
o
.
Type
!=
PaymentType
.
AliPay
&&
o
.
Type
!=
PaymentType
.
Cash
&&
o
.
Type
!=
PaymentType
.
Pos
&&
o
.
Type
!=
PaymentType
.
Split
&&
o
.
Type
!=
PaymentType
.
Assign
&&
o
.
Type
!=
PaymentType
.
WeChat
)).
ThrowIfTrue
(
"请选择正确收款进行关联"
);
var
payedTime
=
payments
.
Max
(
o
=>
o
.
OperateTime
);
var
rtns
=
new
List
<
Invoice
>();
...
...
Src/Extensions/PayExtension.cs
View file @
fed5068e
...
...
@@ -24,7 +24,7 @@ namespace Kivii.Finances
payment
.
ThrowIfNull
(
"未传入到账信息!"
);
accountPayee
.
ThrowIfNull
(
"未传入指定收款账户!"
);
(
settlements
.
Exists
(
o
=>
o
.
Currency
!=
payment
.
Currency
||
o
.
Currency
!=
accountPayee
.
Currency
)).
ThrowIfTrue
(
"存在不相符的货币单位!"
);
if
(
payment
.
Type
!=
PaymentType
.
Split
&&
payment
.
Type
!=
PaymentType
.
Pos
&&
payment
.
Type
!=
PaymentType
.
Cash
&&
payment
.
Type
!=
PaymentType
.
AliPay
&&
payment
.
Type
!=
PaymentType
.
WeChat
)
throw
new
Exception
(
"请选择正确的付款方式!"
);
if
(
payment
.
Type
!=
PaymentType
.
Split
&&
payment
.
Type
!=
PaymentType
.
Assign
&&
payment
.
Type
!=
PaymentType
.
Pos
&&
payment
.
Type
!=
PaymentType
.
Cash
&&
payment
.
Type
!=
PaymentType
.
AliPay
&&
payment
.
Type
!=
PaymentType
.
WeChat
)
throw
new
Exception
(
"请选择正确的付款方式!"
);
var
amountSettlement
=
settlements
.
Sum
(
o
=>
o
.
Amount
-
o
.
AmountPayment
);
if
(
amountSettlement
<=
0
)
throw
new
Exception
(
"当前结算已无需付款登记!"
);
if
(
amount
<=
0
||
amount
>
amountSettlement
)
amount
=
amountSettlement
;
...
...
Src/Extensions/PaymentExtension.cs
View file @
fed5068e
This diff is collapsed.
Click to expand it.
Src/Transforms/RestfulInvoice.cs
View file @
fed5068e
...
...
@@ -278,7 +278,7 @@ namespace Kivii.Finances.Transforms
var
existPayments
=
conn
.
SelectByIds
<
Payment
>(
Payments
.
ConvertAll
(
o
=>
o
.
Kvid
));
existPayments
.
ThrowIfNullOrEmpty
(
"未找到指定的到账信息!"
);
(
existPayments
.
Count
!=
Payments
.
Count
).
ThrowIfTrue
(
"指定的到账信息与查询到的到账信息不匹配!"
);
existPayments
.
Exists
(
o
=>
o
.
Type
!=
PaymentType
.
Bank
&&
o
.
Type
!=
PaymentType
.
AliPay
&&
o
.
Type
!=
PaymentType
.
Cash
&&
o
.
Type
!=
PaymentType
.
Pos
&&
o
.
Type
!=
PaymentType
.
Split
&&
o
.
Type
!=
PaymentType
.
WeChat
).
ThrowIfTrue
(
"存在不正确的到账类型"
);
existPayments
.
Exists
(
o
=>
o
.
Type
!=
PaymentType
.
Bank
&&
o
.
Type
!=
PaymentType
.
AliPay
&&
o
.
Type
!=
PaymentType
.
Cash
&&
o
.
Type
!=
PaymentType
.
Pos
&&
o
.
Type
!=
PaymentType
.
Split
&&
o
.
Type
!=
PaymentType
.
Assign
&&
o
.
Type
!=
PaymentType
.
WeChat
).
ThrowIfTrue
(
"存在不正确的到账类型"
);
foreach
(
var
item
in
existPayments
)
{
var
payment
=
Payments
.
FirstOrDefault
(
o
=>
o
.
Kvid
==
item
.
Kvid
);
...
...
@@ -376,8 +376,8 @@ namespace Kivii.Finances.Transforms
{
var
correlatedInvoices
=
insertInvoices
.
Correlating
(
preCorrelatingPayments
);
insertInvoices
.
AddRange
(
correlatedInvoices
);
var
current
RootKvids
=
preCorrelatingPayments
.
Where
(
o
=>
o
.
Type
==
PaymentType
.
Split
).
ToList
().
ConvertAll
(
p
=>
p
.
Roo
tKvid
);
if
(!
current
RootKvids
.
IsNullOrEmpty
())
parentPayments
=
conn
.
Select
<
Payment
>(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Kvid
,
currentRoo
tKvids
));
var
current
ParentKvids
=
preCorrelatingPayments
.
Where
(
o
=>
o
.
Type
==
PaymentType
.
Split
||
o
.
Type
==
PaymentType
.
Assign
).
ToList
().
ConvertAll
(
p
=>
p
.
Paren
tKvid
);
if
(!
current
ParentKvids
.
IsNullOrEmpty
())
parentPayments
=
conn
.
Select
<
Payment
>(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Kvid
,
currentParen
tKvids
));
}
var
rtns
=
new
RestfulUpdateResponse
<
Invoice
>();
rtns
.
Results
=
new
List
<
Invoice
>();
...
...
Src/Transforms/RestfulInvoiceApply.Apply.cs
View file @
fed5068e
...
...
@@ -97,11 +97,34 @@ namespace Kivii.Finances.Transforms
var
paymentKvidsDistinct
=
PaymentKvids
.
Distinct
().
ToList
();
var
payments
=
conn
.
Select
<
Payment
>(
o
=>
Sql
.
In
(
o
.
Kvid
,
paymentKvidsDistinct
));
(
payments
.
Count
<=
0
||
payments
.
Count
!=
paymentKvidsDistinct
.
Count
).
ThrowIfTrue
(
"收款信息与所选项目不一致!"
);
(
payments
.
Exists
(
o
=>
o
.
Type
!=
PaymentType
.
Bank
&&
o
.
Type
!=
PaymentType
.
Split
&&
o
.
Type
!=
PaymentType
.
AliPay
&&
o
.
Type
!=
PaymentType
.
Pos
&&
o
.
Type
!=
PaymentType
.
WeChat
&&
o
.
Type
!=
PaymentType
.
Cash
)).
ThrowIfTrue
(
"请选择正确的收款信息进行申请!"
);
(
payments
.
Exists
(
o
=>
o
.
Type
!=
PaymentType
.
Bank
&&
o
.
Type
!=
PaymentType
.
Assign
&&
o
.
Type
!=
PaymentType
.
Split
&&
o
.
Type
!=
PaymentType
.
AliPay
&&
o
.
Type
!=
PaymentType
.
Pos
&&
o
.
Type
!=
PaymentType
.
WeChat
&&
o
.
Type
!=
PaymentType
.
Cash
)).
ThrowIfTrue
(
"请选择正确的收款信息进行申请!"
);
(
payments
.
Exists
(
o
=>
o
.
Amount
<=
o
.
AmountInvoice
)).
ThrowIfTrue
(
"存在已开票的到账!无法重复申请!"
);
if
(
Item
.
Amount
!=
payments
.
Sum
(
o
=>
o
.
Amount
-
o
.
AmountInvoice
))
throw
new
Exception
(
"申请金额与所选到账金额不一致!"
);
(
conn
.
Exists
<
InvoiceApply
>(
o
=>
o
.
OperateType
==
InvoiceApplyType
.
Related
&&
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
BizKvid
,
payments
.
ConvertAll
(
p
=>
p
.
Kvid
)))).
ThrowIfTrue
(
"已有申请开票中的到账!"
);
foreach
(
var
item
in
payments
)
{
if
(
item
.
Type
==
PaymentType
.
Split
)
{
if
(
payments
.
Exists
(
o
=>
o
.
ParentKvid
==
item
.
Kvid
&&
o
.
Type
==
PaymentType
.
Assign
))
throw
new
Exception
(
"存在同一笔流水重复选择!"
);
}
if
(
item
.
Type
==
PaymentType
.
Assign
)
{
if
(
payments
.
Exists
(
o
=>
o
.
Kvid
==
item
.
ParentKvid
&&
o
.
Type
==
PaymentType
.
Split
))
throw
new
Exception
(
"存在同一笔流水重复选择!"
);
}
}
var
paymentKvids
=
payments
.
ConvertAll
(
o
=>
o
.
Kvid
);
var
splitPayments
=
payments
.
Where
(
o
=>
o
.
Type
==
PaymentType
.
Split
).
ToList
();
if
(!
splitPayments
.
IsNullOrEmpty
())
//如果是Split申请开票则要查查看子集Assgin是否也有正在申请中的,不然申请时可能重复申请开票
{
var
existAssignPayments
=
conn
.
Select
<
Payment
>(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
o
.
Type
==
PaymentType
.
Assign
&&
Sql
.
In
(
o
.
ParentKvid
,
splitPayments
.
ConvertAll
(
p
=>
p
.
Kvid
)));
if
(!
existAssignPayments
.
IsNullOrEmpty
())
paymentKvids
.
AddRange
(
existAssignPayments
.
ConvertAll
(
p
=>
p
.
Kvid
));
}
var
assginPayments
=
payments
.
Where
(
o
=>
o
.
Type
==
PaymentType
.
Assign
).
ToList
();
if
(!
assginPayments
.
IsNullOrEmpty
())
//如果是Split申请开票则要查查看子集Assgin是否也有正在申请中的,不然申请时可能重复申请开票
{
var
existSplitPayments
=
conn
.
Select
<
Payment
>(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
o
.
Type
==
PaymentType
.
Split
&&
Sql
.
In
(
o
.
Kvid
,
assginPayments
.
ConvertAll
(
p
=>
p
.
ParentKvid
)));
if
(!
existSplitPayments
.
IsNullOrEmpty
())
paymentKvids
.
AddRange
(
existSplitPayments
.
ConvertAll
(
p
=>
p
.
Kvid
));
}
(
conn
.
Exists
<
InvoiceApply
>(
o
=>
o
.
OperateType
==
InvoiceApplyType
.
Related
&&
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
BizKvid
,
paymentKvids
))).
ThrowIfTrue
(
"已有申请开票中的到账!"
);
//(conn.Exists<Invoice>(o => o.OffsetKvid == Guid.Empty && Sql.In(o.BizKvid, payments.ConvertAll(p => p.RootKvid)))).ThrowIfTrue("已有开票的到账!");
var
trans
=
conn
.
OpenTransaction
();
...
...
Src/Transforms/RestfulPay.cs
View file @
fed5068e
...
...
@@ -72,7 +72,7 @@ namespace Kivii.Finances.Transforms
var
payment
=
conn
.
SingleById
<
Payment
>(
payingMethod
.
Kvid
);
payment
.
ThrowIfNull
(
"所选付款数据不存在!"
);
(
payment
.
Currency
!=
currency
).
ThrowIfTrue
(
"存在不相符的货币单位!"
);
if
(
payment
.
Type
!=
PaymentType
.
Split
&&
payment
.
Type
!=
PaymentType
.
Pos
&&
payment
.
Type
!=
PaymentType
.
Cash
&&
payment
.
Type
!=
PaymentType
.
AliPay
&&
payment
.
Type
!=
PaymentType
.
WeChat
)
throw
new
Exception
(
"请选择正确的付款方式!"
);
if
(
payment
.
Type
!=
PaymentType
.
Split
&&
payment
.
Type
!=
PaymentType
.
Assign
&&
payment
.
Type
!=
PaymentType
.
Pos
&&
payment
.
Type
!=
PaymentType
.
Cash
&&
payment
.
Type
!=
PaymentType
.
AliPay
&&
payment
.
Type
!=
PaymentType
.
WeChat
)
throw
new
Exception
(
"请选择正确的付款方式!"
);
var
amount
=
amountSettlement
-
amountPayed
;
if
(
payment
.
Amount
-
payment
.
AmountUsed
<
amount
)
amount
=
payment
.
Amount
-
payment
.
AmountUsed
;
(
payingMethod
.
Amount
>
0
&&
payingMethod
.
Amount
>
payment
.
Amount
-
payment
.
AmountUsed
).
ThrowIfTrue
(
$"所选付款方式余额不足,可用余额:
{
payment
.
Amount
-
payment
.
AmountUsed
}
"
);
...
...
@@ -95,6 +95,7 @@ namespace Kivii.Finances.Transforms
accountDetail
.
Insert
(
conn
);
payment
.
RecalculateAmountUsed
(
conn
);
//重新统计到账的使用情况
if
(
payment
.
Type
==
PaymentType
.
Split
)
payment
.
RecalculateAssignAmount
(
conn
);
#
region
同步更新泛型
Settlement
表中数据
foreach
(
var
item
in
settlements
)
{
...
...
@@ -262,10 +263,20 @@ namespace Kivii.Finances.Transforms
payments
=
conn
.
SelectByIds
<
Payment
>(
paymentKvids
);
payments
.
ThrowIfNullOrEmpty
(
"未找到所选付款数据!"
);
payments
.
Exists
(
o
=>
o
.
Currency
!=
currency
).
ThrowIfTrue
(
"存在不相符的货币单位!"
);
if
(
payments
.
Exists
(
o
=>
o
.
Type
!=
PaymentType
.
Split
&&
o
.
Type
!=
PaymentType
.
Pos
&&
o
.
Type
!=
PaymentType
.
Cash
&&
o
.
Type
!=
PaymentType
.
AliPay
&&
o
.
Type
!=
PaymentType
.
WeChat
))
throw
new
Exception
(
"请选择正确的付款方式!"
);
if
(
payments
.
Exists
(
o
=>
o
.
Type
!=
PaymentType
.
Split
&&
o
.
Type
!=
PaymentType
.
Assign
&&
o
.
Type
!=
PaymentType
.
Pos
&&
o
.
Type
!=
PaymentType
.
Cash
&&
o
.
Type
!=
PaymentType
.
AliPay
&&
o
.
Type
!=
PaymentType
.
WeChat
))
throw
new
Exception
(
"请选择正确的付款方式!"
);
if
(
payments
.
Exists
(
o
=>
(
o
.
Amount
-
o
.
AmountUsed
)
<=
0
))
throw
new
Exception
(
$"所选付款方式余额不足!"
);
//if (payments.Exists(o => (o.AmountInvoice != o.Amount))) throw new Exception($"所选付款尚未开票!");
foreach
(
var
item
in
payments
)
{
if
(
item
.
Type
==
PaymentType
.
Split
)
{
if
(
payments
.
Exists
(
o
=>
o
.
ParentKvid
==
item
.
Kvid
&&
o
.
Type
==
PaymentType
.
Assign
))
throw
new
Exception
(
"存在同一笔流水重复选择!"
);
}
if
(
item
.
Type
==
PaymentType
.
Assign
)
{
if
(
payments
.
Exists
(
o
=>
o
.
Kvid
==
item
.
ParentKvid
&&
o
.
Type
==
PaymentType
.
Split
))
throw
new
Exception
(
"存在同一笔流水重复选择!"
);
}
}
}
List
<
Account
>
accounts
=
null
;
if
(!
accountKvids
.
IsNullOrEmpty
())
...
...
@@ -351,6 +362,7 @@ namespace Kivii.Finances.Transforms
foreach
(
var
item
in
payments
)
{
item
.
RecalculateAmountUsed
(
conn
);
if
(
item
.
Type
==
PaymentType
.
Split
)
item
.
RecalculateAssignAmount
(
conn
);
}
#
region
同步更新泛型
Settlement
表中数据
foreach
(
var
item
in
settlements
)
...
...
Src/Transforms/RestfulPayment.Account.cs
View file @
fed5068e
...
...
@@ -39,7 +39,7 @@ namespace Kivii.Finances.Transforms
var
payment
=
conn
.
SingleById
<
Payment
>(
PaymentKvid
);
if
(
payment
==
null
)
throw
new
Exception
(
"不存在的收款信息!"
);
if
(
payment
.
OffsetKvid
!=
Guid
.
Empty
)
throw
new
Exception
(
"此收款已冲账!"
);
if
(
payment
.
Type
!=
PaymentType
.
UnBiz
&&
payment
.
Type
!=
PaymentType
.
Refund
&&
payment
.
Type
!=
PaymentType
.
Split
&&
payment
.
Type
!=
PaymentType
.
Cash
&&
payment
.
Type
!=
PaymentType
.
AliPay
&&
payment
.
Type
!=
PaymentType
.
WeChat
&&
payment
.
Type
!=
PaymentType
.
Pos
)
throw
new
Exception
(
"不支持收款充值操作类型!"
);
if
(
payment
.
Type
!=
PaymentType
.
UnBiz
&&
payment
.
Type
!=
PaymentType
.
Refund
&&
payment
.
Type
!=
PaymentType
.
Split
&&
payment
.
Type
!=
PaymentType
.
Assign
&&
payment
.
Type
!=
PaymentType
.
Cash
&&
payment
.
Type
!=
PaymentType
.
AliPay
&&
payment
.
Type
!=
PaymentType
.
WeChat
&&
payment
.
Type
!=
PaymentType
.
Pos
)
throw
new
Exception
(
"不支持收款充值操作类型!"
);
if
(
payment
.
Amount
-
payment
.
AmountUsed
<
Amount
)
throw
new
Exception
(
$"此到账可使用金额不足,仅剩:
{
payment
.
Amount
-
payment
.
AmountUsed
}
元"
);
var
accountPayee
=
conn
.
SingleById
<
Account
>(
AccountKvid
);
...
...
@@ -90,6 +90,7 @@ namespace Kivii.Finances.Transforms
rtns
.
Results
.
Add
(
transfer
);
accountDetails
.
ForEach
(
o
=>
o
.
Insert
(
conn
));
payment
.
RecalculateAmountUsed
(
conn
);
//重新计算AmountUsed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if
(
payment
.
Type
==
PaymentType
.
Split
)
payment
.
RecalculateAssignAmount
(
conn
);
//if (parentPayment != null) conn.UpdateOnly(parentPayment);
foreach
(
var
item
in
pays
)
{
...
...
Src/Transforms/RestfulPayment.Split.cs
View file @
fed5068e
This diff is collapsed.
Click to expand it.
Src/Transforms/RestfulPayment.cs
View file @
fed5068e
...
...
@@ -3,6 +3,7 @@ using Kivii.Linq;
using
Kivii.Web
;
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
...
...
@@ -55,7 +56,7 @@ namespace Kivii.Finances.Transforms
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
AliPay
,
PaymentType
.
WeChat
,
PaymentType
.
Bank
,
PaymentType
.
Cash
,
PaymentType
.
Pos
));
if
(
OwnerType
==
OwnerType
.
Organization
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
OrganizationKvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Department
)
sqlExpress
.
And
(
o
=>
Sql
.
In
(
o
.
OwnerKvid
,
KiviiContext
.
CurrentMember
.
DepartmentKvids
)
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Department
)
sqlExpress
.
And
(
o
=>
Sql
.
In
(
o
.
OwnerKvid
,
KiviiContext
.
CurrentMember
.
DepartmentKvids
)
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Member
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
Kvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
IsSplit
!=
null
)
{
...
...
@@ -112,7 +113,7 @@ namespace Kivii.Finances.Transforms
var
request
=
new
RestfulQuery
<
Payment
>();
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
AliPay
,
PaymentType
.
WeChat
,
PaymentType
.
Split
,
PaymentType
.
Cash
,
PaymentType
.
Pos
));
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
AliPay
,
PaymentType
.
WeChat
,
PaymentType
.
Split
,
PaymentType
.
Assign
,
PaymentType
.
Cash
,
PaymentType
.
Pos
));
sqlExpress
.
And
(
o
=>
o
.
AmountUsed
==
0
||
o
.
AmountUsed
<
o
.
Amount
);
var
queryAccount
=
conn
.
From
<
Account
>();
queryAccount
.
Where
(
o
=>
o
.
OrganizationKvid
==
KiviiContext
.
CurrentMember
.
OrganizationKvid
&&
Sql
.
In
(
o
.
Type
,
AccountType
.
Balance
,
AccountType
.
Cash
,
AccountType
.
Pos
));
...
...
@@ -158,7 +159,7 @@ namespace Kivii.Finances.Transforms
var
request
=
new
RestfulQuery
<
Payment
>();
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
AliPay
,
PaymentType
.
WeChat
,
PaymentType
.
Cash
,
PaymentType
.
Pos
,
PaymentType
.
Split
));
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
AliPay
,
PaymentType
.
WeChat
,
PaymentType
.
Cash
,
PaymentType
.
Pos
,
PaymentType
.
Assign
,
PaymentType
.
Split
));
sqlExpress
.
And
(
o
=>
o
.
AmountInvoice
<=
0
||
o
.
AmountInvoice
<
o
.
Amount
);
var
queryInvoiceApplyRelations
=
conn
.
From
<
InvoiceApply
>();
...
...
@@ -203,7 +204,7 @@ namespace Kivii.Finances.Transforms
var
request
=
new
RestfulQuery
<
Payment
>();
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
AliPay
,
PaymentType
.
WeChat
,
PaymentType
.
Split
,
PaymentType
.
Cash
,
PaymentType
.
Pos
)
&&
o
.
AmountInvoice
<
o
.
Amount
);
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
AliPay
,
PaymentType
.
WeChat
,
PaymentType
.
Split
,
PaymentType
.
Assign
,
PaymentType
.
Cash
,
PaymentType
.
Pos
)
&&
o
.
AmountInvoice
<
o
.
Amount
);
var
queryAccount
=
conn
.
From
<
Account
>();
queryAccount
.
Where
(
o
=>
o
.
OrganizationKvid
==
KiviiContext
.
CurrentMember
.
OrganizationKvid
&&
Sql
.
In
(
o
.
Type
,
AccountType
.
Balance
,
AccountType
.
Cash
,
AccountType
.
Pos
));
...
...
@@ -279,6 +280,8 @@ namespace Kivii.Finances.Transforms
public
OwnerType
OwnerType
{
get
;
set
;
}
=
OwnerType
.
Unsupport
;
public
bool
?
IsBiz
{
get
;
set
;
}
//Split,Pos,Cash,WeChat..
public
bool
?
IsAssign
{
get
;
set
;
}
//是否被划转
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Payment
>();
...
...
@@ -291,9 +294,14 @@ namespace Kivii.Finances.Transforms
if
(
OwnerType
==
OwnerType
.
Organization
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
OrganizationKvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Department
)
sqlExpress
.
And
(
o
=>
Sql
.
In
(
o
.
OwnerKvid
,
KiviiContext
.
CurrentMember
.
DepartmentKvids
)
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
OwnerType
==
OwnerType
.
Member
)
sqlExpress
.
And
(
o
=>
o
.
OwnerKvid
==
KiviiContext
.
CurrentMember
.
Kvid
||
o
.
OwnerKvid
==
Guid
.
Empty
);
if
(
IsBiz
==
null
)
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
WeChat
,
PaymentType
.
Cash
,
PaymentType
.
AliPay
,
PaymentType
.
Pos
,
PaymentType
.
Split
,
PaymentType
.
Refund
,
PaymentType
.
UnBiz
));
else
if
(
IsBiz
.
Value
)
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
WeChat
,
PaymentType
.
Cash
,
PaymentType
.
AliPay
,
PaymentType
.
Pos
,
PaymentType
.
Split
));
if
(
IsBiz
==
null
)
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
WeChat
,
PaymentType
.
Cash
,
PaymentType
.
AliPay
,
PaymentType
.
Pos
,
PaymentType
.
Split
,
PaymentType
.
Assign
,
PaymentType
.
Refund
,
PaymentType
.
UnBiz
));
else
if
(
IsBiz
.
Value
)
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
WeChat
,
PaymentType
.
Cash
,
PaymentType
.
AliPay
,
PaymentType
.
Pos
,
PaymentType
.
Split
,
PaymentType
.
Assign
));
else
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
Refund
,
PaymentType
.
UnBiz
));
if
(
IsAssign
!=
null
)
{
if
(
IsAssign
.
Value
)
sqlExpress
.
And
(
o
=>
o
.
AmountSplited
>
0
&&
o
.
Type
!=
PaymentType
.
Assign
);
else
sqlExpress
.
And
(
o
=>
o
.
AmountSplited
==
0
&&
o
.
Type
!=
PaymentType
.
Assign
);
}
var
rtns
=
autoQuery
.
Execute
(
Request
,
conn
,
request
,
sqlExpress
);
return
rtns
;
}
...
...
@@ -322,6 +330,9 @@ namespace Kivii.Finances.Transforms
#
endregion
public
Guid
CurrentKvid
{
get
;
set
;
}
public
bool
IncludeAssign
{
get
;
set
;
}
//查看当前使用情况时是否要包含当前项目子项的使用情况(如果存在的话)
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Payment
>();
...
...
@@ -332,8 +343,20 @@ namespace Kivii.Finances.Transforms
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Where
(
o
=>
Sql
.
In
(
o
.
Type
,
PaymentType
.
Transfer
,
PaymentType
.
DynamicPay
));
if
(
IncludeAssign
&&
CurrentKvid
!=
Guid
.
Empty
)
{
var
queryAssign
=
conn
.
From
<
Payment
>();
queryAssign
.
Where
(
o
=>
o
.
ParentKvid
==
CurrentKvid
&&
o
.
OffsetKvid
==
Guid
.
Empty
&&
o
.
Type
==
PaymentType
.
Assign
);
queryAssign
.
Select
(
o
=>
o
.
Kvid
);
var
kvids
=
conn
.
Select
<
Guid
>(
queryAssign
);
if
(
kvids
.
IsNullOrEmpty
())
kvids
=
new
List
<
Guid
>();
kvids
.
Add
(
CurrentKvid
);
sqlExpress
.
And
(
o
=>
Sql
.
In
(
o
.
ParentKvid
,
kvids
));
}
var
rtns
=
autoQuery
.
Execute
(
Request
,
conn
,
request
,
sqlExpress
);
return
rtns
;
}
}
}
Src/Transforms/RestfulSettlement.Offset.cs
View file @
fed5068e
...
...
@@ -26,7 +26,7 @@ namespace Kivii.Finances.Transforms
var
settlements
=
connF
.
Select
<
Settlement
>(
o
=>
Sql
.
In
(
o
.
Kvid
,
Kvids
));
(
settlements
.
Count
!=
Kvids
.
Count
).
ThrowIfTrue
(
"所选结算和查询结果不一致!"
);
settlements
.
Exists
(
o
=>
o
.
OffsetKvid
!=
Guid
.
Empty
).
ThrowIfTrue
(
"存在已作废结算,无法重复作废"
);
settlements
.
Exists
(
o
=>
o
.
AmountPayment
<=
0
).
ThrowIfTrue
(
"作废错误:作废的结算中包含未收款的结算!"
);
//
settlements.Exists(o => o.AmountPayment <= 0).ThrowIfTrue("作废错误:作废的结算中包含未收款的结算!");
var
policyRecords
=
connF
.
Select
<
PolicyRecord
>(
o
=>
Sql
.
In
(
o
.
SettlementKvid
,
Kvids
));
//connF.Exists<Settlement>(o => o.AmountPayment != o.Amount && Sql.In(o.Kvid, Kvids)).ThrowIfTrue("作废错误:作废的结算中包含未收款的结算!");
////如果泛型类型不是Settlement本身就需要判断
...
...
Src/Transforms/Statistics/RestfulPayment.Statistic.cs
View file @
fed5068e
...
...
@@ -97,6 +97,7 @@ namespace Kivii.Finances.Transforms
public
DateTime
EndTime
{
get
;
set
;
}
public
bool
IsOperated
{
get
;
set
;
}
//如果True则查询OperateTime否则默认CreateTime
//public bool IsTest { get; set; }
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
...
...
@@ -119,7 +120,8 @@ namespace Kivii.Finances.Transforms
var
sqlExpress
=
conn
.
From
<
Payment
>();
sqlExpress
.
Where
(
o
=>
o
.
OffsetKvid
==
Guid
.
Empty
&&
Sql
.
In
(
o
.
Type
,
PaymentType
.
WeChat
,
PaymentType
.
Cash
,
PaymentType
.
AliPay
,
PaymentType
.
Pos
,
PaymentType
.
Split
));
sqlExpress
.
And
(
o
=>
o
.
CreateTime
>=
beginTime
&&
o
.
CreateTime
<
endTime
);
if
(
IsOperated
)
sqlExpress
.
And
(
o
=>
o
.
OperateTime
>=
beginTime
&&
o
.
OperateTime
<
endTime
);
else
sqlExpress
.
And
(
o
=>
o
.
CreateTime
>=
beginTime
&&
o
.
CreateTime
<
endTime
);
if
(!
OwnerKvids
.
IsNullOrEmpty
())
sqlExpress
.
And
(
o
=>
Sql
.
In
(
o
.
OwnerKvid
,
OwnerKvids
));
sqlExpress
.
And
(
o
=>
(
Sql
.
In
(
o
.
PayerAccountKvid
,
queryAccount
)));
sqlExpress
.
OrderBy
(
o
=>
o
.
OwnerName
);
...
...
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