Skip to content

Commit

Permalink
Adds fk for JournalLines in order to match with Journal (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmesel authored Feb 7, 2024
1 parent bab553b commit 5ec10e8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tap_xero/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def write_records(self, records, ctx):
stream = ctx.catalog.get_stream(self.tap_stream_id)
schema = stream.schema.to_dict()
lines_schema = schema["properties"].get("JournalLines", {}).get("items")
lines_schema["JournalID"] = schema["properties"]["JournalID"]
lines_stream_id = "{}_lines".format(self.tap_stream_id)
mdata = stream.metadata
try:
Expand All @@ -220,6 +221,7 @@ def write_records(self, records, ctx):
if "JournalLines" in rec and len(line_mdata) > 0 and ctx.config.get("journal_lines_stream") in ["true", True]:
for line in rec["JournalLines"]:
with Transformer() as transformer:
line["JournalID"] = rec["JournalID"]
line = transformer.transform(line, lines_schema, metadata.to_map(line_mdata))
singer.write_record(lines_stream_id, line)
self.metrics(records)
Expand Down

0 comments on commit 5ec10e8

Please sign in to comment.