Appearance
Payment documents
There are 3 types of documents:
Invoice. Result forsaleoperation.Payment Slip. Result ofpayoutoperation.Credit Note. Result ofrefundoperation.
All of them have dedicated classes:
Invoice:\App\Modules\Payment\Models\PaidSaleInvoicePayment Slip:\App\Modules\Payment\Models\PaymentSlipCredit Note:\App\Modules\Payment\Models\CreditNote
Additionally, we have Order (\App\Modules\Payment\Models\Order class).
Class hierarchy
For historical reasons, we used Invoice model for all types of payment documents. Currently, we are at the process of decoupling these classes.
The plan is to avoid this naming confusion and have this scheme:
Highlights:
Invoiceis a completedOrder(class Invoice extends Order) (result: there is no such term "unpaid invoice" or "pro forma" anymore — it'sOrder, invoice is always paid)- The workflow for
Orderis:unpaid&unfulfilled -> paid&unfulfilled -> paid&fulfilled. So, possible states:unpaidorpaidunfulfilledorfulfilled
Migration steps:
- Rename
InvoiceintoOrderand remove all global scopes from this model. Move all methods from existingOrderclass into a newOrderclass. - Rename
PaidSaleInvoiceintoInvoice - Extract
PaymentSlipinto a separate table (unresolved question: reuse the sameInvoiceLinemodel or use a new one?) - Decide what to do with lines and
InvoiceLinemodel: continue reusing it (and thus rename it toOrderLine) or create new models for all (?) types ofPaymentDocuments.