* refactor(queries): migrate item_query to Query Builder
Use Frappe Query Builder to ensure compatibility with PostgreSQL.
The implementation still relies on raw SQL for fcond and mcond through
LiteralValue to maintain compatibility with legacy filter builders.
* refactor(queries): migrate item_query to Query Builder
Fix the bugs found by coderabbit.
For the eol condition: PostgreSQL raises DatetimeFieldOverflow when evaluating '0000-00-00' as
a date literal, even inside NULLIF(). Added a db_type guard to skip the
zero-date condition on PostgreSQL, where it can never be stored anyway.
No generic cross-db solution found for this case; open to revisiting
* refactor(queries): Rework item_query to use get_query
Rework the item_query method to use get_query with the ignore_permissions flag at False
* refactor(controller): Fix the query builder
Fix the build query in item_query according to coderabbit
* refactor(queries): explicitly add has_variants
Explicitely add has_variants==0 to the query according to coderabbit feedback
* perf: get payment ledger and remove update from delink when immutable ledger is enabled
* revert: changes of get_payment_ledger_entries
* perf: skip delink_original_entry during cancellation when Immutable Ledger is enabled
* test: for immutable ledger
* test: add posting_date in create_sales_invoice
* fix: link validation err with immutable ledger on
* test: update testcase of the immutable ledger
* refactor(test): simpler test for immutable invariants
---------
Co-authored-by: ruthra kumar <ruthra@erpnext.com>
This account holds a debit balance (inventory value delivered but not yet
invoiced) and clears to COGS on Sales Invoice, so it is economically a
short-term clearing asset rather than a trade payable. Move it from the
Stock Liabilities group to Stock Assets under Current Assets, with
account_category "Stock Assets" (and account_number 1420 in the numbered
chart). The account_type "Stock Delivered But Not Billed" is unchanged,
so posting logic in Sales Invoice and Delivery Note continues to key off
the correct account.
Existing tests hardcoded "Cost of Goods Sold" as expected GL account,
but SDBNB overrides it on DN submission. Use dn.items[0].expense_account
to work with both SDBNB-enabled and legacy companies.
Ensures regular transactions only match tax rules where
use_for_shopping_cart = 0, preventing webshop-specific rules
from applying to standard documents.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Migrates from raw frappe.db.sql with string interpolation to frappe.qb.
Adds hierarchical supplier_group matching (mirrors customer_group behaviour).
Removes unused get_customer_group_condition helper.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>