def get_journals(since: Optional[datetime.datetime] = None): if since is None: since = datetime.datetime.now() - relativedelta(days=90) xero_tenant_id = get_xero_tenant_id() accounting_api = AccountingApi(api_client) these = accounting_api.get_journals(xero_tenant_id=xero_tenant_id, if_modified_since=since) while these and these.journals: yield from these.journals offset = these.journals[-1].journal_number these = accounting_api.get_journals(xero_tenant_id=xero_tenant_id, if_modified_since=since, offset=offset)
def journals_list(): xero_tenant_id = get_xero_tenant_id() accounting_api = AccountingApi(api_client) journals = accounting_api.get_journals( xero_tenant_id=xero_tenant_id, if_modified_since=datetime.datetime.now() - relativedelta(days=90)) return render_template( "code.html", title="Journals", code=serialize_model(journals), sub_title="For Past 90 days", )