Skip to content

Commit 18761b5

Browse files
authored
Merge pull request #257 from QuanMPhm/fix/decimal
Fixed CI failure
2 parents f572bdf + 42e35fb commit 18761b5

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

process_report/process_report.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ def merge_csv(files):
105105
for file in files:
106106
dataframe = pandas.read_csv(
107107
file,
108-
dtype={
109-
invoice.COST_FIELD: pandas.ArrowDtype(pyarrow.decimal128(12, 2)),
108+
)
109+
dataframe = dataframe.astype(
110+
{
111+
invoice.COST_FIELD: pandas.ArrowDtype(pyarrow.decimal128(21, 2)),
110112
invoice.RATE_FIELD: str,
111-
},
113+
}
112114
)
113115
dataframes.append(dataframe)
114116

process_report/processors/new_pi_credit_processor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def _load_old_pis(old_pi_filepath) -> pandas.DataFrame:
5050
try:
5151
old_pi_df = pandas.read_csv(
5252
old_pi_filepath,
53-
dtype={
53+
)
54+
old_pi_df = old_pi_df.astype(
55+
{
5456
invoice.PI_INITIAL_CREDITS: pandas.ArrowDtype(
5557
pyarrow.decimal128(21, 2)
5658
),

process_report/tests/unit/processors/test_new_pi_credit_processor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from unittest import TestCase, mock
2+
from decimal import Decimal
23
import pandas
34
import pytest
45

@@ -85,7 +86,7 @@ def _assert_result_invoice_and_old_pi_file(
8586
assert output_old_pi_df.equals(answer_old_pi_df)
8687

8788
def _get_test_invoice(
88-
self, pi, cost, su_type=None, is_billable=None, missing_pi=None
89+
self, pi, costs, su_type=None, is_billable=None, missing_pi=None
8990
):
9091
if not su_type:
9192
su_type = ["CPU" for _ in range(len(pi))]
@@ -99,7 +100,7 @@ def _get_test_invoice(
99100
return pandas.DataFrame(
100101
{
101102
"Manager (PI)": pi,
102-
"Cost": cost,
103+
"Cost": [Decimal(cost) for cost in costs],
103104
"SU Type": su_type,
104105
"Is Billable": is_billable,
105106
"Missing PI": missing_pi,
@@ -119,6 +120,8 @@ def test_no_new_pi(self):
119120
"PI": ["PI"],
120121
"First Invoice Month": ["2024-01"],
121122
"Initial Credits": [1000],
123+
"1st Month Used": [None],
124+
"2nd Month Used": [None],
122125
}
123126
)
124127
test_old_pi_df.to_csv(test_old_pi_file, index=False)

process_report/tests/unit/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_get_month_diff(self):
2626

2727
class TestMergeCSV(TestCase):
2828
def setUp(self):
29-
self.header = ["ID", "Name", "Age"]
29+
self.header = ["Cost", "Name", "Rate"]
3030
self.data = [
3131
[1, "Alice", 25],
3232
[2, "Bob", 30],

0 commit comments

Comments
 (0)