Skip to content

Commit

Permalink
Merge branch 'frappe:version-14' into version-14
Browse files Browse the repository at this point in the history
  • Loading branch information
jfa-name authored Oct 4, 2024
2 parents 353c596 + 96cb08d commit 07988f1
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 37 deletions.
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import frappe

__version__ = "14.74.2"
__version__ = "14.74.3"


def get_default_company(user=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_api_endpoint(service_provider: str | None = None, use_http: bool = False
if service_provider == "exchangerate.host":
api = "api.exchangerate.host/convert"
elif service_provider == "frankfurter.app":
api = "frankfurter.app/{transaction_date}"
api = "api.frankfurter.app/{transaction_date}"

protocol = "https://"
if use_http:
Expand Down
38 changes: 25 additions & 13 deletions erpnext/accounts/doctype/dunning/dunning.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,31 @@ def calculate_interest_and_amount(outstanding_amount, rate_of_interest, dunning_


@frappe.whitelist()
def get_dunning_letter_text(dunning_type, doc, language=None):
def get_dunning_letter_text(dunning_type: str, doc: str | dict, language: str | None = None) -> dict:
DOCTYPE = "Dunning Letter Text"
FIELDS = ["body_text", "closing_text", "language"]

if isinstance(doc, str):
doc = json.loads(doc)

if not language:
language = doc.get("language")

if language:
filters = {"parent": dunning_type, "language": language}
else:
filters = {"parent": dunning_type, "is_default_language": 1}
letter_text = frappe.db.get_value(
"Dunning Letter Text", filters, ["body_text", "closing_text", "language"], as_dict=1
)
if letter_text:
return {
"body_text": frappe.render_template(letter_text.body_text, doc),
"closing_text": frappe.render_template(letter_text.closing_text, doc),
"language": letter_text.language,
}
letter_text = frappe.db.get_value(
DOCTYPE, {"parent": dunning_type, "language": language}, FIELDS, as_dict=1
)

if not letter_text:
letter_text = frappe.db.get_value(
DOCTYPE, {"parent": dunning_type, "is_default_language": 1}, FIELDS, as_dict=1
)

if not letter_text:
return {}

return {
"body_text": frappe.render_template(letter_text.body_text, doc),
"closing_text": frappe.render_template(letter_text.closing_text, doc),
"language": letter_text.language,
}
23 changes: 9 additions & 14 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3124,7 +3124,6 @@ def should_update_supplied_items(doc) -> bool:
items_added_or_removed = False # updated to true if any new item is added or removed
any_conversion_factor_changed = False

sales_doctypes = ["Sales Order", "Sales Invoice", "Delivery Note", "Quotation"]
parent = frappe.get_doc(parent_doctype, parent_doctype_name)

check_doc_permissions(parent, "write")
Expand Down Expand Up @@ -3226,25 +3225,21 @@ def should_update_supplied_items(doc) -> bool:
# if rate is greater than price_list_rate, set margin
# or set discount
child_item.discount_percentage = 0

if parent_doctype in sales_doctypes:
child_item.margin_type = "Amount"
child_item.margin_rate_or_amount = flt(
child_item.rate - child_item.price_list_rate,
child_item.precision("margin_rate_or_amount"),
)
child_item.rate_with_margin = child_item.rate
child_item.margin_type = "Amount"
child_item.margin_rate_or_amount = flt(
child_item.rate - child_item.price_list_rate,
child_item.precision("margin_rate_or_amount"),
)
child_item.rate_with_margin = child_item.rate
else:
child_item.discount_percentage = flt(
(1 - flt(child_item.rate) / flt(child_item.price_list_rate)) * 100.0,
child_item.precision("discount_percentage"),
)
child_item.discount_amount = flt(child_item.price_list_rate) - flt(child_item.rate)

if parent_doctype in sales_doctypes:
child_item.margin_type = ""
child_item.margin_rate_or_amount = 0
child_item.rate_with_margin = 0
child_item.margin_type = ""
child_item.margin_rate_or_amount = 0
child_item.rate_with_margin = 0

child_item.flags.ignore_validate_update_after_submit = True
if new_child_flag:
Expand Down
1 change: 1 addition & 0 deletions erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,4 @@ execute:frappe.db.set_single_value('E Commerce Settings', 'show_actual_qty', 1)
erpnext.patches.v14_0.delete_orphaned_asset_movement_item_records
erpnext.patches.v14_0.remove_cancelled_asset_capitalization_from_asset
erpnext.patches.v14_0.enable_set_priority_for_pricing_rules #1
erpnext.patches.v14_0.update_currency_exchange_settings_for_frankfurter
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import frappe


def execute():
settings = frappe.get_doc("Currency Exchange Settings")
if settings.service_provider != "frankfurter.app":
return

settings.set_parameters_and_result()
settings.flags.ignore_validate = True
settings.save()
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def json(self):
if kwargs["params"].get("date") and kwargs["params"].get("from") and kwargs["params"].get("to"):
if test_exchange_values.get(kwargs["params"]["date"]):
return PatchResponse({"result": test_exchange_values[kwargs["params"]["date"]]}, 200)
elif args[0].startswith("https://frankfurter.app") and kwargs.get("params"):
elif args[0].startswith("https://api.frankfurter.app") and kwargs.get("params"):
if kwargs["params"].get("base") and kwargs["params"].get("symbols"):
date = args[0].replace("https://frankfurter.app/", "")
date = args[0].replace("https://api.frankfurter.app/", "")
if test_exchange_values.get(date):
return PatchResponse(
{"rates": {kwargs["params"].get("symbols"): test_exchange_values.get(date)}}, 200
Expand Down
2 changes: 1 addition & 1 deletion erpnext/setup/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def setup_currency_exchange():
ces.set("result_key", [])
ces.set("req_params", [])

ces.api_endpoint = "https://frankfurter.app/{transaction_date}"
ces.api_endpoint = "https://api.frankfurter.app/{transaction_date}"
ces.append("result_key", {"key": "rates"})
ces.append("result_key", {"key": "{to_currency}"})
ces.append("req_params", {"key": "base", "value": "{from_currency}"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def make_adjustment_entry(self, row, sl_entries):
from erpnext.stock.stock_ledger import get_stock_value_difference

difference_amount = get_stock_value_difference(
row.item_code, row.warehouse, self.posting_date, self.posting_time
row.item_code, row.warehouse, self.posting_date, self.posting_time, self.name
)

if not difference_amount:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def add_invariant_check_fields(sles):
balance_qty = 0.0
balance_stock_value = 0.0
for idx, sle in enumerate(sles):
queue = json.loads(sle.stock_queue)
queue = json.loads(sle.stock_queue) if sle.stock_queue else []

fifo_qty = 0.0
fifo_value = 0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

frappe.query_reports["Warehouse wise Item Balance Age and Value"] = {
filters: [
{
fieldname: "company",
label: __("Company"),
fieldtype: "Link",
width: "80",
options: "Company",
reqd: 1,
default: frappe.defaults.get_user_default("Company"),
},
{
fieldname: "from_date",
label: __("From Date"),
Expand Down Expand Up @@ -40,6 +49,12 @@ frappe.query_reports["Warehouse wise Item Balance Age and Value"] = {
fieldtype: "Link",
width: "80",
options: "Warehouse",
get_query: function () {
const company = frappe.query_report.get_filter_value("company");
return {
filters: { company: company },
};
},
},
{
fieldname: "filter_total_zero_qty",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ def validate_filters(filters):
sle_count = flt(frappe.qb.from_("Stock Ledger Entry").select(Count("name")).run()[0][0])
if sle_count > 500000:
frappe.throw(_("Please set filter based on Item or Warehouse"))
if not filters.get("company"):
filters["company"] = frappe.defaults.get_user_default("Company")


def get_warehouse_list(filters):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/stock/stock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def process_sle(self, sle):
sle.stock_value = self.wh_data.stock_value
sle.stock_queue = json.dumps(self.wh_data.stock_queue)

if not sle.is_adjustment_entry or not self.args.get("sle_id"):
if not sle.is_adjustment_entry:
sle.stock_value_difference = stock_value_difference

sle.doctype = "Stock Ledger Entry"
Expand Down

0 comments on commit 07988f1

Please sign in to comment.