fix: update sql function usage syntax
This commit is contained in:
@@ -657,7 +657,7 @@ def get_tcs_amount(parties, inv, tax_details, vouchers, adv_vouchers):
|
||||
"company": inv.company,
|
||||
"voucher_no": ["in", vouchers],
|
||||
},
|
||||
"sum(debit)",
|
||||
[{"SUM": "debit"}],
|
||||
)
|
||||
or 0.0
|
||||
)
|
||||
@@ -735,7 +735,7 @@ def get_limit_consumed(ldc, parties):
|
||||
"posting_date": ("between", (ldc.valid_from, ldc.valid_upto)),
|
||||
"company": ldc.company,
|
||||
},
|
||||
"sum(tax_withholding_net_total)",
|
||||
[{"SUM": "tax_withholding_net_total"}],
|
||||
)
|
||||
|
||||
return limit_consumed
|
||||
|
||||
@@ -525,7 +525,7 @@ def get_grand_total(filters, doctype):
|
||||
"docstatus": 1,
|
||||
"posting_date": ("between", [filters.get("from_date"), filters.get("to_date")]),
|
||||
},
|
||||
"sum(base_grand_total)",
|
||||
[{"SUM": "base_grand_total"}],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.model.meta import get_field_precision
|
||||
from frappe.query_builder import DocType
|
||||
from frappe.query_builder.functions import Abs
|
||||
from frappe.utils import cint, flt, format_datetime, get_datetime
|
||||
|
||||
import erpnext
|
||||
@@ -661,7 +662,10 @@ def get_rate_for_return(
|
||||
if voucher_type in ("Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"):
|
||||
select_field = "incoming_rate"
|
||||
else:
|
||||
select_field = "abs(stock_value_difference / actual_qty)"
|
||||
StockLedgerEntry = frappe.qb.DocType("Stock Ledger Entry")
|
||||
select_field = Abs(
|
||||
StockLedgerEntry.stock_value_difference / StockLedgerEntry.actual_qty
|
||||
)
|
||||
|
||||
rate = flt(frappe.db.get_value("Stock Ledger Entry", filters, select_field))
|
||||
if not (rate and return_against) and voucher_type in ["Sales Invoice", "Delivery Note"]:
|
||||
|
||||
@@ -9,7 +9,7 @@ def execute():
|
||||
frappe.db.get_value(
|
||||
"Stock Ledger Entry",
|
||||
{"docstatus": 1, "batch_no": batch.batch_id, "is_cancelled": 0},
|
||||
"sum(actual_qty)",
|
||||
[{"SUM": "actual_qty"}],
|
||||
)
|
||||
or 0.0
|
||||
)
|
||||
|
||||
@@ -64,7 +64,7 @@ class SalesPerson(NestedSet):
|
||||
frappe.db.get_value(
|
||||
"Sales Team",
|
||||
{"docstatus": 1, "parenttype": "Sales Order", "sales_person": self.sales_person_name},
|
||||
"sum(allocated_amount)",
|
||||
[{"SUM": "allocated_amount"}],
|
||||
)
|
||||
)
|
||||
|
||||
@@ -72,7 +72,7 @@ class SalesPerson(NestedSet):
|
||||
frappe.db.get_value(
|
||||
"Sales Team",
|
||||
{"docstatus": 1, "parenttype": "Sales Invoice", "sales_person": self.sales_person_name},
|
||||
"sum(allocated_amount)",
|
||||
{"SUM": "allocated_amount"},
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -1799,7 +1799,7 @@ class TestPurchaseReceipt(IntegrationTestCase):
|
||||
"voucher_no": pr.name,
|
||||
"is_cancelled": 0,
|
||||
},
|
||||
fieldname=["sum(stock_value_difference)"],
|
||||
fieldname=[{"SUM": "stock_value_difference"}],
|
||||
)
|
||||
|
||||
# Value of Stock Account should be equal to the sum of Stock Value Difference
|
||||
|
||||
@@ -1039,7 +1039,7 @@ class TestStockLedgerEntry(IntegrationTestCase, StockTestMixin):
|
||||
"is_cancelled": 0,
|
||||
"account": "Stock In Hand - TCP1",
|
||||
},
|
||||
"sum(credit)",
|
||||
[{"SUM": "credit"}],
|
||||
)
|
||||
|
||||
def _day(days):
|
||||
|
||||
Reference in New Issue
Block a user