Skip to content

Commit

Permalink
Merge pull request #37246 from frappe/develop
Browse files Browse the repository at this point in the history
chore: release v15 beta
  • Loading branch information
ankush authored Sep 26, 2023
2 parents 7a391db + 656c758 commit 4aa95ff
Show file tree
Hide file tree
Showing 38 changed files with 846 additions and 213 deletions.
9 changes: 8 additions & 1 deletion erpnext/accounts/doctype/bank_account/bank_account.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"account_type",
"account_subtype",
"column_break_7",
"disabled",
"is_default",
"is_company_account",
"company",
Expand Down Expand Up @@ -199,10 +200,16 @@
"fieldtype": "Data",
"in_global_search": 1,
"label": "Branch Code"
},
{
"default": "0",
"fieldname": "disabled",
"fieldtype": "Check",
"label": "Disabled"
}
],
"links": [],
"modified": "2022-05-04 15:49:42.620630",
"modified": "2023-09-22 21:31:34.763977",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Bank Account",
Expand Down
6 changes: 6 additions & 0 deletions erpnext/accounts/doctype/payment_entry/payment_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ frappe.ui.form.on('Payment Entry', {
frm.events.set_dynamic_labels(frm);
frm.events.show_general_ledger(frm);
erpnext.accounts.ledger_preview.show_accounting_ledger_preview(frm);
if(frm.doc.references.find((elem) => {return elem.exchange_gain_loss != 0})) {
frm.add_custom_button(__("View Exchange Gain/Loss Journals"), function() {
frappe.set_route("List", "Journal Entry", {"voucher_type": "Exchange Gain Or Loss", "reference_name": frm.doc.name});
}, __('Actions'));

}
erpnext.accounts.unreconcile_payments.add_unreconcile_btn(frm);
},

Expand Down
21 changes: 19 additions & 2 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,25 @@ def make_advance_gl_entries(self, against_voucher_type=None, against_voucher=Non
)

make_reverse_gl_entries(gl_entries=gl_entries, partial_cancel=True)
else:
make_gl_entries(gl_entries)
return

# same reference added to payment entry
for gl_entry in gl_entries.copy():
if frappe.db.exists(
"GL Entry",
{
"account": gl_entry.account,
"voucher_type": gl_entry.voucher_type,
"voucher_no": gl_entry.voucher_no,
"voucher_detail_no": gl_entry.voucher_detail_no,
"debit": gl_entry.debit,
"credit": gl_entry.credit,
"is_cancelled": 0,
},
):
gl_entries.remove(gl_entry)

make_gl_entries(gl_entries)

def make_invoice_liability_entry(self, gl_entries, invoice):
args_dict = {
Expand Down
70 changes: 36 additions & 34 deletions erpnext/accounts/doctype/payment_request/payment_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,28 @@
"fieldtype": "Read Only",
"label": "SWIFT Number"
},
{
"collapsible": 1,
"fieldname": "accounting_dimensions_section",
"fieldtype": "Section Break",
"label": "Accounting Dimensions"
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
"options": "Cost Center"
},
{
"fieldname": "dimension_col_break",
"fieldtype": "Column Break"
},
{
"fieldname": "project",
"fieldtype": "Link",
"label": "Project",
"options": "Project"
},
{
"depends_on": "eval: doc.payment_request_type == 'Inward'",
"fieldname": "recipient_and_message",
Expand All @@ -246,7 +268,8 @@
"fieldname": "email_to",
"fieldtype": "Data",
"in_global_search": 1,
"label": "To"
"label": "To",
"options": "Email"
},
{
"depends_on": "eval: doc.payment_channel != \"Phone\"",
Expand Down Expand Up @@ -317,9 +340,10 @@
},
{
"fieldname": "payment_url",
"fieldtype": "Small Text",
"hidden": 1,
"label": "payment_url",
"fieldtype": "Data",
"length": 500,
"options": "URL",
"read_only": 1
},
{
Expand All @@ -343,6 +367,14 @@
"label": "Payment Account",
"read_only": 1
},
{
"fetch_from": "payment_gateway_account.payment_channel",
"fieldname": "payment_channel",
"fieldtype": "Select",
"label": "Payment Channel",
"options": "\nEmail\nPhone",
"read_only": 1
},
{
"fieldname": "payment_order",
"fieldtype": "Link",
Expand All @@ -358,43 +390,13 @@
"options": "Payment Request",
"print_hide": 1,
"read_only": 1
},
{
"fetch_from": "payment_gateway_account.payment_channel",
"fieldname": "payment_channel",
"fieldtype": "Select",
"label": "Payment Channel",
"options": "\nEmail\nPhone",
"read_only": 1
},
{
"collapsible": 1,
"fieldname": "accounting_dimensions_section",
"fieldtype": "Section Break",
"label": "Accounting Dimensions"
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
"options": "Cost Center"
},
{
"fieldname": "dimension_col_break",
"fieldtype": "Column Break"
},
{
"fieldname": "project",
"fieldtype": "Link",
"label": "Project",
"options": "Project"
}
],
"in_create": 1,
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2022-12-21 16:56:40.115737",
"modified": "2023-09-16 14:15:02.510890",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Request",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def on_submit(self):
def on_cancel(self):
self.validate_future_closing_vouchers()
self.db_set("gle_processing_status", "In Progress")
self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry")
self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry", "Payment Ledger Entry")
gle_count = frappe.db.count(
"GL Entry",
{"voucher_type": "Period Closing Voucher", "voucher_no": self.name, "is_cancelled": 0},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def get_report_pdf(doc, consolidated=True):
filters = get_common_filters(doc)

if doc.report == "General Ledger":
filters.update(get_gl_filters(doc, entry, tax_id, presentation_currency))
col, res = get_soa(filters)
for x in [0, -2, -1]:
res[x]["account"] = res[x]["account"].replace("'", "")
Expand Down
32 changes: 28 additions & 4 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1801,6 +1801,10 @@ def test_outstanding_amount_after_advance_jv_cancellation(self):
)

def test_outstanding_amount_after_advance_payment_entry_cancellation(self):
"""Test impact of advance PE submission/cancellation on SI and SO."""
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order

sales_order = make_sales_order(item_code="138-CMS Shoe", qty=1, price_list_rate=500)
pe = frappe.get_doc(
{
"doctype": "Payment Entry",
Expand All @@ -1820,17 +1824,33 @@ def test_outstanding_amount_after_advance_payment_entry_cancellation(self):
"paid_to": "_Test Cash - _TC",
}
)
pe.append(
"references",
{
"reference_doctype": "Sales Order",
"reference_name": sales_order.name,
"total_amount": sales_order.grand_total,
"outstanding_amount": sales_order.grand_total,
"allocated_amount": 300,
},
)
pe.insert()
pe.submit()

sales_order.reload()
self.assertEqual(sales_order.advance_paid, 300)

si = frappe.copy_doc(test_records[0])
si.items[0].sales_order = sales_order.name
si.items[0].so_detail = sales_order.get("items")[0].name
si.is_pos = 0
si.append(
"advances",
{
"doctype": "Sales Invoice Advance",
"reference_type": "Payment Entry",
"reference_name": pe.name,
"reference_row": pe.references[0].name,
"advance_amount": 300,
"allocated_amount": 300,
"remarks": pe.remarks,
Expand All @@ -1839,19 +1859,23 @@ def test_outstanding_amount_after_advance_payment_entry_cancellation(self):
si.insert()
si.submit()

si.load_from_db()
si.reload()
pe.reload()
sales_order.reload()

# Check if SO is unlinked/replaced by SI in PE & if SO advance paid is 0
self.assertEqual(pe.references[0].reference_name, si.name)
self.assertEqual(sales_order.advance_paid, 0.0)

# check outstanding after advance allocation
self.assertEqual(
flt(si.outstanding_amount),
flt(si.rounded_total - si.total_advance, si.precision("outstanding_amount")),
)

# added to avoid Document has been modified exception
pe = frappe.get_doc("Payment Entry", pe.name)
pe.cancel()
si.reload()

si.load_from_db()
# check outstanding after advance cancellation
self.assertEqual(
flt(si.outstanding_amount),
Expand Down
6 changes: 6 additions & 0 deletions erpnext/accounts/report/trial_balance/trial_balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"label": __("Include Default Book Entries"),
"fieldtype": "Check",
"default": 1
},
{
"fieldname": "show_net_values",
"label": __("Show net values in opening and closing columns"),
"fieldtype": "Check",
"default": 1
}
],
"formatter": erpnext.financial_statements.formatter,
Expand Down
11 changes: 7 additions & 4 deletions erpnext/accounts/report/trial_balance/trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ def get_data(filters):
ignore_opening_entries=True,
)

calculate_values(accounts, gl_entries_by_account, opening_balances)
calculate_values(
accounts, gl_entries_by_account, opening_balances, filters.get("show_net_values")
)
accumulate_values_into_parents(accounts, accounts_by_name)

data = prepare_data(accounts, filters, parent_children_map, company_currency)
Expand Down Expand Up @@ -310,7 +312,7 @@ def get_opening_balance(
return gle


def calculate_values(accounts, gl_entries_by_account, opening_balances):
def calculate_values(accounts, gl_entries_by_account, opening_balances, show_net_values):
init = {
"opening_debit": 0.0,
"opening_credit": 0.0,
Expand All @@ -335,7 +337,8 @@ def calculate_values(accounts, gl_entries_by_account, opening_balances):
d["closing_debit"] = d["opening_debit"] + d["debit"]
d["closing_credit"] = d["opening_credit"] + d["credit"]

prepare_opening_closing(d)
if show_net_values:
prepare_opening_closing(d)


def calculate_total_row(accounts, company_currency):
Expand Down Expand Up @@ -375,7 +378,7 @@ def prepare_data(accounts, filters, parent_children_map, company_currency):

for d in accounts:
# Prepare opening closing for group account
if parent_children_map.get(d.account):
if parent_children_map.get(d.account) and filters.get("show_net_values"):
prepare_opening_closing(d)

has_value = False
Expand Down
11 changes: 11 additions & 0 deletions erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,10 @@ def update_reference_in_journal_entry(d, journal_entry, do_not_save=False):
"""
jv_detail = journal_entry.get("accounts", {"name": d["voucher_detail_no"]})[0]

# Update Advance Paid in SO/PO since they might be getting unlinked
if jv_detail.get("reference_type") in ("Sales Order", "Purchase Order"):
frappe.get_doc(jv_detail.reference_type, jv_detail.reference_name).set_total_advance_paid()

if flt(d["unadjusted_amount"]) - flt(d["allocated_amount"]) != 0:
# adjust the unreconciled balance
amount_in_account_currency = flt(d["unadjusted_amount"]) - flt(d["allocated_amount"])
Expand Down Expand Up @@ -647,6 +651,13 @@ def update_reference_in_payment_entry(

if d.voucher_detail_no:
existing_row = payment_entry.get("references", {"name": d["voucher_detail_no"]})[0]

# Update Advance Paid in SO/PO since they are getting unlinked
if existing_row.get("reference_doctype") in ("Sales Order", "Purchase Order"):
frappe.get_doc(
existing_row.reference_doctype, existing_row.reference_name
).set_total_advance_paid()

original_row = existing_row.as_dict().copy()
existing_row.update(reference_details)

Expand Down
13 changes: 9 additions & 4 deletions erpnext/buying/doctype/supplier/supplier.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@
"column_break1",
"contact_html",
"primary_address_and_contact_detail_section",
"supplier_primary_contact",
"mobile_no",
"email_id",
"column_break_44",
"supplier_primary_address",
"primary_address",
"column_break_mglr",
"supplier_primary_contact",
"mobile_no",
"email_id",
"accounting_tab",
"payment_terms",
"default_accounts_section",
Expand Down Expand Up @@ -469,6 +470,10 @@
{
"fieldname": "column_break_1mqv",
"fieldtype": "Column Break"
},
{
"fieldname": "column_break_mglr",
"fieldtype": "Column Break"
}
],
"icon": "fa fa-user",
Expand All @@ -481,7 +486,7 @@
"link_fieldname": "party"
}
],
"modified": "2023-06-26 14:20:00.961554",
"modified": "2023-09-21 12:24:20.398889",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier",
Expand Down
Loading

0 comments on commit 4aa95ff

Please sign in to comment.