chore: clean up purchase invoice and purchase invoice item
1. remove discount accounting related fields from purchase invoice and purchase invoice item 2. clean buying settings doctype
This commit is contained in:
parent
8b21d27f04
commit
21095502b9
@ -98,7 +98,6 @@
|
|||||||
"section_break_44",
|
"section_break_44",
|
||||||
"apply_discount_on",
|
"apply_discount_on",
|
||||||
"base_discount_amount",
|
"base_discount_amount",
|
||||||
"additional_discount_account",
|
|
||||||
"column_break_46",
|
"column_break_46",
|
||||||
"additional_discount_percentage",
|
"additional_discount_percentage",
|
||||||
"discount_amount",
|
"discount_amount",
|
||||||
@ -1387,12 +1386,6 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "additional_discount_account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Additional Discount Account",
|
|
||||||
"options": "Account"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "ignore_default_payment_terms_template",
|
"fieldname": "ignore_default_payment_terms_template",
|
||||||
@ -1445,7 +1438,7 @@
|
|||||||
"idx": 204,
|
"idx": 204,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-09-13 23:39:54.525037",
|
"modified": "2022-09-27 11:07:55.766844",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice",
|
"name": "Purchase Invoice",
|
||||||
|
@ -669,9 +669,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
exchange_rate_map, net_rate_map = get_purchase_document_details(self)
|
exchange_rate_map, net_rate_map = get_purchase_document_details(self)
|
||||||
|
|
||||||
enable_discount_accounting = cint(
|
|
||||||
frappe.db.get_single_value("Buying Settings", "enable_discount_accounting")
|
|
||||||
)
|
|
||||||
provisional_accounting_for_non_stock_items = cint(
|
provisional_accounting_for_non_stock_items = cint(
|
||||||
frappe.db.get_value(
|
frappe.db.get_value(
|
||||||
"Company", self.company, "enable_provisional_accounting_for_non_stock_items"
|
"Company", self.company, "enable_provisional_accounting_for_non_stock_items"
|
||||||
@ -1159,9 +1156,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
def make_tax_gl_entries(self, gl_entries):
|
def make_tax_gl_entries(self, gl_entries):
|
||||||
# tax table gl entries
|
# tax table gl entries
|
||||||
valuation_tax = {}
|
valuation_tax = {}
|
||||||
enable_discount_accounting = cint(
|
|
||||||
frappe.db.get_single_value("Buying Settings", "enable_discount_accounting")
|
|
||||||
)
|
|
||||||
|
|
||||||
for tax in self.get("taxes"):
|
for tax in self.get("taxes"):
|
||||||
amount, base_amount = self.get_tax_amounts(tax, None)
|
amount, base_amount = self.get_tax_amounts(tax, None)
|
||||||
@ -1249,15 +1243,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
def enable_discount_accounting(self):
|
|
||||||
if not hasattr(self, "_enable_discount_accounting"):
|
|
||||||
self._enable_discount_accounting = cint(
|
|
||||||
frappe.db.get_single_value("Buying Settings", "enable_discount_accounting")
|
|
||||||
)
|
|
||||||
|
|
||||||
return self._enable_discount_accounting
|
|
||||||
|
|
||||||
def make_internal_transfer_gl_entries(self, gl_entries):
|
def make_internal_transfer_gl_entries(self, gl_entries):
|
||||||
if self.is_internal_transfer() and flt(self.base_total_taxes_and_charges):
|
if self.is_internal_transfer() and flt(self.base_total_taxes_and_charges):
|
||||||
account_currency = get_account_currency(self.unrealized_profit_loss_account)
|
account_currency = get_account_currency(self.unrealized_profit_loss_account)
|
||||||
|
@ -74,7 +74,6 @@
|
|||||||
"manufacturer_part_no",
|
"manufacturer_part_no",
|
||||||
"accounting",
|
"accounting",
|
||||||
"expense_account",
|
"expense_account",
|
||||||
"discount_account",
|
|
||||||
"col_break5",
|
"col_break5",
|
||||||
"is_fixed_asset",
|
"is_fixed_asset",
|
||||||
"asset_location",
|
"asset_location",
|
||||||
@ -860,12 +859,6 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "discount_account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Discount Account",
|
|
||||||
"options": "Account"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "product_bundle",
|
"fieldname": "product_bundle",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@ -877,7 +870,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-06-17 05:31:10.520171",
|
"modified": "2022-09-27 10:54:23.980713",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice Item",
|
"name": "Purchase Invoice Item",
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
"maintain_same_rate",
|
"maintain_same_rate",
|
||||||
"allow_multiple_items",
|
"allow_multiple_items",
|
||||||
"bill_for_rejected_quantity_in_purchase_invoice",
|
"bill_for_rejected_quantity_in_purchase_invoice",
|
||||||
"enable_discount_accounting",
|
|
||||||
"subcontract",
|
"subcontract",
|
||||||
"backflush_raw_materials_of_subcontract_based_on",
|
"backflush_raw_materials_of_subcontract_based_on",
|
||||||
"column_break_11",
|
"column_break_11",
|
||||||
@ -134,13 +133,6 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "column_break_12",
|
"fieldname": "column_break_12",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "0",
|
|
||||||
"description": "If enabled, additional ledger entries will be made for discounts in a separate Discount Account",
|
|
||||||
"fieldname": "enable_discount_accounting",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Enable Discount Accounting for Buying"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-cog",
|
"icon": "fa fa-cog",
|
||||||
@ -148,7 +140,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-09-01 18:01:34.994657",
|
"modified": "2022-09-27 10:50:27.050252",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Buying Settings",
|
"name": "Buying Settings",
|
||||||
|
@ -5,15 +5,10 @@
|
|||||||
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import cint
|
|
||||||
|
|
||||||
|
|
||||||
class BuyingSettings(Document):
|
class BuyingSettings(Document):
|
||||||
def on_update(self):
|
|
||||||
self.toggle_discount_accounting_fields()
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
for key in ["supplier_group", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
|
for key in ["supplier_group", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
|
||||||
frappe.db.set_default(key, self.get(key, ""))
|
frappe.db.set_default(key, self.get(key, ""))
|
||||||
@ -26,60 +21,3 @@ class BuyingSettings(Document):
|
|||||||
self.get("supp_master_name") == "Naming Series",
|
self.get("supp_master_name") == "Naming Series",
|
||||||
hide_name_field=False,
|
hide_name_field=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
def toggle_discount_accounting_fields(self):
|
|
||||||
enable_discount_accounting = cint(self.enable_discount_accounting)
|
|
||||||
|
|
||||||
make_property_setter(
|
|
||||||
"Purchase Invoice Item",
|
|
||||||
"discount_account",
|
|
||||||
"hidden",
|
|
||||||
not (enable_discount_accounting),
|
|
||||||
"Check",
|
|
||||||
validate_fields_for_doctype=False,
|
|
||||||
)
|
|
||||||
if enable_discount_accounting:
|
|
||||||
make_property_setter(
|
|
||||||
"Purchase Invoice Item",
|
|
||||||
"discount_account",
|
|
||||||
"mandatory_depends_on",
|
|
||||||
"eval: doc.discount_amount",
|
|
||||||
"Code",
|
|
||||||
validate_fields_for_doctype=False,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
make_property_setter(
|
|
||||||
"Purchase Invoice Item",
|
|
||||||
"discount_account",
|
|
||||||
"mandatory_depends_on",
|
|
||||||
"",
|
|
||||||
"Code",
|
|
||||||
validate_fields_for_doctype=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
make_property_setter(
|
|
||||||
"Purchase Invoice",
|
|
||||||
"additional_discount_account",
|
|
||||||
"hidden",
|
|
||||||
not (enable_discount_accounting),
|
|
||||||
"Check",
|
|
||||||
validate_fields_for_doctype=False,
|
|
||||||
)
|
|
||||||
if enable_discount_accounting:
|
|
||||||
make_property_setter(
|
|
||||||
"Purchase Invoice",
|
|
||||||
"additional_discount_account",
|
|
||||||
"mandatory_depends_on",
|
|
||||||
"eval: doc.discount_amount",
|
|
||||||
"Code",
|
|
||||||
validate_fields_for_doctype=False,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
make_property_setter(
|
|
||||||
"Purchase Invoice",
|
|
||||||
"additional_discount_account",
|
|
||||||
"mandatory_depends_on",
|
|
||||||
"",
|
|
||||||
"Code",
|
|
||||||
validate_fields_for_doctype=False,
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user