Class: Dolibarr::RecurringInvoices
- Defined in:
- lib/dolibarr/recurring_invoices.rb
Overview
Recurring / template invoices ("factures modèles"). Read-only: Dolibarr 23.0.3
exposes only GET on /invoices/templates — creating a template or triggering a
generation is not available over REST (it happens in the UI or the internal cron).
Returns normalised hashes (amounts coerced); the generated child invoices surface in the ordinary Invoices domain, where the full cycle (validate/pay/close) lives.
Instance Method Summary collapse
- #all(**filters) ⇒ Array<Hash>
-
#each(limit: 100, **filters, &block) ⇒ Object
Every matching template, paginating transparently.
-
#find(id:) ⇒ Hash
Fetch a single template invoice by id.
-
#list(thirdparty_id: nil, status: nil, sqlfilters: nil, limit: 100, page: 0, sortfield: 't.rowid', sortorder: 'ASC') ⇒ Array<Hash>
One page of template invoices as normalised hashes.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Dolibarr::Resource
Instance Method Details
#all(**filters) ⇒ Array<Hash>
38 39 40 |
# File 'lib/dolibarr/recurring_invoices.rb', line 38 def all(**filters) each(**filters).to_a end |
#each(limit: 100, **filters, &block) ⇒ Object
Every matching template, paginating transparently. Enumerator when no block.
32 33 34 35 |
# File 'lib/dolibarr/recurring_invoices.rb', line 32 def each(limit: 100, **filters, &block) enum = paginate(limit: limit) { |page, lim| list(page: page, limit: lim, **filters) } block ? enum.each(&block) : enum end |
#find(id:) ⇒ Hash
Fetch a single template invoice by id.
47 48 49 |
# File 'lib/dolibarr/recurring_invoices.rb', line 47 def find(id:) Coerce.amounts(get_one("/invoices/templates/#{encode(id)}", "template invoice #{id}")) end |
#list(thirdparty_id: nil, status: nil, sqlfilters: nil, limit: 100, page: 0, sortfield: 't.rowid', sortorder: 'ASC') ⇒ Array<Hash>
One page of template invoices as normalised hashes.
21 22 23 24 25 26 27 28 29 |
# File 'lib/dolibarr/recurring_invoices.rb', line 21 def list(thirdparty_id: nil, status: nil, sqlfilters: nil, limit: 100, page: 0, sortfield: 't.rowid', sortorder: 'ASC') get_list( '/invoices/templates', 'sortfield' => sortfield, 'sortorder' => sortorder, 'limit' => limit, 'page' => page, 'thirdparty_ids' => thirdparty_id, 'status' => status, 'sqlfilters' => sqlfilters ).map { |raw| Coerce.amounts(raw) } end |