Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
71131e04
authored
2020-10-09 17:05:48 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix amount 0.00
1 parent
bd738e36
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
src/apps/doc/ocr/wb.py
src/apps/doc/ocr/wb.py
View file @
71131e0
...
...
@@ -254,6 +254,10 @@ class BSWorkbook(Workbook):
if
isinstance
(
rows
[
consts
.
INCOME_IDX
]
.
value
,
str
):
rows
[
consts
.
OUTLAY_IDX
]
.
value
=
rows
[
consts
.
INCOME_IDX
]
.
value
.
translate
(
consts
.
TRANS
)
amount_cell
.
value
=
locale
.
atof
(
rows
[
consts
.
OUTLAY_IDX
]
.
value
)
if
amount_cell
.
value
==
0
:
raise
elif
amount_cell
.
value
<
0
:
amount_cell
.
value
=
-
amount_cell
.
value
except
Exception
as
e
:
if
isinstance
(
rows
[
consts
.
OUTLAY_IDX
]
.
value
,
str
):
rows
[
consts
.
OUTLAY_IDX
]
.
value
=
rows
[
consts
.
OUTLAY_IDX
]
.
value
.
translate
(
consts
.
TRANS
)
...
...
@@ -313,18 +317,18 @@ class BSWorkbook(Workbook):
# }
for
card
,
summary
in
bs_summary
.
items
():
# 1.原表修剪、排列、按照月份分割
start_date
=
summary
[
'start_date'
]
end_date
=
summary
[
'end_date'
]
start_date
=
summary
.
get
(
'start_date'
)
end_date
=
summary
.
get
(
'end_date'
)
date_statistics
=
False
if
start_date
is
None
or
end_date
is
None
:
date_statistics
=
True
date_list
=
[]
month_mapping
=
{}
reverse_trend_list
=
[]
for
sheet
in
summary
[
'sheet'
]
:
for
sheet
in
summary
.
get
(
'sheet'
,
[])
:
ws
=
self
.
get_sheet_by_name
(
sheet
)
# 1.1.删除多余列、排列
min_row
=
self
.
sheet_prune
(
ws
,
summary
[
'classify'
]
)
min_row
=
self
.
sheet_prune
(
ws
,
summary
.
get
(
'classify'
,
0
)
)
# 1.2.按月份分割
self
.
sheet_split
(
ws
,
month_mapping
,
reverse_trend_list
,
min_row
,
date_list
,
date_statistics
)
...
...
@@ -334,9 +338,9 @@ class BSWorkbook(Workbook):
# 2.元信息提取表
ms
=
self
.
build_meta_sheet
(
card
,
summary
[
'confidence'
]
,
summary
[
'code'
]
,
summary
[
'print_time'
]
,
summary
.
get
(
'confidence'
,
1
)
,
summary
.
get
(
'code'
)
,
summary
.
get
(
'print_time'
)
,
start_date
,
end_date
)
...
...
@@ -349,7 +353,7 @@ class BSWorkbook(Workbook):
self
.
build_month_sheet
(
card
,
month_mapping
,
ms
,
is_reverse
)
# 4.删除原表
for
sheet
in
summary
[
'sheet'
]
:
for
sheet
in
summary
.
get
(
'sheet'
)
:
self
.
remove
(
self
.
get_sheet_by_name
(
sheet
))
def
license_rebuild
(
self
,
license_summary
):
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment