Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Third.Finances.Seeyon.V4.5
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.Third.Finances.Seeyon.V4.5
Commits
db2418b8
Commit
db2418b8
authored
Oct 16, 2023
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
0f8e711c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
172 additions
and
37 deletions
+172
-37
ApplyExtension.cs
Src/ApplyExtension.cs
+130
-15
BillApply.cs
Src/Entities/BillApply.cs
+42
-22
No files found.
Src/ApplyExtension.cs
View file @
db2418b8
...
@@ -38,22 +38,62 @@ namespace Kivii.Finances.Seeyon.Extensions
...
@@ -38,22 +38,62 @@ namespace Kivii.Finances.Seeyon.Extensions
//var settlementType = "code|MonthlySettlement";//默认月结
//var settlementType = "code|MonthlySettlement";//默认月结
rtns
.
业务类型
=
typeof
(
BillApply
).
FullName
;
rtns
.
业务类型
=
typeof
(
BillApply
).
FullName
;
rtns
.
业务编号
=
apply
.
Kvid
.
ToString
();
rtns
.
业务编号
=
apply
.
Kvid
.
ToString
();
rtns
.
单据编号
=
apply
.
SerialNumber
;
rtns
.
编号
=
apply
.
SerialNumber
;
rtns
.
日期
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd"
);
rtns
.
借票日期
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd"
);
rtns
.
所属部门
=
KiviiContext
.
CurrentMember
.
DepartmentName
;
rtns
.
借票科室
=
KiviiContext
.
CurrentMember
.
DepartmentName
;
rtns
.
经办人
=
apply
.
OperatorName
;
rtns
.
借票人
=
KiviiContext
.
CurrentMember
.
FullName
;
rtns
.
付款单位名称
=
apply
.
PayerName
;
rtns
.
借票总额
=
apply
.
Amount
.
ToString
();
rtns
.
纳税人识别号
=
apply
.
PayerTaxNumber
;
rtns
.
地址电话
=
$"
{
apply
.
PayerCompanyAddress
}{
apply
.
PayerPhone
}
"
;
rtns
.
开户行及账号
=
$"
{
apply
.
PayerRegisteredBank
}{
apply
.
PayerBankAccount
}
"
;
rtns
.
发票类型
=
apply
.
Type
==
"增值税专用发票"
?
"-4189929216282050282"
:
"4529935671729733794"
;
rtns
.
申请原因
=
apply
.
Remark
;
rtns
.
数量
=
"1"
;
rtns
.
金额
=
apply
.
Amount
.
ToString
();
return
rtns
;
return
rtns
;
}
}
public
static
ResponseForm
<
ResponseData
>
RequestBillForm
(
this
JsonServiceClient
client
,
Form_InvoiceApply
form
,
IAuthSession
session
)
public
static
List
<
Form_InvoiceApplyDetail
>
ConvertToFormDetail
(
this
InvoiceApply
apply
)
{
var
rtns
=
new
List
<
Form_InvoiceApplyDetail
>();
var
index
=
1
;
var
detail
=
new
Form_InvoiceApplyDetail
();
detail
.
序号
1
=
index
!=
-
1
?
index
.
ToString
()
:
"0"
;
detail
.
单位名称
=
apply
.
PayerName
;
detail
.
金额
=
apply
.
Amount
.
ToString
();
rtns
.
Add
(
detail
);
return
rtns
;
}
public
static
Form_InvoiceApply
ConvertToForm
(
this
List
<
InvoiceApply
>
applys
)
{
var
bizKvids
=
applys
.
ConvertAll
(
o
=>
o
.
Kvid
);
var
strBizKvids
=
string
.
Join
(
","
,
bizKvids
);
var
amount
=
applys
.
Sum
(
o
=>
o
.
Amount
);
var
rtns
=
new
Form_InvoiceApply
();
//var settlementType = "code|MonthlySettlement";//默认月结
rtns
.
业务类型
=
typeof
(
BillApply
).
FullName
;
rtns
.
业务编号
=
strBizKvids
;
//rtns.编号 = applys.SerialNumber;
rtns
.
借票日期
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd"
);
rtns
.
借票科室
=
KiviiContext
.
CurrentMember
.
DepartmentName
;
rtns
.
借票人
=
KiviiContext
.
CurrentMember
.
FullName
;
rtns
.
借票总额
=
amount
.
ToString
();
rtns
.
借票总额人民币
=
amount
.
ConvertToChinese
();
return
rtns
;
}
public
static
List
<
Form_InvoiceApplyDetail
>
ConvertToFormDetail
(
this
List
<
InvoiceApply
>
applys
)
{
var
rtns
=
new
List
<
Form_InvoiceApplyDetail
>();
foreach
(
var
item
in
applys
)
{
var
index
=
applys
.
FindIndex
(
o
=>
o
.
Kvid
==
item
.
Kvid
);
var
detail
=
new
Form_InvoiceApplyDetail
();
detail
.
序号
1
=
index
!=
-
1
?
index
.
ToString
()
:
"0"
;
detail
.
单位名称
=
item
.
PayerName
;
detail
.
金额
=
item
.
Amount
.
ToString
();
rtns
.
Add
(
detail
);
}
return
rtns
;
}
public
static
ResponseForm
<
ResponseData
>
RequestBillForm
(
this
JsonServiceClient
client
,
Form_InvoiceApply
form
,
List
<
Form_InvoiceApplyDetail
>
details
,
IAuthSession
session
)
{
{
if
(
client
==
null
)
throw
new
ArgumentNullException
(
"client"
);
if
(
client
==
null
)
throw
new
ArgumentNullException
(
"client"
);
if
(
form
==
null
)
throw
new
ArgumentNullException
(
"form"
);
if
(
form
==
null
)
throw
new
ArgumentNullException
(
"form"
);
...
@@ -66,10 +106,85 @@ namespace Kivii.Finances.Seeyon.Extensions
...
@@ -66,10 +106,85 @@ namespace Kivii.Finances.Seeyon.Extensions
//request.data.senderLoginName = token.bindingUser.loginName;
//request.data.senderLoginName = token.bindingUser.loginName;
request
.
data
.
subject
=
$"预借发票申请(
{
token
.
bindingUser
.
name
}
{
DateTime
.
Now
:
yyyy
-
MM
-
dd
HH
:
mm
}
)"
;
request
.
data
.
subject
=
$"预借发票申请(
{
token
.
bindingUser
.
name
}
{
DateTime
.
Now
:
yyyy
-
MM
-
dd
HH
:
mm
}
)"
;
request
.
data
.
data
=
new
RequestForm_InvoiceApply
();
request
.
data
.
data
=
new
RequestForm_InvoiceApply
();
request
.
data
.
data
.
formmain_0318
=
new
Form_InvoiceApply
();
request
.
data
.
data
.
formmain_0171
=
new
Form_InvoiceApply
();
request
.
data
.
data
.
formmain_0318
=
form
;
request
.
data
.
data
.
formmain_0171
=
form
;
request
.
data
.
data
.
formson_0172
=
new
List
<
Form_InvoiceApplyDetail
>();
request
.
data
.
data
.
formson_0172
=
details
;
var
rtns
=
client
.
Post
<
ResponseForm
<
ResponseData
>>(
$"
{
Configs
.
RouteRequestForm
}
?token=
{
token
.
id
}
"
,
request
);
var
rtns
=
client
.
Post
<
ResponseForm
<
ResponseData
>>(
$"
{
Configs
.
RouteRequestForm
}
?token=
{
token
.
id
}
"
,
request
);
return
rtns
;
return
rtns
;
}
}
public
static
string
ConvertToChinese
(
this
decimal
Num
)
{
string
[]
DX_SZ
=
{
"零"
,
"壹"
,
"贰"
,
"叁"
,
"肆"
,
"伍"
,
"陆"
,
"柒"
,
"捌"
,
"玖"
,
"拾"
};
//大写数字
string
[]
DX_DW
=
{
"元"
,
"拾"
,
"佰"
,
"仟"
,
"万"
,
"拾"
,
"佰"
,
"仟"
,
"亿"
,
"拾"
,
"佰"
,
"仟"
,
"万"
};
string
[]
DX_XSDS
=
{
"角"
,
"分"
};
//大些小数单位
if
(
Num
==
0
)
return
DX_SZ
[
0
];
Boolean
IsXS_bool
=
false
;
//是否小数
string
NumStr
;
//整个数字字符串
string
NumStr_Zs
;
//整数部分
string
NumSr_Xs
=
""
;
//小数部分
string
NumStr_R
=
""
;
//返回的字符串
NumStr
=
Num
.
ToString
();
NumStr_Zs
=
NumStr
;
if
(
NumStr_Zs
.
Contains
(
"."
))
{
NumStr
=
Math
.
Round
(
Num
,
2
).
ToString
();
NumStr_Zs
=
NumStr
.
Substring
(
0
,
NumStr
.
IndexOf
(
"."
));
NumSr_Xs
=
NumStr
.
Substring
((
NumStr
.
IndexOf
(
"."
)
+
1
),
(
NumStr
.
Length
-
NumStr
.
IndexOf
(
"."
)
-
1
));
IsXS_bool
=
true
;
}
int
k
=
0
;
Boolean
IsZeor
=
false
;
//整数中间连续0的情况
for
(
int
i
=
0
;
i
<
NumStr_Zs
.
Length
;
i
++)
//整数
{
int
j
=
int
.
Parse
(
NumStr_Zs
.
Substring
(
i
,
1
));
if
(
j
!=
0
)
{
NumStr_R
+=
DX_SZ
[
j
]
+
DX_DW
[
NumStr_Zs
.
Length
-
i
-
1
];
IsZeor
=
false
;
//没有连续0
}
else
if
(
j
==
0
)
{
k
++;
if
(!
IsZeor
&&
!(
NumStr_Zs
.
Length
==
i
+
1
))
//等于0不是最后一位,连续0取一次
{
//有问题
if
(
NumStr_Zs
.
Length
-
i
-
1
>=
4
&&
NumStr_Zs
.
Length
-
i
-
1
<=
6
)
NumStr_R
+=
DX_DW
[
4
]
+
"零"
;
else
if
(
NumStr_Zs
.
Length
-
i
-
1
>
7
)
NumStr_R
+=
DX_DW
[
8
]
+
"零"
;
else
NumStr_R
+=
"零"
;
IsZeor
=
true
;
}
if
(
NumStr_Zs
.
Length
==
i
+
1
)
// 等于0且是最后一位 变成 XX元整
NumStr_R
+=
DX_DW
[
NumStr_Zs
.
Length
-
i
-
1
];
}
}
if
(
NumStr_Zs
.
Length
>
2
&&
k
==
NumStr_Zs
.
Length
-
1
)
NumStr_R
=
NumStr_R
.
Remove
(
NumStr_R
.
IndexOf
(
'零'
),
1
);
//比如1000,10000元整的情况下 去0
if
(!
IsXS_bool
)
return
NumStr_R
+
"整"
;
//如果没有小数就返回
else
{
for
(
int
i
=
0
;
i
<
NumSr_Xs
.
Length
;
i
++)
{
int
j
=
int
.
Parse
(
NumSr_Xs
.
Substring
(
i
,
1
));
NumStr_R
+=
DX_SZ
[
j
]
+
DX_XSDS
[
NumSr_Xs
.
Length
-
i
-
1
];
}
}
return
NumStr_R
;
}
}
}
}
}
Src/Entities/BillApply.cs
View file @
db2418b8
...
@@ -142,10 +142,11 @@ namespace Kivii.Finances.Seeyon.Entities
...
@@ -142,10 +142,11 @@ namespace Kivii.Finances.Seeyon.Entities
apply
.
ThrowIfNull
(
"未找到此业务信息!"
);
apply
.
ThrowIfNull
(
"未找到此业务信息!"
);
if
(
apply
.
Status
>
(
int
)
InvoiceApplyStatus
.
ProcessAdoption
)
throw
new
Exception
(
"当前账单借票非待审批状态,无法申请审批!"
);
if
(
apply
.
Status
>
(
int
)
InvoiceApplyStatus
.
ProcessAdoption
)
throw
new
Exception
(
"当前账单借票非待审批状态,无法申请审批!"
);
var
applyForm
=
apply
.
ConvertToForm
();
var
applyForm
=
apply
.
ConvertToForm
();
var
applyFormDetail
=
apply
.
ConvertToFormDetail
();
var
session
=
KiviiContext
.
Request
.
GetSession
();
var
session
=
KiviiContext
.
Request
.
GetSession
();
var
client
=
new
JsonServiceClient
(
Configs
.
BaseUrl
);
var
client
=
new
JsonServiceClient
(
Configs
.
BaseUrl
);
var
resp
=
client
.
RequestBillForm
(
applyForm
,
session
);
var
resp
=
client
.
RequestBillForm
(
applyForm
,
applyFormDetail
,
session
);
if
(
resp
.
code
!=
"0"
)
throw
new
Exception
(
$"OA接口调用失败,原因:
{
resp
.
message
}
"
);
if
(
resp
.
code
!=
"0"
)
throw
new
Exception
(
$"OA接口调用失败,原因:
{
resp
.
message
}
"
);
apply
.
BizId
=
resp
.
data
.
subject
;
apply
.
BizId
=
resp
.
data
.
subject
;
apply
.
AddOnlyProperties
(
o
=>
o
.
BizId
);
apply
.
AddOnlyProperties
(
o
=>
o
.
BizId
);
...
@@ -180,12 +181,13 @@ namespace Kivii.Finances.Seeyon.Entities
...
@@ -180,12 +181,13 @@ namespace Kivii.Finances.Seeyon.Entities
var
groupPayer
=
applys
.
GroupBy
(
a
=>
a
.
PayerName
);
var
groupPayer
=
applys
.
GroupBy
(
a
=>
a
.
PayerName
);
if
(
groupPayer
.
Count
()
!=
1
)
throw
new
Exception
(
"不允许多个借票抬头同时申请!"
);
if
(
groupPayer
.
Count
()
!=
1
)
throw
new
Exception
(
"不允许多个借票抬头同时申请!"
);
var
applySum
=
new
InvoiceApply
();
//
var applySum = new InvoiceApply();
applySum
.
PopulateWith
(
applys
[
0
]);
//
applySum.PopulateWith(applys[0]);
applySum
.
Amount
=
applys
.
Sum
(
a
=>
a
.
Amount
);
//
applySum.Amount = applys.Sum(a => a.Amount);
applySum
.
Remark
=
applys
[
0
].
Remark
;
//
applySum.Remark = applys[0].Remark;
var
applyForm
=
applySum
.
ConvertToForm
();
var
applyForm
=
applys
.
ConvertToForm
();
var
applyFormDetail
=
applys
.
ConvertToFormDetail
();
var
bizKvids
=
applys
.
ConvertAll
(
o
=>
o
.
Kvid
);
var
bizKvids
=
applys
.
ConvertAll
(
o
=>
o
.
Kvid
);
var
strBizKvids
=
string
.
Join
(
","
,
bizKvids
);
var
strBizKvids
=
string
.
Join
(
","
,
bizKvids
);
...
@@ -194,7 +196,7 @@ namespace Kivii.Finances.Seeyon.Entities
...
@@ -194,7 +196,7 @@ namespace Kivii.Finances.Seeyon.Entities
var
session
=
KiviiContext
.
Request
.
GetSession
();
var
session
=
KiviiContext
.
Request
.
GetSession
();
var
client
=
new
JsonServiceClient
(
Configs
.
BaseUrl
);
var
client
=
new
JsonServiceClient
(
Configs
.
BaseUrl
);
var
resp
=
client
.
RequestBillForm
(
applyForm
,
session
);
var
resp
=
client
.
RequestBillForm
(
applyForm
,
applyFormDetail
,
session
);
if
(
resp
.
code
!=
"0"
)
throw
new
Exception
(
$"OA接口调用失败,原因:
{
resp
.
message
}
"
);
if
(
resp
.
code
!=
"0"
)
throw
new
Exception
(
$"OA接口调用失败,原因:
{
resp
.
message
}
"
);
var
rtns
=
new
RestfulUpdateResponse
<
InvoiceApply
>();
var
rtns
=
new
RestfulUpdateResponse
<
InvoiceApply
>();
rtns
.
Results
=
new
List
<
InvoiceApply
>();
rtns
.
Results
=
new
List
<
InvoiceApply
>();
...
@@ -213,10 +215,10 @@ namespace Kivii.Finances.Seeyon.Entities
...
@@ -213,10 +215,10 @@ namespace Kivii.Finances.Seeyon.Entities
_log
.
Type
=
"流转"
;
_log
.
Type
=
"流转"
;
_log
.
Summary
=
$"提交了账单借票,审批将在OA执行"
;
_log
.
Summary
=
$"提交了账单借票,审批将在OA执行"
;
conn
.
Insert
(
_log
);
conn
.
Insert
(
_log
);
rtns
.
Results
.
Add
(
apply
);
rtns
.
Results
.
Add
(
apply
);
}
}
return
rtns
;
return
rtns
;
}
}
...
@@ -227,7 +229,8 @@ namespace Kivii.Finances.Seeyon.Entities
...
@@ -227,7 +229,8 @@ namespace Kivii.Finances.Seeyon.Entities
public
class
RequestForm_InvoiceApply
public
class
RequestForm_InvoiceApply
{
{
public
Form_InvoiceApply
formmain_0318
{
get
;
set
;
}
public
Form_InvoiceApply
formmain_0171
{
get
;
set
;
}
public
List
<
Form_InvoiceApplyDetail
>
formson_0172
{
get
;
set
;
}
}
}
public
class
Form_InvoiceApply
public
class
Form_InvoiceApply
{
{
...
@@ -243,26 +246,43 @@ namespace Kivii.Finances.Seeyon.Entities
...
@@ -243,26 +246,43 @@ namespace Kivii.Finances.Seeyon.Entities
/// <summary>
/// <summary>
/// 单据编号
/// 单据编号
/// </summary>
/// </summary>
public
string
单据编号
{
get
;
set
;
}
public
string
编号
{
get
;
set
;
}
public
string
借票人
{
get
;
set
;
}
public
string
借票科室
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 格式:2023-10-11
/// 格式:2023-10-11
/// </summary>
/// </summary>
public
string
日期
{
get
;
set
;
}
public
string
借票
日期
{
get
;
set
;
}
public
string
所属部门
{
get
;
set
;
}
public
string
借票总额
{
get
;
set
;
}
public
string
经办人
{
get
;
set
;
}
public
string
付款单位名称
{
get
;
set
;
}
public
string
纳税人识别号
{
get
;
set
;
}
public
string
地址电话
{
get
;
set
;
}
public
string
开户行及账号
{
get
;
set
;
}
/// <summary>
/// <summary>
///
发票类型{普通:4529935671729733794 专票:-4189929216282050282}
///
金额大写
/// </summary>
/// </summary>
public
string
发票类型
{
get
;
set
;
}
public
string
借票总额人民币
{
get
;
set
;
}
public
string
申请原因
{
get
;
set
;
}
public
string
数量
{
get
;
set
;
}
//public string 付款单位名称 { get; set; }
//public string 纳税人识别号 { get; set; }
//public string 地址电话 { get; set; }
//public string 开户行及账号 { get; set; }
///// <summary>
///// 发票类型{普通:4529935671729733794 专票:-4189929216282050282}
///// </summary>
//public string 发票类型 { get; set; }
//public string 申请原因 { get; set; }
//public string 数量 { get; set; }
}
public
class
Form_InvoiceApplyDetail
{
public
string
序号
1
{
get
;
set
;
}
public
string
单位名称
{
get
;
set
;
}
public
string
金额
{
get
;
set
;
}
public
string
金额
{
get
;
set
;
}
}
}
}
}
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