Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gl_journal_entries - API V2 #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,15 @@ This tap:
- Bookmark: last_modified_date (date-time)
- Transformations: Fields camelCase to snake_case, Abstract/generalize custom_field_sets

[**gl_journal_entries (POST v1)**](https://support.mambu.com/docs/en/gl-journal-entries-api#post-search)
- Endpoint: https://instance.sandbox.mambu.com/api/gljournalentries/search
[**gl_journal_entries (POST v2)**](https://support.mambu.com/docs/en/gl-journal-entries-api#post-search)

- Endpoint: https://instance.sandbox.mambu.com/api/gljournalentries:search
- Primary keys: entry_id
- Replication strategy: Incremental (query filtered based on date)
- Bookmark query field: bookingDate
- Sort by: bookingDate:ASC
- Bookmark: booking_date (date-time)
- Transformations: Fields camelCase to snake_case, Abstract/generalize custom_field_sets
- Transformations: Fields camelCase to snake_case

[**activities (GET v1)**](https://support.mambu.com/docs/activities-api)
- Endpoint: https://instance.sandbox.mambu.com/api/activities
Expand Down
258 changes: 148 additions & 110 deletions tap_mambu/schemas/gl_journal_entries.json
Original file line number Diff line number Diff line change
@@ -1,117 +1,155 @@
{
"type": "object",
"additionalProperties": false,
"properties": {
"encoded_key": {
"type": ["null", "string"]
},
"entry_id": {
"type": ["null", "string"]
},
"creation_date": {
"type": ["null", "string"],
"format": "date-time"
},
"entry_date": {
"type": ["null", "string"],
"format": "date-time"
},
"transaction_id": {
"type": ["null", "string"]
},
"account_key": {
"type": ["null", "string"]
},
"product_key": {
"type": ["null", "string"]
},
"amount": {
"type": ["null", "number"],
"multipleOf": 1e-10
},
"type": {
"type": ["null", "string"]
},
"user_key": {
"type": ["null", "string"]
},
"booking_date": {
"type": ["null", "string"],
"format": "date-time"
},
"gl_account": {
"type": ["null", "object"],
"additionalProperties": false,
"properties": {
"encoded_key": {
"type": ["null", "string"]
},
"entry_id": {
"type": ["null", "string"]
},
"creation_date": {
"type": ["null", "string"],
"format": "date-time"
},
"last_modified_date": {
"type": ["null", "string"],
"format": "date-time"
},
"gl_code": {
"type": ["null", "string"]
},
"type": {
"type": ["null", "string"]
},
"usage": {
"type": ["null", "string"]
},
"name": {
"type": ["null", "string"]
},
"activated": {
"type": ["null", "boolean"]
},
"allow_manual_journal_entries": {
"type": ["null", "boolean"]
},
"strip_trailing_zeros": {
"type": ["null", "boolean"]
},
"currency": {
"type": ["null", "object"],
"additionalProperties": false,
"properties": {
"code": {
"type": ["null", "string"]
},
"name": {
"type": ["null", "string"]
},
"symbol": {
"type": ["null", "string"]
},
"digits_after_decimal": {
"type": ["null", "integer"]
},
"currency_symbol_position": {
"type": ["null", "string"]
},
"is_base_currency": {
"type": ["null", "boolean"]
},
"last_modified_date": {
"type": ["null", "string"],
"format": "date-time"
}
"type": "object",
"additionalProperties": false,
"properties": {
"account_key": {
"type": ["null", "string"]
},
"amount": {
"type": ["null", "number"],
"multipleOf": 1e-10
},
"assigned_branch_key": {
"type": ["null", "string"]
},
"booking_date": {
"type": ["null", "string"],
"format": "date-time"
},
"creation_date": {
"type": ["null", "string"],
"format": "date-time"
},
"encoded_key": {
"type": ["null", "string"]
},
"entry_id": {
"type": ["null", "string"]
},
"foreign_amount": {
"type": ["null", "object"],
"additionalProperties": false,
"properties": {
"accounting_rate": {
"type": ["null", "object"],
"additionalProperties": false,
"properties": {
"encoded_key": {
"type": ["null", "string"]
},
"end_date": {
"type": ["null", "string"],
"format": "date-time"
},
"from_currency_code": {
"type": ["null", "string"]
},
"rate": {
"type": ["null", "number"],
"multipleOf": 1e-10
},
"start_date": {
"type": ["null", "string"],
"format": "date-time"
},
"to_currency_code": {
"type": ["null", "string"]
}
},
"balance": {
"type": ["null", "number"],
"multipleOf": 1e-10
}
},
"ammount": {
"type": ["null", "number"],
"multipleOf": 1e-10
},
"currency": {
"type": ["null", "object"],
"additionalProperties": false,
"properties": {
"code": {
"type": ["null", "string"]
}
}
}
}
},
"gl_account": {
"type": ["null", "object"],
"additionalProperties": false,
"properties": {
"activated": {
"type": ["null", "boolean"]
},
"allow_manual_journal_entries": {
"type": ["null", "boolean"]
},
"balance": {
"type": ["null", "number"],
"multipleOf": 1e-10
},
"creation_date": {
"type": ["null", "string"],
"format": "date-time"
},
"currency": {
"type": ["null", "object"],
"additionalProperties": false,
"properties": {
"code": {
"type": ["null", "string"]
}
}
},
"description": {
"type": ["null", "string"]
},
"encoded_key": {
"type": ["null", "string"]
},
"gl_code": {
"type": ["null", "string"]
},
"last_modified_date": {
"type": ["null", "string"],
"format": "date-time"
},
"migration_event_key": {
"type": ["null", "string"],
"format": "date-time"
},
"name": {
"type": ["null", "string"]
},
"strip_trailing_zeros": {
"type": ["null", "boolean"]
},
"type": {
"type": ["null", "string"]
},
"usage": {
"type": ["null", "string"]
}
}
},
"notes": {
"type": ["null", "string"]
},
"product_key": {
"type": ["null", "string"]
},
"product_type": {
"type": ["null", "string"]
},
"reversal_entry_key": {
"type": ["null", "string"]
},
"transaction_id": {
"type": ["null", "string"]
},
"type": {
"type": ["null", "string"]
},
"user_key": {
"type": ["null", "string"]
}
}
}
37 changes: 14 additions & 23 deletions tap_mambu/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ def sync(client, config, catalog, state):
groups_dttm_str = get_bookmark(state, 'groups', 'self', start_date)
groups_dt_str = transform_datetime(groups_dttm_str)[:10]

gl_journal_entries_dttm_str = get_bookmark(state, 'gl_journal_entries', 'self', start_date)
gl_journal_entries_dt_str = transform_datetime(gl_journal_entries_dttm_str)
# LOGGER.info('gl_journal_entries bookmark_date = {}'.format(gl_journal_entries_dt_str))

lookback_days = int(config.get('lookback_window', LOOKBACK_DEFAULT))
lookback_date = utils.now() - timedelta(lookback_days)
if loan_transactions_dttm > lookback_date:
Expand Down Expand Up @@ -678,16 +682,19 @@ def sync(client, config, catalog, state):
'sub_types': ['ASSET', 'LIABILITY', 'EQUITY', 'INCOME', 'EXPENSE']
},
'gl_journal_entries': {
'path': 'gljournalentries/search',
'api_version': 'v1',
'path': 'gljournalentries:search',
'api_version': 'v2',
'api_method': 'POST',
'body': {
"filterConstraints": [
"sortingCriteria": {
"field": "bookingDate",
"order": "ASC"
},
"filterCriteria": [
{
"filterSelection": "CREATION_DATE",
"filterElement": "BETWEEN",
"value": '{gl_journal_entries_from_dt_str}',
"secondValue": "{now_date_str}"
"field": "bookingDate",
"operator": "AFTER",
"value": gl_journal_entries_dt_str
}
]
},
Expand Down Expand Up @@ -751,22 +758,6 @@ def sync(client, config, catalog, state):
for sub_type in sub_types:
LOGGER.info('START Syncing: {}, Type: {}'.format(stream_name, sub_type))

# Now date
if stream_name == 'gl_journal_entries':
now_date_str = strftime(utils.now())[:10]
gl_journal_entries_from_dttm_str = get_bookmark(
state, 'gl_journal_entries', sub_type, start_date)
gl_journal_entries_from_dt_str = transform_datetime(
gl_journal_entries_from_dttm_str)[:10]
gl_journal_entries_from_param = endpoint_config.get(
'body', {}).get('filterConstraints', {})[0].get('value')
if gl_journal_entries_from_param:
endpoint_config['body']['filterConstraints'][0]['value'] = gl_journal_entries_from_dt_str
gl_journal_entries_to_param = endpoint_config.get(
'body', {}).get('filterConstraints', {})[0].get('secondValue')
if gl_journal_entries_to_param:
endpoint_config['body']['filterConstraints'][0]['secondValue'] = now_date_str

if stream_name == 'activities':
now_date_str = strftime(utils.now())[:10]
activities_from_dttm_str = get_bookmark(
Expand Down