Aller au contenu

Firm resources

Resources of PennylaneFirm. Every method takes $companyId as its first argument, except FirmCompanies. FirmCompanies, FirmFiscalYears and FirmTrialBalance use page-number pagination (NumberedPage); every other list method on this page uses cursor pagination (CursorPage), where a foreach walks all pages automatically.

FirmCompanies ($firm->companies)

Manages the client companies of the firm itself. Unlike every other class on this page, its methods do not take a companyId first argument, and list() returns a NumberedPage (page/per_page), not a CursorPage.

Method HTTP Scope Description
list($page = null, $perPage = null, $filter = null) GET /companies companies:readonly List client companies.
get($companyId) GET /companies/{companyId} companies:readonly Retrieve a client company by its identifier.

FirmFiscalYears ($firm->fiscalYears)

Manages the fiscal years of a client company. list() returns a NumberedPage (page/per_page pagination), one of only three exceptions to cursor pagination on this page.

Method HTTP Scope Description
list($companyId, $page = null, $perPage = null) GET /companies/{companyId}/fiscal_years fiscal_years:all or fiscal_years:readonly List the fiscal years of a company.
create($companyId, $start, $finish) POST /companies/{companyId}/fiscal_years fiscal_years:all Create a fiscal year for a company (fiscal years must be consecutive and not overlap).

FirmTrialBalance ($firm->trialBalance)

Reads the trial balance of a client company. list() returns a NumberedPage (page/per_page pagination), one of only three exceptions to cursor pagination on this page.

Method HTTP Scope Description
list($companyId, $periodStart, $periodEnd, $isAuxiliary = null, $page = null, $perPage = null) GET /companies/{companyId}/trial_balance trial_balance:readonly List the trial balance lines of a company over a period.

FirmJournals ($firm->journals)

Manages the accounting journals of a client company.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null) GET /companies/{companyId}/journals journals:all or journals:readonly List the journals of a company.
create($companyId, $code, $label) POST /companies/{companyId}/journals journals:all Create a journal for a company.
get($companyId, $journalId) GET /companies/{companyId}/journals/{journalId} journals:all or journals:readonly Retrieve a journal by its identifier.

FirmLedgerAccounts ($firm->ledgerAccounts)

Manages the chart of accounts of a client company.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null) GET /companies/{companyId}/ledger_accounts ledger_accounts:all or ledger_accounts:readonly List the ledger accounts of a company.
create($companyId, $number, $label, $vatRate = null, $countryAlpha2 = null) POST /companies/{companyId}/ledger_accounts ledger_accounts:all Create a ledger account for a company.
get($companyId, $ledgerAccountId) GET /companies/{companyId}/ledger_accounts/{ledgerAccountId} ledger_accounts:all or ledger_accounts:readonly Retrieve a ledger account by its identifier.
update($companyId, $ledgerAccountId, $label = null, $letterable = null) PUT /companies/{companyId}/ledger_accounts/{ledgerAccountId} ledger_accounts:all Update a ledger account's label or letterable flag.

FirmLedgerEntries ($firm->ledgerEntries)

Manages the ledger entries (accounting pieces) of a client company.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null, $sort = null) GET /companies/{companyId}/ledger_entries ledger_entries:all or ledger_entries:readonly List the ledger entries of a company.
create($companyId, $date, $label, $journalId, $ledgerEntryLines, $fileAttachmentId = null, $currency = null) POST /companies/{companyId}/ledger_entries ledger_entries:all Create a ledger entry; every line needs a debit and a credit key ("0.00" on the unused side) and the lines must balance.
get($companyId, $ledgerEntryId) GET /companies/{companyId}/ledger_entries/{ledgerEntryId} ledger_entries:all or ledger_entries:readonly Retrieve a ledger entry by its identifier.
update($companyId, $ledgerEntryId, $date = null, $label = null, $journalId = null, $fileAttachmentId = null, $currency = null, $ledgerEntryLines = null) PUT /companies/{companyId}/ledger_entries/{ledgerEntryId} ledger_entries:all Update a ledger entry, including creating, updating or deleting its lines, staying balanced.

FirmLedgerEntryLines ($firm->ledgerEntryLines)

Reads the entry lines (debit or credit movements) of a client company.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null, $sort = null) GET /companies/{companyId}/ledger_entry_lines ledger_entries:all or ledger_entries:readonly List the ledger entry lines of a company.
get($companyId, $ledgerEntryLineId) GET /companies/{companyId}/ledger_entry_lines/{ledgerEntryLineId} ledger_entries:all or ledger_entries:readonly Retrieve a ledger entry line by its identifier.
listLetteredLines($companyId, $ledgerEntryLineId, $cursor = null, $limit = null, $sort = null) GET /companies/{companyId}/ledger_entry_lines/{ledgerEntryLineId}/lettered_ledger_entry_lines ledger_entries:all or ledger_entries:readonly List the ledger entry lines lettered together with a given entry line.

FirmExports ($firm->exports)

Entry point for the accounting exports of a client company. It carries no methods of its own: it only wires the fecs (FirmFecExports) and analyticalGeneralLedgers (FirmAnalyticalGeneralLedgerExports) sub resources documented next.

FirmFecExports ($firm->exports->fecs)

Exports the FEC (fichier des ecritures comptables) of a client company.

Method HTTP Scope Description
create($companyId, $periodStart, $periodEnd) POST /companies/{companyId}/exports/fecs exports:fec Start a FEC export for a period (generated asynchronously).
get($companyId, $exportId) GET /companies/{companyId}/exports/fecs/{exportId} exports:fec Retrieve the state of a FEC export; poll until status is done, then read fileUrl.

FirmAnalyticalGeneralLedgerExports ($firm->exports->analyticalGeneralLedgers)

Exports the analytical general ledger of a client company.

Method HTTP Scope Description
create($companyId, $periodStart, $periodEnd, $mode = null) POST /companies/{companyId}/exports/analytical_general_ledgers exports:agl Start an analytical general ledger export for a period (generated asynchronously).
get($companyId, $exportId) GET /companies/{companyId}/exports/analytical_general_ledgers/{exportId} exports:agl Retrieve the state of an analytical general ledger export; poll until status is done, then read fileUrl.

FirmDms ($firm->dms)

Entry point for a client company's document management system (DMS). It carries no methods of its own: it only wires the files (FirmDmsFiles) and folders (FirmDmsFolders) sub resources documented next.

FirmDmsFiles ($firm->dms->files)

Manages the files stored in a client company's DMS.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null) GET /companies/{companyId}/dms/files dms_files:readonly or dms_files:all List the files of a company's DMS.
upload($companyId, $file, $name = null, $parentFolderId = null) POST /companies/{companyId}/dms/files dms_files:all Upload a file to a company's DMS.

FirmDmsFolders ($firm->dms->folders)

Manages the folders of a client company's DMS.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null) GET /companies/{companyId}/dms/folders dms_files:readonly or dms_files:all List the folders of a company's DMS.
create($companyId, $name, $parentFolderId = null) POST /companies/{companyId}/dms/folders dms_files:all Create a DMS folder for a company.

FirmFileAttachments ($firm->fileAttachments)

Uploads standalone file attachments for a client company.

Method HTTP Scope Description
create($companyId, $file, $filename = null) POST /companies/{companyId}/file_attachments file_attachments:all Upload a file attachment.

FirmCustomerInvoices ($firm->customerInvoices)

Reads the customer invoices of a client company (read only, beta).

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null, $sort = null) GET /companies/{companyId}/customer_invoices customer_invoices:readonly List customer invoices (beta, subject to change).
get($companyId, $customerInvoiceId) GET /companies/{companyId}/customer_invoices/{customerInvoiceId} customer_invoices:readonly Retrieve a customer invoice by its identifier (beta, subject to change).

FirmSupplierInvoices ($firm->supplierInvoices)

Reads the supplier invoices of a client company (read only, beta).

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null, $sort = null) GET /companies/{companyId}/supplier_invoices supplier_invoices:readonly List supplier invoices (beta, subject to change).
get($companyId, $supplierInvoiceId) GET /companies/{companyId}/supplier_invoices/{supplierInvoiceId} supplier_invoices:readonly Retrieve a supplier invoice by its identifier (beta, subject to change).

FirmCustomers ($firm->customers)

Reads the customers of a client company (read only, beta). No get() method: list() is the only entry point.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null, $sort = null) GET /companies/{companyId}/customers customers:readonly List customers (read only, beta).

FirmSuppliers ($firm->suppliers)

Reads the suppliers of a client company (read only, beta). No get() method: list() is the only entry point.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null, $sort = null) GET /companies/{companyId}/suppliers suppliers:readonly List suppliers (read only, beta).

FirmBankAccounts ($firm->bankAccounts)

Manages the bank accounts of a client company.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $sort = null) GET /companies/{companyId}/bank_accounts bank_accounts:readonly or bank_accounts:all List bank accounts.
create($companyId, $name, $bankEstablishmentId = null, $iban = null, $bic = null, $currency = null, $accountType = null) POST /companies/{companyId}/bank_accounts bank_accounts:all Create a bank account (uses the "Other" establishment if none is given).

FirmTransactions ($firm->transactions)

Manages the bank transactions of a client company.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null, $sort = null) GET /companies/{companyId}/transactions transactions:readonly or transactions:all List transactions.
create($companyId, $bankAccountId, $label, $date, $amount, $fee = null) POST /companies/{companyId}/transactions transactions:all Create a transaction.
update($companyId, $transactionId, $customerId = null, $supplierId = null) PUT /companies/{companyId}/transactions/{transactionId} transactions:all Reconcile a transaction with a customer or a supplier (never both).

FirmCategories ($firm->categories)

Reads the analytical categories of a client company.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null, $filter = null, $sort = null) GET /companies/{companyId}/categories categories:readonly List categories.
get($companyId, $categoryId) GET /companies/{companyId}/categories/{categoryId} categories:readonly Retrieve a category by its identifier.

FirmCategoryGroups ($firm->categoryGroups)

Reads the category groups of a client company.

Method HTTP Scope Description
list($companyId, $cursor = null, $limit = null) GET /companies/{companyId}/category_groups categories:readonly List category groups.
get($companyId, $categoryGroupId) GET /companies/{companyId}/category_groups/{categoryGroupId} categories:readonly Retrieve a category group by its identifier.
listCategories($companyId, $categoryGroupId, $cursor = null, $limit = null) GET /companies/{companyId}/category_groups/{categoryGroupId}/categories categories:readonly List the categories that belong to a category group.

FirmChangelogs ($firm->changelogs)

Reads the change events of a client company's data, one method per watched resource type.

Method HTTP Scope Description
dmsFiles($companyId, $cursor = null, $limit = null, $startDate = null) GET /companies/{companyId}/changelogs/dms_files dms_files:readonly or dms_files:all Get DMS files change events.
ledgerEntryLines($companyId, $cursor = null, $limit = null, $startDate = null) GET /companies/{companyId}/changelogs/ledger_entry_lines ledger_entries:readonly or ledger_entries:all Get ledger entry line change events.
supplierInvoices($companyId, $cursor = null, $limit = null, $startDate = null) GET /companies/{companyId}/changelogs/supplier_invoices supplier_invoices:readonly Get supplier invoices change events (beta, subject to change).
customerInvoices($companyId, $cursor = null, $limit = null, $startDate = null) GET /companies/{companyId}/changelogs/customer_invoices customer_invoices:readonly Get customer invoices change events (beta, subject to change).

startDate is mutually exclusive with cursor on every FirmChangelogs method: pass one or the other, not both.

Example

<?php

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

use Pennylane\Sdk\PennylaneFirm;

$firm = new PennylaneFirm(); // reads PENNYLANE_FIRM_API_TOKEN

// FirmCompanies uses page-number pagination, but foreach still walks every page.
foreach ($firm->companies->list() as $company) {
    echo $company->id . ' ' . $company->name . PHP_EOL;
}

$companyId = 4217;

// Every other resource takes $companyId as its first argument, and lists here
// use cursor pagination.
foreach ($firm->ledgerAccounts->list($companyId, limit: 50) as $ledgerAccount) {
    echo $ledgerAccount->id . ' ' . $ledgerAccount->number . ' ' . $ledgerAccount->label . PHP_EOL;
}

$fiscalYears = $firm->fiscalYears->list($companyId);
foreach ($fiscalYears as $fiscalYear) {
    echo $fiscalYear->id . PHP_EOL;
}