Default batch number selection (#11454)

* fetch batch_no in `get_basic_details`

* PEP8 changes and docstring

* only auto-fetch batch number for Sales documents:
otherwise, automatic batch creation will not work properly because all new
stock will be added to old batch

* new function to fetch batch number using FEFO:
FEFO - First Expiring First Out

* fetch batch number in `get_basic_details` using FEFO

* add new function - `set_batch_number`

* `set_batch_number` when `qty` is triggered

* `set_batch_number` when `uom` is triggered

* whitelist `get_batch_no_fefo`

* code clean up

* move `set_batch_number` to conversion_factor instead of uom

* rename `get_batch_no_fefo` to `get_batch_no`

* fix test case

* final cleanup

* Revert "fetch batch_no in `get_basic_details`"

This reverts commit dd024b1eb3.

* fix test case

* update Sales Invoice manual

* move changes away from `transaction.js`

* query should not fetch expired batches

* refactor `get_batch_no`:
add new function `get_batches`

* Update batch.py
This commit is contained in:
tundebabzy
2017-11-23 08:35:15 +01:00
committed by Nabin Hait
parent 82027ea3bf
commit acccdb3890
5 changed files with 167 additions and 51 deletions

View File

@@ -56,6 +56,21 @@ bill this Invoice and the period for which the contract is valid.
ERPNext will automatically create new Invoices and mail it to the Email Addresses
you set.
#### Automatically Fetching Item Batch Numbers
If you are selling an item from a [Batch](/docs/user/manual/en/stock/batch),
ERPNext will automatically fetch a batch number for you if "Update Stock"
is checked. The batch number will be fetched on a First Expiring First Out
(FEFO) basis. This is a variant of First In First Out (FIFO) that gives
highest priority to the soonest to expire Items.
<img class="screenshot" alt="POS Invoice" src="/docs/assets/img/accounts/sales-invoice-fetch-batch.png">
Note that if the first batch in the queue cannot satisfy the order on the invoice,
the next batch in the queue that can satisfy the order will be selected. If there is
no batch that can satisfy the order, ERPNext will cancel its attempt to automatically
fetch a suitable batch number.
#### POS Invoices
Consider a scenario where retail transaction is carried out. For e.g: A retail shop.