Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
financial-system
Project
Project
Details
Activity
Releases
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
xianyang
financial-system
Commits
d1b46b71
Commit
d1b46b71
authored
Apr 17, 2023
by
xupeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/development' into development
parents
dc28ee88
a0192c8a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
24 deletions
+27
-24
crud.py
app/api/account/crud.py
+13
-15
schemas.py
app/api/account/schemas.py
+4
-3
views.py
app/api/account/views.py
+8
-4
crud.py
app/api/export/crud.py
+2
-2
No files found.
app/api/account/crud.py
View file @
d1b46b71
...
...
@@ -282,36 +282,34 @@ def get_account_type(**data):
return
[],
0
def
update_account_type
(
d
b
:
Session
,
d
ata
):
def
update_account_type
(
data
):
"""修改账目类型"""
try
:
db
.
query
(
AccountType
)
.
filter
(
AccountType
.
id
==
data
.
id
)
.
update
({
AccountType
.
key_name
:
data
.
key_name
,
AccountType
.
key_value
:
data
.
key_value
,
AccountType
.
type
:
data
.
type
})
db
.
commit
()
sql
=
f
"update fi_account_type set keyName='{data.keyName}', keyValue='{data.keyValue}',type={data.type} where id = {data.id}"
LinkMysql
(
env
.
DB_3YV2
)
.
perform_mysql
(
sql
)
return
True
except
Exception
as
e
:
print
(
e
)
return
False
def
get_account_type_value
(
db
:
Session
,
key
,
type
):
def
get_account_type_value
(
key
,
type
):
"""新建类型 查询是否有重复数据"""
return
db
.
query
(
AccountType
)
.
filter
(
AccountType
.
key_value
==
key
,
AccountType
.
type
==
type
)
.
first
()
sql
=
f
"select id from fi_account_type where keyValue='{key}' and type={type}"
res_data
=
LinkMysql
(
env
.
DB_3YV2
)
.
query_mysql
(
sql
)
return
res_data
def
create_type
(
d
b
:
Session
,
d
ata
):
def
create_type
(
data
):
"""创建新账目类型"""
try
:
db_type
=
AccountType
(
key_name
=
data
.
key_name
,
key_value
=
data
.
key_value
,
type
=
data
.
type
,
create_time
=
datetime
.
now
())
db
.
add
(
db_type
)
db
.
commit
()
db
.
refresh
(
db_type
)
create_time
=
get_now_timestamp
()
ins_sql
=
f
"insert into fi_account_type(keyName, keyValue, createTime, type) values('{data.keyName}', '{data.keyValue}', {create_time}, {data.type});"
res_data
=
LinkMysql
(
env
.
DB_3YV2
)
.
perform_mysql
(
ins_sql
)
except
Exception
as
e
:
print
(
e
)
return
{}
return
db_type
return
res_data
def
out_income_combine
(
data
):
...
...
@@ -403,7 +401,7 @@ class AccountStatistics(object):
"""公共查询条件判断"""
public_list
=
[]
if
self
.
gift_type
:
public_list
.
append
(
f
" reference_type =
{self.gift_type}
"
)
public_list
.
append
(
f
" reference_type =
'{self.gift_type}'
"
)
if
self
.
type
or
self
.
type
==
0
:
public_list
.
append
(
f
" type={self.type}"
)
if
self
.
start_time
:
...
...
app/api/account/schemas.py
View file @
d1b46b71
...
...
@@ -67,9 +67,10 @@ class AccountTypeList(AccountTypeUpdate):
class
CreateType
(
BaseModel
):
key_name
:
str
key_value
:
str
type
:
int
id
:
Optional
[
int
]
=
None
keyName
:
Optional
[
str
]
=
None
keyValue
:
Optional
[
str
]
=
None
type
:
Optional
[
int
]
=
None
class
Recovery_fix
(
PublicModel
):
...
...
app/api/account/views.py
View file @
d1b46b71
...
...
@@ -132,9 +132,11 @@ def finance_fix(page: int,
@
router
.
post
(
"/type/update"
)
def
finance_fix
(
data
:
schemas
.
AccountTypeList
,
token
=
Depends
(
login_required
),
db
:
Session
=
Depends
(
get_db
)):
def
finance_fix
(
data
:
schemas
.
CreateType
,
token
=
Depends
(
login_required
),
db
:
Session
=
Depends
(
get_db
)):
"""出入账目类型修改"""
res
=
crud
.
update_account_type
(
db
,
data
)
if
not
all
([
data
.
keyName
,
data
.
keyValue
])
or
data
.
type
is
None
:
return
HttpResultResponse
(
code
=
500
,
msg
=
"缺少必传参数"
)
res
=
crud
.
update_account_type
(
data
)
if
res
:
return
HttpResultResponse
()
return
HttpResultResponse
(
code
=
422
,
msg
=
'修改失败'
)
...
...
@@ -143,10 +145,12 @@ def finance_fix(data: schemas.AccountTypeList, token=Depends(login_required), db
@
router
.
post
(
"/create/type"
)
def
create_user
(
data
:
schemas
.
CreateType
,
token
=
Depends
(
login_required
),
db
:
Session
=
Depends
(
get_db
)):
"""添加账目类型"""
res_type
=
crud
.
get_account_type_value
(
db
,
data
.
key_value
,
data
.
type
)
if
not
all
([
data
.
keyName
,
data
.
keyValue
])
or
data
.
type
is
None
:
return
HttpResultResponse
(
code
=
500
,
msg
=
"缺少必传参数"
)
res_type
=
crud
.
get_account_type_value
(
data
.
keyValue
,
data
.
type
)
if
res_type
:
return
HttpResultResponse
(
code
=
400
,
msg
=
HttpMessage
.
TYPE_EXIST
)
res
=
crud
.
create_type
(
d
b
,
d
ata
)
res
=
crud
.
create_type
(
data
)
if
not
res
:
return
HttpResultResponse
(
code
=
500
,
msg
=
res
)
return
HttpResultResponse
(
data
=
res
.
id
)
...
...
app/api/export/crud.py
View file @
d1b46b71
...
...
@@ -277,10 +277,10 @@ class ReferenceTypeClassification():
outcome
=
pd
.
DataFrame
(
self
.
outcome
)
ogs
=
outcome
.
groupby
(
"nickname"
)
.
sum
()
for
k
,
v
in
ogs
.
to_dict
()
.
get
(
'money'
)
.
items
():
res_list
.
append
({
"type"
:
"出账"
,
"name"
:
k
,
"money"
:
v
})
res_list
.
append
({
"type"
:
"出账"
,
"name"
:
k
,
"money"
:
round
(
float
(
v
),
3
)
})
if
self
.
income
:
income
=
pd
.
DataFrame
(
self
.
income
)
igs
=
income
.
groupby
(
"nickname"
)
.
sum
()
for
k
,
v
in
igs
.
to_dict
()
.
get
(
'money'
)
.
items
():
res_list
.
append
({
"type"
:
"入账"
,
"name"
:
k
,
"money"
:
v
})
res_list
.
append
({
"type"
:
"入账"
,
"name"
:
k
,
"money"
:
round
(
float
(
v
),
3
)
})
return
res_list
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