Skip to content

Commit

Permalink
Merge pull request #44740 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
ruthra-kumar authored Dec 18, 2024
2 parents 225d4cc + caea52c commit 8e34e20
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 60

name: Patch Test
Expand Down
18 changes: 18 additions & 0 deletions erpnext/accounts/doctype/payment_entry/payment_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,24 @@ frappe.ui.form.on('Payment Entry', {
if (r.message) {
if (!frm.doc.mode_of_payment) {
frm.set_value(field, r.message.account);
} else {
frappe.call({
method: "frappe.client.get_value",
args: {
doctype: "Mode of Payment Account",
filters: {
parent: frm.doc.mode_of_payment,
company: frm.doc.company,
},
fieldname: "default_account",
parent: "Mode of Payment",
},
callback: function (res) {
if (!res.message.default_account) {
frm.set_value(field, r.message.account);
}
},
});
}
frm.set_value('bank', r.message.bank);
frm.set_value('bank_account_no', r.message.bank_account_no);
Expand Down
2 changes: 2 additions & 0 deletions erpnext/accounts/doctype/pricing_rule/pricing_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ def get_pricing_rule_for_item(args, doc=None, for_validate=False):
"parent": args.parent,
"parenttype": args.parenttype,
"child_docname": args.get("child_docname"),
"discount_percentage": 0.0,
"discount_amount": 0,
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,7 @@ def get_payment_terms(self, row):
self.append_payment_term(row, d, term)

def append_payment_term(self, row, d, term):
if (
self.filters.get("customer") or self.filters.get("supplier")
) and d.currency == d.party_account_currency:
if d.currency == d.party_account_currency:
invoiced = d.payment_amount
else:
invoiced = d.base_payment_amount
Expand Down
11 changes: 9 additions & 2 deletions erpnext/accounts/report/financial_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,16 @@ def get_accounting_entries(
query = apply_additional_conditions(doctype, query, from_date, ignore_closing_entries, filters)
query = query.where(gl_entry.account.isin(accounts))

entries = query.run(as_dict=True)
from frappe.desk.reportview import build_match_conditions

return entries
match_conditions = build_match_conditions(doctype)

if match_conditions:
query += "and" + match_conditions

query, params = query.walk()

return frappe.db.sql(query, params, as_dict=True)


def apply_additional_conditions(doctype, query, from_date, ignore_closing_entries, filters):
Expand Down
5 changes: 4 additions & 1 deletion erpnext/accounts/report/gross_profit/gross_profit.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,10 @@ def load_invoice_items(self):
"""

if self.filters.group_by == "Sales Person":
sales_person_cols = ", sales.sales_person, sales.allocated_amount, sales.incentives"
sales_person_cols = """, sales.sales_person,
sales.allocated_percentage * `tabSales Invoice Item`.base_net_amount / 100 as allocated_amount,
sales.incentives
"""
sales_team_table = "left join `tabSales Team` sales on sales.parent = `tabSales Invoice`.name"
else:
sales_person_cols = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_
if net_total_map.get((voucher_type, name)):
if voucher_type == "Journal Entry" and tax_amount and rate:
# back calcalute total amount from rate and tax_amount
if rate:
total_amount = grand_total = base_total = tax_amount / (rate / 100)
base_total = min(tax_amount / (rate / 100), net_total_map.get((voucher_type, name))[0])
total_amount = grand_total = base_total
elif voucher_type == "Purchase Invoice":
total_amount, grand_total, base_total, bill_no, bill_date = net_total_map.get(
(voucher_type, name)
Expand Down Expand Up @@ -405,7 +405,7 @@ def get_doc_info(vouchers, doctype, tax_category_map, net_total_map=None):
"paid_amount_after_tax",
"base_paid_amount",
],
"Journal Entry": ["total_amount"],
"Journal Entry": ["total_debit"],
}

entries = frappe.get_all(
Expand All @@ -427,7 +427,7 @@ def get_doc_info(vouchers, doctype, tax_category_map, net_total_map=None):
elif doctype == "Payment Entry":
value = [entry.paid_amount, entry.paid_amount_after_tax, entry.base_paid_amount]
else:
value = [entry.total_amount] * 3
value = [entry.total_debit] * 3

net_total_map[(doctype, entry.name)] = value

Expand Down
26 changes: 15 additions & 11 deletions erpnext/controllers/sales_and_purchase_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,13 @@ def validate_returned_items(doc):

valid_items = frappe._dict()

select_fields = "item_code, qty, stock_qty, rate, parenttype, conversion_factor"
select_fields = "item_code, qty, stock_qty, rate, parenttype, conversion_factor, name"
if doc.doctype != "Purchase Invoice":
select_fields += ",serial_no, batch_no"

if doc.doctype in ["Purchase Invoice", "Purchase Receipt", "Subcontracting Receipt"]:
select_fields += ",rejected_qty, received_qty"

if doc.doctype in ["Purchase Receipt", "Purchase Invoice"]:
select_fields += ",name"

for d in frappe.db.sql(
f"""select {select_fields} from `tab{doc.doctype} Item` where parent = %s""",
doc.return_against,
Expand Down Expand Up @@ -108,11 +105,13 @@ def validate_returned_items(doc):
for d in doc.get("items"):
key = d.item_code
raise_exception = False
if doc.doctype in ["Purchase Receipt", "Purchase Invoice"]:
if doc.doctype in ["Purchase Receipt", "Purchase Invoice", "Sales Invoice"]:
field = frappe.scrub(doc.doctype) + "_item"
if d.get(field):
key = (d.item_code, d.get(field))
raise_exception = True
elif doc.doctype == "Delivery Note":
key = (d.item_code, d.get("dn_detail"))

if d.item_code and (flt(d.qty) < 0 or flt(d.get("received_qty")) < 0):
if key not in valid_items:
Expand All @@ -124,7 +123,7 @@ def validate_returned_items(doc):
)
else:
ref = valid_items.get(key, frappe._dict())
validate_quantity(doc, d, ref, valid_items, already_returned_items)
validate_quantity(doc, key, d, ref, valid_items, already_returned_items)

if (
ref.rate
Expand Down Expand Up @@ -174,12 +173,12 @@ def validate_returned_items(doc):
frappe.throw(_("Atleast one item should be entered with negative quantity in return document"))


def validate_quantity(doc, args, ref, valid_items, already_returned_items):
def validate_quantity(doc, key, args, ref, valid_items, already_returned_items):
fields = ["stock_qty"]
if doc.doctype in ["Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"]:
fields.extend(["received_qty", "rejected_qty"])

already_returned_data = already_returned_items.get(args.item_code) or {}
already_returned_data = already_returned_items.get(key) or {}

company_currency = erpnext.get_company_currency(doc.company)
stock_qty_precision = get_field_precision(
Expand Down Expand Up @@ -262,15 +261,20 @@ def get_already_returned_items(doc):
column += """, sum(abs(child.rejected_qty) * child.conversion_factor) as rejected_qty,
sum(abs(child.received_qty) * child.conversion_factor) as received_qty"""

field = (
frappe.scrub(doc.doctype) + "_item"
if doc.doctype in ["Purchase Invoice", "Purchase Receipt", "Sales Invoice"]
else "dn_detail"
)
data = frappe.db.sql(
f"""
select {column}
select {column}, {field}
from
`tab{doc.doctype} Item` child, `tab{doc.doctype}` par
where
child.parent = par.name and par.docstatus = 1
and par.is_return = 1 and par.return_against = %s
group by item_code
group by item_code, {field}
""",
doc.return_against,
as_dict=1,
Expand All @@ -280,7 +284,7 @@ def get_already_returned_items(doc):

for d in data:
items.setdefault(
d.item_code,
(d.item_code, d.get(field)),
frappe._dict(
{
"qty": d.get("qty"),
Expand Down
5 changes: 4 additions & 1 deletion erpnext/controllers/status_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ def validate_status(status, options):
["To Bill", "eval:self.per_billed == 0 and self.docstatus == 1"],
["Partly Billed", "eval:self.per_billed > 0 and self.per_billed < 100 and self.docstatus == 1"],
["Return Issued", "eval:self.per_returned == 100 and self.docstatus == 1"],
["Completed", "eval:self.per_billed == 100 and self.docstatus == 1"],
[
"Completed",
"eval:(self.per_billed == 100 and self.docstatus == 1) or (self.docstatus == 1 and self.grand_total == 0 and self.per_returned != 100 and self.is_return == 0)",
],
["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed' and self.docstatus != 2"],
],
Expand Down
5 changes: 4 additions & 1 deletion erpnext/public/js/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ $.extend(erpnext.queries, {
},

dispatch_address_query: function (doc) {
var filters = { link_doctype: "Company", link_name: doc.company || "" };
var is_drop_ship = doc.items.some((item) => item.delivered_by_supplier);
if (is_drop_ship) filters = {};
return {
query: "frappe.contacts.doctype.address.address.address_query",
filters: { link_doctype: "Company", link_name: doc.company || "" },
filters: filters,
};
},

Expand Down
1 change: 1 addition & 0 deletions erpnext/stock/doctype/pick_list/pick_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ def create_stock_entry(pick_list):
stock_entry = frappe.new_doc("Stock Entry")
stock_entry.pick_list = pick_list.get("name")
stock_entry.purpose = pick_list.get("purpose")
stock_entry.company = pick_list.get("company")
stock_entry.set_stock_entry_type()

if pick_list.get("work_order"):
Expand Down

0 comments on commit 8e34e20

Please sign in to comment.