Skip to content

Commit

Permalink
Merge pull request #34611 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
deepeshgarg007 authored Mar 28, 2023
2 parents e271935 + cff35d7 commit efdbb91
Show file tree
Hide file tree
Showing 85 changed files with 243 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ def calculate_exchange_rate_using_last_gle(company, account, party_type, party):
conditions.append(gl.company == company)
conditions.append(gl.account == account)
conditions.append(gl.is_cancelled == 0)
conditions.append((gl.debit > 0) | (gl.credit > 0))
conditions.append((gl.debit_in_account_currency > 0) | (gl.credit_in_account_currency > 0))
if party_type:
conditions.append(gl.party_type == party_type)
if party:
Expand Down
3 changes: 3 additions & 0 deletions erpnext/accounts/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def _get_party_details(
party_type, party.name, "tax_withholding_category"
)

if not party_details.get("tax_category") and pos_profile:
party_details["tax_category"] = frappe.get_value("POS Profile", pos_profile, "tax_category")

return party_details


Expand Down
5 changes: 2 additions & 3 deletions erpnext/accounts/report/general_ledger/general_ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ frappe.query_reports["General Ledger"] = {
{
"fieldname":"party_type",
"label": __("Party Type"),
"fieldtype": "Link",
"options": "Party Type",
"default": "",
"fieldtype": "Autocomplete",
options: Object.keys(frappe.boot.party_account_types),
on_change: function() {
frappe.query_report.set_filter_value('party', "");
}
Expand Down
37 changes: 37 additions & 0 deletions erpnext/accounts/report/payment_ledger/payment_ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ function get_filters() {
});
}
},
{
"fieldname":"party_type",
"label": __("Party Type"),
"fieldtype": "Link",
"options": "Party Type",
"default": "",
on_change: function() {
frappe.query_report.set_filter_value('party', "");
}
},
{
"fieldname":"party",
"label": __("Party"),
"fieldtype": "MultiSelectList",
get_data: function(txt) {
if (!frappe.query_report.filters) return;

let party_type = frappe.query_report.get_filter_value('party_type');
if (!party_type) return;

return frappe.db.get_link_options(party_type, txt);
},
},
{
"fieldname":"voucher_no",
"label": __("Voucher No"),
Expand All @@ -49,6 +72,20 @@ function get_filters() {
"fieldtype": "Data",
"width": 100,
},
{
"fieldname":"include_account_currency",
"label": __("Include Account Currency"),
"fieldtype": "Check",
"width": 100,
},
{
"fieldname":"group_party",
"label": __("Group by Party"),
"fieldtype": "Check",
"width": 100,
},



]
return filters;
Expand Down
64 changes: 36 additions & 28 deletions erpnext/accounts/report/payment_ledger/payment_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,26 @@ def __init__(self, filters=None):
self.ple = qb.DocType("Payment Ledger Entry")

def init_voucher_dict(self):

if self.voucher_amount:
s = set()
# build a set of unique vouchers
# for each ple, using group_by_key to create a key and assign it to +/- list
for ple in self.voucher_amount:
key = (ple.voucher_type, ple.voucher_no, ple.party)
s.add(key)

# for each unique vouchers, initialize +/- list
for key in s:
self.voucher_dict[key] = frappe._dict(increase=list(), decrease=list())
group_by_key = None
if not self.filters.group_party:
group_by_key = (ple.against_voucher_type, ple.against_voucher_no, ple.party)
else:
group_by_key = (ple.party_type, ple.party)

# for each ple, using against voucher and amount, assign it to +/- list
# group by against voucher
for ple in self.voucher_amount:
against_key = (ple.against_voucher_type, ple.against_voucher_no, ple.party)
target = None
if self.voucher_dict.get(against_key):
if ple.amount > 0:
target = self.voucher_dict.get(against_key).increase
else:
target = self.voucher_dict.get(against_key).decrease
if ple.amount > 0:
target = self.voucher_dict.setdefault(group_by_key, {}).setdefault("increase", [])
else:
target = self.voucher_dict.setdefault(group_by_key, {}).setdefault("decrease", [])

# this if condition will lose unassigned ple entries(against_voucher doc doesn't have ple)
# need to somehow include the stray entries as well.
if target is not None:
entry = frappe._dict(
company=ple.company,
posting_date=ple.posting_date,
account=ple.account,
party_type=ple.party_type,
party=ple.party,
Expand All @@ -66,10 +58,10 @@ def build_data(self):

for value in self.voucher_dict.values():
voucher_data = []
if value.increase != []:
voucher_data.extend(value.increase)
if value.decrease != []:
voucher_data.extend(value.decrease)
if value.get("increase"):
voucher_data.extend(value.get("increase"))
if value.get("decrease"):
voucher_data.extend(value.get("decrease"))

if voucher_data:
# balance row
Expand Down Expand Up @@ -117,6 +109,12 @@ def build_conditions(self):
if self.filters.against_voucher_no:
self.conditions.append(self.ple.against_voucher_no == self.filters.against_voucher_no)

if self.filters.party_type:
self.conditions.append(self.ple.party_type == self.filters.party_type)

if self.filters.party:
self.conditions.append(self.ple.party.isin(self.filters.party))

def get_data(self):
ple = self.ple

Expand All @@ -134,7 +132,13 @@ def get_data(self):
def get_columns(self):
options = None
self.columns.append(
dict(label=_("Company"), fieldname="company", fieldtype="data", options=options, width="100")
dict(
label=_("Posting Date"),
fieldname="posting_date",
fieldtype="Date",
options=options,
width="100",
)
)

self.columns.append(
Expand All @@ -160,7 +164,11 @@ def get_columns(self):
)
self.columns.append(
dict(
label=_("Voucher No"), fieldname="voucher_no", fieldtype="data", options=options, width="100"
label=_("Voucher No"),
fieldname="voucher_no",
fieldtype="Dynamic Link",
options="voucher_type",
width="100",
)
)
self.columns.append(
Expand All @@ -176,8 +184,8 @@ def get_columns(self):
dict(
label=_("Against Voucher No"),
fieldname="against_voucher_no",
fieldtype="data",
options=options,
fieldtype="Dynamic Link",
options="against_voucher_type",
width="100",
)
)
Expand Down Expand Up @@ -209,7 +217,7 @@ def run(self):
self.get_columns()
self.get_data()

# initialize dictionary and group using against voucher
# initialize dictionary and group using key
self.init_voucher_dict()

# convert dictionary to list and add balance rows
Expand Down
6 changes: 0 additions & 6 deletions erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,6 @@ def reconcile_against_document(args): # nosemgrep
else:
update_reference_in_payment_entry(entry, doc, do_not_save=True)

if doc.doctype == "Journal Entry":
try:
doc.validate_total_debit_and_credit()
except Exception as validation_exception:
raise frappe.ValidationError(_(f"Validation Error for {doc.name}")) from validation_exception

doc.save(ignore_permissions=True)
# re-submit advance entry
doc = frappe.get_doc(entry.voucher_type, entry.voucher_no)
Expand Down
32 changes: 18 additions & 14 deletions erpnext/assets/doctype/asset/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,19 +375,12 @@ def _make_depreciation_schedule(self, finance_book, start, date_of_disposal):
value_after_depreciation -= flt(depreciation_amount, self.precision("gross_purchase_amount"))

# Adjust depreciation amount in the last period based on the expected value after useful life
if (
finance_book.expected_value_after_useful_life
and (
(
n == cint(number_of_pending_depreciations) - 1
and value_after_depreciation != finance_book.expected_value_after_useful_life
)
or value_after_depreciation < finance_book.expected_value_after_useful_life
)
and (
not self.flags.increase_in_asset_value_due_to_repair
or not finance_book.depreciation_method in ("Written Down Value", "Double Declining Balance")
if finance_book.expected_value_after_useful_life and (
(
n == cint(number_of_pending_depreciations) - 1
and value_after_depreciation != finance_book.expected_value_after_useful_life
)
or value_after_depreciation < finance_book.expected_value_after_useful_life
):
depreciation_amount += value_after_depreciation - finance_book.expected_value_after_useful_life
skip_row = True
Expand Down Expand Up @@ -913,11 +906,22 @@ def get_depreciation_rate(self, args, on_validate=False):
return 200.0 / args.get("total_number_of_depreciations")

if args.get("depreciation_method") == "Written Down Value":
if args.get("rate_of_depreciation") and on_validate:
if (
args.get("rate_of_depreciation")
and on_validate
and not self.flags.increase_in_asset_value_due_to_repair
):
return args.get("rate_of_depreciation")

value = flt(args.get("expected_value_after_useful_life")) / flt(self.gross_purchase_amount)
if self.flags.increase_in_asset_value_due_to_repair:
value = flt(args.get("expected_value_after_useful_life")) / flt(
args.get("value_after_depreciation")
)
else:
value = flt(args.get("expected_value_after_useful_life")) / flt(self.gross_purchase_amount)

depreciation_rate = math.pow(value, 1.0 / flt(args.get("total_number_of_depreciations"), 2))

return flt((100 * (1 - depreciation_rate)), float_precision)

def get_pro_rata_amt(self, row, depreciation_amount, from_date, to_date):
Expand Down
24 changes: 0 additions & 24 deletions erpnext/assets/doctype/asset_repair/asset_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ def before_submit(self):

self.asset_doc.flags.ignore_validate_update_after_submit = True
self.asset_doc.prepare_depreciation_data()
if self.asset_doc.calculate_depreciation:
self.update_asset_expected_value_after_useful_life()
self.asset_doc.save()

def before_cancel(self):
Expand All @@ -81,8 +79,6 @@ def before_cancel(self):

self.asset_doc.flags.ignore_validate_update_after_submit = True
self.asset_doc.prepare_depreciation_data()
if self.asset_doc.calculate_depreciation:
self.update_asset_expected_value_after_useful_life()
self.asset_doc.save()

def after_delete(self):
Expand All @@ -103,26 +99,6 @@ def check_for_stock_items_and_warehouse(self):
title=_("Missing Warehouse"),
)

def update_asset_expected_value_after_useful_life(self):
for row in self.asset_doc.get("finance_books"):
if row.depreciation_method in ("Written Down Value", "Double Declining Balance"):
accumulated_depreciation_after_full_schedule = [
d.accumulated_depreciation_amount
for d in self.asset_doc.get("schedules")
if cint(d.finance_book_id) == row.idx
]

accumulated_depreciation_after_full_schedule = max(
accumulated_depreciation_after_full_schedule
)

asset_value_after_full_schedule = flt(
flt(row.value_after_depreciation) - flt(accumulated_depreciation_after_full_schedule),
row.precision("expected_value_after_useful_life"),
)

row.expected_value_after_useful_life = asset_value_after_full_schedule

def increase_asset_value(self):
total_value_of_stock_consumed = self.get_total_value_of_stock_consumed()

Expand Down
2 changes: 1 addition & 1 deletion erpnext/buying/doctype/supplier/supplier.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ frappe.ui.form.on("Supplier", {
// custom buttons
frm.add_custom_button(__('Accounting Ledger'), function () {
frappe.set_route('query-report', 'General Ledger',
{ party_type: 'Supplier', party: frm.doc.name });
{ party_type: 'Supplier', party: frm.doc.name, party_name: frm.doc.supplier_name });
}, __("View"));

frm.add_custom_button(__('Accounts Payable'), function () {
Expand Down
15 changes: 3 additions & 12 deletions erpnext/buying/doctype/supplier/supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,9 @@ def create_primary_address(self):

def on_trash(self):
if self.supplier_primary_contact:
frappe.db.sql(
"""
UPDATE `tabSupplier`
SET
supplier_primary_contact=null,
supplier_primary_address=null,
mobile_no=null,
email_id=null,
primary_address=null
WHERE name=%(name)s""",
{"name": self.name},
)
self.db_set("supplier_primary_contact", None)
if self.supplier_primary_address:
self.db_set("supplier_primary_address", None)

delete_contact_and_address("Supplier", self.name)

Expand Down
2 changes: 1 addition & 1 deletion erpnext/controllers/status_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def _update_percent_field(self, args, update_modified=True):
ifnull((select
ifnull(sum(case when abs(%(target_ref_field)s) > abs(%(target_field)s) then abs(%(target_field)s) else abs(%(target_ref_field)s) end), 0)
/ sum(abs(%(target_ref_field)s)) * 100
from `tab%(target_dt)s` where parent='%(name)s' having sum(abs(%(target_ref_field)s)) > 0), 0), 6)
from `tab%(target_dt)s` where parent='%(name)s' and parenttype='%(target_parent_dt)s' having sum(abs(%(target_ref_field)s)) > 0), 0), 6)
%(update_modified)s
where name='%(name)s'"""
% args
Expand Down
2 changes: 1 addition & 1 deletion erpnext/controllers/subcontracting_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def __add_supplied_item(self, item_row, bom_item, qty):
"allow_zero_valuation": 1,
}
)
rm_obj.rate = get_incoming_rate(args)
rm_obj.rate = bom_item.rate if self.backflush_based_on == "BOM" else get_incoming_rate(args)

if self.doctype == self.subcontract_data.order_doctype:
rm_obj.required_qty = qty
Expand Down
2 changes: 1 addition & 1 deletion erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
before_tests = "erpnext.setup.utils.before_tests"

standard_queries = {
"Customer": "erpnext.selling.doctype.customer.customer.get_customer_list",
"Customer": "erpnext.controllers.queries.customer_query",
}

doc_events = {
Expand Down
2 changes: 1 addition & 1 deletion erpnext/manufacturing/doctype/job_card/job_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ frappe.ui.form.on('Job Card', {
// and if stock mvt for WIP is required
if (frm.doc.work_order) {
frappe.db.get_value('Work Order', frm.doc.work_order, ['skip_transfer', 'status'], (result) => {
if (result.skip_transfer === 1 || result.status == 'In Process') {
if (result.skip_transfer === 1 || result.status == 'In Process' || frm.doc.transferred_qty > 0) {
frm.trigger("prepare_timer_buttons");
}
});
Expand Down
2 changes: 1 addition & 1 deletion erpnext/public/js/templates/crm_notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{{ frappe.avatar(notes[i].added_by) }}
</div>
<div class="col-xs-10">
<div class="mr-2 title font-weight-bold">
<div class="mr-2 title font-weight-bold ellipsis" title="{{ strip_html(notes[i].added_by) }}">
{{ strip_html(notes[i].added_by) }}
</div>
<div class="time small text-muted">
Expand Down
2 changes: 1 addition & 1 deletion erpnext/selling/doctype/customer/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ frappe.ui.form.on("Customer", {

frm.add_custom_button(__('Accounting Ledger'), function () {
frappe.set_route('query-report', 'General Ledger',
{party_type: 'Customer', party: frm.doc.name});
{party_type: 'Customer', party: frm.doc.name, party_name: frm.doc.customer_name});
}, __('View'));

frm.add_custom_button(__('Pricing Rule'), function () {
Expand Down
Loading

0 comments on commit efdbb91

Please sign in to comment.