parent
f6245a3413
commit
fa7f1516c8
@ -1,44 +0,0 @@ |
||||
output_path = '../Work' |
||||
db_path = "OnHold.db" |
||||
|
||||
# Columns added each 'working' sheet in the new report dataframe |
||||
work_columns = [ |
||||
"HideNextMonth", # Boolean column for user to indicate if this contract should be ignored next month |
||||
"Resolution" # Text field describing the disprecany and how it may be resolved |
||||
] |
||||
|
||||
# List of Columns to show on the 'working' sheets of the rec report |
||||
output_columns = [ |
||||
"contract_number", |
||||
"vendor_name", |
||||
"AppNum", # OB only |
||||
"Document Number",# GP Only |
||||
"DateBooked",# OB only |
||||
"Document Date", #GP Only |
||||
"HideNextMonth", |
||||
"Resolution", |
||||
# 'Source' added for 'no match' |
||||
] |
||||
|
||||
[filters] |
||||
# These regex will be combined and with ORs and used to filer |
||||
# the document number column of the GP report |
||||
doc_num_filters = [ |
||||
"p(oin)?ts", |
||||
"pool", |
||||
"promo", |
||||
"o(ver)?f(und)?", |
||||
"m(ar)?ke?t", |
||||
"title", |
||||
"adj", |
||||
"reg fee", |
||||
"rent", |
||||
"cma" |
||||
] |
||||
po_filter = ["^(?!.*cma(\\s|\\d)).*$"] |
||||
|
||||
# Columns that are common to both GP and OB |
||||
[shared_columns] |
||||
contract_number = { GP = "Transaction Description", OB = "Contract"} |
||||
onhold_amount = { GP = "Current Trx Amount", OB = "CurrentOnHold" } |
||||
vendor_name = { GP = "Vendor Name", OB = "DealerName"} |
||||
@ -1,19 +1,33 @@ |
||||
{ |
||||
"input_directory": "", |
||||
"output_directory": "", |
||||
"input_directory": "/path/to/input/folder", |
||||
"input_glob_pattern": { |
||||
"GP": "*GP*.xlsx", |
||||
"OB": "*OB*.xlsx" |
||||
}, |
||||
"output_directory": "/path/to/output", |
||||
"interactive_inputs": false, |
||||
"use_mssql": false, |
||||
"database_path": "", |
||||
"work_columns": [], |
||||
"finished_column": [], |
||||
"database_path": "./onhold.db", |
||||
"work_columns": [ |
||||
"Col_A", |
||||
"Col_B" |
||||
], |
||||
"finished_column": [ |
||||
"Notes", |
||||
"Conctract Number" |
||||
], |
||||
"filters": { |
||||
"filter_name": [], |
||||
"other_filter": "" |
||||
"filter_name": [ |
||||
"\\d{7}", |
||||
"\\w+" |
||||
], |
||||
"other_filter": "(OB|GP)$" |
||||
}, |
||||
"shared_columns": [ |
||||
{ |
||||
"standardized_name": "", |
||||
"GP": "", |
||||
"OB": "" |
||||
"standardized_name": "contract_number", |
||||
"GP": "Transactoin Description", |
||||
"OB": "ContractNumber" |
||||
} |
||||
] |
||||
} |
||||
@ -0,0 +1,72 @@ |
||||
#### Paths: using '' makes the string 'raw' to avoid escape characters |
||||
|
||||
# Path to the directory to search for input report files |
||||
input_directory = '../Reports' |
||||
# Regex used to discover newest files |
||||
input_glob_pattern = { GP = "*GP*.xlsx", OB = '*OB*.xlsx'} |
||||
# Path to the directory to save the reconcilation work report |
||||
output_directory = '../Output' |
||||
# Fallback to interactive? |
||||
interactive_inputs = false # NOT YET IMPLEMENTED |
||||
|
||||
|
||||
#### DB |
||||
|
||||
# Whether to try using a mssql database |
||||
# NOT YET IMPLEMENTED! |
||||
use_mssql = false |
||||
# Path to the SQLite database used to view/save reconcilations |
||||
database_path = './onhold_reconciliation.db' |
||||
|
||||
|
||||
### Finished rec details |
||||
|
||||
# Columns to add to all 'work' sheets |
||||
# also saved 'Reconcilations' database |
||||
work_columns = [ |
||||
"HideNextMonth", # Boolean column for user to indicate if this contract should be ignored next month |
||||
"Resolution" # Text field describing the disprecany and how it may be resolved |
||||
] |
||||
# Columns to keep on reconcilation 'work' sheets |
||||
finished_column = [ |
||||
"contract_number", |
||||
"vendor_name", |
||||
"AppNum", # OB only |
||||
"Document Number", # GP Only |
||||
"DateBooked", # OB only |
||||
"Document Date", # GP Only |
||||
# 'Source' added for 'no match' |
||||
] |
||||
|
||||
# Any regex filters that might be needed |
||||
[filters] |
||||
# Use label to distinguish a regex set |
||||
doc_num_filters = [ |
||||
"p(oin)?ts", |
||||
"pool", |
||||
"promo", |
||||
"o(ver)?f(und)?", |
||||
"m(ar)?ke?t", |
||||
"title", |
||||
"adj", |
||||
"reg fee", |
||||
"rent", |
||||
"cma" |
||||
] |
||||
po_filter = ["^(?!.*cma(\\s|\\d)).*$"] |
||||
|
||||
# Columns that are featured & expected on both OB & GP |
||||
[[shared_columns]] |
||||
standardized_name = "contract_number" # The name you'd like to use to standardize them |
||||
GP = "Transaction Description" # Column name used in GP |
||||
OB = "Contract" # Column name used in GP |
||||
|
||||
[[shared_columns]] |
||||
standardized_name = "onhold_amount" |
||||
GP = "Current Trx Amount" |
||||
OB = "CurrentOnHold" |
||||
|
||||
[[shared_columns]] |
||||
standardized_name = "vendor_name" |
||||
GP = "Vendor Name" |
||||
OB = "DealerName" |
||||
@ -0,0 +1,5 @@ |
||||
import os |
||||
import sys |
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) |
||||
|
||||
import src |
||||
@ -0,0 +1,73 @@ |
||||
import unittest |
||||
from pathlib import Path |
||||
from re import Pattern, compile |
||||
from .context import src |
||||
from src import config |
||||
from src import ReportSource |
||||
|
||||
class TestReportConfig(unittest.TestCase): |
||||
|
||||
def test_from_file(self): |
||||
# Provide the path to your config file |
||||
config_file = Path(r"tests\test_inputs\TEST_reports_config.toml") |
||||
|
||||
# Call the static method from_file to create an instance of ReportConfig |
||||
report_config = config.ReportConfig.from_file(config_file) |
||||
|
||||
# Assert the values of the attributes in the created instance |
||||
self.assertEqual(report_config.paths.input_directory, Path(r"tests\test_inputs")) |
||||
self.assertEqual(report_config.paths.gp_glob, r'*GP*.xlsx') |
||||
self.assertEqual(report_config.paths.ob_glob, r"*OB*.xlsx") |
||||
self.assertEqual(report_config.paths.output_directory, Path(r"tests\test_outputs")) |
||||
self.assertEqual(report_config.use_mssql, False) |
||||
self.assertEqual(report_config.paths.db_path, Path("./onhold_reconciliation.db")) |
||||
self.assertEqual(report_config.work_columns, ["HideNextMonth", "Resolution"]) |
||||
self.assertEqual(report_config.finished_columns, [ |
||||
"contract_number", |
||||
"vendor_name", |
||||
"AppNum", |
||||
"Document Number", |
||||
"DateBooked", |
||||
"Document Date", |
||||
]) |
||||
self.assertEqual(report_config.filters["doc_num_filters"], [ |
||||
compile(r"p(oin)?ts",), |
||||
compile(r"pool",), |
||||
compile(r"promo",), |
||||
compile(r"o(ver)?f(und)?",), |
||||
compile(r"m(ar)?ke?t",), |
||||
compile(r"title",), |
||||
compile(r"adj",), |
||||
compile(r"reg fee",), |
||||
compile(r"rent",), |
||||
compile(r"cma",), |
||||
]) |
||||
self.assertEqual(report_config.filters["po_filter"], [compile(r"^(?!.*cma(\s|\d)).*$")]) |
||||
self.assertEqual(report_config.shared_columns[0]["standardized_name"], "contract_number") |
||||
self.assertEqual(report_config.shared_columns[0]["GP"], "Transaction Description") |
||||
self.assertEqual(report_config.shared_columns[0]["OB"], "Contract") |
||||
self.assertEqual(report_config.shared_columns[1]["standardized_name"], "onhold_amount") |
||||
self.assertEqual(report_config.shared_columns[1]["GP"], "Current Trx Amount") |
||||
self.assertEqual(report_config.shared_columns[1]["OB"], "CurrentOnHold") |
||||
self.assertEqual(report_config.shared_columns[2]["standardized_name"], "vendor_name") |
||||
self.assertEqual(report_config.shared_columns[2]["GP"], "Vendor Name") |
||||
self.assertEqual(report_config.shared_columns[2]["OB"], "DealerName") |
||||
|
||||
def test_get_newest(self): |
||||
# Provide the path to your config file |
||||
config_file = Path(r"tests\test_inputs\TEST_reports_config.toml") |
||||
|
||||
# Call the static method from_file to create an instance of ReportConfig |
||||
report_config = config.ReportConfig.from_file(config_file) |
||||
|
||||
newest_ob: Path = report_config.paths.get_most_recent(report_type=ReportSource.OB) |
||||
self.assertEqual(newest_ob.name, "April 2023 OB.xlsx") |
||||
newest_gp: Path = report_config.paths.get_most_recent(report_type=ReportSource.GP) |
||||
self.assertEqual(newest_gp.name, "April GP.xlsx") |
||||
|
||||
nob, ngp = report_config.paths.get_most_recent() |
||||
self.assertEqual(nob.name, "April 2023 OB.xlsx") |
||||
self.assertEqual(ngp.name, "April GP.xlsx") |
||||
|
||||
if __name__ == '__main__': |
||||
unittest.main() |
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,72 @@ |
||||
#### Paths: using '' makes the string 'raw' to avoid escape characters |
||||
|
||||
# Path to the directory to search for input report files |
||||
input_directory = 'tests\test_inputs' |
||||
# Regex used to discover newest files |
||||
input_glob_pattern = { GP = "*GP*.xlsx", OB = '*OB*.xlsx'} |
||||
# Path to the directory to save the reconcilation work report |
||||
output_directory = 'tests\test_outputs' |
||||
# Fallback to interactive? |
||||
interactive_inputs = false # NOT YET IMPLEMENTED |
||||
|
||||
|
||||
#### DB |
||||
|
||||
# Whether to try using a mssql database |
||||
# NOT YET IMPLEMENTED! |
||||
use_mssql = false |
||||
# Path to the SQLite database used to view/save reconcilations |
||||
database_path = './onhold_reconciliation.db' |
||||
|
||||
|
||||
### Finished rec details |
||||
|
||||
# Columns to add to all 'work' sheets |
||||
# also saved 'Reconcilations' database |
||||
work_columns = [ |
||||
"HideNextMonth", # Boolean column for user to indicate if this contract should be ignored next month |
||||
"Resolution" # Text field describing the disprecany and how it may be resolved |
||||
] |
||||
# Columns to keep on reconcilation 'work' sheets |
||||
finished_column = [ |
||||
"contract_number", |
||||
"vendor_name", |
||||
"AppNum", # OB only |
||||
"Document Number", # GP Only |
||||
"DateBooked", # OB only |
||||
"Document Date", # GP Only |
||||
# 'Source' added for 'no match' |
||||
] |
||||
|
||||
# Any regex filters that might be needed |
||||
[filters] |
||||
# Use label to distinguish a regex set |
||||
doc_num_filters = [ |
||||
"p(oin)?ts", |
||||
"pool", |
||||
"promo", |
||||
"o(ver)?f(und)?", |
||||
"m(ar)?ke?t", |
||||
"title", |
||||
"adj", |
||||
"reg fee", |
||||
"rent", |
||||
"cma" |
||||
] |
||||
po_filter = ['^(?!.*cma(\s|\d)).*$'] |
||||
|
||||
# Columns that are featured & expected on both OB & GP |
||||
[[shared_columns]] |
||||
standardized_name = "contract_number" # The name you'd like to use to standardize them |
||||
GP = "Transaction Description" # Column name used in GP |
||||
OB = "Contract" # Column name used in GP |
||||
|
||||
[[shared_columns]] |
||||
standardized_name = "onhold_amount" |
||||
GP = "Current Trx Amount" |
||||
OB = "CurrentOnHold" |
||||
|
||||
[[shared_columns]] |
||||
standardized_name = "vendor_name" |
||||
GP = "Vendor Name" |
||||
OB = "DealerName" |
||||
Loading…
Reference in new issue