mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-23 04:04:52 +00:00
@@ -7,6 +7,7 @@ import frappe
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.query_builder import Order, Tuple
|
from frappe.query_builder import Order, Tuple
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
|
from frappe.utils.formatters import format_value
|
||||||
|
|
||||||
AFFECTED_DOCTYPES = frozenset(
|
AFFECTED_DOCTYPES = frozenset(
|
||||||
(
|
(
|
||||||
@@ -62,22 +63,13 @@ def get_columns():
|
|||||||
{
|
{
|
||||||
"fieldname": "actual_discount_amount",
|
"fieldname": "actual_discount_amount",
|
||||||
"label": _("Discount Amount in Transaction"),
|
"label": _("Discount Amount in Transaction"),
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Data",
|
||||||
"options": "currency",
|
|
||||||
"width": 180,
|
"width": 180,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "suspected_discount_amount",
|
"fieldname": "suspected_discount_amount",
|
||||||
"label": _("Suspected Discount Amount"),
|
"label": _("Suspected Discount Amount"),
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Data",
|
||||||
"options": "currency",
|
|
||||||
"width": 180,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "difference",
|
|
||||||
"label": _("Difference"),
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 180,
|
"width": 180,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -122,6 +114,9 @@ def get_data():
|
|||||||
version_map[key].append(version.data)
|
version_map[key].append(version.data)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
discount_amount_field_map = {
|
||||||
|
doctype: frappe.get_meta(doctype).get_field("discount_amount") for doctype in AFFECTED_DOCTYPES
|
||||||
|
}
|
||||||
for doc, versions in version_map.items():
|
for doc, versions in version_map.items():
|
||||||
for version_data in versions:
|
for version_data in versions:
|
||||||
if '"additional_discount_percentage"' in version_data:
|
if '"additional_discount_percentage"' in version_data:
|
||||||
@@ -137,22 +132,28 @@ def get_data():
|
|||||||
if not discount_values:
|
if not discount_values:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
old = flt(discount_values[1][2:])
|
old = discount_values[1]
|
||||||
new = flt(discount_values[2][2:])
|
new = discount_values[2]
|
||||||
|
doctype = doc[0]
|
||||||
doc_values = transactions_with_discount_percentage.get(doc)
|
doc_values = transactions_with_discount_percentage.get(doc)
|
||||||
if new != doc_values.discount_amount:
|
formatted_discount_amount = format_value(
|
||||||
|
doc_values.discount_amount,
|
||||||
|
df=discount_amount_field_map[doctype],
|
||||||
|
currency=doc_values.currency,
|
||||||
|
)
|
||||||
|
|
||||||
|
if new != formatted_discount_amount:
|
||||||
# if the discount amount in the version is not equal to the current value, skip
|
# if the discount amount in the version is not equal to the current value, skip
|
||||||
break
|
break
|
||||||
|
|
||||||
data.append(
|
data.append(
|
||||||
{
|
{
|
||||||
"doctype": doc[0],
|
"doctype": doctype,
|
||||||
"docname": doc[1],
|
"docname": doc_values.name,
|
||||||
"currency": doc_values.currency,
|
"currency": doc_values.currency,
|
||||||
"actual_discount_percentage": doc_values.additional_discount_percentage,
|
"actual_discount_percentage": doc_values.additional_discount_percentage,
|
||||||
"actual_discount_amount": new,
|
"actual_discount_amount": new,
|
||||||
"suspected_discount_amount": old,
|
"suspected_discount_amount": old,
|
||||||
"difference": flt(old - new, 9),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user