Skip to content

Commit

Permalink
feat: some ledger account endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderKoen committed Jun 22, 2023
1 parent 67bd74f commit ab162fe
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -14,6 +14,7 @@
- Sales invoice*
- Tax rates
- Custom Fields
- Ledger accounts*

*not all endpoints are yet implemented

Expand Down
8 changes: 5 additions & 3 deletions example/example.js
Expand Up @@ -14,8 +14,10 @@ moneybird.instance.setOptions({
percentage: 21,
});

console.log(taxes);

console.log(await administration.customFields());
console.log(
(await administration.ledgerAccounts()).filter(
(x) => x.name === "Ongecategoriseerde inkomsten"
)
);
}
})().catch(console.log);
19 changes: 16 additions & 3 deletions src/administration.ts
Expand Up @@ -4,6 +4,7 @@ import {
IContact,
IContactCreate,
ICustomField,
ILedgerAccount,
ISalesInvoice,
ISalesInvoiceCreate,
ISalesInvoiceState,
Expand Down Expand Up @@ -253,7 +254,7 @@ export class Administration {

//endregion Invoices

////////////////////////// TAXES //////////////////////////
////////////////////////// TAXES /////////////////////////////
//region Taxes

/**
Expand Down Expand Up @@ -309,7 +310,7 @@ export class Administration {
}
//endregion Taxes

////////////////////////// CUSTOM FIELDS //////////////////////////
////////////////////////// CUSTOM FIELDS /////////////////////
//region Custom Fields

/**
Expand All @@ -321,6 +322,18 @@ export class Administration {
return await this.HTTP.GET<ICustomField[]>("custom_fields", { params });
}
//endregion Custom Fields

////////////////////////// LEDGER ACCOUNTS ///////////////////
//region Ledger Accounts

/**
* Returns a list of all ledger accounts in the administration
*/
public async ledgerAccounts(
params?: PaginatedOptions
): Promise<ILedgerAccount[]> {
return await this.HTTP.GET<ILedgerAccount[]>("ledger_accounts", { params });
}


//endregion Ledger Accounts
}
31 changes: 31 additions & 0 deletions src/common.ts
Expand Up @@ -272,3 +272,34 @@ export interface ICustomField {
name: string;
source: ICustomFieldSource;
}

export type AccountType =
| "non_current_assets"
| "current_assets"
| "equity"
| "provisions"
| "non_current_liabilities"
| "current_liabilities"
| "revenue"
| "direct_costs"
| "expenses"
| "other_income_expenses";

export type DocumentType =
| "sales_invoice"
| "purchase_invoice"
| "general_journal_document"
| "financial_mutation"
| "payment";

export interface ILedgerAccount {
id: string;
administration_id: string;
name: string;
account_type: AccountType;
account_id?: string;
parent_id?: string;
created_at: string;
updated_at: string;
allowed_document_types: DocumentType[];
}

0 comments on commit ab162fe

Please sign in to comment.