Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release v14 #43668

Merged
merged 33 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1f09975
fix: validation for corrective job card (backport #43555) (backport #…
mergify[bot] Oct 12, 2024
01d6c10
fix: Use `ref_doc.get()` for `party_account_currency`
Abdeali099 Oct 13, 2024
16d9ca7
Merge pull request #43640 from frappe/mergify/bp/version-14-hotfix/pr…
vorasmit Oct 14, 2024
ae47fb9
fix: ignore free item when qty is zero
Ninad1306 Oct 11, 2024
3b1f0c1
test: test case to validate free item is ignored when qty is zero
Ninad1306 Oct 11, 2024
fc7207b
refactor: remove 'format:' based naming
venkat102 Oct 10, 2024
0654656
chore: resolve conflict
ruthra-kumar Oct 15, 2024
2cce2cf
Merge pull request #43649 from frappe/mergify/bp/version-14-hotfix/pr…
ruthra-kumar Oct 15, 2024
475c9b8
Merge pull request #43653 from frappe/mergify/bp/version-14-hotfix/pr…
ruthra-kumar Oct 15, 2024
c520a7c
fix: update item details with actual quantity.
Bhavan23 Oct 8, 2024
dc2483b
test: Validate the actual quantity when creating a material request f…
Bhavan23 Oct 8, 2024
699b098
fix: update formatings
Bhavan23 Oct 8, 2024
a8ad608
fix: update formatings
Bhavan23 Oct 8, 2024
7eac9cc
fix: zero incoming rate for delivery note return (#43642)
rohitwaghchaure Oct 15, 2024
a585a70
chore: fix conflicts
rohitwaghchaure Oct 15, 2024
dcbfd4a
fix: removed unused query
ljain112 Oct 15, 2024
be78e17
chore: resolve conflict
ruthra-kumar Oct 15, 2024
9697cb0
Merge pull request #43659 from frappe/mergify/bp/version-14-hotfix/pr…
ruthra-kumar Oct 15, 2024
e7f630f
chore: resolve conflict
ruthra-kumar Oct 15, 2024
5aff424
Merge pull request #43657 from frappe/mergify/bp/version-14-hotfix/pr…
ruthra-kumar Oct 15, 2024
1913caf
Merge pull request #43665 from frappe/mergify/bp/version-14-hotfix/pr…
ruthra-kumar Oct 15, 2024
c7c2bdd
fix: delete invalid pricing rule on change of applicable_for
ljain112 Oct 8, 2024
5d9474c
test: added test for change in applicable_for_value in promotional sc…
ljain112 Oct 8, 2024
aa85c3a
Merge pull request #43669 from frappe/mergify/bp/version-14-hotfix/pr…
ruthra-kumar Oct 15, 2024
1262c32
fix: conversion factor issue (backport #43645) (#43675)
mergify[bot] Oct 15, 2024
32f6eb7
fix: added string for translation in bank reconciliation statement
ljain112 Oct 10, 2024
8701cb7
Merge pull request #43677 from frappe/mergify/bp/version-14-hotfix/pr…
ruthra-kumar Oct 15, 2024
0f738de
fix: added parentheses for correct query formation for logical OR con…
ljain112 Oct 11, 2024
59c314c
fix: run gl_entries and closing voucher processes in same function
ljain112 Oct 15, 2024
7c549e6
Merge pull request #43679 from frappe/mergify/bp/version-14-hotfix/pr…
ruthra-kumar Oct 15, 2024
bb774ce
fix: missing child company accounts in consolidated balance sheet
ljain112 Oct 15, 2024
7005008
Merge pull request #43681 from frappe/mergify/bp/version-14-hotfix/pr…
ruthra-kumar Oct 15, 2024
2e6ead3
Merge pull request #43683 from frappe/mergify/bp/version-14-hotfix/pr…
ruthra-kumar Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def make_payment_request(**args):
)

party_type = args.get("party_type") or "Customer"
party_account_currency = ref_doc.party_account_currency
party_account_currency = ref_doc.get("party_account_currency")

if not party_account_currency:
party_account = get_party_account(party_type, ref_doc.get(party_type.lower()), ref_doc.company)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def on_cancel(self):
)
if gle_count > 5000:
frappe.enqueue(
make_reverse_gl_entries,
process_cancellation,
voucher_type="Period Closing Voucher",
voucher_no=self.name,
queue="long",
Expand All @@ -51,9 +51,7 @@ def on_cancel(self):
alert=True,
)
else:
make_reverse_gl_entries(voucher_type="Period Closing Voucher", voucher_no=self.name)

self.delete_closing_entries()
process_cancellation(voucher_type="Period Closing Voucher", voucher_no=self.name)

def validate_future_closing_vouchers(self):
if frappe.db.exists(
Expand All @@ -66,12 +64,6 @@ def validate_future_closing_vouchers(self):
)
)

def delete_closing_entries(self):
closing_balance = frappe.qb.DocType("Account Closing Balance")
frappe.qb.from_(closing_balance).delete().where(
closing_balance.period_closing_voucher == self.name
).run()

def validate_account_head(self):
closing_account_type = frappe.get_cached_value("Account", self.closing_account_head, "root_type")

Expand Down Expand Up @@ -136,14 +128,7 @@ def make_gl_entries(self, get_opening_entries=False):
closing_entries = self.get_grouped_gl_entries(get_opening_entries=get_opening_entries)
if len(gl_entries + closing_entries) > 3000:
frappe.enqueue(
process_gl_entries,
gl_entries=gl_entries,
voucher_name=self.name,
timeout=3000,
)

frappe.enqueue(
process_closing_entries,
process_gl_and_closing_entries,
gl_entries=gl_entries,
closing_entries=closing_entries,
voucher_name=self.name,
Expand All @@ -157,8 +142,9 @@ def make_gl_entries(self, get_opening_entries=False):
alert=True,
)
else:
process_gl_entries(gl_entries, self.name)
process_closing_entries(gl_entries, closing_entries, self.name, self.company, self.posting_date)
process_gl_and_closing_entries(
gl_entries, closing_entries, self.name, self.company, self.posting_date
)

def get_grouped_gl_entries(self, get_opening_entries=False):
closing_entries = []
Expand Down Expand Up @@ -323,9 +309,10 @@ def get_balances_based_on_dimensions(

if get_opening_entries:
query = query.where(
gl_entry.posting_date.between(self.get("year_start_date"), self.posting_date)
| gl_entry.is_opening
== "Yes"
( # noqa: UP034
(gl_entry.posting_date.between(self.get("year_start_date"), self.posting_date))
| (gl_entry.is_opening == "Yes")
)
)
else:
query = query.where(
Expand All @@ -343,38 +330,38 @@ def get_balances_based_on_dimensions(
return query.run(as_dict=1)


def process_gl_entries(gl_entries, voucher_name):
def process_gl_and_closing_entries(gl_entries, closing_entries, voucher_name, company, closing_date):
from erpnext.accounts.doctype.account_closing_balance.account_closing_balance import (
make_closing_entries,
)
from erpnext.accounts.general_ledger import make_gl_entries

try:
if gl_entries:
make_gl_entries(gl_entries, merge_entries=False)
make_closing_entries(gl_entries + closing_entries, voucher_name, company, closing_date)
frappe.db.set_value("Period Closing Voucher", voucher_name, "gle_processing_status", "Completed")
except Exception as e:
frappe.db.rollback()
frappe.log_error(e)
frappe.db.set_value("Period Closing Voucher", voucher_name, "gle_processing_status", "Failed")


def process_closing_entries(gl_entries, closing_entries, voucher_name, company, closing_date):
from erpnext.accounts.doctype.account_closing_balance.account_closing_balance import (
make_closing_entries,
)

try:
make_closing_entries(gl_entries + closing_entries, voucher_name, company, closing_date)
except Exception as e:
frappe.db.rollback()
frappe.log_error(e)


def make_reverse_gl_entries(voucher_type, voucher_no):
def process_cancellation(voucher_type, voucher_no):
from erpnext.accounts.general_ledger import make_reverse_gl_entries

try:
make_reverse_gl_entries(voucher_type=voucher_type, voucher_no=voucher_no)
delete_closing_entries(voucher_no)
frappe.db.set_value("Period Closing Voucher", voucher_no, "gle_processing_status", "Completed")
except Exception as e:
frappe.db.rollback()
frappe.log_error(e)
frappe.db.set_value("Period Closing Voucher", voucher_no, "gle_processing_status", "Failed")


def delete_closing_entries(voucher_no):
closing_balance = frappe.qb.DocType("Account Closing Balance")
frappe.qb.from_(closing_balance).delete().where(
closing_balance.period_closing_voucher == voucher_no
).run()
6 changes: 6 additions & 0 deletions erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,12 @@ def test_pricing_rule_for_product_free_item_rounded_qty_and_recursion(self):
self.assertEqual(so.items[1].item_code, "_Test Item")
self.assertEqual(so.items[1].qty, 3)

so = make_sales_order(item_code="_Test Item", qty=5, do_not_submit=1)
so.items[0].qty = 1
del so.items[-1]
so.save()
self.assertEqual(len(so.items), 1)

def test_apply_multiple_pricing_rules_for_discount_percentage_and_amount(self):
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 1")
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 2")
Expand Down
3 changes: 3 additions & 0 deletions erpnext/accounts/doctype/pricing_rule/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None):
if pricing_rule.round_free_qty:
qty = math.floor(qty)

if not qty:
return

free_item_data_args = {
"item_code": free_item,
"qty": qty,
Expand Down
52 changes: 41 additions & 11 deletions erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.query_builder import Criterion
from frappe.query_builder.functions import IfNull

pricing_rule_fields = [
"apply_on",
Expand Down Expand Up @@ -91,22 +93,50 @@ def validate_pricing_rules(self):
if self.is_new():
return

transaction_exists = False
docnames = []
invalid_pricing_rule = self.get_invalid_pricing_rules()

# If user has changed applicable for
if self.get_doc_before_save() and self.get_doc_before_save().applicable_for == self.applicable_for:
if not invalid_pricing_rule:
return

docnames = frappe.get_all("Pricing Rule", filters={"promotional_scheme": self.name})
if frappe.db.exists(
"Pricing Rule Detail",
{
"pricing_rule": ["in", invalid_pricing_rule],
"docstatus": ["<", 2],
},
):
raise_for_transaction_exists(self.name)

for doc in invalid_pricing_rule:
frappe.delete_doc("Pricing Rule", doc)

frappe.msgprint(
_("The following invalid Pricing Rules are deleted:")
+ "<br><br><ul><li>"
+ "</li><li>".join(invalid_pricing_rule)
+ "</li></ul>"
)

def get_invalid_pricing_rules(self):
pr = frappe.qb.DocType("Pricing Rule")
conditions = []
conditions.append(pr.promotional_scheme == self.name)

if self.applicable_for:
applicable_for = frappe.scrub(self.applicable_for)
applicable_for_list = [d.get(applicable_for) for d in self.get(applicable_for)]

for docname in docnames:
if frappe.db.exists("Pricing Rule Detail", {"pricing_rule": docname.name, "docstatus": ("<", 2)}):
raise_for_transaction_exists(self.name)
conditions.append(
(IfNull(pr.applicable_for, "") != self.applicable_for)
| (
(IfNull(pr.applicable_for, "") == self.applicable_for)
& IfNull(pr[applicable_for], "").notin(applicable_for_list)
)
)
else:
conditions.append(IfNull(pr.applicable_for, "") != "")

if docnames and not transaction_exists:
for docname in docnames:
frappe.delete_doc("Pricing Rule", docname.name)
return frappe.qb.from_(pr).select(pr.name).where(Criterion.all(conditions)).run(pluck=True)

def on_update(self):
self.validate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,31 @@ def test_change_applicable_for_in_promotional_scheme(self):
price_rules = frappe.get_all("Pricing Rule", filters={"promotional_scheme": ps.name})
self.assertEqual(price_rules, [])

def test_change_applicable_for_values_in_promotional_scheme(self):
ps = make_promotional_scheme(applicable_for="Customer", customer="_Test Customer")
ps.append("customer", {"customer": "_Test Customer 2"})
ps.save()

price_rules = frappe.get_all(
"Pricing Rule", filters={"promotional_scheme": ps.name, "applicable_for": "Customer"}
)
self.assertTrue(len(price_rules), 2)

ps.set("customer", [])
ps.append("customer", {"customer": "_Test Customer 2"})
ps.save()

price_rules = frappe.get_all(
"Pricing Rule",
filters={
"promotional_scheme": ps.name,
"applicable_for": "Customer",
"customer": "_Test Customer",
},
)
self.assertEqual(price_rules, [])
frappe.delete_doc("Promotional Scheme", ps.name)

def test_min_max_amount_configuration(self):
ps = make_promotional_scheme()
ps.price_discount_slabs[0].min_amount = 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,6 @@ def get_tcs_amount(parties, inv, tax_details, vouchers, adv_vouchers):
conditions.append(ple.voucher_no == ple.against_voucher_no)
conditions.append(ple.company == inv.company)

(qb.from_(ple).select(Abs(Sum(ple.amount))).where(Criterion.all(conditions)).run(as_list=1))

advance_amt = (
qb.from_(ple).select(Abs(Sum(ple.amount))).where(Criterion.all(conditions)).run()[0][0] or 0.0
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:UNREC-{#####}",
"creation": "2023-08-22 10:26:34.421423",
"default_view": "List",
"doctype": "DocType",
Expand Down Expand Up @@ -58,11 +56,10 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-08-28 17:42:50.261377",
"modified": "2024-10-10 12:03:50.022444",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Unreconcile Payment",
"naming_rule": "Expression",
"owner": "Administrator",
"permissions": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ frappe.query_reports["Bank Reconciliation Statement"] = {
},
],
formatter: function (value, row, column, data, default_formatter, filter) {
if (column.fieldname == "payment_entry" && value == "Cheques and Deposits incorrectly cleared") {
if (column.fieldname == "payment_entry" && value == __("Cheques and Deposits incorrectly cleared")) {
column.link_onclick =
"frappe.query_reports['Bank Reconciliation Statement'].open_utility_report()";
}
Expand Down
Loading
Loading