fix amount 0.00
Showing
1 changed file
with
12 additions
and
8 deletions
... | @@ -254,6 +254,10 @@ class BSWorkbook(Workbook): | ... | @@ -254,6 +254,10 @@ class BSWorkbook(Workbook): |
254 | if isinstance(rows[consts.INCOME_IDX].value, str): | 254 | if isinstance(rows[consts.INCOME_IDX].value, str): |
255 | rows[consts.OUTLAY_IDX].value = rows[consts.INCOME_IDX].value.translate(consts.TRANS) | 255 | rows[consts.OUTLAY_IDX].value = rows[consts.INCOME_IDX].value.translate(consts.TRANS) |
256 | amount_cell.value = locale.atof(rows[consts.OUTLAY_IDX].value) | 256 | amount_cell.value = locale.atof(rows[consts.OUTLAY_IDX].value) |
257 | if amount_cell.value == 0: | ||
258 | raise | ||
259 | elif amount_cell.value < 0: | ||
260 | amount_cell.value = -amount_cell.value | ||
257 | except Exception as e: | 261 | except Exception as e: |
258 | if isinstance(rows[consts.OUTLAY_IDX].value, str): | 262 | if isinstance(rows[consts.OUTLAY_IDX].value, str): |
259 | rows[consts.OUTLAY_IDX].value = rows[consts.OUTLAY_IDX].value.translate(consts.TRANS) | 263 | rows[consts.OUTLAY_IDX].value = rows[consts.OUTLAY_IDX].value.translate(consts.TRANS) |
... | @@ -313,18 +317,18 @@ class BSWorkbook(Workbook): | ... | @@ -313,18 +317,18 @@ class BSWorkbook(Workbook): |
313 | # } | 317 | # } |
314 | for card, summary in bs_summary.items(): | 318 | for card, summary in bs_summary.items(): |
315 | # 1.原表修剪、排列、按照月份分割 | 319 | # 1.原表修剪、排列、按照月份分割 |
316 | start_date = summary['start_date'] | 320 | start_date = summary.get('start_date') |
317 | end_date = summary['end_date'] | 321 | end_date = summary.get('end_date') |
318 | date_statistics = False | 322 | date_statistics = False |
319 | if start_date is None or end_date is None: | 323 | if start_date is None or end_date is None: |
320 | date_statistics = True | 324 | date_statistics = True |
321 | date_list = [] | 325 | date_list = [] |
322 | month_mapping = {} | 326 | month_mapping = {} |
323 | reverse_trend_list = [] | 327 | reverse_trend_list = [] |
324 | for sheet in summary['sheet']: | 328 | for sheet in summary.get('sheet', []): |
325 | ws = self.get_sheet_by_name(sheet) | 329 | ws = self.get_sheet_by_name(sheet) |
326 | # 1.1.删除多余列、排列 | 330 | # 1.1.删除多余列、排列 |
327 | min_row = self.sheet_prune(ws, summary['classify']) | 331 | min_row = self.sheet_prune(ws, summary.get('classify', 0)) |
328 | # 1.2.按月份分割 | 332 | # 1.2.按月份分割 |
329 | self.sheet_split(ws, month_mapping, reverse_trend_list, min_row, date_list, date_statistics) | 333 | self.sheet_split(ws, month_mapping, reverse_trend_list, min_row, date_list, date_statistics) |
330 | 334 | ||
... | @@ -334,9 +338,9 @@ class BSWorkbook(Workbook): | ... | @@ -334,9 +338,9 @@ class BSWorkbook(Workbook): |
334 | 338 | ||
335 | # 2.元信息提取表 | 339 | # 2.元信息提取表 |
336 | ms = self.build_meta_sheet(card, | 340 | ms = self.build_meta_sheet(card, |
337 | summary['confidence'], | 341 | summary.get('confidence', 1), |
338 | summary['code'], | 342 | summary.get('code'), |
339 | summary['print_time'], | 343 | summary.get('print_time'), |
340 | start_date, | 344 | start_date, |
341 | end_date) | 345 | end_date) |
342 | 346 | ||
... | @@ -349,7 +353,7 @@ class BSWorkbook(Workbook): | ... | @@ -349,7 +353,7 @@ class BSWorkbook(Workbook): |
349 | self.build_month_sheet(card, month_mapping, ms, is_reverse) | 353 | self.build_month_sheet(card, month_mapping, ms, is_reverse) |
350 | 354 | ||
351 | # 4.删除原表 | 355 | # 4.删除原表 |
352 | for sheet in summary['sheet']: | 356 | for sheet in summary.get('sheet'): |
353 | self.remove(self.get_sheet_by_name(sheet)) | 357 | self.remove(self.get_sheet_by_name(sheet)) |
354 | 358 | ||
355 | def license_rebuild(self, license_summary): | 359 | def license_rebuild(self, license_summary): | ... | ... |
-
Please register or sign in to post a comment