Skip to content

Commit cd3fd9b

Browse files
authored
add support for multiple languages (#178)
1 parent 30479f3 commit cd3fd9b

File tree

6 files changed

+60
-8
lines changed

6 files changed

+60
-8
lines changed

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def get_version():
1818
author='hotglue',
1919
url='http://hotglue.xyz/',
2020
classifiers=['Programming Language :: Python :: 3 :: Only'],
21-
py_modules=['tap_quickbooks'],
2221
install_requires=[
2322
'requests>=2.20.0',
2423
'singer-python==5.3.1',
@@ -33,7 +32,9 @@ def get_version():
3332
''',
3433
packages=find_packages(exclude=['tests']),
3534
package_data={
36-
'tap_quickbooks.quickbooks': ['schemas/*.json', 'reportstreams/*']
35+
'tap_quickbooks.quickbooks': ['schemas/*.json'],
36+
'tap_quickbooks.quickbooks.reportstreams': ['*.py'],
37+
'tap_quickbooks.quickbooks.reportstreams.english_schemas': ['*.py']
3738
},
3839
include_package_data=True,
3940
)

tap_quickbooks/quickbooks/reportstreams/BaseReport.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,21 @@ def concurrent_get(self, report_entity, params):
2727
else:
2828
return response
2929

30-
def _get_column_metadata(self, resp):
30+
def _get_column_metadata(self, resp, schema=None):
3131
columns = []
3232
for column in resp.get("Columns").get("Column"):
33-
if column.get("ColTitle") == "Memo/Description":
34-
columns.append("Memo")
33+
# To handle multiple languages if schema is passed, always convert Col Titles to english
34+
if schema is not None:
35+
col_type = column["MetaData"][0].get("Value") if column.get("MetaData") else None
36+
if not col_type:
37+
LOGGER.info(f"Metadata for col {column.get('ColTitle')} not found, skipping.")
38+
continue
39+
# append col to columns
40+
columns.append(schema.get(col_type))
3541
else:
36-
columns.append(column.get("ColTitle").replace(" ", ""))
42+
if column.get("ColTitle") == "Memo/Description":
43+
columns.append("Memo")
44+
else:
45+
columns.append(column.get("ColTitle").replace(" ", ""))
3746
columns.append("Categories")
3847
return columns

tap_quickbooks/quickbooks/reportstreams/GeneralLedgerReport.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import logging
1010
import concurrent.futures
1111
from calendar import monthrange
12+
from tap_quickbooks.quickbooks.reportstreams.english_schemas.GeneralLedgerReportFields import glr_english_schema as eng_schema
1213

1314

1415
LOGGER = singer.get_logger()
@@ -225,7 +226,7 @@ def sync(self, catalog_entry):
225226
self.gl_daily = False
226227

227228
# Get column metadata.
228-
columns = self._get_column_metadata(r)
229+
columns = self._get_column_metadata(r, eng_schema)
229230

230231
# Recursively get row data.
231232
row_group = r.get("Rows")
@@ -259,7 +260,7 @@ def sync(self, catalog_entry):
259260
resp = self._get(report_entity="GeneralLedger", params=params)
260261

261262
# Get column metadata.
262-
columns = self._get_column_metadata(resp)
263+
columns = self._get_column_metadata(resp, eng_schema)
263264

264265
# Recursively get row data.
265266
row_group = resp.get("Rows")

tap_quickbooks/quickbooks/reportstreams/__init__.py

Whitespace-only changes.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
glr_english_schema = {
2+
"tx_date": "Date",
3+
"txn_type": "TransactionType",
4+
"doc_num": "Num",
5+
"is_adj": "Adj",
6+
"create_date": "CreateDate",
7+
"create_by": "CreatedBy",
8+
"last_mod_date": "LastModified",
9+
"last_mod_by": "LastModifiedBy",
10+
"name": "Name",
11+
"cust_name": "Customer",
12+
"emp_name": "Employee",
13+
"item_name": "Product/Service",
14+
"memo": "Memo",
15+
"quantity": "Qty",
16+
"rate": "Rate",
17+
"account_name": "Account",
18+
"split_acc": "Split",
19+
"inv_date": "Invoice Date",
20+
"is_ar_paid": "A/RPaid",
21+
"is_ap_paid": "A/PPaid",
22+
"is_cleared": "Clr",
23+
"chk_print_state": "CheckPrinted",
24+
"debt_home_amt": "Debit",
25+
"credit_home_amt": "Credit",
26+
"nat_home_open_bal": "OpenBalance",
27+
"subt_nat_home_amount": "Amount",
28+
"rbal_nat_home_amount": "Balance",
29+
"exch_rate": "ExchangeRate",
30+
"currency": "Currency",
31+
"home_tax_amount": "TaxAmount",
32+
"home_net_amount": "TaxableAmount",
33+
"nat_foreign_open_bal": "ForeignOpenBalance",
34+
"credit_amt": "ForeignCredit",
35+
"nat_foreign_amount": "ForeignAmount",
36+
"vend_name": "Vendor",
37+
"dept_name": "Department",
38+
"klass_name": "Class",
39+
"account_num": "Account#",
40+
"debt_amt": "ForeignDebit"
41+
}

tap_quickbooks/quickbooks/reportstreams/english_schemas/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)