frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.85k stars 7.33k forks source link

Invalid Purchasing Flow: Purchase Receipt -> Get Items -> Purchase Invoice #33408

Open dj12djdjs opened 1 year ago

dj12djdjs commented 1 year ago

Information about bug

Overview

The problem is, when a return is processed against a purchase invoice, the returned items are completely ignored when creating the purchase receipt.

This becomes a problem during the following scenario. The company creates a Purchase Order against Supplier X, then Supplier X issues an invoice. In this example the invoice is for two items. Item 1 x10 Item 2 x10

After 1 month, the supplier is no longer able to fulfil Item 2 and issues a credit note. In ERPNext we create a return against the original invoice crediting Item 2 of 10x.

Another 1 month goes by, the goods are received. We go to Purchase Receipt, Get Items -> From -> Purchase Invoice we select the original invoice from supplier.

Expected Behavior Only Item 1 x10 will be added to purchase receipt because Item 2 x10 was credited.

Observed Behavior Both Item 1 x10 and Item 2 x10 are added to the purchase receipt.

Module

buying

Version

+---------+----------------+---------+---------+ | App | Version | Branch | Commit | +---------+----------------+---------+---------+ | erpnext | 14.x.x-develop | develop | 76be35a | | frappe | 15.x.x-develop | develop | bb5e21d | +---------+----------------+---------+---------+

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

No response

rohitwaghchaure commented 1 year ago

Most users create the purchase invoice after the purchase receipt, why you create the purchase invoice first and then purchase receipt? Could you share the use case?

dj12djdjs commented 1 year ago

Hello @rohitwaghchaure,

Sure, let me give an overview of our full ordering process.

We're a distributor in Canada, we import manufactured goods from Europe and China, lead times can be between 3-6 months. Sometimes even longer.

In this case we create a Purchase Order for the following items: Item A x10 Item B x10 Item C x10

We send our Purchase Order to the supplier. The supplier says okay, we can fulfill the following: Item A x10 Item B x10

The supplier will issue an invoice for the above items and we will pay them. The supplier will then begin manufacturing those items.

After two weeks we re-submit our open order to our supplier with the remaining Item C x10 In this case they are able to fulfill it now, so they issue us an invoice for Item C x10, we pay it, they begin manufacturing it.

Sometimes it happens where the supplier is unable to fulfill an invoice fully. Before they ship the goods, they will issue us a credit note for the item(s) they were not able to fulfill.

When this happens, we will make the credit note against the purchase invoice, and the billed_amt for that Purchase Order Item will be corrected. So we can re-submit this order to supplier again at a later date.

The problem now is, we've received the goods and operator is creating the purchase receipt. They will create the purchase receipt and get items from the two purchase invoices expected to arrive. PINV-1 PINV-2

At this stage PINV-1 contains Item A x10 Item B x10 (Credited)

PIN-2 contains Item C x10

When pulled into the Purchase Receipt Item A x10 Item B x10 Item C x10

Will all exist in the the purchase receipt even though Item B is credited and is not expected to arrive with this invoice.

In this example it is easy, but in real world we have hundreds of items across multiple invoices. It is nearly impossible to remember which ones are credited to remove them manually.

Does this use case make sense?