Skip to content

Payment documents

There are 3 types of documents:

  • Invoice. Result for sale operation.
  • Payment Slip. Result of payout operation.
  • Credit Note. Result of refund operation.

All of them have dedicated classes:

  • Invoice: \App\Modules\Payment\Models\PaidSaleInvoice
  • Payment Slip: \App\Modules\Payment\Models\PaymentSlip
  • Credit 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:

  1. Invoice is a completed Order (class Invoice extends Order) (result: there is no such term "unpaid invoice" or "pro forma" anymore — it's Order, invoice is always paid)
  2. The workflow for Order is: unpaid&unfulfilled -> paid&unfulfilled -> paid&fulfilled. So, possible states:
    1. unpaid or paid
    2. unfulfilled or fulfilled

Migration steps:

  1. Rename Invoice into Order and remove all global scopes from this model. Move all methods from existing Order class into a new Order class.
  2. Rename PaidSaleInvoice into Invoice
  3. Extract PaymentSlip into a separate table (unresolved question: reuse the same InvoiceLine model or use a new one?)
  4. Decide what to do with lines and InvoiceLine model: continue reusing it (and thus rename it to OrderLine) or create new models for all (?) types of PaymentDocuments.