Skip to content

Commit

Permalink
Merge pull request #32 from knikolla/decimals
Browse files Browse the repository at this point in the history
Read cost as a Decimal from collected invoices
  • Loading branch information
knikolla authored Apr 29, 2024
2 parents b1f1af1 + cde1c86 commit f601e3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions process_report/process_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
import os
import sys
import datetime
from decimal import Decimal

import json
import pandas
import boto3
import pyarrow


### Invoice field names
Expand Down Expand Up @@ -229,7 +231,9 @@ def merge_csv(files):
"""Merge multiple CSV files and return a single pandas dataframe"""
dataframes = []
for file in files:
dataframe = pandas.read_csv(file)
dataframe = pandas.read_csv(
file, dtype={COST_FIELD: pandas.ArrowDtype(pyarrow.decimal128(12, 3))}
)
dataframes.append(dataframe)

merged_dataframe = pandas.concat(dataframes, ignore_index=True)
Expand Down Expand Up @@ -298,7 +302,7 @@ def apply_credits_new_pi(dataframe, old_pi_file):

dataframe[CREDIT_FIELD] = None
dataframe[CREDIT_CODE_FIELD] = None
dataframe[BALANCE_FIELD] = 0
dataframe[BALANCE_FIELD] = Decimal(0)

old_pi_dict = load_old_pis(old_pi_file)

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pandas
pyarrow
boto3

0 comments on commit f601e3d

Please sign in to comment.