magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

No control over invoice generation #81

Open magento-engcom-team opened 5 years ago

magento-engcom-team commented 5 years ago

Summary

Magento currently automatically creates Invoices associated with Sales Orders when a payment for a sales order is received. This is incorrect and this is currently the case for Braintree, PayPal and other payment methods developed by the magento core team.

The fundamental problem with this is that there is no control over it and not all merchants should have an Invoice automatically generated.

Although this may be fine for some small merchants, it is not appropriate for larger merchants that have an integration with an ERP system and follow GAAP.

In particular GAAP stipulate that revenue should NOT be recognised too early and an Invoice is fundamentally an accounting transaction that affects the P&L statement. By creating and issuing an Invoice at the time of payment receipt for the Sales Order the merchant is effectively not following GAAP as they are recognising the revenue too early. It is generally accepted under GAAP to recognise revenue (i.e. Issuing of Invoice) at the time of order fulfillment / shipment rather than receipt of payment. Furthermore it results in time-separation of Revenue recognition (Invoice) and related COGS expense that is directly related to that revenue, which is also against GAAP.

Receipt of Payment for a Sales Order is actually a Balance Sheet transaction with Debit (Increase) to a Bank Account (Asset) account and a Credit (Increase) to a Customer Prepayments (Liability) account.

Invoicing and Item Fulfillment in turn result in Credit (Increase) to Sales Revenue, Debit (Decrease) in Customer Prepayments Liability, Credit (Decrease) in Inventory Asset and Debit (Increase) in COGS Expense.

Furthermore, it is possible for a Sales Order to change between the time it is received and fulfilled when stock isn't available or sold through another channel, the customer changes their mind, etc.

Where Magento is integrated with an ERP it is also generally desirable to have the ERP create the invoice and sync the invoice to Magento, rather than having the eCommerce platform try to handle accounting concepts and do so incorrectly.

If a merchant wants to generate an Invoice at the time of Payment receipt they should be allowed to do so, but at the same time they should not be forced to do so.

Similarly a refund (which is a balance sheet transaction) should not be tied to a Credit Memo (which is a P&L transaction).

This has been a constant problem and frustration for a number of larger clients with ERP integrations with Magento.

This is particularly important in the B2B space.

Examples

Create an order and pay for it through Braintree or PayPal and see how an Invoice is automatically generated.

Proposed solution

Implement a configuration option on the base payment method class that controls whether an Invoice is automatically generated when a payment accepted by that payment method. Also implement and expose a Payment entity that actually keeps track of payments.

Magento already separates payments from invoices at the lower level with data stored in sales_order_payment and sales_payment_transaction so it should not be particularly difficult to show it that way.

It is also worth noting that Payments are usually applied / allocated to Invoices when an Invoice is created and it should be possible to configure the system to either automatically allocate Payments associated with Sales Orders to Invoices or to do so manually (and sync back from the backend ERP).

Original Report: https://github.com/magento/magento2/issues/17952 by @sheldmandu

tomekjordan commented 5 years ago

I agree, totally disaster when customer makes refund request on Paypal and Magento automatically create credit memo (in mosta cases with wrong calculations, totals)