InvoiceCreditNoteFormTrait
Form of a manual credit note for an issued invoice.
The user chooses the type (credit note/cancellation), the scope (the whole remaining balance or
only selected rows) and, per row, a quantity field whose maximum is the remaining quantity. There
is no ceiling logic of its own: both the preview and the issuing go through the Api
(api/invoicer/invoice/credit-note-preview / credit-note); the server enforces the ceiling
under the invoice lock and locks the source on issuing. max in HTML is only a convenience.
A fixed discount (voucher) is not in the form; a partial credit note spreads it proportionally.
Table of Contents
Constants
- CREDIT_NOTE_COLLECTIONS : array<string|int, mixed> = ['items', 'shippers', 'paymentMethods']
- Row collections that carry a quantity (same as `CreditNoteLedger`).
Methods
- createComponentCreditNoteForm() : Form
- creditNoteTypeOptions() : array<int, string>
- Returns the credit types from the preview (id => key) translated to invoice type names.
- defaultCreditNoteTypeId() : int|null
- Returns the default type: `DOBROPIS` (the corrective tax document), otherwise the first one offered.
- processCreditNote() : bool
- Issues the credit note through the Api; redirects on success, returns false (with a flash) otherwise.
Constants
CREDIT_NOTE_COLLECTIONS
Row collections that carry a quantity (same as `CreditNoteLedger`).
private
array<string|int, mixed>
CREDIT_NOTE_COLLECTIONS
= ['items', 'shippers', 'paymentMethods']
Methods
createComponentCreditNoteForm()
protected
createComponentCreditNoteForm() : Form
Return values
FormcreditNoteTypeOptions()
Returns the credit types from the preview (id => key) translated to invoice type names.
private
creditNoteTypeOptions(array<string, mixed> $preview) : array<int, string>
Parameters
- $preview : array<string, mixed>
Return values
array<int, string>defaultCreditNoteTypeId()
Returns the default type: `DOBROPIS` (the corrective tax document), otherwise the first one offered.
private
defaultCreditNoteTypeId(array<string, mixed> $preview) : int|null
Parameters
- $preview : array<string, mixed>
Return values
int|nullprocessCreditNote()
Issues the credit note through the Api; redirects on success, returns false (with a flash) otherwise.
private
processCreditNote(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>