* refactor: DB independent quoting and truthy/falsy values
* style: reformat to black spec
* fix: ifnull -> coalesce
* fix: coalesce -> Coalesce
* fix: revert pypika comparison
* refactor: convert queries to QB
* fix: incorrect value types for query
`=` query makes no sense with list of values
* fix: remove warehouse docstatus condition
* fix: keep using base rate as rate
Co-authored-by: Ankush Menat <ankush@frappe.io>
If stock voucher count goes >1000 then fetching all gles and reposting
them all at once requires much more memory and can cause crash.
- This PR ensures that GLE reposting is done in chunks of 100 vouchers.
- This PR also starts keeping track of how many such chunks were
processed so in future progress is resumed in event of timeout.
If you have a huge list of docs to repost then maintaining transaction
throughtout entire GL reposting is not only unnecessary but also creates
performance issues. Periodically commiting the changes prevents lost
progress and reduces memory usage.
In Sales/Purchase invoices credit/debit are flipped and negated while making GLE,
this is unflipped while posting them but if we compare the flipped ones
it will always result in comparison failure and repost it.
- It runs after repost (after commiting), so it has 0 impact on repost itself
- Just that scheduled job log shows up as failed, while actually repost is done and repost document is "Completed"
- The check is inaccurate also, so best to remove this
- Users cant do anything about it anyway. This just piles up phantom failed jobs unneccessarily
* perf: only validate if voucher is journal entry
* perf: optimize merge GLE
- Order fields such that comparison will fail faster
- Break out of loops if not matched
* perf: don't try to match SLE if count mismatch
* refactor: simplify initialize_previous_data
* perf: use cache for fetching valuation_method
These are set only once fields
* refactor: simplify get_future_stock_vouchers
* refactor: simplify get_voucherwise_gl_entries
* perf: fetch only required fields for GL comparison
`select *` fetches all fields, output of this function is only used for
comparing.
* perf: reorder conditions in PL cost center check
* perf: reduce query while validating new gle
* perf: use cache for validating warehouse props
These properties don't change often, no need to query everytime.
* perf: use cached stock settings to validate SLE
* docs: update misleading docstring
Co-authored-by: Marica <maricadsouza221197@gmail.com>
* fix: finished item validation and rate
* fix: Check if stock and account balance in sync after reposting
* fix: validate stock accounts in journal entry
* fix: validate expense against budget
* feat: Reposting logic for future finished/transferred item
* feat: added fields to identify needs to recalculate rate while reposting
* refactor: Set rate for outgoing and finished items
* refactor: Arranged fields in Stock Entry item table and added fields to identify finished and scrap item
* refactor: Arranged fields in Stock Entry item table and added fields to identify finished and scrap item
* refactor: Get outgoing rate for purchase return
* refactor: Get incoming rate for sales return
* test: Added tests for reposting valuation of transferred/finished/returned items
* feat: added incoming rate field in DN, SI and Packed Item table
* feat: get incoming rate for returned item
* fix: no error while getting valuation rate in stock entry
* fix: update stock ledger for DN and SI
* feat: update item valuation rate in PR and PI based on supplied items cost
* feat: SLE reposting logic for sales return and subcontracted item with test cases
* feat: update qty in future sle
* feat: repost future sle and gle via Repost Item Valuation
* fix: Skip unwanted function calling while reposting
* fix: repost sle for specific item and warehouse
* test: Modified tests for backdated stock reco
* fix: ignore cancelled sle in few methods
* feat: role allowed to do backdated entry
* feat: Show reposting status on stock valuation related reports
* fix: minor fixes
* fix: fixed sider issues
* fix: serial no fix related to immutable ledger
* fix: Test cases fixes related to perpetual inventory
* fix: Test cases fixed
* fix: Fixed reposting on cancel and test cases
* feat: Restart reposting item valuation
* refactor: Code cleanup using small functions and test case fixes
* fix: minor fixes
* fix: Raise on error while reposting item valuation
* fix: minor fix
* fix: Tests fixed
* fix: skip some validation ig gle made from reposting
* fix: test fixes
* fix: debugging stock and account validation
* fix: debugging stock and account validation
* fix: debugging travis for stock and account sync validation
* fix: debugging travis
* fix: debugging travis
* fix: debugging travis