Skip to content

Commit

Permalink
Merge pull request #43774 from frappe/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
ruthra-kumar authored Oct 23, 2024
2 parents 08cabd1 + 879b2b7 commit 692de89
Show file tree
Hide file tree
Showing 29 changed files with 272 additions and 159 deletions.
2 changes: 1 addition & 1 deletion erpnext/accounts/deferred_revenue.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def build_conditions(process_type, account, company):
)

if account:
conditions += f"AND {deferred_account}='{account}'"
conditions += f"AND {deferred_account}='{frappe.db.escape(account)}'"
elif company:
conditions += f"AND p.company = {frappe.db.escape(company)}"

Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/bank_clearance/bank_clearance.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_payment_entries_for_bank_clearance(
"Payment Entry" as payment_document, name as payment_entry,
reference_no as cheque_number, reference_date as cheque_date,
if(paid_from=%(account)s, paid_amount + total_taxes_and_charges, 0) as credit,
if(paid_from=%(account)s, 0, received_amount) as debit,
if(paid_from=%(account)s, 0, received_amount + total_taxes_and_charges) as debit,
posting_date, ifnull(party,if(paid_from=%(account)s,paid_to,paid_from)) as against_account, clearance_date,
if(paid_to=%(account)s, paid_to_account_currency, paid_from_account_currency) as account_currency
from `tabPayment Entry`
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/journal_entry/journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def validate_depr_entry_voucher_type(self):
frappe.throw(_("Journal Entry type should be set as Depreciation Entry for asset depreciation"))

def validate_stock_accounts(self):
stock_accounts = get_stock_accounts(self.company, self.doctype, self.name)
stock_accounts = get_stock_accounts(self.company, accounts=self.accounts)
for account in stock_accounts:
account_bal, stock_bal, warehouse_list = get_stock_and_account_balance(
account, self.posting_date, self.company
Expand Down
4 changes: 3 additions & 1 deletion erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2486,7 +2486,9 @@ def get_party_details(company, party_type, party, date, cost_center=None):
account_balance = get_balance_on(party_account, date, cost_center=cost_center)
_party_name = "title" if party_type == "Shareholder" else party_type.lower() + "_name"
party_name = frappe.db.get_value(party_type, party, _party_name)
party_balance = get_balance_on(party_type=party_type, party=party, cost_center=cost_center)
party_balance = get_balance_on(
party_type=party_type, party=party, company=company, cost_center=cost_center
)
if party_type in ["Customer", "Supplier"]:
party_bank_account = get_party_bank_account(party_type, party)
bank_account = get_default_company_bank_account(company, party_type, party)
Expand Down
12 changes: 12 additions & 0 deletions erpnext/accounts/doctype/payment_request/payment_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
from erpnext.accounts.utils import get_account_currency, get_currency_precision
from erpnext.utilities import payment_app_import_guard

ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST = [
"Sales Order",
"Purchase Order",
"Sales Invoice",
"Purchase Invoice",
"POS Invoice",
"Fees",
]


def _get_payment_gateway_controller(*args, **kwargs):
with payment_app_import_guard():
Expand Down Expand Up @@ -525,6 +534,9 @@ def make_payment_request(**args):

args = frappe._dict(args)

if args.dt not in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST:
frappe.throw(_("Payment Requests cannot be created against: {0}").format(frappe.bold(args.dt)))

ref_doc = frappe.get_doc(args.dt, args.dn)
gateway_account = get_gateway_details(args) or frappe._dict()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ frappe.ui.form.on("POS Closing Entry", {
) {
reset_values(frm);
frappe.run_serially([
() => frappe.dom.freeze(__("Loading Invoices! Please Wait...")),
() => frm.trigger("set_opening_amounts"),
() => frm.trigger("get_pos_invoices"),
() => frappe.dom.unfreeze(),
]);
}
},
Expand Down
1 change: 1 addition & 0 deletions erpnext/accounts/doctype/pos_invoice/pos_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex
}

onload_post_render(frm) {
super.onload_post_render();
this.pos_profile(frm);
}

Expand Down
13 changes: 5 additions & 8 deletions erpnext/accounts/doctype/pricing_rule/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,14 +728,11 @@ def get_pricing_rule_items(pr_doc, other_items=False) -> list:

def validate_coupon_code(coupon_name):
coupon = frappe.get_doc("Coupon Code", coupon_name)

if coupon.valid_from:
if coupon.valid_from > getdate(today()):
frappe.throw(_("Sorry, this coupon code's validity has not started"))
elif coupon.valid_upto:
if coupon.valid_upto < getdate(today()):
frappe.throw(_("Sorry, this coupon code's validity has expired"))
elif coupon.used >= coupon.maximum_use:
if coupon.valid_from and coupon.valid_from > getdate(today()):
frappe.throw(_("Sorry, this coupon code's validity has not started"))
elif coupon.valid_upto and coupon.valid_upto < getdate(today()):
frappe.throw(_("Sorry, this coupon code's validity has expired"))
elif coupon.maximum_use and coupon.used >= coupon.maximum_use:
frappe.throw(_("Sorry, this coupon code is no longer valid"))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"payment_terms_template",
"sales_partner",
"sales_person",
"show_remarks",
"based_on_payment_terms",
"section_break_3",
"customer_collection",
Expand Down Expand Up @@ -390,10 +391,16 @@
"fieldname": "ignore_cr_dr_notes",
"fieldtype": "Check",
"label": "Ignore System Generated Credit / Debit Notes"
},
{
"default": "0",
"fieldname": "show_remarks",
"fieldtype": "Check",
"label": "Show Remarks"
}
],
"links": [],
"modified": "2024-08-13 10:41:18.381165",
"modified": "2024-10-18 17:51:39.108481",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Process Statement Of Accounts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ProcessStatementOfAccounts(Document):
sales_person: DF.Link | None
sender: DF.Link | None
show_net_values_in_party_account: DF.Check
show_remarks: DF.Check
start_date: DF.Date | None
subject: DF.Data | None
terms_and_conditions: DF.Link | None
Expand Down Expand Up @@ -187,6 +188,7 @@ def get_common_filters(doc):
"finance_book": doc.finance_book if doc.finance_book else None,
"account": [doc.account] if doc.account else None,
"cost_center": [cc.cost_center_name for cc in doc.cost_center],
"show_remarks": doc.show_remarks,
}
)

Expand Down
17 changes: 9 additions & 8 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,14 +1359,15 @@ def make_item_gl_entries(self, gl_entries):

else:
if asset.calculate_depreciation:
notes = _(
"This schedule was created when Asset {0} was sold through Sales Invoice {1}."
).format(
get_link_to_form(asset.doctype, asset.name),
get_link_to_form(self.doctype, self.get("name")),
)
depreciate_asset(asset, self.posting_date, notes)
asset.reload()
if not asset.status == "Fully Depreciated":
notes = _(
"This schedule was created when Asset {0} was sold through Sales Invoice {1}."
).format(
get_link_to_form(asset.doctype, asset.name),
get_link_to_form(self.doctype, self.get("name")),
)
depreciate_asset(asset, self.posting_date, notes)
asset.reload()

fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
asset,
Expand Down
44 changes: 34 additions & 10 deletions erpnext/accounts/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,16 +881,17 @@ def get_party_shipping_address(doctype: str, name: str) -> str | None:
def get_partywise_advanced_payment_amount(
party_type, posting_date=None, future_payment=0, company=None, party=None
):
account_type = frappe.get_cached_value("Party Type", party_type, "account_type")

ple = frappe.qb.DocType("Payment Ledger Entry")
acc = frappe.qb.DocType("Account")

query = (
frappe.qb.from_(ple)
.select(ple.party, Abs(Sum(ple.amount).as_("amount")))
.where(
(ple.party_type.isin(party_type))
& (ple.amount < 0)
& (ple.against_voucher_no == ple.voucher_no)
& (ple.delinked == 0)
)
.inner_join(acc)
.on(ple.account == acc.name)
.select(ple.party)
.where((ple.party_type.isin(party_type)) & (acc.account_type == account_type) & (ple.delinked == 0))
.groupby(ple.party)
)

Expand All @@ -909,9 +910,32 @@ def get_partywise_advanced_payment_amount(
if invoice_doctypes := frappe.get_hooks("invoice_doctypes"):
query = query.where(ple.voucher_type.notin(invoice_doctypes))

data = query.run()
if data:
return frappe._dict(data)
# Get advance amount from Receivable / Payable Account
party_ledger = query.select(Abs(Sum(ple.amount).as_("amount")))
party_ledger = party_ledger.where(ple.amount < 0)
party_ledger = party_ledger.where(ple.against_voucher_no == ple.voucher_no)
party_ledger = party_ledger.where(
acc.root_type == ("Liability" if account_type == "Payable" else "Asset")
)

data = party_ledger.run()
data = frappe._dict(data or {})

# Get advance amount from Advance Account
advance_ledger = query.select(Sum(ple.amount).as_("amount"), ple.account)
advance_ledger = advance_ledger.where(
acc.root_type == ("Asset" if account_type == "Payable" else "Liability")
)
advance_ledger = advance_ledger.groupby(ple.account)
advance_ledger = advance_ledger.having(Sum(ple.amount) < 0)

advance_data = advance_ledger.run()

for row in advance_data:
data.setdefault(row[0], 0)
data[row[0]] += abs(row[1])

return data


def get_default_contact(doctype: str, name: str) -> str | None:
Expand Down
14 changes: 7 additions & 7 deletions erpnext/accounts/report/balance_sheet/balance_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ def get_provisional_profit_loss(

for period in period_list:
key = period if consolidated else period.key
total_assets = flt(asset[0].get(key))
total_assets = flt(asset[-2].get(key))
effective_liability = 0.00

if liability:
effective_liability += flt(liability[0].get(key))
if equity:
effective_liability += flt(equity[0].get(key))
if liability and liability[-1] == {}:
effective_liability += flt(liability[-2].get(key))
if equity and equity[-1] == {}:
effective_liability += flt(equity[-2].get(key))

provisional_profit_loss[key] = total_assets - effective_liability
total_row[key] = provisional_profit_loss[key] + effective_liability
Expand Down Expand Up @@ -195,9 +195,9 @@ def get_report_summary(
key = period if consolidated else period.key
if asset:
net_asset += asset[-2].get(key)
if liability:
if liability and liability[-1] == {}:
net_liability += liability[-2].get(key)
if equity:
if equity and equity[-1] == {}:
net_equity += equity[-2].get(key)
if provisional_profit_loss:
net_provisional_profit_loss += provisional_profit_loss.get(key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,24 @@ def simulate_future_posting(self):
"""
simulate future posting by creating dummy gl entries. starts from the last posting date.
"""
if self.service_start_date != self.service_end_date:
if add_days(self.last_entry_date, 1) < self.period_list[-1].to_date:
self.estimate_for_period_list = get_period_list(
self.filters.from_fiscal_year,
self.filters.to_fiscal_year,
add_days(self.last_entry_date, 1),
self.period_list[-1].to_date,
"Date Range",
"Monthly",
company=self.filters.company,
)
for period in self.estimate_for_period_list:
amount = self.calculate_amount(period.from_date, period.to_date)
gle = self.make_dummy_gle(period.key, period.to_date, amount)
self.gle_entries.append(gle)
if (
self.service_start_date != self.service_end_date
and add_days(self.last_entry_date, 1) < self.service_end_date
):
self.estimate_for_period_list = get_period_list(
self.filters.from_fiscal_year,
self.filters.to_fiscal_year,
add_days(self.last_entry_date, 1),
self.service_end_date,
"Date Range",
"Monthly",
company=self.filters.company,
)

for period in self.estimate_for_period_list:
amount = self.calculate_amount(period.from_date, period.to_date)
gle = self.make_dummy_gle(period.key, period.to_date, amount)
self.gle_entries.append(gle)

def calculate_item_revenue_expense_for_period(self):
"""
Expand Down
8 changes: 6 additions & 2 deletions erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,12 +1547,16 @@ def compare_existing_and_expected_gle(existing_gle, expected_gle, precision):
return matched


def get_stock_accounts(company, voucher_type=None, voucher_no=None):
def get_stock_accounts(company, voucher_type=None, voucher_no=None, accounts=None):
stock_accounts = [
d.name
for d in frappe.db.get_all("Account", {"account_type": "Stock", "company": company, "is_group": 0})
]
if voucher_type and voucher_no:

if accounts:
stock_accounts = [row.account for row in accounts if row.account in stock_accounts]

elif voucher_type and voucher_no:
if voucher_type == "Journal Entry":
stock_accounts = [
d.account
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def update_maintenance_log(asset_maintenance, item_code, item_name, task):
"has_certificate": task.certificate_required,
"description": task.description,
"assign_to_name": task.assign_to_name,
"task_assignee_email": task.assign_to,
"periodicity": str(task.periodicity),
"maintenance_type": task.maintenance_type,
"due_date": task.next_due_date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"column_break_6",
"maintenance_status",
"assign_to_name",
"task_assignee_email",
"due_date",
"completion_date",
"description",
Expand Down Expand Up @@ -168,15 +169,22 @@
"in_preview": 1,
"label": "Task Name",
"read_only": 1
},
{
"fieldname": "task_assignee_email",
"fieldtype": "Data",
"label": "Task Assignee Email",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2021-01-22 12:33:45.888124",
"modified": "2024-09-24 15:12:37.497853",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset Maintenance Log",
"naming_rule": "By \"Naming Series\" field",
"owner": "Administrator",
"permissions": [
{
Expand All @@ -199,4 +207,4 @@
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AssetMaintenanceLog(Document):
naming_series: DF.Literal["ACC-AML-.YYYY.-"]
periodicity: DF.Data | None
task: DF.Link | None
task_assignee_email: DF.Data | None
task_name: DF.Data | None
# end: auto-generated types

Expand Down
Loading

0 comments on commit 692de89

Please sign in to comment.