From 91b307e7f8bc2ccc9865f2650777e49475becae7 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 11 Mar 2020 13:59:15 +0530 Subject: [PATCH 01/54] fix: project link not set in accounts other than profilt and loss accounts --- .../accounts_settings/accounts_settings.json | 416 +++++++++--------- erpnext/accounts/doctype/gl_entry/gl_entry.py | 6 - .../purchase_invoice/purchase_invoice.json | 9 +- .../purchase_invoice/purchase_invoice.py | 39 +- .../doctype/sales_invoice/sales_invoice.py | 12 +- .../sales_invoice_item.json | 9 +- erpnext/accounts/utils.py | 9 +- erpnext/controllers/stock_controller.py | 2 + .../delivery_note_item.json | 10 +- .../purchase_receipt/purchase_receipt.json | 10 +- 10 files changed, 276 insertions(+), 246 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 4ff4212920..d2f7de3be5 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -1,210 +1,210 @@ { - "creation": "2013-06-24 15:49:57", - "description": "Settings for Accounts", - "doctype": "DocType", - "document_type": "Other", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "auto_accounting_for_stock", - "acc_frozen_upto", - "frozen_accounts_modifier", - "determine_address_tax_category_from", - "over_billing_allowance", - "column_break_4", - "credit_controller", - "check_supplier_invoice_uniqueness", - "make_payment_via_journal_entry", - "unlink_payment_on_cancellation_of_invoice", - "unlink_advance_payment_on_cancelation_of_order", - "book_asset_depreciation_entry_automatically", - "allow_cost_center_in_entry_of_bs_account", - "add_taxes_from_item_tax_template", - "automatically_fetch_payment_terms", - "print_settings", - "show_inclusive_tax_in_print", - "column_break_12", - "show_payment_schedule_in_print", - "currency_exchange_section", - "allow_stale", - "stale_days", - "report_settings_sb", - "use_custom_cash_flow" - ], - "fields": [ - { - "default": "1", - "description": "If enabled, the system will post accounting entries for inventory automatically.", - "fieldname": "auto_accounting_for_stock", - "fieldtype": "Check", - "hidden": 1, - "in_list_view": 1, - "label": "Make Accounting Entry For Every Stock Movement" - }, - { - "description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.", - "fieldname": "acc_frozen_upto", - "fieldtype": "Date", - "in_list_view": 1, - "label": "Accounts Frozen Upto" - }, - { - "description": "Users with this role are allowed to set frozen accounts and create / modify accounting entries against frozen accounts", - "fieldname": "frozen_accounts_modifier", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Role Allowed to Set Frozen Accounts & Edit Frozen Entries", - "options": "Role" - }, - { - "default": "Billing Address", - "description": "Address used to determine Tax Category in transactions.", - "fieldname": "determine_address_tax_category_from", - "fieldtype": "Select", - "label": "Determine Address Tax Category From", - "options": "Billing Address\nShipping Address" - }, - { - "fieldname": "column_break_4", - "fieldtype": "Column Break" - }, - { - "description": "Role that is allowed to submit transactions that exceed credit limits set.", - "fieldname": "credit_controller", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Credit Controller", - "options": "Role" - }, - { - "fieldname": "check_supplier_invoice_uniqueness", - "fieldtype": "Check", - "label": "Check Supplier Invoice Number Uniqueness" - }, - { - "fieldname": "make_payment_via_journal_entry", - "fieldtype": "Check", - "label": "Make Payment via Journal Entry" - }, - { - "default": "1", - "fieldname": "unlink_payment_on_cancellation_of_invoice", - "fieldtype": "Check", - "label": "Unlink Payment on Cancellation of Invoice" - }, - { - "default": "1", - "fieldname": "unlink_advance_payment_on_cancelation_of_order", - "fieldtype": "Check", - "label": "Unlink Advance Payment on Cancelation of Order" - }, - { - "default": "1", - "fieldname": "book_asset_depreciation_entry_automatically", - "fieldtype": "Check", - "label": "Book Asset Depreciation Entry Automatically" - }, - { - "fieldname": "allow_cost_center_in_entry_of_bs_account", - "fieldtype": "Check", - "label": "Allow Cost Center In Entry of Balance Sheet Account" - }, - { - "default": "1", - "fieldname": "add_taxes_from_item_tax_template", - "fieldtype": "Check", - "label": "Automatically Add Taxes and Charges from Item Tax Template" - }, - { - "fieldname": "print_settings", - "fieldtype": "Section Break", - "label": "Print Settings" - }, - { - "fieldname": "show_inclusive_tax_in_print", - "fieldtype": "Check", - "label": "Show Inclusive Tax In Print" - }, - { - "fieldname": "column_break_12", - "fieldtype": "Column Break" - }, - { - "fieldname": "show_payment_schedule_in_print", - "fieldtype": "Check", - "label": "Show Payment Schedule in Print" - }, - { - "fieldname": "currency_exchange_section", - "fieldtype": "Section Break", - "label": "Currency Exchange Settings" - }, - { - "default": "1", - "fieldname": "allow_stale", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Allow Stale Exchange Rates" - }, - { - "default": "1", - "depends_on": "eval:doc.allow_stale==0", - "fieldname": "stale_days", - "fieldtype": "Int", - "label": "Stale Days" - }, - { - "fieldname": "report_settings_sb", - "fieldtype": "Section Break", - "label": "Report Settings" - }, - { - "default": "0", - "description": "Only select if you have setup Cash Flow Mapper documents", - "fieldname": "use_custom_cash_flow", - "fieldtype": "Check", - "label": "Use Custom Cash Flow Format" - }, - { - "fieldname": "automatically_fetch_payment_terms", - "fieldtype": "Check", - "label": "Automatically Fetch Payment Terms" - }, - { - "description": "Percentage you are allowed to bill more against the amount ordered. For example: If the order value is $100 for an item and tolerance is set as 10% then you are allowed to bill for $110.", - "fieldname": "over_billing_allowance", - "fieldtype": "Currency", - "label": "Over Billing Allowance (%)" - } - ], - "icon": "icon-cog", - "idx": 1, - "issingle": 1, - "modified": "2019-07-04 18:20:55.789946", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Accounts Settings", - "owner": "Administrator", - "permissions": [ - { - "create": 1, - "email": 1, - "print": 1, - "read": 1, - "role": "Accounts Manager", - "share": 1, - "write": 1 - }, - { - "read": 1, - "role": "Sales User" - }, - { - "read": 1, - "role": "Purchase User" - } - ], - "quick_entry": 1, - "sort_order": "ASC", - "track_changes": 1 + "creation": "2013-06-24 15:49:57", + "description": "Settings for Accounts", + "doctype": "DocType", + "document_type": "Other", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "auto_accounting_for_stock", + "acc_frozen_upto", + "frozen_accounts_modifier", + "determine_address_tax_category_from", + "over_billing_allowance", + "column_break_4", + "credit_controller", + "check_supplier_invoice_uniqueness", + "make_payment_via_journal_entry", + "unlink_payment_on_cancellation_of_invoice", + "unlink_advance_payment_on_cancelation_of_order", + "book_asset_depreciation_entry_automatically", + "add_taxes_from_item_tax_template", + "automatically_fetch_payment_terms", + "print_settings", + "show_inclusive_tax_in_print", + "column_break_12", + "show_payment_schedule_in_print", + "currency_exchange_section", + "allow_stale", + "stale_days", + "report_settings_sb", + "use_custom_cash_flow" + ], + "fields": [ + { + "default": "1", + "description": "If enabled, the system will post accounting entries for inventory automatically.", + "fieldname": "auto_accounting_for_stock", + "fieldtype": "Check", + "hidden": 1, + "in_list_view": 1, + "label": "Make Accounting Entry For Every Stock Movement" + }, + { + "description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.", + "fieldname": "acc_frozen_upto", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Accounts Frozen Upto" + }, + { + "description": "Users with this role are allowed to set frozen accounts and create / modify accounting entries against frozen accounts", + "fieldname": "frozen_accounts_modifier", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Role Allowed to Set Frozen Accounts & Edit Frozen Entries", + "options": "Role" + }, + { + "default": "Billing Address", + "description": "Address used to determine Tax Category in transactions.", + "fieldname": "determine_address_tax_category_from", + "fieldtype": "Select", + "label": "Determine Address Tax Category From", + "options": "Billing Address\nShipping Address" + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "description": "Role that is allowed to submit transactions that exceed credit limits set.", + "fieldname": "credit_controller", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Credit Controller", + "options": "Role" + }, + { + "default": "0", + "fieldname": "check_supplier_invoice_uniqueness", + "fieldtype": "Check", + "label": "Check Supplier Invoice Number Uniqueness" + }, + { + "default": "0", + "fieldname": "make_payment_via_journal_entry", + "fieldtype": "Check", + "label": "Make Payment via Journal Entry" + }, + { + "default": "1", + "fieldname": "unlink_payment_on_cancellation_of_invoice", + "fieldtype": "Check", + "label": "Unlink Payment on Cancellation of Invoice" + }, + { + "default": "1", + "fieldname": "unlink_advance_payment_on_cancelation_of_order", + "fieldtype": "Check", + "label": "Unlink Advance Payment on Cancelation of Order" + }, + { + "default": "1", + "fieldname": "book_asset_depreciation_entry_automatically", + "fieldtype": "Check", + "label": "Book Asset Depreciation Entry Automatically" + }, + { + "default": "1", + "fieldname": "add_taxes_from_item_tax_template", + "fieldtype": "Check", + "label": "Automatically Add Taxes and Charges from Item Tax Template" + }, + { + "fieldname": "print_settings", + "fieldtype": "Section Break", + "label": "Print Settings" + }, + { + "default": "0", + "fieldname": "show_inclusive_tax_in_print", + "fieldtype": "Check", + "label": "Show Inclusive Tax In Print" + }, + { + "fieldname": "column_break_12", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "show_payment_schedule_in_print", + "fieldtype": "Check", + "label": "Show Payment Schedule in Print" + }, + { + "fieldname": "currency_exchange_section", + "fieldtype": "Section Break", + "label": "Currency Exchange Settings" + }, + { + "default": "1", + "fieldname": "allow_stale", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Allow Stale Exchange Rates" + }, + { + "default": "1", + "depends_on": "eval:doc.allow_stale==0", + "fieldname": "stale_days", + "fieldtype": "Int", + "label": "Stale Days" + }, + { + "fieldname": "report_settings_sb", + "fieldtype": "Section Break", + "label": "Report Settings" + }, + { + "default": "0", + "description": "Only select if you have setup Cash Flow Mapper documents", + "fieldname": "use_custom_cash_flow", + "fieldtype": "Check", + "label": "Use Custom Cash Flow Format" + }, + { + "default": "0", + "fieldname": "automatically_fetch_payment_terms", + "fieldtype": "Check", + "label": "Automatically Fetch Payment Terms" + }, + { + "description": "Percentage you are allowed to bill more against the amount ordered. For example: If the order value is $100 for an item and tolerance is set as 10% then you are allowed to bill for $110.", + "fieldname": "over_billing_allowance", + "fieldtype": "Currency", + "label": "Over Billing Allowance (%)" } + ], + "icon": "icon-cog", + "idx": 1, + "issingle": 1, + "modified": "2020-03-11 13:09:26.235848", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Accounts Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "Accounts Manager", + "share": 1, + "write": 1 + }, + { + "read": 1, + "role": "Sales User" + }, + { + "read": 1, + "role": "Purchase User" + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "ASC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index f9e4fd7714..38b8876341 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -75,12 +75,6 @@ class GLEntry(Document): if not self.cost_center and self.voucher_type != 'Period Closing Voucher': frappe.throw(_("{0} {1}: Cost Center is required for 'Profit and Loss' account {2}. Please set up a default Cost Center for the Company.") .format(self.voucher_type, self.voucher_no, self.account)) - else: - from erpnext.accounts.utils import get_allow_cost_center_in_entry_of_bs_account - if not get_allow_cost_center_in_entry_of_bs_account() and self.cost_center: - self.cost_center = None - if self.project: - self.project = None def validate_dimensions_for_pl_and_bs(self): diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index 3cd988ccd2..8c4fad5cb6 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -25,6 +25,7 @@ "accounting_dimensions_section", "cost_center", "dimension_col_break", + "project", "sb_14", "on_hold", "release_date", @@ -1292,13 +1293,19 @@ "fieldtype": "Check", "label": "Is Internal Supplier", "read_only": 1 + }, + { + "fieldname": "project", + "fieldtype": "Link", + "label": "Project", + "options": "Project" } ], "icon": "fa fa-file-text", "idx": 204, "is_submittable": 1, "links": [], - "modified": "2019-12-30 19:13:49.610538", + "modified": "2020-03-11 12:28:45.711416", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index cc992cec44..14bf174804 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -466,7 +466,8 @@ class PurchaseInvoice(BuyingController): if self.party_account_currency==self.company_currency else grand_total, "against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name, "against_voucher_type": self.doctype, - "cost_center": self.cost_center + "cost_center": self.cost_center, + "project": self.project }, self.party_account_currency) ) @@ -506,6 +507,7 @@ class PurchaseInvoice(BuyingController): "account": warehouse_account[item.warehouse]['account'], "against": warehouse_account[item.from_warehouse]["account"], "cost_center": item.cost_center, + "project": item_row.project or self.project, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "debit": warehouse_debit_amount, }, warehouse_account[item.warehouse]["account_currency"], item=item)) @@ -515,6 +517,7 @@ class PurchaseInvoice(BuyingController): "account": warehouse_account[item.from_warehouse]['account'], "against": warehouse_account[item.warehouse]["account"], "cost_center": item.cost_center, + "project": item_row.project or self.project, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "debit": -1 * flt(item.base_net_amount, item.precision("base_net_amount")), }, warehouse_account[item.from_warehouse]["account_currency"], item=item)) @@ -538,7 +541,7 @@ class PurchaseInvoice(BuyingController): "debit": warehouse_debit_amount, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "cost_center": item.cost_center, - "project": item.project + "project": item.project or self.project }, account_currency, item=item) ) @@ -551,7 +554,7 @@ class PurchaseInvoice(BuyingController): "cost_center": item.cost_center, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "credit": flt(amount), - "project": item.project + "project": item.project or self.project }, item=item)) # sub-contracting warehouse @@ -564,6 +567,7 @@ class PurchaseInvoice(BuyingController): "account": supplier_warehouse_account, "against": item.expense_account, "cost_center": item.cost_center, + "project": item.project or self.project, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "credit": flt(item.rm_supp_cost) }, warehouse_account[self.supplier_warehouse]["account_currency"], item=item)) @@ -582,7 +586,7 @@ class PurchaseInvoice(BuyingController): "against": self.supplier, "debit": amount, "cost_center": item.cost_center, - "project": item.project + "project": item.project or self.project }, account_currency, item=item)) # If asset is bought through this document and not linked to PR @@ -595,7 +599,7 @@ class PurchaseInvoice(BuyingController): "cost_center": item.cost_center, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "credit": flt(item.landed_cost_voucher_amount), - "project": item.project + "project": item.project or self.project }, item=item)) gl_entries.append(self.get_gl_dict({ @@ -604,7 +608,7 @@ class PurchaseInvoice(BuyingController): "cost_center": item.cost_center, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "debit": flt(item.landed_cost_voucher_amount), - "project": item.project + "project": item.project or self.project }, item=item)) # update gross amount of asset bought through this document @@ -630,7 +634,8 @@ class PurchaseInvoice(BuyingController): "against": self.supplier, "debit": flt(item.item_tax_amount, item.precision("item_tax_amount")), "remarks": self.remarks or "Accounting Entry for Stock", - "cost_center": self.cost_center + "cost_center": self.cost_center, + "project": item.project or self.project }, item=item) ) @@ -659,7 +664,8 @@ class PurchaseInvoice(BuyingController): "debit": base_asset_amount, "debit_in_account_currency": (base_asset_amount if arbnb_currency == self.company_currency else asset_amount), - "cost_center": item.cost_center + "cost_center": item.cost_center, + "project": item.project or self.project }, item=item)) if item.item_tax_amount: @@ -669,6 +675,7 @@ class PurchaseInvoice(BuyingController): "against": self.supplier, "remarks": self.get("remarks") or _("Accounting Entry for Asset"), "cost_center": item.cost_center, + "project": item.project or self.project, "credit": item.item_tax_amount, "credit_in_account_currency": (item.item_tax_amount if asset_eiiav_currency == self.company_currency else @@ -685,7 +692,8 @@ class PurchaseInvoice(BuyingController): "debit": base_asset_amount, "debit_in_account_currency": (base_asset_amount if cwip_account_currency == self.company_currency else asset_amount), - "cost_center": self.cost_center + "cost_center": self.cost_center, + "project": item.project or self.project }, item=item)) if item.item_tax_amount and not cint(erpnext.is_perpetual_inventory_enabled(self.company)): @@ -696,6 +704,7 @@ class PurchaseInvoice(BuyingController): "remarks": self.get("remarks") or _("Accounting Entry for Asset"), "cost_center": item.cost_center, "credit": item.item_tax_amount, + "project": item.project or self.project, "credit_in_account_currency": (item.item_tax_amount if asset_eiiav_currency == self.company_currency else item.item_tax_amount / self.conversion_rate) @@ -711,7 +720,7 @@ class PurchaseInvoice(BuyingController): "cost_center": item.cost_center, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "credit": flt(item.landed_cost_voucher_amount), - "project": item.project + "project": item.project or self.project }, item=item)) gl_entries.append(self.get_gl_dict({ @@ -720,7 +729,7 @@ class PurchaseInvoice(BuyingController): "cost_center": item.cost_center, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "debit": flt(item.landed_cost_voucher_amount), - "project": item.project + "project": item.project or self.project }, item=item)) # update gross amount of assets bought through this document @@ -755,7 +764,7 @@ class PurchaseInvoice(BuyingController): "debit": stock_adjustment_amt, "remarks": self.get("remarks") or _("Stock Adjustment"), "cost_center": item.cost_center, - "project": item.project + "project": item.project or self.project }, account_currency, item=item) ) @@ -847,7 +856,8 @@ class PurchaseInvoice(BuyingController): if self.party_account_currency==self.company_currency else self.paid_amount, "against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name, "against_voucher_type": self.doctype, - "cost_center": self.cost_center + "cost_center": self.cost_center, + "project": self.project }, self.party_account_currency) ) @@ -879,7 +889,8 @@ class PurchaseInvoice(BuyingController): if self.party_account_currency==self.company_currency else self.write_off_amount, "against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name, "against_voucher_type": self.doctype, - "cost_center": self.cost_center + "cost_center": self.cost_center, + "project": self.project }, self.party_account_currency) ) gl_entries.append( diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 7f7938db24..6fbd630c1e 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -777,7 +777,8 @@ class SalesInvoice(SellingController): if self.party_account_currency==self.company_currency else grand_total, "against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name, "against_voucher_type": self.doctype, - "cost_center": self.cost_center + "cost_center": self.cost_center, + "project": self.project }, self.party_account_currency) ) @@ -832,7 +833,8 @@ class SalesInvoice(SellingController): "credit_in_account_currency": (flt(item.base_net_amount, item.precision("base_net_amount")) if account_currency==self.company_currency else flt(item.net_amount, item.precision("net_amount"))), - "cost_center": item.cost_center + "cost_center": item.cost_center, + "project": item.project or self.project }, account_currency, item=item) ) @@ -913,7 +915,8 @@ class SalesInvoice(SellingController): if self.party_account_currency==self.company_currency else flt(self.change_amount), "against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name, "against_voucher_type": self.doctype, - "cost_center": self.cost_center + "cost_center": self.cost_center, + "project": self.project }, self.party_account_currency) ) @@ -946,7 +949,8 @@ class SalesInvoice(SellingController): else flt(self.write_off_amount, self.precision("write_off_amount"))), "against_voucher": self.return_against if cint(self.is_return) else self.name, "against_voucher_type": self.doctype, - "cost_center": self.cost_center + "cost_center": self.cost_center, + "project": self.project }, self.party_account_currency) ) gl_entries.append( diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json index b2294e4318..9bc24664d1 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -94,6 +94,7 @@ "accounting_dimensions_section", "cost_center", "dimension_col_break", + "project", "section_break_54", "page_break" ], @@ -783,12 +784,18 @@ "fieldtype": "Link", "label": "Finance Book", "options": "Finance Book" + }, + { + "fieldname": "project", + "fieldtype": "Link", + "label": "Project", + "options": "Project" } ], "idx": 1, "istable": 1, "links": [], - "modified": "2019-12-04 12:22:38.517710", + "modified": "2020-03-11 12:24:41.749986", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Item", diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 4789063ba5..4f4c0860b0 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -124,14 +124,12 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company # hence, assuming balance as 0.0 return 0.0 - allow_cost_center_in_entry_of_bs_account = get_allow_cost_center_in_entry_of_bs_account() - if account: report_type = acc.report_type else: report_type = "" - if cost_center and (allow_cost_center_in_entry_of_bs_account or report_type =='Profit and Loss'): + if cost_center and report_type == 'Profit and Loss': cc = frappe.get_doc("Cost Center", cost_center) if cc.is_group: cond.append(""" exists ( @@ -888,11 +886,6 @@ def get_coa(doctype, parent, is_root, chart=None): return accounts -def get_allow_cost_center_in_entry_of_bs_account(): - def generator(): - return cint(frappe.db.get_value('Accounts Settings', None, 'allow_cost_center_in_entry_of_bs_account')) - return frappe.local_cache("get_allow_cost_center_in_entry_of_bs_account", (), generator, regenerate_if_none=True) - def get_stock_accounts(company): return frappe.get_all("Account", filters = { "account_type": "Stock", diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index d452fe4ac0..37cea28fad 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -91,6 +91,7 @@ class StockController(AccountsController): "account": warehouse_account[sle.warehouse]["account"], "against": item_row.expense_account, "cost_center": item_row.cost_center, + "project": item_row.project or self.project if hasattr(self, 'project') else None, "remarks": self.get("remarks") or "Accounting Entry for Stock", "debit": flt(sle.stock_value_difference, precision), "is_opening": item_row.get("is_opening") or self.get("is_opening") or "No", @@ -101,6 +102,7 @@ class StockController(AccountsController): "account": item_row.expense_account, "against": warehouse_account[sle.warehouse]["account"], "cost_center": item_row.cost_center, + "project": item_row.project or self.project if hasattr(self, 'project') else None, "remarks": self.get("remarks") or "Accounting Entry for Stock", "credit": flt(sle.stock_value_difference, precision), "project": item_row.get("project") or self.get("project"), diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json index 782ac84e57..475a8198dc 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -1,5 +1,4 @@ { - "actions": [], "autoname": "hash", "creation": "2013-04-22 13:15:44", "doctype": "DocType", @@ -81,6 +80,7 @@ "accounting_dimensions_section", "cost_center", "dimension_col_break", + "project", "section_break_72", "page_break" ], @@ -699,12 +699,18 @@ { "fieldname": "dimension_col_break", "fieldtype": "Column Break" + }, + { + "fieldname": "project", + "fieldtype": "Link", + "label": "Project", + "options": "Project" } ], "idx": 1, "istable": 1, "links": [], - "modified": "2020-03-05 14:18:33.131672", + "modified": "2020-03-11 12:25:06.177894", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note Item", diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json index 35446ecb1f..bc2f09e6e2 100755 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json @@ -1,5 +1,4 @@ { - "actions": [], "allow_import": 1, "autoname": "naming_series:", "creation": "2013-05-21 16:16:39", @@ -105,6 +104,7 @@ "amended_from", "range", "column_break4", + "project", "per_billed", "is_internal_supplier", "inter_company_reference", @@ -925,6 +925,12 @@ "print_width": "50%", "width": "50%" }, + { + "fieldname": "project", + "fieldtype": "Link", + "label": "Project", + "options": "Project" + }, { "fieldname": "per_billed", "fieldtype": "Percent", @@ -1076,7 +1082,7 @@ "idx": 261, "is_submittable": 1, "links": [], - "modified": "2019-12-30 19:12:49.709711", + "modified": "2020-03-11 12:58:46.515404", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt", From 0a42d819934d9c1732a135bded575641ea9cc73b Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 11 Mar 2020 14:27:40 +0530 Subject: [PATCH 02/54] fix: cannot find get_allow_cost_center_in_entry_of_bs_account --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 55d275831e..ef1261baf1 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe, erpnext, json from frappe import _, scrub, ValidationError from frappe.utils import flt, comma_or, nowdate, getdate -from erpnext.accounts.utils import get_outstanding_invoices, get_account_currency, get_balance_on, get_allow_cost_center_in_entry_of_bs_account +from erpnext.accounts.utils import get_outstanding_invoices, get_account_currency, get_balance_on from erpnext.accounts.party import get_party_account from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account from erpnext.setup.utils import get_exchange_rate @@ -597,7 +597,7 @@ def get_outstanding_reference_documents(args): .format(frappe.db.escape(args["voucher_type"]), frappe.db.escape(args["voucher_no"])) # Add cost center condition - if args.get("cost_center") and get_allow_cost_center_in_entry_of_bs_account(): + if args.get("cost_center"): condition += " and cost_center='%s'" % args.get("cost_center") date_fields_dict = { From 706c239cf608b75afcde837cd449747c0a60828c Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 11 Mar 2020 15:01:02 +0530 Subject: [PATCH 03/54] fix: remove enable_allow_cost_center_in_entry_of_bs_account --- .../accounts_settings/accounts_settings.py | 6 -- .../journal_entry/test_journal_entry.py | 16 +--- .../payment_entry/test_payment_entry.py | 76 +------------------ .../purchase_invoice/test_purchase_invoice.py | 13 +--- .../sales_invoice/test_sales_invoice.py | 16 +--- .../delivery_note/test_delivery_note.py | 12 +-- .../purchase_receipt/test_purchase_receipt.py | 14 +--- 7 files changed, 14 insertions(+), 139 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py index 2473d715d0..5593466fc2 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -20,7 +20,6 @@ class AccountsSettings(Document): self.validate_stale_days() self.enable_payment_schedule_in_print() - self.enable_fields_for_cost_center_settings() def validate_stale_days(self): if not self.allow_stale and cint(self.stale_days) <= 0: @@ -33,8 +32,3 @@ class AccountsSettings(Document): for doctype in ("Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"): make_property_setter(doctype, "due_date", "print_hide", show_in_print, "Check") make_property_setter(doctype, "payment_schedule", "print_hide", 0 if show_in_print else 1, "Check") - - def enable_fields_for_cost_center_settings(self): - show_field = 0 if cint(self.allow_cost_center_in_entry_of_bs_account) else 1 - for doctype in ("Sales Invoice", "Purchase Invoice", "Payment Entry"): - make_property_setter(doctype, "cost_center", "hidden", show_field, "Check") diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py index 6996c775b3..0b30f9f5c9 100644 --- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py @@ -204,11 +204,8 @@ class TestJournalEntry(unittest.TestCase): self.assertEqual(jv.inter_company_journal_entry_reference, "") self.assertEqual(jv1.inter_company_journal_entry_reference, "") - def test_jv_for_enable_allow_cost_center_in_entry_of_bs_account(self): + def test_jv_with_cost_centre(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 1 - accounts_settings.save() cost_center = "_Test Cost Center for BS Account - _TC" create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company") jv = make_journal_entry("_Test Cash - _TC", "_Test Bank - _TC", 100, cost_center = cost_center, save=False) @@ -237,15 +234,9 @@ class TestJournalEntry(unittest.TestCase): for gle in gl_entries: self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - - def test_jv_account_and_party_balance_for_enable_allow_cost_center_in_entry_of_bs_account(self): + def test_jv_account_and_party_balance_with_cost_centre(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center from erpnext.accounts.utils import get_balance_on - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 1 - accounts_settings.save() cost_center = "_Test Cost Center for BS Account - _TC" create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company") jv = make_journal_entry("_Test Cash - _TC", "_Test Bank - _TC", 100, cost_center = cost_center, save=False) @@ -261,9 +252,6 @@ class TestJournalEntry(unittest.TestCase): account_balance = get_balance_on(account="_Test Bank - _TC", cost_center=cost_center) self.assertEqual(expected_account_balance, account_balance) - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - def make_journal_entry(account1, account2, amount, cost_center=None, posting_date=None, exchange_rate=1, save=True, submit=False, project=None): if not cost_center: cost_center = "_Test Cost Center - _TC" diff --git a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py index 5303743d42..3ae5b2d5c4 100644 --- a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py @@ -438,11 +438,8 @@ class TestPaymentEntry(unittest.TestCase): outstanding_amount = flt(frappe.db.get_value("Sales Invoice", si.name, "outstanding_amount")) self.assertEqual(outstanding_amount, 0) - def test_payment_entry_against_sales_invoice_for_enable_allow_cost_center_in_entry_of_bs_account(self): + def test_payment_entry_against_sales_invoice_with_cost_centre(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 1 - accounts_settings.save() cost_center = "_Test Cost Center for BS Account - _TC" create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company") @@ -477,39 +474,8 @@ class TestPaymentEntry(unittest.TestCase): for gle in gl_entries: self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - - def test_payment_entry_against_sales_invoice_for_disable_allow_cost_center_in_entry_of_bs_account(self): - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - si = create_sales_invoice(debit_to="Debtors - _TC") - - pe = get_payment_entry("Sales Invoice", si.name, bank_account="_Test Bank - _TC") - - pe.reference_no = "112211-2" - pe.reference_date = nowdate() - pe.paid_to = "_Test Bank - _TC" - pe.paid_amount = si.grand_total - pe.insert() - pe.submit() - - gl_entries = frappe.db.sql("""select account, cost_center, account_currency, debit, credit, - debit_in_account_currency, credit_in_account_currency - from `tabGL Entry` where voucher_type='Payment Entry' and voucher_no=%s - order by account asc""", pe.name, as_dict=1) - - self.assertTrue(gl_entries) - - for gle in gl_entries: - self.assertEqual(gle.cost_center, None) - - def test_payment_entry_against_purchase_invoice_for_enable_allow_cost_center_in_entry_of_bs_account(self): + def test_payment_entry_against_purchase_invoice_with_cost_center(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 1 - accounts_settings.save() cost_center = "_Test Cost Center for BS Account - _TC" create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company") @@ -544,40 +510,9 @@ class TestPaymentEntry(unittest.TestCase): for gle in gl_entries: self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - - def test_payment_entry_against_purchase_invoice_for_disable_allow_cost_center_in_entry_of_bs_account(self): - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - pi = make_purchase_invoice(credit_to="Creditors - _TC") - - pe = get_payment_entry("Purchase Invoice", pi.name, bank_account="_Test Bank - _TC") - - pe.reference_no = "112222-2" - pe.reference_date = nowdate() - pe.paid_from = "_Test Bank - _TC" - pe.paid_amount = pi.grand_total - pe.insert() - pe.submit() - - gl_entries = frappe.db.sql("""select account, cost_center, account_currency, debit, credit, - debit_in_account_currency, credit_in_account_currency - from `tabGL Entry` where voucher_type='Payment Entry' and voucher_no=%s - order by account asc""", pe.name, as_dict=1) - - self.assertTrue(gl_entries) - - for gle in gl_entries: - self.assertEqual(gle.cost_center, None) - - def test_payment_entry_account_and_party_balance_for_enable_allow_cost_center_in_entry_of_bs_account(self): + def test_payment_entry_account_and_party_balance_with_cost_center(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center from erpnext.accounts.utils import get_balance_on - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 1 - accounts_settings.save() cost_center = "_Test Cost Center for BS Account - _TC" create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company") @@ -606,7 +541,4 @@ class TestPaymentEntry(unittest.TestCase): self.assertEqual(pe.cost_center, si.cost_center) self.assertEqual(expected_account_balance, account_balance) self.assertEqual(expected_party_balance, party_balance) - self.assertEqual(expected_party_account_balance, party_account_balance) - - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() \ No newline at end of file + self.assertEqual(expected_party_account_balance, party_account_balance) \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index e41ad42846..c2343319ab 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -791,11 +791,8 @@ class TestPurchaseInvoice(unittest.TestCase): pi_doc = frappe.get_doc('Purchase Invoice', pi.name) self.assertEqual(pi_doc.outstanding_amount, 0) - def test_purchase_invoice_for_enable_allow_cost_center_in_entry_of_bs_account(self): + def test_purchase_invoice_with_cost_center(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 1 - accounts_settings.save() cost_center = "_Test Cost Center for BS Account - _TC" create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company") @@ -821,13 +818,7 @@ class TestPurchaseInvoice(unittest.TestCase): for gle in gl_entries: self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - - def test_purchase_invoice_for_disable_allow_cost_center_in_entry_of_bs_account(self): - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() + def test_purchase_invoice_without_cost_center(self): cost_center = "_Test Cost Center - _TC" pi = make_purchase_invoice(credit_to="Creditors - _TC") diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index e48e6c95a3..6636025910 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -1633,11 +1633,8 @@ class TestSalesInvoice(unittest.TestCase): si_doc = frappe.get_doc('Sales Invoice', si.name) self.assertEqual(si_doc.outstanding_amount, 0) - def test_sales_invoice_for_enable_allow_cost_center_in_entry_of_bs_account(self): + def test_sales_invoice_with_cost_center(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 1 - accounts_settings.save() cost_center = "_Test Cost Center for BS Account - _TC" create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company") @@ -1663,13 +1660,7 @@ class TestSalesInvoice(unittest.TestCase): for gle in gl_entries: self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - - def test_sales_invoice_for_disable_allow_cost_center_in_entry_of_bs_account(self): - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 1 - accounts_settings.save() + def test_sales_invoice_without_cost_center(self): cost_center = "_Test Cost Center - _TC" si = create_sales_invoice(debit_to="Debtors - _TC") @@ -1692,9 +1683,6 @@ class TestSalesInvoice(unittest.TestCase): for gle in gl_entries: self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - def test_deferred_revenue(self): deferred_account = create_account(account_name="Deferred Revenue", parent_account="Current Liabilities - _TC", company="_Test Company") diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py index dc92c5c9ff..2c8414ab70 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -547,11 +547,8 @@ class TestDeliveryNote(unittest.TestCase): dt = make_delivery_trip(dn.name) self.assertEqual(dn.name, dt.delivery_stops[0].delivery_note) - def test_delivery_note_for_enable_allow_cost_center_in_entry_of_bs_account(self): + def test_delivery_note_with_cost_center(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 1 - accounts_settings.save() cost_center = "_Test Cost Center for BS Account - TCP1" create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company with perpetual inventory") @@ -577,13 +574,8 @@ class TestDeliveryNote(unittest.TestCase): } for i, gle in enumerate(gl_entries): self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - def test_delivery_note_for_disable_allow_cost_center_in_entry_of_bs_account(self): - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() + def test_delivery_note_without_cost_center(self): cost_center = "Main - TCP1" company = frappe.db.get_value('Warehouse', 'Stores - TCP1', 'company') diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index d80e8f211b..07f89ee9ab 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -372,11 +372,8 @@ class TestPurchaseReceipt(unittest.TestCase): location = frappe.db.get_value('Asset', assets[0].name, 'location') self.assertEquals(location, "Test Location") - def test_purchase_receipt_for_enable_allow_cost_center_in_entry_of_bs_account(self): + def test_purchase_receipt_cost_center(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 1 - accounts_settings.save() cost_center = "_Test Cost Center for BS Account - TCP1" create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company with perpetual inventory") @@ -404,14 +401,7 @@ class TestPurchaseReceipt(unittest.TestCase): for i, gle in enumerate(gl_entries): self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - - def test_purchase_receipt_for_disable_allow_cost_center_in_entry_of_bs_account(self): - accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings') - accounts_settings.allow_cost_center_in_entry_of_bs_account = 0 - accounts_settings.save() - + def test_purchase_receipt_without_cost_center(self): if not frappe.db.exists('Location', 'Test Location'): frappe.get_doc({ 'doctype': 'Location', From af1221bcbd9045b18fb37a0e1865eafa8c5356fe Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Thu, 12 Mar 2020 17:04:17 +0530 Subject: [PATCH 04/54] chore: add tests and remove test based on allow_cost_center_for_bs_accounts --- .../journal_entry/test_journal_entry.py | 36 +++++++++++++++++ .../purchase_invoice/test_purchase_invoice.py | 38 ++++++++++++++++++ .../sales_invoice/test_sales_invoice.py | 39 +++++++++++++++++++ .../projects/doctype/project/test_project.py | 22 ++++++++++- .../project_template/test_project_template.py | 21 +++++++++- 5 files changed, 154 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py index 0b30f9f5c9..23ad1eef14 100644 --- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py @@ -234,6 +234,42 @@ class TestJournalEntry(unittest.TestCase): for gle in gl_entries: self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) + def test_jv_with_project(self): + from erpnext.projects.doctype.project.test_project import make_project + project = make_project({ + 'project_name': 'Journal Entry Project', + 'project_template_name': 'Test Project Template', + 'start_date': '2020-01-01' + }) + + jv = make_journal_entry("_Test Cash - _TC", "_Test Bank - _TC", 100, save=False) + for d in jv.accounts: + d.project = project.project_name + jv.voucher_type = "Bank Entry" + jv.multi_currency = 0 + jv.cheque_no = "112233" + jv.cheque_date = nowdate() + jv.insert() + jv.submit() + + expected_values = { + "_Test Cash - _TC": { + "project": project.project_name + }, + "_Test Bank - _TC": { + "project": project.project_name + } + } + + gl_entries = frappe.db.sql("""select account, project, debit, credit + from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no=%s + order by account asc""", jv.name, as_dict=1) + + self.assertTrue(gl_entries) + + for gle in gl_entries: + self.assertEqual(expected_values[gle.account]["project"], gle.project) + def test_jv_account_and_party_balance_with_cost_centre(self): from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center from erpnext.accounts.utils import get_balance_on diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index c2343319ab..af0eddf3de 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -840,7 +840,45 @@ class TestPurchaseInvoice(unittest.TestCase): for gle in gl_entries: self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) + + def test_purchase_invoice_with_project_link(self): + from erpnext.projects.doctype.project.test_project import make_project + project = make_project({ + 'project_name': 'Purchase Invoice Project', + 'project_template_name': 'Test Project Template', + 'start_date': '2020-01-01' + }) + item_project = make_project({ + 'project_name': 'Purchase Invoice Item Project', + 'project_template_name': 'Test Project Template', + 'start_date': '2019-06-01' + }) + + pi = make_purchase_invoice(credit_to="Creditors - _TC" ,do_not_save=1) + pi.items[0].project = item_project.project_name + pi.project = project.project_name + + pi.submit() + + expected_values = { + "Creditors - _TC": { + "project": project.project_name + }, + "_Test Account Cost for Goods Sold - _TC": { + "project": item_project.project_name + } + } + + gl_entries = frappe.db.sql("""select account, cost_center, project, account_currency, debit, credit, + debit_in_account_currency, credit_in_account_currency + from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s + order by account asc""", pi.name, as_dict=1) + + self.assertTrue(gl_entries) + + for gle in gl_entries: + self.assertEqual(expected_values[gle.account]["project"], gle.project) def unlink_payment_on_cancel_of_invoice(enable=1): accounts_settings = frappe.get_doc("Accounts Settings") diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 6636025910..cb2d8c35bd 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -1659,6 +1659,45 @@ class TestSalesInvoice(unittest.TestCase): for gle in gl_entries: self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) + + def test_sales_invoice_with_project_link(self): + from erpnext.projects.doctype.project.test_project import make_project + + project = make_project({ + 'project_name': 'Sales Invoice Project', + 'project_template_name': 'Test Project Template', + 'start_date': '2020-01-01' + }) + item_project = make_project({ + 'project_name': 'Sales Invoice Item Project', + 'project_template_name': 'Test Project Template', + 'start_date': '2019-06-01' + }) + + sales_invoice = create_sales_invoice(do_not_save=1) + sales_invoice.items[0].project = item_project.project_name + sales_invoice.project = project.project_name + + sales_invoice.submit() + + expected_values = { + "Debtors - _TC": { + "project": project.project_name + }, + "Sales - _TC": { + "project": item_project.project_name + } + } + + gl_entries = frappe.db.sql("""select account, cost_center, project, account_currency, debit, credit, + debit_in_account_currency, credit_in_account_currency + from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s + order by account asc""", sales_invoice.name, as_dict=1) + + self.assertTrue(gl_entries) + + for gle in gl_entries: + self.assertEqual(expected_values[gle.account]["project"], gle.project) def test_sales_invoice_without_cost_center(self): cost_center = "_Test Cost Center - _TC" diff --git a/erpnext/projects/doctype/project/test_project.py b/erpnext/projects/doctype/project/test_project.py index 06c62b62d2..0c4f6f1bdf 100644 --- a/erpnext/projects/doctype/project/test_project.py +++ b/erpnext/projects/doctype/project/test_project.py @@ -7,7 +7,7 @@ import frappe, unittest test_records = frappe.get_test_records('Project') test_ignore = ["Sales Order"] -from erpnext.projects.doctype.project_template.test_project_template import get_project_template +from erpnext.projects.doctype.project_template.test_project_template import get_project_template, make_project_template from erpnext.projects.doctype.project.project import set_project_status from frappe.utils import getdate @@ -43,4 +43,24 @@ def get_project(name): expected_start_date = '2019-01-01' )).insert() + return project + +def make_project(args): + args = frappe._dict(args) + if args.project_template_name: + template = make_project_template(args.project_template_name) + else: + template = get_project_template() + + project = frappe.get_doc(dict( + doctype = 'Project', + project_name = args.project_name, + status = 'Open', + project_template = template.name, + expected_start_date = args.start_date + )) + + if not frappe.db.exists("Project", args.project_name): + project.insert() + return project \ No newline at end of file diff --git a/erpnext/projects/doctype/project_template/test_project_template.py b/erpnext/projects/doctype/project_template/test_project_template.py index efcb2eab68..2c5831a5dc 100644 --- a/erpnext/projects/doctype/project_template/test_project_template.py +++ b/erpnext/projects/doctype/project_template/test_project_template.py @@ -26,4 +26,23 @@ def get_project_template(): ] )).insert() - return frappe.get_doc('Project Template', 'Test Project Template') \ No newline at end of file + return frappe.get_doc('Project Template', 'Test Project Template') + +def make_project_template(project_template_name, project_tasks=[]): + if not frappe.db.exists('Project Template', project_template_name): + frappe.get_doc(dict( + doctype = 'Project Template', + name = project_template_name, + tasks = project_tasks or [ + dict(subject='Task 1', description='Task 1 description', + start=0, duration=3), + dict(subject='Task 2', description='Task 2 description', + start=0, duration=2), + dict(subject='Task 3', description='Task 3 description', + start=2, duration=4), + dict(subject='Task 4', description='Task 4 description', + start=3, duration=2), + ] + )).insert() + + return frappe.get_doc('Project Template', project_template_name) \ No newline at end of file From 4a85b42da0838817396503b71af4831204adec3e Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Fri, 3 Apr 2020 14:31:00 +0530 Subject: [PATCH 05/54] fix: travis --- erpnext/assets/doctype/asset/depreciation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py index 522c1fef67..c50211e6ab 100644 --- a/erpnext/assets/doctype/asset/depreciation.py +++ b/erpnext/assets/doctype/asset/depreciation.py @@ -10,7 +10,7 @@ from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import g def post_depreciation_entries(date=None): # Return if automatic booking of asset depreciation is disabled - if not cint(frappe.db.get_single_value("Accounts Settings", "book_asset_depreciation_entry_automatically")): + if not cint(frappe.db.get_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically")): return if not date: @@ -58,7 +58,8 @@ def make_depreciation_entry(asset_name, date=None): "account": accumulated_depreciation_account, "credit_in_account_currency": d.depreciation_amount, "reference_type": "Asset", - "reference_name": asset.name + "reference_name": asset.name, + "cost_center": "" } debit_entry = { From aa196c0a667ee7c3f2400fc7bd65319ccbb25a5a Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Tue, 14 Apr 2020 14:03:02 +0530 Subject: [PATCH 06/54] fix: travis --- .../purchase_invoice_item/purchase_invoice_item.json | 4 ++-- erpnext/assets/doctype/asset/depreciation.py | 3 +-- erpnext/crm/doctype/opportunity/test_records.json | 1 + erpnext/healthcare/setup.py | 3 ++- erpnext/manufacturing/doctype/bom/test_records.json | 9 ++++++--- .../setup/setup_wizard/operations/install_fixtures.py | 1 - erpnext/www/book-appointment/__init__.py | 0 erpnext/www/book-appointment/verify/__init__.py | 0 8 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 erpnext/www/book-appointment/__init__.py create mode 100644 erpnext/www/book-appointment/verify/__init__.py diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index ef90b942b5..5e073f8e32 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -761,7 +761,7 @@ "depends_on": "is_fixed_asset", "fetch_from": "item_code.asset_category", "fieldname": "asset_category", - "fieldtype": "Data", + "fieldtype": "Link", "label": "Asset Category", "options": "Asset Category", "read_only": 1 @@ -777,7 +777,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2020-03-11 14:20:17.297284", + "modified": "2020-04-14 03:33:32.981331", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py index c50211e6ab..ad671ba0f2 100644 --- a/erpnext/assets/doctype/asset/depreciation.py +++ b/erpnext/assets/doctype/asset/depreciation.py @@ -58,8 +58,7 @@ def make_depreciation_entry(asset_name, date=None): "account": accumulated_depreciation_account, "credit_in_account_currency": d.depreciation_amount, "reference_type": "Asset", - "reference_name": asset.name, - "cost_center": "" + "reference_name": asset.name } debit_entry = { diff --git a/erpnext/crm/doctype/opportunity/test_records.json b/erpnext/crm/doctype/opportunity/test_records.json index a1e0ad921b..0a6c29b637 100644 --- a/erpnext/crm/doctype/opportunity/test_records.json +++ b/erpnext/crm/doctype/opportunity/test_records.json @@ -2,6 +2,7 @@ { "doctype": "Opportunity", "name": "_Test Opportunity 1", + "company": "Wind Power LLC", "opportunity_from": "Lead", "enquiry_type": "Sales", "party_name": "_T-Lead-00001", diff --git a/erpnext/healthcare/setup.py b/erpnext/healthcare/setup.py index 2087f49f32..224dc8d3ad 100644 --- a/erpnext/healthcare/setup.py +++ b/erpnext/healthcare/setup.py @@ -198,7 +198,8 @@ def add_healthcare_service_unit_tree_root(): { "doctype": "Healthcare Service Unit", "healthcare_service_unit_name": "All Healthcare Service Units", - "is_group": 1 + "is_group": 1, + "company": "Wind Power LLC" } ] insert_record(record) diff --git a/erpnext/manufacturing/doctype/bom/test_records.json b/erpnext/manufacturing/doctype/bom/test_records.json index 25730f9b9f..3913268e1d 100644 --- a/erpnext/manufacturing/doctype/bom/test_records.json +++ b/erpnext/manufacturing/doctype/bom/test_records.json @@ -32,7 +32,8 @@ "is_active": 1, "is_default": 1, "item": "_Test Item Home Desktop Manufactured", - "quantity": 1.0 + "quantity": 1.0, + "company": "_Test Company" }, { "scrap_items":[ @@ -78,7 +79,8 @@ "is_default": 1, "currency": "USD", "item": "_Test FG Item", - "quantity": 1.0 + "quantity": 1.0, + "company":"_Test Company" }, { "operations": [ @@ -160,6 +162,7 @@ "currency": "USD", "item": "_Test Variant Item", "quantity": 1.0, - "with_operations": 1 + "with_operations": 1, + "company": "_Test Company" } ] diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index ebd7b50939..432df5b901 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -435,7 +435,6 @@ def install_defaults(args=None): global_defaults.update({ 'current_fiscal_year': current_fiscal_year.name, 'default_currency': args.get('currency'), - 'default_company':args.get('company_name') , "country": args.get("country"), }) diff --git a/erpnext/www/book-appointment/__init__.py b/erpnext/www/book-appointment/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/www/book-appointment/verify/__init__.py b/erpnext/www/book-appointment/verify/__init__.py new file mode 100644 index 0000000000..e69de29bb2 From 1f20c99ecfb51675d7182588001bb3c1d581f415 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Tue, 14 Apr 2020 19:40:25 +0530 Subject: [PATCH 07/54] fix: tests depending on global default company --- .../sales_invoice/test_sales_invoice.py | 1 + .../doctype/subscription/test_subscription.py | 43 +++++++++++++++++++ erpnext/assets/doctype/asset/test_asset.py | 3 +- .../test_procurement_tracker.py | 6 ++- erpnext/controllers/tests/test_mapper.py | 2 + .../doctype/opportunity/test_opportunity.py | 1 + .../plaid_settings/test_plaid_settings.py | 2 +- .../inpatient_record/test_inpatient_record.py | 3 +- .../test_compensatory_leave_request.py | 3 +- .../hr/doctype/department/test_department.py | 2 +- erpnext/hr/doctype/employee/test_employee.py | 2 +- ...test_employee_tax_exemption_declaration.py | 2 +- .../expense_claim/test_expense_claim.py | 1 + .../hr/doctype/job_offer/test_job_offer.py | 4 +- .../doctype/salary_slip/test_salary_slip.py | 2 +- .../salary_structure/test_salary_structure.py | 2 +- .../training_event/test_training_event.py | 3 +- .../delivery_note/test_delivery_note.py | 27 +----------- .../delivery_trip/test_delivery_trip.py | 2 +- .../purchase_receipt/test_purchase_receipt.py | 24 ----------- .../stock/doctype/serial_no/test_serial_no.py | 1 + 21 files changed, 72 insertions(+), 64 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 2692465051..df2cc29a16 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -1058,6 +1058,7 @@ class TestSalesInvoice(unittest.TestCase): serial_no = frappe.get_doc({ "doctype": "Serial No", "item_code": "_Test Serialized Item With Series", + "company": "Wind Power LLC", "serial_no": make_autoname("SR", "Serial No") }) serial_no.save() diff --git a/erpnext/accounts/doctype/subscription/test_subscription.py b/erpnext/accounts/doctype/subscription/test_subscription.py index 3d96f233b4..a0784e6719 100644 --- a/erpnext/accounts/doctype/subscription/test_subscription.py +++ b/erpnext/accounts/doctype/subscription/test_subscription.py @@ -101,6 +101,7 @@ class TestSubscription(unittest.TestCase): subscription.delete() def test_invoice_is_generated_at_end_of_billing_period(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.start = '2018-01-01' @@ -116,8 +117,10 @@ class TestSubscription(unittest.TestCase): self.assertEqual(subscription.current_invoice_start, '2018-01-01') self.assertEqual(subscription.status, 'Past Due Date') subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_status_goes_back_to_active_after_invoice_is_paid(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -141,8 +144,10 @@ class TestSubscription(unittest.TestCase): self.assertEqual(len(subscription.invoices), 1) subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_cancel_after_grace_period(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 1 @@ -164,8 +169,11 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_unpaid_after_grace_period(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") + settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 0 @@ -187,8 +195,11 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_invoice_days_until_due(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") + subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -200,8 +211,11 @@ class TestSubscription(unittest.TestCase): self.assertEqual(subscription.status, 'Active') subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_is_past_due_doesnt_change_within_grace_period(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") + settings = frappe.get_single('Subscription Settings') grace_period = settings.grace_period settings.grace_period = 1000 @@ -229,6 +243,7 @@ class TestSubscription(unittest.TestCase): settings.grace_period = grace_period settings.save() subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_remains_active_during_invoice_period(self): subscription = frappe.new_doc('Subscription') @@ -257,6 +272,7 @@ class TestSubscription(unittest.TestCase): subscription.delete() def test_subscription_cancelation(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -266,8 +282,10 @@ class TestSubscription(unittest.TestCase): self.assertEqual(subscription.status, 'Cancelled') subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_cancellation_invoices(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") settings = frappe.get_single('Subscription Settings') to_prorate = settings.prorate settings.prorate = 1 @@ -301,8 +319,11 @@ class TestSubscription(unittest.TestCase): subscription.delete() settings.prorate = to_prorate settings.save() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_cancellation_invoices_with_prorata_false(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") + settings = frappe.get_single('Subscription Settings') to_prorate = settings.prorate settings.prorate = 0 @@ -321,8 +342,11 @@ class TestSubscription(unittest.TestCase): settings.save() subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_cancellation_invoices_with_prorata_true(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") + settings = frappe.get_single('Subscription Settings') to_prorate = settings.prorate settings.prorate = 1 @@ -345,8 +369,10 @@ class TestSubscription(unittest.TestCase): settings.save() subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subcription_cancellation_and_process(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 1 @@ -378,8 +404,11 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_restart_and_process(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") + settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.grace_period = 0 @@ -416,8 +445,11 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_unpaid_back_to_active(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") + settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 0 @@ -450,6 +482,7 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_restart_active_subscription(self): subscription = frappe.new_doc('Subscription') @@ -462,6 +495,8 @@ class TestSubscription(unittest.TestCase): subscription.delete() def test_subscription_invoice_discount_percentage(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") + subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.additional_discount_percentage = 10 @@ -475,8 +510,11 @@ class TestSubscription(unittest.TestCase): self.assertEqual(invoice.apply_discount_on, 'Grand Total') subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_invoice_discount_amount(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") + subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.additional_discount_amount = 11 @@ -490,10 +528,12 @@ class TestSubscription(unittest.TestCase): self.assertEqual(invoice.apply_discount_on, 'Grand Total') subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_prepaid_subscriptions(self): # Create a non pre-billed subscription, processing should not create # invoices. + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -509,8 +549,10 @@ class TestSubscription(unittest.TestCase): subscription.process() self.assertEqual(len(subscription.invoices), 1) + frappe.db.set_value("Global Defaults", None, "default_company", None) def test_prepaid_subscriptions_with_prorate_true(self): + frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") settings = frappe.get_single('Subscription Settings') to_prorate = settings.prorate settings.prorate = 1 @@ -538,3 +580,4 @@ class TestSubscription(unittest.TestCase): settings.save() subscription.delete() + frappe.db.set_value("Global Defaults", None, "default_company", None) \ No newline at end of file diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index a56440de3d..d2a70375c2 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -78,6 +78,7 @@ class TestAsset(unittest.TestCase): 'qty': 1, 'asset': asset.name }) + doc.company = 'Wind Power LLC' doc.set_missing_values() self.assertEquals(doc.items[0].is_fixed_asset, 1) @@ -595,7 +596,7 @@ def create_asset(**args): "asset_name": args.asset_name or "Macbook Pro 1", "asset_category": "Computers", "item_code": args.item_code or "Macbook Pro", - "company": args.company or"_Test Company", + "company": args.company or "_Test Company", "purchase_date": "2015-01-01", "calculate_depreciation": 0, "gross_purchase_amount": 100000, diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py index bebf0ccec5..0c840ecbd8 100644 --- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py @@ -36,16 +36,18 @@ class TestProcurementTracker(unittest.TestCase): mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse) po = make_purchase_order(mr.name) po.supplier = "_Test Supplier" - po.get("items")[0].cost_center = "_Test Cost Center - _TC" + po.company = "_Test Procurement Company" + po.get("items")[0].cost_center = "_Test Cost Center - _TPC" po.submit() pr = make_purchase_receipt(po.name) + pr.company = "_Test Procurement Company" pr.submit() frappe.db.commit() date_obj = datetime.date(datetime.now()) expected_data = { "material_request_date": date_obj, - "cost_center": "_Test Cost Center - _TC", + "cost_center": "_Test Cost Center - _TPC", "project": None, "requesting_site": "_Test Procurement Warehouse - _TPC", "requestor": "Administrator", diff --git a/erpnext/controllers/tests/test_mapper.py b/erpnext/controllers/tests/test_mapper.py index d02308d8f2..93d1b321b4 100644 --- a/erpnext/controllers/tests/test_mapper.py +++ b/erpnext/controllers/tests/test_mapper.py @@ -43,6 +43,7 @@ class TestMapper(unittest.TestCase): qtn = frappe.get_doc({ "doctype": "Quotation", "quotation_to": "Customer", + "company": "_Test Company", "party_name": customer, "order_type": "Sales", "transaction_date" : nowdate(), @@ -59,6 +60,7 @@ class TestMapper(unittest.TestCase): "base_amount": 1000.0, "base_rate": 100.0, "description": "CPU", + "company": "_Test Company", "doctype": "Sales Order Item", "item_code": "_Test Item Home Desktop 100", "item_name": "CPU", diff --git a/erpnext/crm/doctype/opportunity/test_opportunity.py b/erpnext/crm/doctype/opportunity/test_opportunity.py index 33d90076c4..fc852b19a1 100644 --- a/erpnext/crm/doctype/opportunity/test_opportunity.py +++ b/erpnext/crm/doctype/opportunity/test_opportunity.py @@ -30,6 +30,7 @@ class TestOpportunity(unittest.TestCase): new_lead_email_id = "new{}@example.com".format(random_string(5)) args = { "doctype": "Opportunity", + "company": "_Test Company", "contact_email": new_lead_email_id, "opportunity_type": "Sales", "with_items": 0, diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py index 29e8fa4fec..75184d989a 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py @@ -108,7 +108,7 @@ class TestPlaidSettings(unittest.TestCase): } bank = json.dumps(frappe.get_doc("Bank", "Citi").as_dict(), default=json_handler) - company = frappe.db.get_single_value('Global Defaults', 'default_company') + company = frappe.db.get_single_value('Global Defaults', 'default_company') or '_Test Company' if frappe.db.get_value("Company", company, "default_bank_account") is None: frappe.db.set_value("Company", company, "default_bank_account", get_default_bank_cash_account(company, "Cash").get("account")) diff --git a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py index e15324c55b..7a7936a0f8 100644 --- a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py @@ -84,7 +84,8 @@ def get_healthcare_service_unit(): service_unit.service_unit_type = get_service_unit_type() service_unit.inpatient_occupancy = 1 service_unit.occupancy_status = "Vacant" - service_unit.is_group = 0 + service_unit.is_group = 0, + service_unit.company = "_Test Company" service_unit_parent_name = frappe.db.exists({ "doctype": "Healthcare Service Unit", "healthcare_service_unit_name": "All Healthcare Service Units", diff --git a/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py b/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py index 1615ab30f1..1181192cbe 100644 --- a/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py +++ b/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py @@ -104,7 +104,8 @@ def mark_attendance(employee, date=today(), status='Present'): "doctype": "Attendance", "employee": employee.name, "attendance_date": date, - "status": status + "status": status, + "company": "_Test Company" }) attendance.save() attendance.submit() diff --git a/erpnext/hr/doctype/department/test_department.py b/erpnext/hr/doctype/department/test_department.py index 2eeca26e30..a6e8aae625 100644 --- a/erpnext/hr/doctype/department/test_department.py +++ b/erpnext/hr/doctype/department/test_department.py @@ -16,7 +16,7 @@ def create_department(department_name, parent_department=None): 'is_group': 0, 'parent_department': parent_department, 'department_name': department_name, - 'company': frappe.defaults.get_defaults().company + 'company': frappe.defaults.get_defaults().company or 'Wind Power LLC' }).insert() return doc diff --git a/erpnext/hr/doctype/employee/test_employee.py b/erpnext/hr/doctype/employee/test_employee.py index d3410de2eb..eff382d973 100644 --- a/erpnext/hr/doctype/employee/test_employee.py +++ b/erpnext/hr/doctype/employee/test_employee.py @@ -60,7 +60,7 @@ def make_employee(user, company=None): "doctype": "Employee", "naming_series": "EMP-", "first_name": user, - "company": company or erpnext.get_default_company(), + "company": company or erpnext.get_default_company() or 'Wind Power LLC', "user_id": user, "date_of_birth": "1990-05-08", "date_of_joining": "2013-01-01", diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py index 9c87bbd1f3..d53f6a706d 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py @@ -88,7 +88,7 @@ def create_payroll_period(): payroll_period = frappe.get_doc(dict( doctype = 'Payroll Period', name = "_Test Payroll Period", - company = erpnext.get_default_company(), + company = erpnext.get_default_company() or 'Wind Power LLC', start_date = date(date.today().year, 1, 1), end_date = date(date.today().year, 12, 31) )).insert() diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py index 6e97f0513d..e7ee108142 100644 --- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py @@ -94,6 +94,7 @@ class TestExpenseClaim(unittest.TestCase): payable_account = get_payable_account(company_name) expense_claim = frappe.get_doc({ "doctype": "Expense Claim", + "company": "_Test Company", "employee": "_T-Employee-00001", "payable_account": payable_account, "approval_status": "Rejected", diff --git a/erpnext/hr/doctype/job_offer/test_job_offer.py b/erpnext/hr/doctype/job_offer/test_job_offer.py index 8886596450..1da107bfe7 100644 --- a/erpnext/hr/doctype/job_offer/test_job_offer.py +++ b/erpnext/hr/doctype/job_offer/test_job_offer.py @@ -55,7 +55,8 @@ def create_job_offer(**args): "job_applicant": args.job_applicant or job_applicant.name, "offer_date": args.offer_date or nowdate(), "designation": args.designation or "Researcher", - "status": args.status or "Accepted" + "status": args.status or "Accepted", + "company": "_Test Company" }) return job_offer @@ -68,6 +69,7 @@ def create_staffing_plan(**args): staffing_plan = frappe.get_doc({ "doctype": "Staffing Plan", "name": args.name or "Test", + "company": "_Test Company", "from_date": args.from_date or nowdate(), "to_date": args.to_date or add_days(nowdate(), 10), "staffing_details": args.staffing_details or [{ diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index ecccac7d41..cd73b94719 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -359,7 +359,7 @@ def make_salary_component(salary_components, test_tax, company_list=None): get_salary_component_account(salary_component["salary_component"], company_list) def get_salary_component_account(sal_comp, company_list=None): - company = erpnext.get_default_company() + company = erpnext.get_default_company() or 'Wind Power LLC' if company_list and company not in company_list: company_list.append(company) diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.py b/erpnext/hr/doctype/salary_structure/test_salary_structure.py index 6ca6dfd2c0..e465d04f4d 100644 --- a/erpnext/hr/doctype/salary_structure/test_salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.py @@ -116,7 +116,7 @@ def make_salary_structure(salary_structure, payroll_frequency, employee=None, do details = { "doctype": "Salary Structure", "name": salary_structure, - "company": company or erpnext.get_default_company(), + "company": company or erpnext.get_default_company() or "_Test Company", "earnings": make_earning_salary_component(test_tax=test_tax, company_list=["_Test Company"]), "deductions": make_deduction_salary_component(test_tax=test_tax, company_list=["_Test Company"]), "payroll_frequency": payroll_frequency, diff --git a/erpnext/hr/doctype/training_event/test_training_event.py b/erpnext/hr/doctype/training_event/test_training_event.py index 57123e304f..5ddb99b8ea 100644 --- a/erpnext/hr/doctype/training_event/test_training_event.py +++ b/erpnext/hr/doctype/training_event/test_training_event.py @@ -32,7 +32,8 @@ def create_training_program(training_program): frappe.get_doc({ "doctype": "Training Program", "training_program": training_program, - "description": training_program + "description": training_program, + "company": "Wind Power LLC" }).insert() def get_attendees(employee, employee2): diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py index c15fada525..a0c69c3518 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -192,6 +192,7 @@ class TestDeliveryNote(unittest.TestCase): serial_no = frappe.get_doc({ "doctype": "Serial No", "item_code": "_Test Serialized Item With Series", + "company": "Wind Power LLC", "serial_no": make_autoname("SR", "Serial No") }) serial_no.save() @@ -585,32 +586,6 @@ class TestDeliveryNote(unittest.TestCase): for i, gle in enumerate(gl_entries): self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - def test_delivery_note_without_cost_center(self): - cost_center = "Main - TCP1" - - company = frappe.db.get_value('Warehouse', 'Stores - TCP1', 'company') - - set_valuation_method("_Test Item", "FIFO") - - make_stock_entry(target="Stores - TCP1", qty=5, basic_rate=100) - - stock_in_hand_account = get_inventory_account('_Test Company with perpetual inventory') - dn = create_delivery_note(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', cost_center = 'Main - TCP1', expense_account = "Cost of Goods Sold - TCP1") - - gl_entries = get_gl_entries("Delivery Note", dn.name) - - self.assertTrue(gl_entries) - expected_values = { - "Cost of Goods Sold - TCP1": { - "cost_center": cost_center - }, - stock_in_hand_account: { - "cost_center": None - } - } - for i, gle in enumerate(gl_entries): - self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - def test_make_sales_invoice_from_dn_for_returned_qty(self): from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice diff --git a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py index eeea6da7a4..da2c97cb8c 100644 --- a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py +++ b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py @@ -172,7 +172,7 @@ def create_delivery_trip(driver, address, contact=None): delivery_trip = frappe.get_doc({ "doctype": "Delivery Trip", - "company": erpnext.get_default_company(), + "company": erpnext.get_default_company() or 'Wind Power LLC', "departure_time": add_days(now_datetime(), 5), "driver": driver.name, "driver_address": address.name, diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 9d41b45686..a45fb304d1 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -432,30 +432,6 @@ class TestPurchaseReceipt(unittest.TestCase): for i, gle in enumerate(gl_entries): self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - def test_purchase_receipt_without_cost_center(self): - if not frappe.db.exists('Location', 'Test Location'): - frappe.get_doc({ - 'doctype': 'Location', - 'location_name': 'Test Location' - }).insert() - pr = make_purchase_receipt(company="_Test Company with perpetual inventory", warehouse = "Stores - TCP1", supplier_warehouse = "Work in Progress - TCP1") - - stock_in_hand_account = get_inventory_account(pr.company, pr.get("items")[0].warehouse) - gl_entries = get_gl_entries("Purchase Receipt", pr.name) - - self.assertTrue(gl_entries) - - expected_values = { - "Stock Received But Not Billed - TCP1": { - "cost_center": None - }, - stock_in_hand_account: { - "cost_center": None - } - } - for i, gle in enumerate(gl_entries): - self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - def test_make_purchase_invoice_from_pr_for_returned_qty(self): from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order, create_pr_against_po diff --git a/erpnext/stock/doctype/serial_no/test_serial_no.py b/erpnext/stock/doctype/serial_no/test_serial_no.py index ab061076e5..7b06ef96ce 100644 --- a/erpnext/stock/doctype/serial_no/test_serial_no.py +++ b/erpnext/stock/doctype/serial_no/test_serial_no.py @@ -24,6 +24,7 @@ class TestSerialNo(unittest.TestCase): frappe.delete_doc_if_exists("Serial No", "_TCSER0001") sr = frappe.new_doc("Serial No") + sr.company = '_Test Company' sr.item_code = "_Test Serialized Item" sr.warehouse = "_Test Warehouse - _TC" sr.serial_no = "_TCSER0001" From 55410e03e41f8859faf18d6ac4af319a3a0ae6b4 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 15 Apr 2020 12:57:55 +0530 Subject: [PATCH 08/54] fix: tests depending on global default company --- erpnext/accounts/doctype/subscription/subscription.py | 4 ++++ .../clinical_procedure/test_clinical_procedure.py | 2 ++ erpnext/healthcare/doctype/patient/test_patient.py | 2 ++ .../test_patient_medical_record.py | 2 ++ erpnext/hr/doctype/employee/test_employee.py | 2 +- .../test_employee_tax_exemption_declaration.py | 8 ++++---- erpnext/hr/doctype/leave_period/test_leave_period.py | 4 ++-- erpnext/hr/doctype/payroll_entry/test_payroll_entry.py | 6 +++--- erpnext/hr/doctype/salary_slip/test_salary_slip.py | 10 +++++----- .../doctype/salary_structure/test_salary_structure.py | 4 ++-- 10 files changed, 27 insertions(+), 17 deletions(-) diff --git a/erpnext/accounts/doctype/subscription/subscription.py b/erpnext/accounts/doctype/subscription/subscription.py index 0933c7e8b8..fbdaf1bc95 100644 --- a/erpnext/accounts/doctype/subscription/subscription.py +++ b/erpnext/accounts/doctype/subscription/subscription.py @@ -238,6 +238,10 @@ class Subscription(Document): Creates a `Sales Invoice`, submits it and returns it """ invoice = frappe.new_doc('Sales Invoice') + + if not invoice.company: + invoice.company = frappe.db.get_value('Global Defaults', None, 'default_company') + invoice.set_posting_time = 1 invoice.posting_date = self.current_invoice_start invoice.customer = self.customer diff --git a/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py b/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py index 207351ff20..100addc9ba 100644 --- a/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py +++ b/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py @@ -18,6 +18,7 @@ class TestClinicalProcedure(unittest.TestCase): self.assertEquals(frappe.db.get_value('Item', procedure_template.item, 'disabled'), 1) def test_consumables(self): + frappe.db.set_value('Global Defaults', None, 'default_company', '_Test Company') patient, medical_department, practitioner = create_healthcare_docs() procedure_template = create_clinical_procedure_template() procedure_template.allow_stock_consumption = 1 @@ -38,6 +39,7 @@ class TestClinicalProcedure(unittest.TestCase): result = procedure.complete_procedure() # check consumption self.assertTrue(frappe.db.exists('Stock Entry', result)) + frappe.db.set_value('Global Defaults', None, 'default_company', None) def create_consumable(): diff --git a/erpnext/healthcare/doctype/patient/test_patient.py b/erpnext/healthcare/doctype/patient/test_patient.py index 9274b6f5e8..dfe61bd6c1 100644 --- a/erpnext/healthcare/doctype/patient/test_patient.py +++ b/erpnext/healthcare/doctype/patient/test_patient.py @@ -15,6 +15,7 @@ class TestPatient(unittest.TestCase): self.assertTrue(frappe.db.get_value('Patient', patient, 'customer')) def test_patient_registration(self): + frappe.db.set_value('Global Defaults', None, 'default_company', '_Test Company') frappe.db.sql("""delete from `tabPatient`""") settings = frappe.get_single('Healthcare Settings') settings.collect_registration_fee = 1 @@ -32,3 +33,4 @@ class TestPatient(unittest.TestCase): settings.collect_registration_fee = 0 settings.save() + frappe.db.set_value('Global Defaults', None, 'default_company', None) diff --git a/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py b/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py index e5a5e4c010..4de90bc09f 100644 --- a/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py +++ b/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py @@ -13,6 +13,7 @@ class TestPatientMedicalRecord(unittest.TestCase): frappe.db.set_value('Healthcare Settings', None, 'automate_appointment_invoicing', 1) def test_medical_record(self): + frappe.db.set_value('Global Defaults', None, 'default_company', '_Test Company') patient, medical_department, practitioner = create_healthcare_docs() appointment = create_appointment(patient, practitioner, nowdate(), invoice=1) encounter = create_encounter(appointment) @@ -38,6 +39,7 @@ class TestPatientMedicalRecord(unittest.TestCase): # check for lab test medical_rec = frappe.db.exists('Patient Medical Record', {'status': 'Open', 'reference_name': lab_test.name}) self.assertTrue(medical_rec) + frappe.db.set_value('Global Defaults', None, 'default_company', None) def create_procedure(appointment): diff --git a/erpnext/hr/doctype/employee/test_employee.py b/erpnext/hr/doctype/employee/test_employee.py index eff382d973..755393ea04 100644 --- a/erpnext/hr/doctype/employee/test_employee.py +++ b/erpnext/hr/doctype/employee/test_employee.py @@ -55,7 +55,7 @@ def make_employee(user, company=None): "roles": [{"doctype": "Has Role", "role": "Employee"}] }).insert() - if not frappe.db.get_value("Employee", { "user_id": user, "company": company or erpnext.get_default_company() }): + if not frappe.db.get_value("Employee", { "user_id": user, "company": company or erpnext.get_default_company() or 'Wind Power LLC' }): employee = frappe.get_doc({ "doctype": "Employee", "naming_series": "EMP-", diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py index d53f6a706d..4dc77ccc51 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py @@ -20,7 +20,7 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "company": erpnext.get_default_company(), + "company": erpnext.get_default_company() or 'Wind Power LLC', "payroll_period": "_Test Payroll Period", "declarations": [ dict(exemption_sub_category = "_Test Sub Category", @@ -37,7 +37,7 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "company": erpnext.get_default_company(), + "company": erpnext.get_default_company() or 'Wind Power LLC', "payroll_period": "_Test Payroll Period", "declarations": [ dict(exemption_sub_category = "_Test Sub Category", @@ -52,7 +52,7 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): duplicate_declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "company": erpnext.get_default_company(), + "company": erpnext.get_default_company() or 'Wind Power LLC', "payroll_period": "_Test Payroll Period", "declarations": [ dict(exemption_sub_category = "_Test Sub Category", @@ -68,7 +68,7 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "company": erpnext.get_default_company(), + "company": erpnext.get_default_company() or 'Wind Power LLC', "payroll_period": "_Test Payroll Period", "declarations": [ dict(exemption_sub_category = "_Test Sub Category", diff --git a/erpnext/hr/doctype/leave_period/test_leave_period.py b/erpnext/hr/doctype/leave_period/test_leave_period.py index 1762cf917a..06e5836738 100644 --- a/erpnext/hr/doctype/leave_period/test_leave_period.py +++ b/erpnext/hr/doctype/leave_period/test_leave_period.py @@ -45,7 +45,7 @@ class TestLeavePeriod(unittest.TestCase): def create_leave_period(from_date, to_date, company=None): leave_period = frappe.db.get_value('Leave Period', - dict(company=company or erpnext.get_default_company(), + dict(company=company or erpnext.get_default_company() or 'Wind Power LLC', from_date=from_date, to_date=to_date, is_active=1), 'name') @@ -54,7 +54,7 @@ def create_leave_period(from_date, to_date, company=None): leave_period = frappe.get_doc({ "doctype": "Leave Period", - "company": company or erpnext.get_default_company(), + "company": company or erpnext.get_default_company() or 'Wind Power LLC', "from_date": from_date, "to_date": to_date, "is_active": 1 diff --git a/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py b/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py index 49671d5e22..52fb69f1a4 100644 --- a/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py +++ b/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py @@ -26,7 +26,7 @@ class TestPayrollEntry(unittest.TestCase): frappe.db.set_value("HR Settings", None, "email_salary_slip_to_employee", 0) def test_payroll_entry(self): # pylint: disable=no-self-use - company = erpnext.get_default_company() + company = erpnext.get_default_company() or 'Wind Power LLC' for data in frappe.get_all('Salary Component', fields = ["name"]): if not frappe.db.get_value('Salary Component Account', {'parent': data.name, 'company': company}, 'name'): @@ -109,7 +109,7 @@ def make_payroll_entry(**args): args = frappe._dict(args) payroll_entry = frappe.new_doc("Payroll Entry") - payroll_entry.company = args.company or erpnext.get_default_company() + payroll_entry.company = args.company or erpnext.get_default_company() or 'Wind Power LLC' payroll_entry.start_date = args.start_date or "2016-11-01" payroll_entry.end_date = args.end_date or "2016-11-30" payroll_entry.payment_account = get_payment_account() @@ -133,7 +133,7 @@ def make_payroll_entry(**args): def get_payment_account(): return frappe.get_value('Account', - {'account_type': 'Cash', 'company': erpnext.get_default_company(),'is_group':0}, "name") + {'account_type': 'Cash', 'company': erpnext.get_default_company() or 'Wind Power LLC', 'is_group':0}, "name") def make_holiday(holiday_list_name): if not frappe.db.exists('Holiday List', holiday_list_name): diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index cd73b94719..ac91aec282 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -26,7 +26,7 @@ class TestSalarySlip(unittest.TestCase): self.make_holiday_list() - frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List") + frappe.db.set_value("Company", erpnext.get_default_company() or 'Wind Power LLC', "default_holiday_list", "Salary Slip Test Holiday List") frappe.db.set_value("HR Settings", None, "email_salary_slip_to_employee", 0) def tearDown(self): @@ -175,7 +175,7 @@ class TestSalarySlip(unittest.TestCase): self.assertEqual(ss.net_pay, (flt(ss.gross_pay) - (flt(ss.total_deduction) + flt(ss.total_loan_repayment)))) def test_payroll_frequency(self): - fiscal_year = get_fiscal_year(nowdate(), company=erpnext.get_default_company())[0] + fiscal_year = get_fiscal_year(nowdate(), company=erpnext.get_default_company() or 'Wind Power LLC')[0] month = "%02d" % getdate(nowdate()).month m = get_month_details(fiscal_year, month) @@ -295,7 +295,7 @@ class TestSalarySlip(unittest.TestCase): frappe.db.rollback() def make_holiday_list(self): - fiscal_year = get_fiscal_year(nowdate(), company=erpnext.get_default_company()) + fiscal_year = get_fiscal_year(nowdate(), company=erpnext.get_default_company() or 'Wind Power LLC') if not frappe.db.get_value("Holiday List", "Salary Slip Test Holiday List"): holiday_list = frappe.get_doc({ "doctype": "Holiday List", @@ -499,7 +499,7 @@ def create_exemption_declaration(employee, payroll_period): "doctype": "Employee Tax Exemption Declaration", "employee": employee, "payroll_period": payroll_period, - "company": erpnext.get_default_company() + "company": erpnext.get_default_company() or 'Wind Power LLC' }) declaration.append("declarations", { "exemption_sub_category": "_Test Sub Category", @@ -588,7 +588,7 @@ def create_additional_salary(employee, payroll_period, amount): frappe.get_doc({ "doctype": "Additional Salary", "employee": employee, - "company": erpnext.get_default_company(), + "company": erpnext.get_default_company() or 'Wind Power LLC', "salary_component": "Performance Bonus", "payroll_date": salary_date, "amount": amount, diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.py b/erpnext/hr/doctype/salary_structure/test_salary_structure.py index e465d04f4d..17087d14cf 100644 --- a/erpnext/hr/doctype/salary_structure/test_salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.py @@ -21,7 +21,7 @@ class TestSalaryStructure(unittest.TestCase): frappe.db.sql("delete from `tab%s`" % dt) self.make_holiday_list() - frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Structure Test Holiday List") + frappe.db.set_value("Company", erpnext.get_default_company() or 'Wind Power LLC', "default_holiday_list", "Salary Structure Test Holiday List") make_employee("test_employee@salary.com") make_employee("test_employee_2@salary.com") @@ -145,7 +145,7 @@ def create_salary_structure_assignment(employee, salary_structure, from_date=Non salary_structure_assignment.variable = 5000 salary_structure_assignment.from_date = from_date or add_months(nowdate(), -1) salary_structure_assignment.salary_structure = salary_structure - salary_structure_assignment.company = company or erpnext.get_default_company() + salary_structure_assignment.company = company or erpnext.get_default_company() or 'Wind Power LLC' salary_structure_assignment.save(ignore_permissions=True) salary_structure_assignment.submit() return salary_structure_assignment From 52baf8f863539b5ad5063c640374dd31ee7e6408 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 29 May 2020 17:20:03 +0530 Subject: [PATCH 09/54] fix: Test Cases --- .../purchase_invoice/purchase_invoice.json | 2 +- .../purchase_invoice/test_purchase_invoice.py | 13 +++++++------ .../doctype/sales_invoice/test_records.json | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index b8d173bcc8..a80637e7a4 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -1316,7 +1316,7 @@ "idx": 204, "is_submittable": 1, "links": [], - "modified": "2020-04-18 13:05:25.199832", + "modified": "2020-05-29 13:05:25.199832", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 5cbfad2051..f61d27aee3 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -15,6 +15,7 @@ from erpnext.controllers.accounts_controller import get_payment_terms from erpnext.exceptions import InvalidCurrency from erpnext.stock.doctype.stock_entry.test_stock_entry import get_qty_after_transaction from erpnext.accounts.doctype.account.test_account import get_inventory_account +from erpnext.projects.doctype.project.test_project import make_project test_dependencies = ["Item", "Cost Center", "Payment Term", "Payment Terms Template"] test_ignore = ["Serial No"] @@ -434,6 +435,8 @@ class TestPurchaseInvoice(unittest.TestCase): ) def test_total_purchase_cost_for_project(self): + make_project({'project_name':'_Test Project'}) + existing_purchase_cost = frappe.db.sql("""select sum(base_net_amount) from `tabPurchase Invoice Item` where project = '_Test Project' and docstatus=1""") existing_purchase_cost = existing_purchase_cost and existing_purchase_cost[0][0] or 0 @@ -819,7 +822,7 @@ class TestPurchaseInvoice(unittest.TestCase): "Creditors - _TC": { "cost_center": cost_center }, - "_Test Account Cost for Goods Sold - _TC": { + "Cost of Goods Sold - _TC": { "cost_center": cost_center } } @@ -856,10 +859,8 @@ class TestPurchaseInvoice(unittest.TestCase): for gle in gl_entries: self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - - def test_purchase_invoice_with_project_link(self): - from erpnext.projects.doctype.project.test_project import make_project + def test_purchase_invoice_with_project_link(self): project = make_project({ 'project_name': 'Purchase Invoice Project', 'project_template_name': 'Test Project Template', @@ -890,9 +891,9 @@ class TestPurchaseInvoice(unittest.TestCase): debit_in_account_currency, credit_in_account_currency from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s order by account asc""", pi.name, as_dict=1) - + self.assertTrue(gl_entries) - + for gle in gl_entries: self.assertEqual(expected_values[gle.account]["project"], gle.project) diff --git a/erpnext/accounts/doctype/sales_invoice/test_records.json b/erpnext/accounts/doctype/sales_invoice/test_records.json index ebe6e3da8d..11ebe6a573 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_records.json +++ b/erpnext/accounts/doctype/sales_invoice/test_records.json @@ -3,6 +3,7 @@ "company": "_Test Company", "conversion_rate": 1.0, "currency": "INR", + "cost_center": "_Test Cost Center - _TC", "customer": "_Test Customer", "customer_name": "_Test Customer", "debit_to": "_Test Receivable - _TC", @@ -37,7 +38,8 @@ "charge_type": "On Net Total", "description": "VAT", "doctype": "Sales Taxes and Charges", - "parentfield": "taxes", + "parentfield": "taxes", + "cost_center": "_Test Cost Center - _TC", "rate": 6 }, { @@ -45,7 +47,8 @@ "charge_type": "On Net Total", "description": "Service Tax", "doctype": "Sales Taxes and Charges", - "parentfield": "taxes", + "parentfield": "taxes", + "cost_center": "_Test Cost Center - _TC", "rate": 6.36 } ], @@ -76,6 +79,7 @@ "customer_name": "_Test Customer", "debit_to": "_Test Receivable - _TC", "doctype": "Sales Invoice", + "cost_center": "_Test Cost Center - _TC", "items": [ { "amount": 500.0, @@ -107,7 +111,8 @@ "charge_type": "On Net Total", "description": "VAT", "doctype": "Sales Taxes and Charges", - "parentfield": "taxes", + "parentfield": "taxes", + "cost_center": "_Test Cost Center - _TC", "rate": 16 }, { @@ -115,7 +120,8 @@ "charge_type": "On Net Total", "description": "Service Tax", "doctype": "Sales Taxes and Charges", - "parentfield": "taxes", + "parentfield": "taxes", + "cost_center": "_Test Cost Center - _TC", "rate": 10 } ], @@ -132,6 +138,7 @@ "customer_name": "_Test Customer", "debit_to": "_Test Receivable - _TC", "doctype": "Sales Invoice", + "cost_center": "_Test Cost Center - _TC", "items": [ { "cost_center": "_Test Cost Center - _TC", @@ -259,6 +266,7 @@ "customer_name": "_Test Customer", "debit_to": "_Test Receivable - _TC", "doctype": "Sales Invoice", + "cost_center": "_Test Cost Center - _TC", "items": [ { "cost_center": "_Test Cost Center - _TC", From dfa32a77c1bdfc23ab2722682b3f0412986fe7e5 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 29 May 2020 17:20:33 +0530 Subject: [PATCH 10/54] fix: Patch to remove Property Setter --- erpnext/patches.txt | 3 ++- erpnext/patches/v12_0/unhide_cost_center_field.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 erpnext/patches/v12_0/unhide_cost_center_field.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index b0421f43c6..7125abfb69 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -694,4 +694,5 @@ execute:frappe.delete_doc("Report", "Department Analytics") execute:frappe.rename_doc("Desk Page", "Loan Management", "Loan", force=True) erpnext.patches.v12_0.update_uom_conversion_factor erpnext.patches.v13_0.delete_old_purchase_reports -erpnext.patches.v12_0.set_italian_import_supplier_invoice_permissions \ No newline at end of file +erpnext.patches.v12_0.set_italian_import_supplier_invoice_permissions +erpnext.patches.v12_0.unhide_cost_center_field \ No newline at end of file diff --git a/erpnext/patches/v12_0/unhide_cost_center_field.py b/erpnext/patches/v12_0/unhide_cost_center_field.py new file mode 100644 index 0000000000..6005ab7072 --- /dev/null +++ b/erpnext/patches/v12_0/unhide_cost_center_field.py @@ -0,0 +1,13 @@ +# Copyright (c) 2017, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.db.sql(""" + DELETE FROM `tabProperty Setter` + WHERE doc_type in ('Sales Invoice', 'Purchase Invoice', 'Payment Entry') + AND field_name = 'cost_center' + AND property = 'hidden' + """) \ No newline at end of file From f8550790fa8850c73ab1489379aa17e9d771091a Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 30 May 2020 11:37:36 +0530 Subject: [PATCH 11/54] This reverts commit aa196c0a667ee7c3f2400fc7bd65319ccbb25a5a --- .../purchase_invoice_item/purchase_invoice_item.json | 2 +- erpnext/assets/doctype/asset/depreciation.py | 3 ++- erpnext/crm/doctype/opportunity/test_records.json | 1 - erpnext/manufacturing/doctype/bom/test_records.json | 9 +++------ .../setup/setup_wizard/operations/install_fixtures.py | 1 + erpnext/www/book-appointment/__init__.py | 0 erpnext/www/book-appointment/verify/__init__.py | 0 7 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 erpnext/www/book-appointment/__init__.py delete mode 100644 erpnext/www/book-appointment/verify/__init__.py diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index 52a5be0984..cfbe06ad02 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -753,7 +753,7 @@ "depends_on": "is_fixed_asset", "fetch_from": "item_code.asset_category", "fieldname": "asset_category", - "fieldtype": "Link", + "fieldtype": "Data", "label": "Asset Category", "options": "Asset Category", "read_only": 1 diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py index ad671ba0f2..c50211e6ab 100644 --- a/erpnext/assets/doctype/asset/depreciation.py +++ b/erpnext/assets/doctype/asset/depreciation.py @@ -58,7 +58,8 @@ def make_depreciation_entry(asset_name, date=None): "account": accumulated_depreciation_account, "credit_in_account_currency": d.depreciation_amount, "reference_type": "Asset", - "reference_name": asset.name + "reference_name": asset.name, + "cost_center": "" } debit_entry = { diff --git a/erpnext/crm/doctype/opportunity/test_records.json b/erpnext/crm/doctype/opportunity/test_records.json index 0a6c29b637..a1e0ad921b 100644 --- a/erpnext/crm/doctype/opportunity/test_records.json +++ b/erpnext/crm/doctype/opportunity/test_records.json @@ -2,7 +2,6 @@ { "doctype": "Opportunity", "name": "_Test Opportunity 1", - "company": "Wind Power LLC", "opportunity_from": "Lead", "enquiry_type": "Sales", "party_name": "_T-Lead-00001", diff --git a/erpnext/manufacturing/doctype/bom/test_records.json b/erpnext/manufacturing/doctype/bom/test_records.json index 3913268e1d..25730f9b9f 100644 --- a/erpnext/manufacturing/doctype/bom/test_records.json +++ b/erpnext/manufacturing/doctype/bom/test_records.json @@ -32,8 +32,7 @@ "is_active": 1, "is_default": 1, "item": "_Test Item Home Desktop Manufactured", - "quantity": 1.0, - "company": "_Test Company" + "quantity": 1.0 }, { "scrap_items":[ @@ -79,8 +78,7 @@ "is_default": 1, "currency": "USD", "item": "_Test FG Item", - "quantity": 1.0, - "company":"_Test Company" + "quantity": 1.0 }, { "operations": [ @@ -162,7 +160,6 @@ "currency": "USD", "item": "_Test Variant Item", "quantity": 1.0, - "with_operations": 1, - "company": "_Test Company" + "with_operations": 1 } ] diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 56899d5fbb..0d70d91f73 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -437,6 +437,7 @@ def install_defaults(args=None): global_defaults.update({ 'current_fiscal_year': current_fiscal_year.name, 'default_currency': args.get('currency'), + 'default_company':args.get('company_name') , "country": args.get("country"), }) diff --git a/erpnext/www/book-appointment/__init__.py b/erpnext/www/book-appointment/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/www/book-appointment/verify/__init__.py b/erpnext/www/book-appointment/verify/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 From 36f7710356a2fa55db8c5401b4db48bb098b2a28 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 30 May 2020 11:38:04 +0530 Subject: [PATCH 12/54] Revert "fix: tests depending on global default company" This reverts commit 1f20c99ecfb51675d7182588001bb3c1d581f415. --- .../sales_invoice/test_sales_invoice.py | 1 - .../doctype/subscription/test_subscription.py | 43 ------------------- erpnext/assets/doctype/asset/test_asset.py | 3 +- .../test_procurement_tracker.py | 6 +-- erpnext/controllers/tests/test_mapper.py | 2 - .../doctype/opportunity/test_opportunity.py | 1 - .../plaid_settings/test_plaid_settings.py | 2 +- .../inpatient_record/test_inpatient_record.py | 3 +- .../test_compensatory_leave_request.py | 3 +- .../hr/doctype/department/test_department.py | 2 +- erpnext/hr/doctype/employee/test_employee.py | 2 +- ...test_employee_tax_exemption_declaration.py | 2 +- .../expense_claim/test_expense_claim.py | 1 - .../hr/doctype/job_offer/test_job_offer.py | 4 +- .../doctype/salary_slip/test_salary_slip.py | 2 +- .../salary_structure/test_salary_structure.py | 2 +- .../training_event/test_training_event.py | 3 +- .../delivery_note/test_delivery_note.py | 27 +++++++++++- .../delivery_trip/test_delivery_trip.py | 2 +- .../purchase_receipt/test_purchase_receipt.py | 24 +++++++++++ .../stock/doctype/serial_no/test_serial_no.py | 1 - 21 files changed, 64 insertions(+), 72 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index fc53f8818a..a2f9040670 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -1065,7 +1065,6 @@ class TestSalesInvoice(unittest.TestCase): serial_no = frappe.get_doc({ "doctype": "Serial No", "item_code": "_Test Serialized Item With Series", - "company": "Wind Power LLC", "serial_no": make_autoname("SR", "Serial No") }) serial_no.save() diff --git a/erpnext/accounts/doctype/subscription/test_subscription.py b/erpnext/accounts/doctype/subscription/test_subscription.py index a0784e6719..3d96f233b4 100644 --- a/erpnext/accounts/doctype/subscription/test_subscription.py +++ b/erpnext/accounts/doctype/subscription/test_subscription.py @@ -101,7 +101,6 @@ class TestSubscription(unittest.TestCase): subscription.delete() def test_invoice_is_generated_at_end_of_billing_period(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.start = '2018-01-01' @@ -117,10 +116,8 @@ class TestSubscription(unittest.TestCase): self.assertEqual(subscription.current_invoice_start, '2018-01-01') self.assertEqual(subscription.status, 'Past Due Date') subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_status_goes_back_to_active_after_invoice_is_paid(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -144,10 +141,8 @@ class TestSubscription(unittest.TestCase): self.assertEqual(len(subscription.invoices), 1) subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_cancel_after_grace_period(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 1 @@ -169,11 +164,8 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_unpaid_after_grace_period(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 0 @@ -195,11 +187,8 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_invoice_days_until_due(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -211,11 +200,8 @@ class TestSubscription(unittest.TestCase): self.assertEqual(subscription.status, 'Active') subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_is_past_due_doesnt_change_within_grace_period(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - settings = frappe.get_single('Subscription Settings') grace_period = settings.grace_period settings.grace_period = 1000 @@ -243,7 +229,6 @@ class TestSubscription(unittest.TestCase): settings.grace_period = grace_period settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_remains_active_during_invoice_period(self): subscription = frappe.new_doc('Subscription') @@ -272,7 +257,6 @@ class TestSubscription(unittest.TestCase): subscription.delete() def test_subscription_cancelation(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -282,10 +266,8 @@ class TestSubscription(unittest.TestCase): self.assertEqual(subscription.status, 'Cancelled') subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_cancellation_invoices(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") settings = frappe.get_single('Subscription Settings') to_prorate = settings.prorate settings.prorate = 1 @@ -319,11 +301,8 @@ class TestSubscription(unittest.TestCase): subscription.delete() settings.prorate = to_prorate settings.save() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_cancellation_invoices_with_prorata_false(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - settings = frappe.get_single('Subscription Settings') to_prorate = settings.prorate settings.prorate = 0 @@ -342,11 +321,8 @@ class TestSubscription(unittest.TestCase): settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_cancellation_invoices_with_prorata_true(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - settings = frappe.get_single('Subscription Settings') to_prorate = settings.prorate settings.prorate = 1 @@ -369,10 +345,8 @@ class TestSubscription(unittest.TestCase): settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subcription_cancellation_and_process(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 1 @@ -404,11 +378,8 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_restart_and_process(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.grace_period = 0 @@ -445,11 +416,8 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_unpaid_back_to_active(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - settings = frappe.get_single('Subscription Settings') default_grace_period_action = settings.cancel_after_grace settings.cancel_after_grace = 0 @@ -482,7 +450,6 @@ class TestSubscription(unittest.TestCase): settings.cancel_after_grace = default_grace_period_action settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_restart_active_subscription(self): subscription = frappe.new_doc('Subscription') @@ -495,8 +462,6 @@ class TestSubscription(unittest.TestCase): subscription.delete() def test_subscription_invoice_discount_percentage(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.additional_discount_percentage = 10 @@ -510,11 +475,8 @@ class TestSubscription(unittest.TestCase): self.assertEqual(invoice.apply_discount_on, 'Grand Total') subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_subscription_invoice_discount_amount(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") - subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.additional_discount_amount = 11 @@ -528,12 +490,10 @@ class TestSubscription(unittest.TestCase): self.assertEqual(invoice.apply_discount_on, 'Grand Total') subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_prepaid_subscriptions(self): # Create a non pre-billed subscription, processing should not create # invoices. - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") subscription = frappe.new_doc('Subscription') subscription.customer = '_Test Customer' subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1}) @@ -549,10 +509,8 @@ class TestSubscription(unittest.TestCase): subscription.process() self.assertEqual(len(subscription.invoices), 1) - frappe.db.set_value("Global Defaults", None, "default_company", None) def test_prepaid_subscriptions_with_prorate_true(self): - frappe.db.set_value("Global Defaults", None, "default_company", "_Test Company") settings = frappe.get_single('Subscription Settings') to_prorate = settings.prorate settings.prorate = 1 @@ -580,4 +538,3 @@ class TestSubscription(unittest.TestCase): settings.save() subscription.delete() - frappe.db.set_value("Global Defaults", None, "default_company", None) \ No newline at end of file diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 9490c8cbc7..aed78e7746 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -75,7 +75,6 @@ class TestAsset(unittest.TestCase): 'qty': 1, 'asset': asset.name }) - doc.company = 'Wind Power LLC' doc.set_missing_values() self.assertEquals(doc.items[0].is_fixed_asset, 1) @@ -667,7 +666,7 @@ def create_asset(**args): "asset_name": args.asset_name or "Macbook Pro 1", "asset_category": "Computers", "item_code": args.item_code or "Macbook Pro", - "company": args.company or "_Test Company", + "company": args.company or"_Test Company", "purchase_date": "2015-01-01", "calculate_depreciation": 0, "gross_purchase_amount": 100000, diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py index 0c840ecbd8..bebf0ccec5 100644 --- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py @@ -36,18 +36,16 @@ class TestProcurementTracker(unittest.TestCase): mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse) po = make_purchase_order(mr.name) po.supplier = "_Test Supplier" - po.company = "_Test Procurement Company" - po.get("items")[0].cost_center = "_Test Cost Center - _TPC" + po.get("items")[0].cost_center = "_Test Cost Center - _TC" po.submit() pr = make_purchase_receipt(po.name) - pr.company = "_Test Procurement Company" pr.submit() frappe.db.commit() date_obj = datetime.date(datetime.now()) expected_data = { "material_request_date": date_obj, - "cost_center": "_Test Cost Center - _TPC", + "cost_center": "_Test Cost Center - _TC", "project": None, "requesting_site": "_Test Procurement Warehouse - _TPC", "requestor": "Administrator", diff --git a/erpnext/controllers/tests/test_mapper.py b/erpnext/controllers/tests/test_mapper.py index 08248be0e9..8839e002a4 100644 --- a/erpnext/controllers/tests/test_mapper.py +++ b/erpnext/controllers/tests/test_mapper.py @@ -43,7 +43,6 @@ class TestMapper(unittest.TestCase): qtn = frappe.get_doc({ "doctype": "Quotation", "quotation_to": "Customer", - "company": "_Test Company", "party_name": customer, "order_type": "Sales", "transaction_date" : nowdate(), @@ -60,7 +59,6 @@ class TestMapper(unittest.TestCase): "base_amount": 1000.0, "base_rate": 100.0, "description": "CPU", - "company": "_Test Company", "doctype": "Sales Order Item", "item_code": "_Test Item Home Desktop 100", "item_name": "CPU", diff --git a/erpnext/crm/doctype/opportunity/test_opportunity.py b/erpnext/crm/doctype/opportunity/test_opportunity.py index fc852b19a1..33d90076c4 100644 --- a/erpnext/crm/doctype/opportunity/test_opportunity.py +++ b/erpnext/crm/doctype/opportunity/test_opportunity.py @@ -30,7 +30,6 @@ class TestOpportunity(unittest.TestCase): new_lead_email_id = "new{}@example.com".format(random_string(5)) args = { "doctype": "Opportunity", - "company": "_Test Company", "contact_email": new_lead_email_id, "opportunity_type": "Sales", "with_items": 0, diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py index 8be2510b11..1a063d6b6f 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py @@ -108,7 +108,7 @@ class TestPlaidSettings(unittest.TestCase): } bank = json.dumps(frappe.get_doc("Bank", "Citi").as_dict(), default=json_handler) - company = frappe.db.get_single_value('Global Defaults', 'default_company') or '_Test Company' + company = frappe.db.get_single_value('Global Defaults', 'default_company') if frappe.db.get_value("Company", company, "default_bank_account") is None: frappe.db.set_value("Company", company, "default_bank_account", get_default_bank_cash_account(company, "Cash").get("account")) diff --git a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py index c4826c94c3..4c2d3f692a 100644 --- a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py @@ -83,8 +83,7 @@ def get_healthcare_service_unit(): service_unit.service_unit_type = get_service_unit_type() service_unit.inpatient_occupancy = 1 service_unit.occupancy_status = "Vacant" - service_unit.is_group = 0, - service_unit.company = "_Test Company" + service_unit.is_group = 0 service_unit_parent_name = frappe.db.exists({ "doctype": "Healthcare Service Unit", "healthcare_service_unit_name": "All Healthcare Service Units", diff --git a/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py b/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py index 1181192cbe..1615ab30f1 100644 --- a/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py +++ b/erpnext/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py @@ -104,8 +104,7 @@ def mark_attendance(employee, date=today(), status='Present'): "doctype": "Attendance", "employee": employee.name, "attendance_date": date, - "status": status, - "company": "_Test Company" + "status": status }) attendance.save() attendance.submit() diff --git a/erpnext/hr/doctype/department/test_department.py b/erpnext/hr/doctype/department/test_department.py index a6e8aae625..2eeca26e30 100644 --- a/erpnext/hr/doctype/department/test_department.py +++ b/erpnext/hr/doctype/department/test_department.py @@ -16,7 +16,7 @@ def create_department(department_name, parent_department=None): 'is_group': 0, 'parent_department': parent_department, 'department_name': department_name, - 'company': frappe.defaults.get_defaults().company or 'Wind Power LLC' + 'company': frappe.defaults.get_defaults().company }).insert() return doc diff --git a/erpnext/hr/doctype/employee/test_employee.py b/erpnext/hr/doctype/employee/test_employee.py index b92b8e7e4e..f4b214adc3 100644 --- a/erpnext/hr/doctype/employee/test_employee.py +++ b/erpnext/hr/doctype/employee/test_employee.py @@ -60,7 +60,7 @@ def make_employee(user, company=None, **kwargs): "doctype": "Employee", "naming_series": "EMP-", "first_name": user, - "company": company or erpnext.get_default_company() or 'Wind Power LLC', + "company": company or erpnext.get_default_company(), "user_id": user, "date_of_birth": "1990-05-08", "date_of_joining": "2013-01-01", diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py index e22948c655..867c35b1b8 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py @@ -88,7 +88,7 @@ def create_payroll_period(): payroll_period = frappe.get_doc(dict( doctype = 'Payroll Period', name = "_Test Payroll Period", - company = erpnext.get_default_company() or 'Wind Power LLC', + company = erpnext.get_default_company(), start_date = date(date.today().year, 1, 1), end_date = date(date.today().year, 12, 31) )).insert() diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py index e7ee108142..6e97f0513d 100644 --- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py @@ -94,7 +94,6 @@ class TestExpenseClaim(unittest.TestCase): payable_account = get_payable_account(company_name) expense_claim = frappe.get_doc({ "doctype": "Expense Claim", - "company": "_Test Company", "employee": "_T-Employee-00001", "payable_account": payable_account, "approval_status": "Rejected", diff --git a/erpnext/hr/doctype/job_offer/test_job_offer.py b/erpnext/hr/doctype/job_offer/test_job_offer.py index 1da107bfe7..8886596450 100644 --- a/erpnext/hr/doctype/job_offer/test_job_offer.py +++ b/erpnext/hr/doctype/job_offer/test_job_offer.py @@ -55,8 +55,7 @@ def create_job_offer(**args): "job_applicant": args.job_applicant or job_applicant.name, "offer_date": args.offer_date or nowdate(), "designation": args.designation or "Researcher", - "status": args.status or "Accepted", - "company": "_Test Company" + "status": args.status or "Accepted" }) return job_offer @@ -69,7 +68,6 @@ def create_staffing_plan(**args): staffing_plan = frappe.get_doc({ "doctype": "Staffing Plan", "name": args.name or "Test", - "company": "_Test Company", "from_date": args.from_date or nowdate(), "to_date": args.to_date or add_days(nowdate(), 10), "staffing_details": args.staffing_details or [{ diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index d002e5408a..a61ce79d0f 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -414,7 +414,7 @@ def make_salary_component(salary_components, test_tax, company_list=None): get_salary_component_account(salary_component["salary_component"], company_list) def get_salary_component_account(sal_comp, company_list=None): - company = erpnext.get_default_company() or 'Wind Power LLC' + company = erpnext.get_default_company() if company_list and company not in company_list: company_list.append(company) diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.py b/erpnext/hr/doctype/salary_structure/test_salary_structure.py index ba3a968af0..d350031df7 100644 --- a/erpnext/hr/doctype/salary_structure/test_salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.py @@ -116,7 +116,7 @@ def make_salary_structure(salary_structure, payroll_frequency, employee=None, do details = { "doctype": "Salary Structure", "name": salary_structure, - "company": company or erpnext.get_default_company() or "_Test Company", + "company": company or erpnext.get_default_company(), "earnings": make_earning_salary_component(test_tax=test_tax, company_list=["_Test Company"]), "deductions": make_deduction_salary_component(test_tax=test_tax, company_list=["_Test Company"]), "payroll_frequency": payroll_frequency, diff --git a/erpnext/hr/doctype/training_event/test_training_event.py b/erpnext/hr/doctype/training_event/test_training_event.py index 5ddb99b8ea..57123e304f 100644 --- a/erpnext/hr/doctype/training_event/test_training_event.py +++ b/erpnext/hr/doctype/training_event/test_training_event.py @@ -32,8 +32,7 @@ def create_training_program(training_program): frappe.get_doc({ "doctype": "Training Program", "training_program": training_program, - "description": training_program, - "company": "Wind Power LLC" + "description": training_program }).insert() def get_attendees(employee, employee2): diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py index 13bd02f416..2e38e8ff9e 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -192,7 +192,6 @@ class TestDeliveryNote(unittest.TestCase): serial_no = frappe.get_doc({ "doctype": "Serial No", "item_code": "_Test Serialized Item With Series", - "company": "Wind Power LLC", "serial_no": make_autoname("SR", "Serial No") }) serial_no.save() @@ -566,6 +565,32 @@ class TestDeliveryNote(unittest.TestCase): for i, gle in enumerate(gl_entries): self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) + def test_delivery_note_without_cost_center(self): + cost_center = "Main - TCP1" + + company = frappe.db.get_value('Warehouse', 'Stores - TCP1', 'company') + + set_valuation_method("_Test Item", "FIFO") + + make_stock_entry(target="Stores - TCP1", qty=5, basic_rate=100) + + stock_in_hand_account = get_inventory_account('_Test Company with perpetual inventory') + dn = create_delivery_note(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', cost_center = 'Main - TCP1', expense_account = "Cost of Goods Sold - TCP1") + + gl_entries = get_gl_entries("Delivery Note", dn.name) + + self.assertTrue(gl_entries) + expected_values = { + "Cost of Goods Sold - TCP1": { + "cost_center": cost_center + }, + stock_in_hand_account: { + "cost_center": None + } + } + for i, gle in enumerate(gl_entries): + self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) + def test_make_sales_invoice_from_dn_for_returned_qty(self): from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice diff --git a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py index da2c97cb8c..eeea6da7a4 100644 --- a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py +++ b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py @@ -172,7 +172,7 @@ def create_delivery_trip(driver, address, contact=None): delivery_trip = frappe.get_doc({ "doctype": "Delivery Trip", - "company": erpnext.get_default_company() or 'Wind Power LLC', + "company": erpnext.get_default_company(), "departure_time": add_days(now_datetime(), 5), "driver": driver.name, "driver_address": address.name, diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index af25ba68ea..53f8b47f68 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -432,6 +432,30 @@ class TestPurchaseReceipt(unittest.TestCase): for i, gle in enumerate(gl_entries): self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) + def test_purchase_receipt_without_cost_center(self): + if not frappe.db.exists('Location', 'Test Location'): + frappe.get_doc({ + 'doctype': 'Location', + 'location_name': 'Test Location' + }).insert() + pr = make_purchase_receipt(company="_Test Company with perpetual inventory", warehouse = "Stores - TCP1", supplier_warehouse = "Work in Progress - TCP1") + + stock_in_hand_account = get_inventory_account(pr.company, pr.get("items")[0].warehouse) + gl_entries = get_gl_entries("Purchase Receipt", pr.name) + + self.assertTrue(gl_entries) + + expected_values = { + "Stock Received But Not Billed - TCP1": { + "cost_center": None + }, + stock_in_hand_account: { + "cost_center": None + } + } + for i, gle in enumerate(gl_entries): + self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) + def test_make_purchase_invoice_from_pr_for_returned_qty(self): from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order, create_pr_against_po diff --git a/erpnext/stock/doctype/serial_no/test_serial_no.py b/erpnext/stock/doctype/serial_no/test_serial_no.py index 7b06ef96ce..ab061076e5 100644 --- a/erpnext/stock/doctype/serial_no/test_serial_no.py +++ b/erpnext/stock/doctype/serial_no/test_serial_no.py @@ -24,7 +24,6 @@ class TestSerialNo(unittest.TestCase): frappe.delete_doc_if_exists("Serial No", "_TCSER0001") sr = frappe.new_doc("Serial No") - sr.company = '_Test Company' sr.item_code = "_Test Serialized Item" sr.warehouse = "_Test Warehouse - _TC" sr.serial_no = "_TCSER0001" From 8a4dc521cdc721d75bb0078787c332d3599b3af4 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 30 May 2020 11:40:16 +0530 Subject: [PATCH 13/54] Revert 'fix: tests depending on global default company' --- erpnext/accounts/doctype/subscription/subscription.py | 4 ---- .../doctype/clinical_procedure/test_clinical_procedure.py | 2 -- erpnext/healthcare/doctype/patient/test_patient.py | 2 -- .../patient_medical_record/test_patient_medical_record.py | 2 -- .../test_employee_tax_exemption_declaration.py | 8 ++++---- erpnext/hr/doctype/leave_period/test_leave_period.py | 4 ++-- erpnext/hr/doctype/payroll_entry/test_payroll_entry.py | 6 +++--- erpnext/hr/doctype/salary_slip/test_salary_slip.py | 6 +++--- .../hr/doctype/salary_structure/test_salary_structure.py | 4 ++-- 9 files changed, 14 insertions(+), 24 deletions(-) diff --git a/erpnext/accounts/doctype/subscription/subscription.py b/erpnext/accounts/doctype/subscription/subscription.py index fbdaf1bc95..0933c7e8b8 100644 --- a/erpnext/accounts/doctype/subscription/subscription.py +++ b/erpnext/accounts/doctype/subscription/subscription.py @@ -238,10 +238,6 @@ class Subscription(Document): Creates a `Sales Invoice`, submits it and returns it """ invoice = frappe.new_doc('Sales Invoice') - - if not invoice.company: - invoice.company = frappe.db.get_value('Global Defaults', None, 'default_company') - invoice.set_posting_time = 1 invoice.posting_date = self.current_invoice_start invoice.customer = self.customer diff --git a/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py b/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py index 100addc9ba..207351ff20 100644 --- a/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py +++ b/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py @@ -18,7 +18,6 @@ class TestClinicalProcedure(unittest.TestCase): self.assertEquals(frappe.db.get_value('Item', procedure_template.item, 'disabled'), 1) def test_consumables(self): - frappe.db.set_value('Global Defaults', None, 'default_company', '_Test Company') patient, medical_department, practitioner = create_healthcare_docs() procedure_template = create_clinical_procedure_template() procedure_template.allow_stock_consumption = 1 @@ -39,7 +38,6 @@ class TestClinicalProcedure(unittest.TestCase): result = procedure.complete_procedure() # check consumption self.assertTrue(frappe.db.exists('Stock Entry', result)) - frappe.db.set_value('Global Defaults', None, 'default_company', None) def create_consumable(): diff --git a/erpnext/healthcare/doctype/patient/test_patient.py b/erpnext/healthcare/doctype/patient/test_patient.py index dfe61bd6c1..9274b6f5e8 100644 --- a/erpnext/healthcare/doctype/patient/test_patient.py +++ b/erpnext/healthcare/doctype/patient/test_patient.py @@ -15,7 +15,6 @@ class TestPatient(unittest.TestCase): self.assertTrue(frappe.db.get_value('Patient', patient, 'customer')) def test_patient_registration(self): - frappe.db.set_value('Global Defaults', None, 'default_company', '_Test Company') frappe.db.sql("""delete from `tabPatient`""") settings = frappe.get_single('Healthcare Settings') settings.collect_registration_fee = 1 @@ -33,4 +32,3 @@ class TestPatient(unittest.TestCase): settings.collect_registration_fee = 0 settings.save() - frappe.db.set_value('Global Defaults', None, 'default_company', None) diff --git a/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py b/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py index 4de90bc09f..e5a5e4c010 100644 --- a/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py +++ b/erpnext/healthcare/doctype/patient_medical_record/test_patient_medical_record.py @@ -13,7 +13,6 @@ class TestPatientMedicalRecord(unittest.TestCase): frappe.db.set_value('Healthcare Settings', None, 'automate_appointment_invoicing', 1) def test_medical_record(self): - frappe.db.set_value('Global Defaults', None, 'default_company', '_Test Company') patient, medical_department, practitioner = create_healthcare_docs() appointment = create_appointment(patient, practitioner, nowdate(), invoice=1) encounter = create_encounter(appointment) @@ -39,7 +38,6 @@ class TestPatientMedicalRecord(unittest.TestCase): # check for lab test medical_rec = frappe.db.exists('Patient Medical Record', {'status': 'Open', 'reference_name': lab_test.name}) self.assertTrue(medical_rec) - frappe.db.set_value('Global Defaults', None, 'default_company', None) def create_procedure(appointment): diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py index 867c35b1b8..9549fd1b75 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py @@ -20,7 +20,7 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "company": erpnext.get_default_company() or 'Wind Power LLC', + "company": erpnext.get_default_company(), "payroll_period": "_Test Payroll Period", "declarations": [ dict(exemption_sub_category = "_Test Sub Category", @@ -37,7 +37,7 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "company": erpnext.get_default_company() or 'Wind Power LLC', + "company": erpnext.get_default_company(), "payroll_period": "_Test Payroll Period", "declarations": [ dict(exemption_sub_category = "_Test Sub Category", @@ -52,7 +52,7 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): duplicate_declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "company": erpnext.get_default_company() or 'Wind Power LLC', + "company": erpnext.get_default_company(), "payroll_period": "_Test Payroll Period", "declarations": [ dict(exemption_sub_category = "_Test Sub Category", @@ -68,7 +68,7 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "company": erpnext.get_default_company() or 'Wind Power LLC', + "company": erpnext.get_default_company(), "payroll_period": "_Test Payroll Period", "declarations": [ dict(exemption_sub_category = "_Test Sub Category", diff --git a/erpnext/hr/doctype/leave_period/test_leave_period.py b/erpnext/hr/doctype/leave_period/test_leave_period.py index 06e5836738..1762cf917a 100644 --- a/erpnext/hr/doctype/leave_period/test_leave_period.py +++ b/erpnext/hr/doctype/leave_period/test_leave_period.py @@ -45,7 +45,7 @@ class TestLeavePeriod(unittest.TestCase): def create_leave_period(from_date, to_date, company=None): leave_period = frappe.db.get_value('Leave Period', - dict(company=company or erpnext.get_default_company() or 'Wind Power LLC', + dict(company=company or erpnext.get_default_company(), from_date=from_date, to_date=to_date, is_active=1), 'name') @@ -54,7 +54,7 @@ def create_leave_period(from_date, to_date, company=None): leave_period = frappe.get_doc({ "doctype": "Leave Period", - "company": company or erpnext.get_default_company() or 'Wind Power LLC', + "company": company or erpnext.get_default_company(), "from_date": from_date, "to_date": to_date, "is_active": 1 diff --git a/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py b/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py index f1393b168d..3c318e78a2 100644 --- a/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py +++ b/erpnext/hr/doctype/payroll_entry/test_payroll_entry.py @@ -27,7 +27,7 @@ class TestPayrollEntry(unittest.TestCase): frappe.db.set_value("HR Settings", None, "email_salary_slip_to_employee", 0) def test_payroll_entry(self): # pylint: disable=no-self-use - company = erpnext.get_default_company() or 'Wind Power LLC' + company = erpnext.get_default_company() for data in frappe.get_all('Salary Component', fields = ["name"]): if not frappe.db.get_value('Salary Component Account', {'parent': data.name, 'company': company}, 'name'): @@ -157,7 +157,7 @@ def make_payroll_entry(**args): args = frappe._dict(args) payroll_entry = frappe.new_doc("Payroll Entry") - payroll_entry.company = args.company or erpnext.get_default_company() or 'Wind Power LLC' + payroll_entry.company = args.company or erpnext.get_default_company() payroll_entry.start_date = args.start_date or "2016-11-01" payroll_entry.end_date = args.end_date or "2016-11-30" payroll_entry.payment_account = get_payment_account() @@ -183,7 +183,7 @@ def make_payroll_entry(**args): def get_payment_account(): return frappe.get_value('Account', - {'account_type': 'Cash', 'company': erpnext.get_default_company() or 'Wind Power LLC', 'is_group':0}, "name") + {'account_type': 'Cash', 'company': erpnext.get_default_company(),'is_group':0}, "name") def make_holiday(holiday_list_name): if not frappe.db.exists('Holiday List', holiday_list_name): diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index a61ce79d0f..9584866f67 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -242,7 +242,7 @@ class TestSalarySlip(unittest.TestCase): self.assertEqual(ss.net_pay, (flt(ss.gross_pay) - (flt(ss.total_deduction) + flt(ss.total_loan_repayment)))) def test_payroll_frequency(self): - fiscal_year = get_fiscal_year(nowdate(), company=erpnext.get_default_company() or 'Wind Power LLC')[0] + fiscal_year = get_fiscal_year(nowdate(), company=erpnext.get_default_company())[0] month = "%02d" % getdate(nowdate()).month m = get_month_details(fiscal_year, month) @@ -560,7 +560,7 @@ def create_exemption_declaration(employee, payroll_period): "doctype": "Employee Tax Exemption Declaration", "employee": employee, "payroll_period": payroll_period, - "company": erpnext.get_default_company() or 'Wind Power LLC' + "company": erpnext.get_default_company() }) declaration.append("declarations", { "exemption_sub_category": "_Test Sub Category", @@ -667,7 +667,7 @@ def create_additional_salary(employee, payroll_period, amount): frappe.get_doc({ "doctype": "Additional Salary", "employee": employee, - "company": erpnext.get_default_company() or 'Wind Power LLC', + "company": erpnext.get_default_company(), "salary_component": "Performance Bonus", "payroll_date": salary_date, "amount": amount, diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.py b/erpnext/hr/doctype/salary_structure/test_salary_structure.py index d350031df7..eb5311e3b8 100644 --- a/erpnext/hr/doctype/salary_structure/test_salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.py @@ -22,7 +22,7 @@ class TestSalaryStructure(unittest.TestCase): frappe.db.sql("delete from `tab%s`" % dt) self.make_holiday_list() - frappe.db.set_value("Company", erpnext.get_default_company() or 'Wind Power LLC', "default_holiday_list", "Salary Structure Test Holiday List") + frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Structure Test Holiday List") make_employee("test_employee@salary.com") make_employee("test_employee_2@salary.com") @@ -151,7 +151,7 @@ def create_salary_structure_assignment(employee, salary_structure, from_date=Non salary_structure_assignment.variable = 5000 salary_structure_assignment.from_date = from_date or add_days(nowdate(), -1) salary_structure_assignment.salary_structure = salary_structure - salary_structure_assignment.company = company or erpnext.get_default_company() or 'Wind Power LLC' + salary_structure_assignment.company = company or erpnext.get_default_company() salary_structure_assignment.save(ignore_permissions=True) salary_structure_assignment.income_tax_slab = "Tax Slab: _Test Payroll Period" salary_structure_assignment.submit() From c96bf870e4c3f08f258098639a71008d5b68078c Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 29 May 2020 23:50:04 +0530 Subject: [PATCH 14/54] fix: Test Cases --- .../invoice_discounting/invoice_discounting.py | 15 ++++++++++++--- .../purchase_invoice/test_purchase_invoice.py | 2 +- erpnext/assets/doctype/asset/depreciation.py | 8 +++++--- .../test_procurement_tracker.py | 1 + .../doctype/employee_advance/employee_advance.py | 2 ++ erpnext/hr/doctype/expense_claim/expense_claim.py | 4 +++- .../doctype/delivery_note/test_delivery_note.py | 10 +++++++--- .../purchase_receipt/test_purchase_receipt.py | 7 ++++--- 8 files changed, 35 insertions(+), 14 deletions(-) diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py index 594b4d4a22..8083b21f75 100644 --- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py +++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py @@ -3,7 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, json +import frappe, json, erpnext from frappe import _ from frappe.utils import flt, getdate, nowdate, add_days from erpnext.controllers.accounts_controller import AccountsController @@ -134,16 +134,19 @@ class InvoiceDiscounting(AccountsController): je.append("accounts", { "account": self.bank_account, "debit_in_account_currency": flt(self.total_amount) - flt(self.bank_charges), + "cost_center": erpnext.get_default_cost_center(self.company) }) je.append("accounts", { "account": self.bank_charges_account, - "debit_in_account_currency": flt(self.bank_charges) + "debit_in_account_currency": flt(self.bank_charges), + "cost_center": erpnext.get_default_cost_center(self.company) }) je.append("accounts", { "account": self.short_term_loan, "credit_in_account_currency": flt(self.total_amount), + "cost_center": erpnext.get_default_cost_center(self.company), "reference_type": "Invoice Discounting", "reference_name": self.name }) @@ -151,6 +154,7 @@ class InvoiceDiscounting(AccountsController): je.append("accounts", { "account": self.accounts_receivable_discounted, "debit_in_account_currency": flt(d.outstanding_amount), + "cost_center": erpnext.get_default_cost_center(self.company), "reference_type": "Invoice Discounting", "reference_name": self.name, "party_type": "Customer", @@ -160,6 +164,7 @@ class InvoiceDiscounting(AccountsController): je.append("accounts", { "account": self.accounts_receivable_credit, "credit_in_account_currency": flt(d.outstanding_amount), + "cost_center": erpnext.get_default_cost_center(self.company), "reference_type": "Invoice Discounting", "reference_name": self.name, "party_type": "Customer", @@ -177,13 +182,15 @@ class InvoiceDiscounting(AccountsController): je.append("accounts", { "account": self.short_term_loan, "debit_in_account_currency": flt(self.total_amount), + "cost_center": erpnext.get_default_cost_center(self.company), "reference_type": "Invoice Discounting", "reference_name": self.name, }) je.append("accounts", { "account": self.bank_account, - "credit_in_account_currency": flt(self.total_amount) + "credit_in_account_currency": flt(self.total_amount), + "cost_center": erpnext.get_default_cost_center(self.company) }) if getdate(self.loan_end_date) > getdate(nowdate()): @@ -193,6 +200,7 @@ class InvoiceDiscounting(AccountsController): je.append("accounts", { "account": self.accounts_receivable_discounted, "credit_in_account_currency": flt(outstanding_amount), + "cost_center": erpnext.get_default_cost_center(self.company), "reference_type": "Invoice Discounting", "reference_name": self.name, "party_type": "Customer", @@ -202,6 +210,7 @@ class InvoiceDiscounting(AccountsController): je.append("accounts", { "account": self.accounts_receivable_unpaid, "debit_in_account_currency": flt(outstanding_amount), + "cost_center": erpnext.get_default_cost_center(self.company), "reference_type": "Invoice Discounting", "reference_name": self.name, "party_type": "Customer", diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index f61d27aee3..4019815e19 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -822,7 +822,7 @@ class TestPurchaseInvoice(unittest.TestCase): "Creditors - _TC": { "cost_center": cost_center }, - "Cost of Goods Sold - _TC": { + "_Test Account Cost for Goods Sold - _TC": { "cost_center": cost_center } } diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py index c50211e6ab..b7ebb4767e 100644 --- a/erpnext/assets/doctype/asset/depreciation.py +++ b/erpnext/assets/doctype/asset/depreciation.py @@ -3,7 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe +import frappe, erpnext from frappe import _ from frappe.utils import flt, today, getdate, cint from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_checks_for_pl_and_bs_accounts @@ -197,12 +197,14 @@ def get_gl_entries_on_asset_disposal(asset, selling_amount=0, finance_book=None) { "account": fixed_asset_account, "credit_in_account_currency": asset.gross_purchase_amount, - "credit": asset.gross_purchase_amount + "credit": asset.gross_purchase_amount, + "cost_center": depreciation_cost_center }, { "account": accumulated_depr_account, "debit_in_account_currency": accumulated_depr_amount, - "debit": accumulated_depr_amount + "debit": accumulated_depr_amount, + "cost_center": depreciation_cost_center } ] diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py index bebf0ccec5..acec4c8502 100644 --- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py @@ -39,6 +39,7 @@ class TestProcurementTracker(unittest.TestCase): po.get("items")[0].cost_center = "_Test Cost Center - _TC" po.submit() pr = make_purchase_receipt(po.name) + pr.get("items")[0].cost_center = "_Test Cost Center - _TC" pr.submit() frappe.db.commit() date_obj = datetime.date(datetime.now()) diff --git a/erpnext/hr/doctype/employee_advance/employee_advance.py b/erpnext/hr/doctype/employee_advance/employee_advance.py index db39eff0e4..c5a9fcec1d 100644 --- a/erpnext/hr/doctype/employee_advance/employee_advance.py +++ b/erpnext/hr/doctype/employee_advance/employee_advance.py @@ -119,12 +119,14 @@ def make_bank_entry(dt, dn): "reference_type": "Employee Advance", "reference_name": doc.name, "party_type": "Employee", + "cost_center": erpnext.get_default_cost_center(doc.company), "party": doc.employee, "is_advance": "Yes" }) je.append("accounts", { "account": payment_account.account, + "cost_center": erpnext.get_default_cost_center(doc.company), "credit_in_account_currency": flt(doc.advance_amount), "account_currency": payment_account.account_currency, "account_type": payment_account.account_type diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py index ea469b82c9..87bfbd18f4 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/expense_claim.py @@ -295,7 +295,7 @@ def make_bank_entry(dt, dn): je = frappe.new_doc("Journal Entry") je.voucher_type = 'Bank Entry' je.company = expense_claim.company - je.remark = 'Payment against Expense Claim: ' + dn; + je.remark = 'Payment against Expense Claim: ' + dn je.append("accounts", { "account": expense_claim.payable_account, @@ -303,6 +303,7 @@ def make_bank_entry(dt, dn): "reference_type": "Expense Claim", "party_type": "Employee", "party": expense_claim.employee, + "cost_center": erpnext.get_default_cost_center(expense_claim.company), "reference_name": expense_claim.name }) @@ -313,6 +314,7 @@ def make_bank_entry(dt, dn): "reference_name": expense_claim.name, "balance": default_bank_cash_account.balance, "account_currency": default_bank_cash_account.account_currency, + "cost_center": erpnext.get_default_cost_center(expense_claim.company), "account_type": default_bank_cash_account.account_type }) diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py index 2e38e8ff9e..4b04a0a8c3 100644 --- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py @@ -565,7 +565,7 @@ class TestDeliveryNote(unittest.TestCase): for i, gle in enumerate(gl_entries): self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - def test_delivery_note_without_cost_center(self): + def test_delivery_note_cost_center_with_balance_sheet_account(self): cost_center = "Main - TCP1" company = frappe.db.get_value('Warehouse', 'Stores - TCP1', 'company') @@ -575,7 +575,11 @@ class TestDeliveryNote(unittest.TestCase): make_stock_entry(target="Stores - TCP1", qty=5, basic_rate=100) stock_in_hand_account = get_inventory_account('_Test Company with perpetual inventory') - dn = create_delivery_note(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', cost_center = 'Main - TCP1', expense_account = "Cost of Goods Sold - TCP1") + dn = create_delivery_note(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', cost_center = 'Main - TCP1', expense_account = "Cost of Goods Sold - TCP1", + do_not_submit=1) + + dn.get('items')[0].cost_center = None + dn.submit() gl_entries = get_gl_entries("Delivery Note", dn.name) @@ -585,7 +589,7 @@ class TestDeliveryNote(unittest.TestCase): "cost_center": cost_center }, stock_in_hand_account: { - "cost_center": None + "cost_center": cost_center } } for i, gle in enumerate(gl_entries): diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 53f8b47f68..d97b9e82c3 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -432,7 +432,7 @@ class TestPurchaseReceipt(unittest.TestCase): for i, gle in enumerate(gl_entries): self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center) - def test_purchase_receipt_without_cost_center(self): + def test_purchase_receipt_cost_center_with_balance_sheet_account(self): if not frappe.db.exists('Location', 'Test Location'): frappe.get_doc({ 'doctype': 'Location', @@ -444,13 +444,14 @@ class TestPurchaseReceipt(unittest.TestCase): gl_entries = get_gl_entries("Purchase Receipt", pr.name) self.assertTrue(gl_entries) + cost_center = pr.get('items')[0].cost_center expected_values = { "Stock Received But Not Billed - TCP1": { - "cost_center": None + "cost_center": cost_center }, stock_in_hand_account: { - "cost_center": None + "cost_center": cost_center } } for i, gle in enumerate(gl_entries): From 1aec30d849fd302726a694070c684d878830d152 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 30 May 2020 00:51:19 +0530 Subject: [PATCH 15/54] fix: Procurement Tracker test case --- .../report/procurement_tracker/test_procurement_tracker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py index acec4c8502..ad355598a0 100644 --- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py @@ -36,10 +36,10 @@ class TestProcurementTracker(unittest.TestCase): mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse) po = make_purchase_order(mr.name) po.supplier = "_Test Supplier" - po.get("items")[0].cost_center = "_Test Cost Center - _TC" + po.get("items")[0].cost_center = "Main - _TPC" po.submit() pr = make_purchase_receipt(po.name) - pr.get("items")[0].cost_center = "_Test Cost Center - _TC" + pr.get("items")[0].cost_center = "Main - _TPC" pr.submit() frappe.db.commit() date_obj = datetime.date(datetime.now()) From 159d0734ef836c627b6acc142de750d05a732b4b Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 30 May 2020 10:08:32 +0530 Subject: [PATCH 16/54] fix: Proccurement tracker report test --- .../test_procurement_tracker.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py index ad355598a0..06da336892 100644 --- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py @@ -15,7 +15,7 @@ class TestProcurementTracker(unittest.TestCase): def test_result_for_procurement_tracker(self): filters = { 'company': '_Test Procurement Company', - 'cost_center': '_Test Cost Center - _TC' + 'cost_center': 'Main - _TPC' } expected_data = self.generate_expected_data() report = execute(filters) @@ -33,10 +33,12 @@ class TestProcurementTracker(unittest.TestCase): country="Pakistan" )).insert() warehouse = create_warehouse("_Test Procurement Warehouse", company="_Test Procurement Company") - mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse) + mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse, cost_center="Main - _TPC") po = make_purchase_order(mr.name) po.supplier = "_Test Supplier" po.get("items")[0].cost_center = "Main - _TPC" + po.items[0].rate = 500.0 + po.save() po.submit() pr = make_purchase_receipt(po.name) pr.get("items")[0].cost_center = "Main - _TPC" @@ -44,9 +46,11 @@ class TestProcurementTracker(unittest.TestCase): frappe.db.commit() date_obj = datetime.date(datetime.now()) + po.load_from_db() + expected_data = { "material_request_date": date_obj, - "cost_center": "_Test Cost Center - _TC", + "cost_center": "Main - _TPC", "project": None, "requesting_site": "_Test Procurement Warehouse - _TPC", "requestor": "Administrator", @@ -60,9 +64,10 @@ class TestProcurementTracker(unittest.TestCase): "supplier": "_Test Supplier", "estimated_cost": 0.0, "actual_cost": None, - "purchase_order_amt": 5000.0, - "purchase_order_amt_in_company_currency": 300000.0, + "purchase_order_amt": po.net_total, + "purchase_order_amt_in_company_currency": po.base_net_total, "expected_delivery_date": date_obj, "actual_delivery_date": date_obj } + return expected_data \ No newline at end of file From 3609ddedbb49e15700c83064edc8be2ff8a71eb5 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 30 May 2020 12:03:37 +0530 Subject: [PATCH 17/54] fix: Purchase receipt item json --- .../doctype/purchase_invoice_item/purchase_invoice_item.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index cfbe06ad02..52a5be0984 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -753,7 +753,7 @@ "depends_on": "is_fixed_asset", "fetch_from": "item_code.asset_category", "fieldname": "asset_category", - "fieldtype": "Data", + "fieldtype": "Link", "label": "Asset Category", "options": "Asset Category", "read_only": 1 From 1b30ca6a36e2f088439641ba5bbd370475defa85 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 19 Jun 2020 12:12:08 +0530 Subject: [PATCH 18/54] fix: Codacy --- erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py | 4 ++-- erpnext/assets/doctype/asset/depreciation.py | 2 +- erpnext/controllers/stock_controller.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index c77e5002dd..f0585ad4d8 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -500,7 +500,7 @@ class PurchaseInvoice(BuyingController): "account": warehouse_account[item.warehouse]['account'], "against": warehouse_account[item.from_warehouse]["account"], "cost_center": item.cost_center, - "project": item_row.project or self.project, + "project": item.project or self.project, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "debit": warehouse_debit_amount, }, warehouse_account[item.warehouse]["account_currency"], item=item)) @@ -510,7 +510,7 @@ class PurchaseInvoice(BuyingController): "account": warehouse_account[item.from_warehouse]['account'], "against": warehouse_account[item.warehouse]["account"], "cost_center": item.cost_center, - "project": item_row.project or self.project, + "project": item.project or self.project, "remarks": self.get("remarks") or _("Accounting Entry for Stock"), "debit": -1 * flt(item.base_net_amount, item.precision("base_net_amount")), }, warehouse_account[item.from_warehouse]["account_currency"], item=item)) diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py index b7ebb4767e..8f0afb42b2 100644 --- a/erpnext/assets/doctype/asset/depreciation.py +++ b/erpnext/assets/doctype/asset/depreciation.py @@ -3,7 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe, erpnext +import frappe from frappe import _ from frappe.utils import flt, today, getdate, cint from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_checks_for_pl_and_bs_accounts diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index d098c1cfd5..e8483da544 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -96,7 +96,7 @@ class StockController(AccountsController): "account": warehouse_account[sle.warehouse]["account"], "against": item_row.expense_account, "cost_center": item_row.cost_center, - "project": item_row.project or self.project if hasattr(self, 'project') else None, + "project": item_row.project or self.get('project'), "remarks": self.get("remarks") or "Accounting Entry for Stock", "debit": flt(sle.stock_value_difference, precision), "is_opening": item_row.get("is_opening") or self.get("is_opening") or "No", @@ -107,7 +107,7 @@ class StockController(AccountsController): "account": item_row.expense_account, "against": warehouse_account[sle.warehouse]["account"], "cost_center": item_row.cost_center, - "project": item_row.project or self.project if hasattr(self, 'project') else None, + "project": item_row.project or self.get('project'), "remarks": self.get("remarks") or "Accounting Entry for Stock", "credit": flt(sle.stock_value_difference, precision), "project": item_row.get("project") or self.get("project"), From d79e8e82cb198c3a191617c8933dbd3d9accafe5 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 22 Jun 2020 10:00:12 +0530 Subject: [PATCH 19/54] fix: Test cases --- erpnext/regional/report/datev/test_datev.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/erpnext/regional/report/datev/test_datev.py b/erpnext/regional/report/datev/test_datev.py index 3cc65fe9d3..eed62a8690 100644 --- a/erpnext/regional/report/datev/test_datev.py +++ b/erpnext/regional/report/datev/test_datev.py @@ -90,7 +90,7 @@ def make_customer_with_account(customer_name, company): if not frappe.db.exists("Customer", customer_name): customer = frappe.get_doc({ - "doctype": "Customer", + "doctype": "Customer", "customer_name": customer_name, "customer_type": "Company", "accounts": [{ @@ -155,17 +155,17 @@ class TestDatev(TestCase): setup_fiscal_year() warehouse = frappe.db.get_value("Item Default", { - "parent": item.name, + "parent": item.name, "company": self.company.name }, "default_warehouse") income_account = frappe.db.get_value("Account", { - "account_number": "4200", + "account_number": "4200", "company": self.company.name }, "name") tax_account = frappe.db.get_value("Account", { - "account_number": "3806", + "account_number": "3806", "company": self.company.name }, "name") @@ -186,9 +186,12 @@ class TestDatev(TestCase): "charge_type": "On Net Total", "account_head": tax_account, "description": "Umsatzsteuer 19 %", - "rate": 19 + "rate": 19, + "cost_center": self.company.cost_center }) + si.cost_center = self.company.cost_center + si.save() si.submit() @@ -196,7 +199,7 @@ class TestDatev(TestCase): def is_subset(get_data, allowed_keys): """ Validate that the dict contains only allowed keys. - + Params: get_data -- Function that returns a list of dicts. allowed_keys -- List of allowed keys From 3c004ad79880f023917017ec715da9b0e07b0b7b Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 2 Jul 2020 21:18:29 +0530 Subject: [PATCH 20/54] fix(GST): Do not add tax amount in grand total for reverse charge invoices --- .../purchase_invoice/purchase_invoice.py | 6 ++ .../purchase_invoice/regional/india.js | 30 ++++++++++ erpnext/accounts/general_ledger.py | 1 + erpnext/hooks.py | 5 +- erpnext/regional/india/utils.py | 59 +++++++++++++------ 5 files changed, 80 insertions(+), 21 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 3cd57d403a..c701a7c9dd 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -438,6 +438,8 @@ class PurchaseInvoice(BuyingController): self.make_tax_gl_entries(gl_entries) + gl_entries = make_regional_gl_entries(gl_entries, self) + gl_entries = merge_similar_entries(gl_entries) self.make_payment_gl_entries(gl_entries) @@ -1097,6 +1099,10 @@ def get_list_context(context=None): }) return list_context +@erpnext.allow_regional +def make_regional_gl_entries(gl_entries, doc): + return gl_entries + @frappe.whitelist() def make_debit_note(source_name, target_doc=None): from erpnext.controllers.sales_and_purchase_return import make_return_doc diff --git a/erpnext/accounts/doctype/purchase_invoice/regional/india.js b/erpnext/accounts/doctype/purchase_invoice/regional/india.js index 81488a2c52..83cb03a77c 100644 --- a/erpnext/accounts/doctype/purchase_invoice/regional/india.js +++ b/erpnext/accounts/doctype/purchase_invoice/regional/india.js @@ -1,3 +1,33 @@ {% include "erpnext/regional/india/taxes.js" %} erpnext.setup_auto_gst_taxation('Purchase Invoice'); + + +frappe.ui.form.on('Purchase Taxes and Charges', { + taxes_add: function(frm) { + if (frm.doc.reverse_charge === 'Y') { + frappe.call({ + 'method': 'erpnext.regional.india.utils.get_gst_accounts', + 'args': { + company: frm.doc.company + }, + 'callback': function(r) { + let accounts = r.message; + let account_list = accounts['cgst_account'] + accounts['sgst_account'] + + accounts['igst_account'] + + let gst_tax = 0; + + $.each(frm.doc.taxes || [], function(i, row) { + if (account_list.includes(row.account_head)) { + gst_tax += row.base_tax_amount_after_discount_amount; + } + }); + + frm.doc.taxes_and_charges_added -= flt(gst_tax); + frm.refresh_field('taxes_and_charges_added'); + } + }) + } + } +}); diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py index bfe35ab006..a1f8c037b3 100644 --- a/erpnext/accounts/general_ledger.py +++ b/erpnext/accounts/general_ledger.py @@ -20,6 +20,7 @@ def make_gl_entries(gl_map, cancel=False, adv_adj=False, merge_entries=True, upd if not cancel: validate_accounting_period(gl_map) gl_map = process_gl_map(gl_map, merge_entries) + print(gl_map, "$$$$$$$$$") if gl_map and len(gl_map) > 1: save_entries(gl_map, adv_adj, update_outstanding) else: diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 835d92ef5c..89c5b7409d 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -246,7 +246,7 @@ doc_events = { "on_trash": "erpnext.regional.check_deletion_permission" }, "Purchase Invoice": { - "on_submit": "erpnext.regional.india.utils.make_reverse_charge_entries" + "validate": "erpnext.regional.india.utils.update_grand_total_for_rcm" }, "Payment Entry": { "on_submit": ["erpnext.regional.create_transaction_log", "erpnext.accounts.doctype.payment_request.payment_request.update_payment_req_status"], @@ -374,7 +374,8 @@ regional_overrides = { 'erpnext.controllers.taxes_and_totals.get_itemised_tax_breakup_data': 'erpnext.regional.india.utils.get_itemised_tax_breakup_data', 'erpnext.accounts.party.get_regional_address_details': 'erpnext.regional.india.utils.get_regional_address_details', 'erpnext.hr.utils.calculate_annual_eligible_hra_exemption': 'erpnext.regional.india.utils.calculate_annual_eligible_hra_exemption', - 'erpnext.hr.utils.calculate_hra_exemption_for_period': 'erpnext.regional.india.utils.calculate_hra_exemption_for_period' + 'erpnext.hr.utils.calculate_hra_exemption_for_period': 'erpnext.regional.india.utils.calculate_hra_exemption_for_period', + 'erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_regional_gl_entries': 'erpnext.regional.india.utils.make_regional_gl_entries' }, 'United Arab Emirates': { 'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.united_arab_emirates.utils.update_itemised_tax_data' diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index 05ffa87f14..c6df1366d1 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals import frappe, re, json from frappe import _ -from frappe.utils import cstr, flt, date_diff, nowdate +from frappe.utils import cstr, flt, date_diff, nowdate, round_based_on_smallest_currency_fraction, money_in_words from erpnext.regional.india import states, state_numbers from erpnext.controllers.taxes_and_totals import get_itemised_tax, get_itemised_taxable_amount from erpnext.controllers.accounts_controller import get_taxes_and_charges @@ -644,6 +644,7 @@ def validate_state_code(state_code, address): else: return int(state_code) +@frappe.whitelist() def get_gst_accounts(company, account_wise=False): gst_accounts = frappe._dict() gst_settings_accounts = frappe.get_all("GST Account", @@ -662,14 +663,49 @@ def get_gst_accounts(company, account_wise=False): return gst_accounts -def make_reverse_charge_entries(doc, method): +def update_grand_total_for_rcm(doc, method): + if doc.reverse_charge == 'Y': + gst_accounts = get_gst_accounts(doc.company) + gst_account_list = gst_accounts.get('cgst_account') + gst_accounts.get('sgst_account') \ + + gst_accounts.get('igst_account') + + gst_tax = 0 + for tax in doc.get('taxes'): + if tax.category not in ("Total", "Valuation and Total"): + continue + + if flt(tax.base_tax_amount_after_discount_amount) and tax.account_head in gst_account_list: + gst_tax += tax.base_tax_amount_after_discount_amount + + doc.taxes_and_charges_added -= gst_tax + doc.total_taxes_and_charges -= gst_tax + + update_totals(gst_tax, doc) + +def update_totals(gst_tax, doc): + doc.grand_total -= gst_tax + + if doc.meta.get_field("rounded_total"): + if doc.is_rounded_total_disabled(): + doc.outstanding_amount = doc.grand_total + else: + doc.rounded_total = round_based_on_smallest_currency_fraction(doc.grand_total, + doc.currency, doc.precision("rounded_total")) + + doc.rounding_adjustment += flt(doc.rounded_total - doc.grand_total, + doc.precision("rounding_adjustment")) + + doc.outstanding_amount = doc.base_rounded_total + + doc.in_words = money_in_words(doc.grand_total, doc.currency) + +def make_regional_gl_entries(gl_entries, doc): country = frappe.get_cached_value('Company', doc.company, 'country') if country != 'India': return if doc.reverse_charge == 'Y': - gl_entries = [] gst_accounts = get_gst_accounts(doc.company) gst_account_list = gst_accounts.get('cgst_account') + gst_accounts.get('sgst_account') \ + gst_accounts.get('igst_account') @@ -694,19 +730,4 @@ def make_reverse_charge_entries(doc, method): }, account_currency, item=tax) ) - gl_entries.append(doc.get_gl_dict( - { - "account": doc.credit_to if doc.doctype == 'Purchase Invoice' else doc.debit_to, - "cost_center": doc.cost_center, - "posting_date": doc.posting_date, - "party_type": 'Supplier', - "party": doc.supplier, - "against": tax.account_head, - "debit": tax.base_tax_amount_after_discount_amount, - "debit_in_account_currency": tax.base_tax_amount_after_discount_amount \ - if account_currency==doc.company_currency \ - else tax.tax_amount_after_discount_amount - }, account_currency, item=doc) - ) - - make_gl_entries(gl_entries) \ No newline at end of file + return gl_entries \ No newline at end of file From 9ed0384bea9d34b2eded39c336965281c4d127ea Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 3 Jul 2020 14:54:41 +0530 Subject: [PATCH 21/54] fix: Code cleanup --- .../purchase_invoice/regional/india.js | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/regional/india.js b/erpnext/accounts/doctype/purchase_invoice/regional/india.js index 83cb03a77c..81488a2c52 100644 --- a/erpnext/accounts/doctype/purchase_invoice/regional/india.js +++ b/erpnext/accounts/doctype/purchase_invoice/regional/india.js @@ -1,33 +1,3 @@ {% include "erpnext/regional/india/taxes.js" %} erpnext.setup_auto_gst_taxation('Purchase Invoice'); - - -frappe.ui.form.on('Purchase Taxes and Charges', { - taxes_add: function(frm) { - if (frm.doc.reverse_charge === 'Y') { - frappe.call({ - 'method': 'erpnext.regional.india.utils.get_gst_accounts', - 'args': { - company: frm.doc.company - }, - 'callback': function(r) { - let accounts = r.message; - let account_list = accounts['cgst_account'] + accounts['sgst_account'] - + accounts['igst_account'] - - let gst_tax = 0; - - $.each(frm.doc.taxes || [], function(i, row) { - if (account_list.includes(row.account_head)) { - gst_tax += row.base_tax_amount_after_discount_amount; - } - }); - - frm.doc.taxes_and_charges_added -= flt(gst_tax); - frm.refresh_field('taxes_and_charges_added'); - } - }) - } - } -}); From 05738bd29aa7b46f86a3f3b7da5d06d3fb571bc4 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 6 Jul 2020 13:40:48 +0530 Subject: [PATCH 22/54] fix: Remove print statements --- erpnext/accounts/general_ledger.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py index a1f8c037b3..bfe35ab006 100644 --- a/erpnext/accounts/general_ledger.py +++ b/erpnext/accounts/general_ledger.py @@ -20,7 +20,6 @@ def make_gl_entries(gl_map, cancel=False, adv_adj=False, merge_entries=True, upd if not cancel: validate_accounting_period(gl_map) gl_map = process_gl_map(gl_map, merge_entries) - print(gl_map, "$$$$$$$$$") if gl_map and len(gl_map) > 1: save_entries(gl_map, adv_adj, update_outstanding) else: From 4355d3cf0fc3de447d653775f2ca79f9812b98e5 Mon Sep 17 00:00:00 2001 From: marination Date: Mon, 6 Jul 2020 23:15:08 +0530 Subject: [PATCH 23/54] fix: Exploded Item Rate --- erpnext/manufacturing/doctype/bom/bom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 7d31a1cd15..58b79d1cac 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -494,7 +494,7 @@ class BOM(WebsiteGenerator): 'image' : d.image, 'stock_uom' : d.stock_uom, 'stock_qty' : flt(d.stock_qty), - 'rate' : d.base_rate, + 'rate' : flt(d.base_rate) / flt(d.conversion_factor), 'include_item_in_manufacturing': d.include_item_in_manufacturing })) From 3d14011d23dd7285f92d4cd4e2250b735fd510aa Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 7 Jul 2020 18:30:54 +0530 Subject: [PATCH 24/54] fix: allow creating SLA documents even if SLA tracking is not enabled --- .../service_level_agreement/service_level_agreement.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py index c692315706..24ddbf8b28 100644 --- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py +++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document from frappe import _ -from frappe.utils import getdate, get_weekdays +from frappe.utils import getdate, get_weekdays, get_link_to_form class ServiceLevelAgreement(Document): @@ -73,8 +73,9 @@ class ServiceLevelAgreement(Document): frappe.throw(_("Workday {0} has been repeated.").format(repeated_days)) def validate_doc(self): - if not frappe.db.get_single_value("Support Settings", "track_service_level_agreement"): - frappe.throw(_("Service Level Agreement tracking is not enabled.")) + if not frappe.db.get_single_value("Support Settings", "track_service_level_agreement") and self.enable: + frappe.throw(_("{0} is not enabled in {1}").format(frappe.bold("Track Service Level Agreement"), + get_link_to_form("Support Settings", "Support Settings"))) if self.default_service_level_agreement: if frappe.db.exists("Service Level Agreement", {"default_service_level_agreement": "1", "name": ["!=", self.name]}): From 923ed8a7412e022c52c7d0f9215cb18bc4d75107 Mon Sep 17 00:00:00 2001 From: Kaviya Periyasamy Date: Wed, 8 Jul 2020 11:15:04 +0530 Subject: [PATCH 25/54] fix: log type mandatory error while exposing api call to employee checkin --- erpnext/hr/doctype/employee_checkin/employee_checkin.js | 4 ++++ erpnext/hr/doctype/employee_checkin/employee_checkin.json | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/hr/doctype/employee_checkin/employee_checkin.js b/erpnext/hr/doctype/employee_checkin/employee_checkin.js index c2403ca2bd..43023b6034 100644 --- a/erpnext/hr/doctype/employee_checkin/employee_checkin.js +++ b/erpnext/hr/doctype/employee_checkin/employee_checkin.js @@ -6,5 +6,9 @@ frappe.ui.form.on('Employee Checkin', { if(!frm.doc.time) { frm.set_value("time", frappe.datetime.now_datetime()); } + }, + refresh: (frm) => { + // make log type mandatory + frm.set_df_property('log_type', 'reqd', frm.doc.log_type ? 0 : 1); } }); diff --git a/erpnext/hr/doctype/employee_checkin/employee_checkin.json b/erpnext/hr/doctype/employee_checkin/employee_checkin.json index 75f699751b..d34316dc0f 100644 --- a/erpnext/hr/doctype/employee_checkin/employee_checkin.json +++ b/erpnext/hr/doctype/employee_checkin/employee_checkin.json @@ -41,8 +41,7 @@ "fieldtype": "Select", "in_list_view": 1, "label": "Log Type", - "options": "\nIN\nOUT", - "reqd": 1 + "options": "\nIN\nOUT" }, { "fieldname": "shift", @@ -108,7 +107,7 @@ } ], "links": [], - "modified": "2020-01-23 04:57:42.551355", + "modified": "2020-07-08 11:02:32.660986", "modified_by": "Administrator", "module": "HR", "name": "Employee Checkin", From 9071a7de82f1e3e663f3ec7bb998e566598853cf Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 8 Jul 2020 11:27:25 +0530 Subject: [PATCH 26/54] fix: Add default cost center in payment reconciliation JV --- .../payment_reconciliation/payment_reconciliation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index 8eaad7acd4..35d8d34c51 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -281,7 +281,8 @@ def reconcile_dr_cr_note(dr_cr_notes, company): 'party_type': d.party_type, d.dr_or_cr: abs(d.allocated_amount), 'reference_type': d.against_voucher_type, - 'reference_name': d.against_voucher + 'reference_name': d.against_voucher, + 'cost_center': erpnext.get_default_cost_center(company) }, { 'account': d.account, @@ -290,7 +291,8 @@ def reconcile_dr_cr_note(dr_cr_notes, company): reconcile_dr_or_cr: (abs(d.allocated_amount) if abs(d.unadjusted_amount) > abs(d.allocated_amount) else abs(d.unadjusted_amount)), 'reference_type': d.voucher_type, - 'reference_name': d.voucher_no + 'reference_name': d.voucher_no, + 'cost_center': erpnext.get_default_cost_center(company) } ] }) From cd445786fe1f01965f8f54191557d8c7c1a9a087 Mon Sep 17 00:00:00 2001 From: Anupam K Date: Sun, 12 Jul 2020 20:03:15 +0530 Subject: [PATCH 27/54] making owner fieldtype to link --- .../crm/report/lead_owner_efficiency/lead_owner_efficiency.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py b/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py index 6172a75fdd..53fc8cd810 100644 --- a/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py +++ b/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py @@ -17,7 +17,8 @@ def get_columns(): { "fieldname": "lead_owner", "label": _("Lead Owner"), - "fieldtype": "Data", + "fieldtype": "Link", + "options":"User", "width": "130" }, { From 2e8d8b9aebdd2b7b372517167508ae030f995d05 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 13 Jul 2020 12:08:58 +0530 Subject: [PATCH 28/54] fix: '>' not supported between instances of 'str' and 'int' --- erpnext/projects/doctype/task/task.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py index 3b75cf4215..4bdda68b69 100755 --- a/erpnext/projects/doctype/task/task.py +++ b/erpnext/projects/doctype/task/task.py @@ -9,7 +9,7 @@ import frappe from frappe import _, throw from frappe.desk.form.assign_to import clear, close_all_assignments from frappe.model.mapper import get_mapped_doc -from frappe.utils import add_days, cstr, date_diff, get_link_to_form, getdate, today +from frappe.utils import add_days, cstr, date_diff, get_link_to_form, getdate, today, flt from frappe.utils.nestedset import NestedSet @@ -63,10 +63,10 @@ class Task(NestedSet): close_all_assignments(self.doctype, self.name) def validate_progress(self): - if (self.progress or 0) > 100: + if flt(self.progress or 0) > 100: frappe.throw(_("Progress % for a task cannot be more than 100.")) - if self.progress == 100: + if flt(self.progress) == 100: self.status = 'Completed' if self.status == 'Completed': From 1791bc187b384ebd840d563e70b84099e1e75b84 Mon Sep 17 00:00:00 2001 From: marination Date: Mon, 13 Jul 2020 12:32:09 +0530 Subject: [PATCH 29/54] fix: Block Invalid Serial No updates in Maintenance Schedule --- .../maintenance_schedule/maintenance_schedule.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py index b58f999cfb..add7bbfa57 100644 --- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py +++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py @@ -44,7 +44,7 @@ class MaintenanceSchedule(TransactionBase): for d in self.get('items'): if d.serial_no: serial_nos = get_valid_serial_nos(d.serial_no) - self.validate_serial_no(serial_nos, d.start_date) + self.validate_serial_no(d.item_code, serial_nos, d.start_date) self.update_amc_date(serial_nos, d.end_date) no_email_sp = [] @@ -178,14 +178,18 @@ class MaintenanceSchedule(TransactionBase): serial_no_doc.amc_expiry_date = amc_expiry_date serial_no_doc.save() - def validate_serial_no(self, serial_nos, amc_start_date): + def validate_serial_no(self, item_code, serial_nos, amc_start_date): for serial_no in serial_nos: sr_details = frappe.db.get_value("Serial No", serial_no, - ["warranty_expiry_date", "amc_expiry_date", "warehouse", "delivery_date"], as_dict=1) + ["warranty_expiry_date", "amc_expiry_date", "warehouse", "delivery_date", "item_code"], as_dict=1) if not sr_details: frappe.throw(_("Serial No {0} not found").format(serial_no)) + if sr_details.get("item_code") != item_code: + frappe.throw(_("Serial No {0} does not belong to Item {1}") + .format(frappe.bold(serial_no), frappe.bold(item_code)), title="Invalid") + if sr_details.warranty_expiry_date \ and getdate(sr_details.warranty_expiry_date) >= getdate(amc_start_date): throw(_("Serial No {0} is under warranty upto {1}") From eb69859d3ef0c4ec1189c4b77a3932cdc0b125c6 Mon Sep 17 00:00:00 2001 From: bhavesh95863 <34086262+bhavesh95863@users.noreply.github.com> Date: Mon, 13 Jul 2020 23:15:31 +0530 Subject: [PATCH 30/54] fix: Quotation list view blank if quotation_to field not set as a standard filter --- .../selling/doctype/quotation/quotation_list.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation_list.js b/erpnext/selling/doctype/quotation/quotation_list.js index 802c0ba641..f425acf180 100644 --- a/erpnext/selling/doctype/quotation/quotation_list.js +++ b/erpnext/selling/doctype/quotation/quotation_list.js @@ -3,13 +3,15 @@ frappe.listview_settings['Quotation'] = { "company", "currency", 'valid_till'], onload: function(listview) { - listview.page.fields_dict.quotation_to.get_query = function() { - return { - "filters": { - "name": ["in", ["Customer", "Lead"]], - } + if (listview.page.fields_dict.quotation_to) { + listview.page.fields_dict.quotation_to.get_query = function() { + return { + "filters": { + "name": ["in", ["Customer", "Lead"]], + } + }; }; - }; + } }, get_indicator: function(doc) { From 72320afb0797d72426ed31827febbc49045da51f Mon Sep 17 00:00:00 2001 From: John Veness Date: Tue, 14 Jul 2020 06:14:15 +0100 Subject: [PATCH 31/54] Correct help link for Address (#22673) --- erpnext/public/js/help_links.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/help_links.js b/erpnext/public/js/help_links.js index 17b726ee18..66ff46405d 100644 --- a/erpnext/public/js/help_links.js +++ b/erpnext/public/js/help_links.js @@ -450,7 +450,7 @@ frappe.help.help_links['Form/Opportunity'] = [ ] frappe.help.help_links['Form/Address'] = [ - { label: 'Address', url: docsUrl + 'user/manual/en/CRM/contact' }, + { label: 'Address', url: docsUrl + 'user/manual/en/CRM/address' }, ] frappe.help.help_links['Form/Contact'] = [ From 88931f0677c4cb8a79f4fdf1055767a1db14616b Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 14 Jul 2020 11:46:11 +0530 Subject: [PATCH 32/54] fix(Support): TypeError while saving Service Level Agreement --- .../service_level_agreement/service_level_agreement.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py index c692315706..61b66a9b13 100644 --- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py +++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py @@ -21,8 +21,8 @@ class ServiceLevelAgreement(Document): for priority in self.priorities: # Check if response and resolution time is set for every priority - if not (priority.response_time or priority.resolution_time): - frappe.throw(_("Set Response Time and Resolution for Priority {0} at index {1}.").format(priority.priority, priority.idx)) + if not priority.response_time or not priority.resolution_time: + frappe.throw(_("Set Response Time and Resolution Time for Priority {0} in row {1}.").format(priority.priority, priority.idx)) priorities.append(priority.priority) @@ -33,7 +33,7 @@ class ServiceLevelAgreement(Document): resolution = priority.resolution_time if response > resolution: - frappe.throw(_("Response Time for {0} at index {1} can't be greater than Resolution Time.").format(priority.priority, priority.idx)) + frappe.throw(_("Response Time for {0} priority in row {1} can't be greater than Resolution Time.").format(priority.priority, priority.idx)) # Check if repeated priority if not len(set(priorities)) == len(priorities): From 82a606d04bd7568aec2206967d3cf11fddb0930b Mon Sep 17 00:00:00 2001 From: Marica Date: Tue, 14 Jul 2020 13:16:28 +0530 Subject: [PATCH 33/54] fix: Added Project Field in Purchase Receipt for Stock Ledger Tagging (#22666) --- .../purchase_receipt/purchase_receipt.json | 452 +++++------------- 1 file changed, 111 insertions(+), 341 deletions(-) diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json index 3b92dac220..0cb85d32a6 100755 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json @@ -103,6 +103,7 @@ "bill_no", "bill_date", "more_info", + "project", "status", "amended_from", "range", @@ -132,17 +133,13 @@ { "fieldname": "supplier_section", "fieldtype": "Section Break", - "options": "fa fa-user", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-user" }, { "fieldname": "column_break0", "fieldtype": "Column Break", "oldfieldtype": "Column Break", "print_width": "50%", - "show_days": 1, - "show_seconds": 1, "width": "50%" }, { @@ -153,9 +150,7 @@ "hidden": 1, "label": "Title", "no_copy": 1, - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "naming_series", @@ -167,9 +162,7 @@ "options": "MAT-PRE-.YYYY.-", "print_hide": 1, "reqd": 1, - "set_only_once": 1, - "show_days": 1, - "show_seconds": 1 + "set_only_once": 1 }, { "bold": 1, @@ -184,8 +177,6 @@ "print_width": "150px", "reqd": 1, "search_index": 1, - "show_days": 1, - "show_seconds": 1, "width": "150px" }, { @@ -196,24 +187,18 @@ "fieldtype": "Data", "in_global_search": 1, "label": "Supplier Name", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "supplier_delivery_note", "fieldtype": "Data", - "label": "Supplier Delivery Note", - "show_days": 1, - "show_seconds": 1 + "label": "Supplier Delivery Note" }, { "fieldname": "column_break1", "fieldtype": "Column Break", "oldfieldtype": "Column Break", "print_width": "50%", - "show_days": 1, - "show_seconds": 1, "width": "50%" }, { @@ -228,8 +213,6 @@ "print_width": "100px", "reqd": 1, "search_index": 1, - "show_days": 1, - "show_seconds": 1, "width": "100px" }, { @@ -243,8 +226,6 @@ "print_hide": 1, "print_width": "100px", "reqd": 1, - "show_days": 1, - "show_seconds": 1, "width": "100px" }, { @@ -253,9 +234,7 @@ "fieldname": "set_posting_time", "fieldtype": "Check", "label": "Edit Posting Date and Time", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "company", @@ -269,8 +248,6 @@ "print_width": "150px", "remember_last_selected_value": 1, "reqd": 1, - "show_days": 1, - "show_seconds": 1, "width": "150px" }, { @@ -280,9 +257,7 @@ "label": "Is Return", "no_copy": 1, "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "is_return", @@ -292,60 +267,46 @@ "no_copy": 1, "options": "Purchase Receipt", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, "fieldname": "section_addresses", "fieldtype": "Section Break", - "label": "Address and Contact", - "show_days": 1, - "show_seconds": 1 + "label": "Address and Contact" }, { "fieldname": "supplier_address", "fieldtype": "Link", "label": "Select Supplier Address", "options": "Address", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "contact_person", "fieldtype": "Link", "label": "Contact Person", "options": "Contact", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "address_display", "fieldtype": "Small Text", "label": "Address", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "contact_display", "fieldtype": "Small Text", "in_global_search": 1, "label": "Contact", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "contact_mobile", "fieldtype": "Small Text", "label": "Mobile No", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "contact_email", @@ -353,42 +314,32 @@ "label": "Contact Email", "options": "Email", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "col_break_address", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "shipping_address", "fieldtype": "Link", "label": "Select Shipping Address", "options": "Address", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "shipping_address_display", "fieldtype": "Small Text", "label": "Shipping Address", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, "fieldname": "currency_and_price_list", "fieldtype": "Section Break", "label": "Currency and Price List", - "options": "fa fa-tag", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-tag" }, { "fieldname": "currency", @@ -398,9 +349,7 @@ "oldfieldtype": "Select", "options": "Currency", "print_hide": 1, - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "description": "Rate at which supplier's currency is converted to company's base currency", @@ -411,17 +360,13 @@ "oldfieldtype": "Currency", "precision": "9", "print_hide": 1, - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fieldname": "column_break2", "fieldtype": "Column Break", "oldfieldtype": "Column Break", "print_width": "50%", - "show_days": 1, - "show_seconds": 1, "width": "50%" }, { @@ -429,9 +374,7 @@ "fieldtype": "Link", "label": "Price List", "options": "Price List", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "depends_on": "buying_price_list", @@ -440,9 +383,7 @@ "label": "Price List Currency", "options": "Currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "buying_price_list", @@ -450,9 +391,7 @@ "fieldtype": "Float", "label": "Price List Exchange Rate", "precision": "9", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "default": "0", @@ -461,15 +400,11 @@ "label": "Ignore Pricing Rule", "no_copy": 1, "permlevel": 1, - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "sec_warehouse", - "fieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Section Break" }, { "description": "Sets 'Accepted Warehouse' in each row of the items table.", @@ -477,9 +412,7 @@ "fieldtype": "Link", "label": "Accepted Warehouse", "options": "Warehouse", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "description": "Sets 'Rejected Warehouse' in each row of the items table.", @@ -490,15 +423,11 @@ "oldfieldname": "rejected_warehouse", "oldfieldtype": "Link", "options": "Warehouse", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "col_break_warehouse", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "default": "No", @@ -508,9 +437,7 @@ "oldfieldname": "is_subcontracted", "oldfieldtype": "Select", "options": "No\nYes", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "depends_on": "eval:doc.is_subcontracted==\"Yes\"", @@ -523,17 +450,13 @@ "options": "Warehouse", "print_hide": 1, "print_width": "50px", - "show_days": 1, - "show_seconds": 1, "width": "50px" }, { "fieldname": "items_section", "fieldtype": "Section Break", "oldfieldtype": "Section Break", - "options": "fa fa-shopping-cart", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-shopping-cart" }, { "allow_bulk_edit": 1, @@ -543,26 +466,20 @@ "oldfieldname": "purchase_receipt_details", "oldfieldtype": "Table", "options": "Purchase Receipt Item", - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "collapsible": 1, "fieldname": "pricing_rule_details", "fieldtype": "Section Break", - "label": "Pricing Rules", - "show_days": 1, - "show_seconds": 1 + "label": "Pricing Rules" }, { "fieldname": "pricing_rules", "fieldtype": "Table", "label": "Pricing Rule Detail", "options": "Pricing Rule Detail", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "supplied_items", @@ -571,9 +488,7 @@ "label": "Get Current Stock", "oldfieldtype": "Button", "options": "get_current_stock", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "collapsible": 1, @@ -584,9 +499,7 @@ "oldfieldtype": "Section Break", "options": "fa fa-table", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "supplied_items", @@ -597,24 +510,18 @@ "oldfieldtype": "Table", "options": "Purchase Receipt Item Supplied", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "section_break0", "fieldtype": "Section Break", - "oldfieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "oldfieldtype": "Section Break" }, { "fieldname": "total_qty", "fieldtype": "Float", "label": "Total Quantity", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_total", @@ -622,9 +529,7 @@ "label": "Total (Company Currency)", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_net_total", @@ -637,24 +542,18 @@ "print_width": "150px", "read_only": 1, "reqd": 1, - "show_days": 1, - "show_seconds": 1, "width": "150px" }, { "fieldname": "column_break_27", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "total", "fieldtype": "Currency", "label": "Total", "options": "currency", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "net_total", @@ -664,56 +563,42 @@ "oldfieldtype": "Currency", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "total_net_weight", "fieldtype": "Float", "label": "Total Net Weight", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "description": "Add / Edit Taxes and Charges", "fieldname": "taxes_charges_section", "fieldtype": "Section Break", "oldfieldtype": "Section Break", - "options": "fa fa-money", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-money" }, { "fieldname": "tax_category", "fieldtype": "Link", "label": "Tax Category", "options": "Tax Category", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "shipping_col", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "shipping_rule", "fieldtype": "Link", "label": "Shipping Rule", - "options": "Shipping Rule", - "show_days": 1, - "show_seconds": 1 + "options": "Shipping Rule" }, { "fieldname": "taxes_section", - "fieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Section Break" }, { "fieldname": "taxes_and_charges", @@ -722,9 +607,7 @@ "oldfieldname": "purchase_other_charges", "oldfieldtype": "Link", "options": "Purchase Taxes and Charges Template", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "taxes", @@ -732,17 +615,13 @@ "label": "Purchase Taxes and Charges", "oldfieldname": "purchase_tax_details", "oldfieldtype": "Table", - "options": "Purchase Taxes and Charges", - "show_days": 1, - "show_seconds": 1 + "options": "Purchase Taxes and Charges" }, { "collapsible": 1, "fieldname": "sec_tax_breakup", "fieldtype": "Section Break", - "label": "Tax Breakup", - "show_days": 1, - "show_seconds": 1 + "label": "Tax Breakup" }, { "fieldname": "other_charges_calculation", @@ -751,17 +630,13 @@ "no_copy": 1, "oldfieldtype": "HTML", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "totals", "fieldtype": "Section Break", "oldfieldtype": "Section Break", - "options": "fa fa-money", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-money" }, { "fieldname": "base_taxes_and_charges_added", @@ -771,9 +646,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_taxes_and_charges_deducted", @@ -783,9 +656,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_total_taxes_and_charges", @@ -795,16 +666,12 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break3", "fieldtype": "Column Break", "print_width": "50%", - "show_days": 1, - "show_seconds": 1, "width": "50%" }, { @@ -815,9 +682,7 @@ "oldfieldtype": "Currency", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "taxes_and_charges_deducted", @@ -827,9 +692,7 @@ "oldfieldtype": "Currency", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "total_taxes_and_charges", @@ -837,18 +700,14 @@ "label": "Total Taxes and Charges", "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, "collapsible_depends_on": "discount_amount", "fieldname": "section_break_42", "fieldtype": "Section Break", - "label": "Additional Discount", - "show_days": 1, - "show_seconds": 1 + "label": "Additional Discount" }, { "default": "Grand Total", @@ -856,9 +715,7 @@ "fieldtype": "Select", "label": "Apply Additional Discount On", "options": "\nGrand Total\nNet Total", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "base_discount_amount", @@ -866,38 +723,28 @@ "label": "Additional Discount Amount (Company Currency)", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_44", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "additional_discount_percentage", "fieldtype": "Float", "label": "Additional Discount Percentage", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "discount_amount", "fieldtype": "Currency", "label": "Additional Discount Amount", "options": "currency", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "section_break_46", - "fieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Section Break" }, { "fieldname": "base_grand_total", @@ -907,9 +754,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_rounding_adjustment", @@ -918,9 +763,7 @@ "no_copy": 1, "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_in_words", @@ -929,9 +772,7 @@ "oldfieldname": "in_words", "oldfieldtype": "Data", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "base_rounded_total", @@ -941,15 +782,11 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_50", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "grand_total", @@ -959,9 +796,7 @@ "oldfieldname": "grand_total_import", "oldfieldtype": "Currency", "options": "currency", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "rounding_adjustment", @@ -970,9 +805,7 @@ "no_copy": 1, "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "depends_on": "eval:!doc.disable_rounded_total", @@ -982,9 +815,7 @@ "no_copy": 1, "options": "currency", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "in_words", @@ -993,17 +824,13 @@ "oldfieldname": "in_words_import", "oldfieldtype": "Data", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "default": "0", "fieldname": "disable_rounded_total", "fieldtype": "Check", - "label": "Disable Rounded Total", - "show_days": 1, - "show_seconds": 1 + "label": "Disable Rounded Total" }, { "collapsible": 1, @@ -1012,9 +839,7 @@ "fieldtype": "Section Break", "label": "Terms and Conditions", "oldfieldtype": "Section Break", - "options": "fa fa-legal", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-legal" }, { "fieldname": "tc_name", @@ -1023,18 +848,14 @@ "oldfieldname": "tc_name", "oldfieldtype": "Link", "options": "Terms and Conditions", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "terms", "fieldtype": "Text Editor", "label": "Terms and Conditions", "oldfieldname": "terms", - "oldfieldtype": "Text Editor", - "show_days": 1, - "show_seconds": 1 + "oldfieldtype": "Text Editor" }, { "fieldname": "bill_no", @@ -1043,9 +864,7 @@ "label": "Bill No", "oldfieldname": "bill_no", "oldfieldtype": "Data", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "bill_date", @@ -1054,9 +873,7 @@ "label": "Bill Date", "oldfieldname": "bill_date", "oldfieldtype": "Date", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "collapsible": 1, @@ -1064,9 +881,7 @@ "fieldtype": "Section Break", "label": "More Information", "oldfieldtype": "Section Break", - "options": "fa fa-file-text", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-file-text" }, { "default": "Draft", @@ -1083,8 +898,6 @@ "read_only": 1, "reqd": 1, "search_index": 1, - "show_days": 1, - "show_seconds": 1, "width": "150px" }, { @@ -1100,8 +913,6 @@ "print_hide": 1, "print_width": "150px", "read_only": 1, - "show_days": 1, - "show_seconds": 1, "width": "150px" }, { @@ -1111,9 +922,7 @@ "label": "Range", "oldfieldname": "range", "oldfieldtype": "Data", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "column_break4", @@ -1121,8 +930,6 @@ "oldfieldtype": "Column Break", "print_hide": 1, "print_width": "50%", - "show_days": 1, - "show_seconds": 1, "width": "50%" }, { @@ -1137,16 +944,12 @@ "label": "% Amount Billed", "no_copy": 1, "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "subscription_detail", "fieldtype": "Section Break", - "label": "Auto Repeat Detail", - "show_days": 1, - "show_seconds": 1 + "label": "Auto Repeat Detail" }, { "fieldname": "auto_repeat", @@ -1155,17 +958,13 @@ "no_copy": 1, "options": "Auto Repeat", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "collapsible": 1, "fieldname": "printing_settings", "fieldtype": "Section Break", - "label": "Printing Settings", - "show_days": 1, - "show_seconds": 1 + "label": "Printing Settings" }, { "allow_on_submit": 1, @@ -1173,9 +972,7 @@ "fieldtype": "Link", "label": "Letter Head", "options": "Letter Head", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "allow_on_submit": 1, @@ -1187,17 +984,13 @@ "oldfieldtype": "Link", "options": "Print Heading", "print_hide": 1, - "report_hide": 1, - "show_days": 1, - "show_seconds": 1 + "report_hide": 1 }, { "fieldname": "language", "fieldtype": "Data", "label": "Print Language", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "allow_on_submit": 1, @@ -1205,15 +998,11 @@ "fieldname": "group_same_items", "fieldtype": "Check", "label": "Group same items", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "fieldname": "column_break_97", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "other_details", @@ -1224,8 +1013,6 @@ "options": "
Other Details
", "print_hide": 1, "print_width": "30%", - "show_days": 1, - "show_seconds": 1, "width": "30%" }, { @@ -1233,17 +1020,13 @@ "fieldtype": "Small Text", "label": "Instructions", "oldfieldname": "instructions", - "oldfieldtype": "Text", - "show_days": 1, - "show_seconds": 1 + "oldfieldtype": "Text" }, { "fieldname": "remarks", "fieldtype": "Small Text", "label": "Remarks", - "print_hide": 1, - "show_days": 1, - "show_seconds": 1 + "print_hide": 1 }, { "collapsible": 1, @@ -1251,25 +1034,19 @@ "fieldname": "transporter_info", "fieldtype": "Section Break", "label": "Transporter Details", - "options": "fa fa-truck", - "show_days": 1, - "show_seconds": 1 + "options": "fa fa-truck" }, { "fieldname": "transporter_name", "fieldtype": "Data", "label": "Transporter Name", "oldfieldname": "transporter_name", - "oldfieldtype": "Data", - "show_days": 1, - "show_seconds": 1 + "oldfieldtype": "Data" }, { "fieldname": "column_break5", "fieldtype": "Column Break", "print_width": "50%", - "show_days": 1, - "show_seconds": 1, "width": "50%" }, { @@ -1280,8 +1057,6 @@ "oldfieldname": "lr_no", "oldfieldtype": "Data", "print_width": "100px", - "show_days": 1, - "show_seconds": 1, "width": "100px" }, { @@ -1292,8 +1067,6 @@ "oldfieldname": "lr_date", "oldfieldtype": "Date", "print_width": "100px", - "show_days": 1, - "show_seconds": 1, "width": "100px" }, { @@ -1302,48 +1075,45 @@ "fieldname": "is_internal_supplier", "fieldtype": "Check", "label": "Is Internal Supplier", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "inter_company_reference", "fieldtype": "Link", "label": "Inter Company Reference", "options": "Delivery Note", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "scan_barcode", "fieldtype": "Data", - "label": "Scan Barcode", - "show_days": 1, - "show_seconds": 1 + "label": "Scan Barcode" }, { "fieldname": "billing_address", "fieldtype": "Link", "label": "Select Billing Address", - "options": "Address", - "show_days": 1, - "show_seconds": 1 + "options": "Address" }, { "fieldname": "billing_address_display", "fieldtype": "Small Text", "label": "Billing Address", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 + }, + { + "description": "Track this Purchase Receipt against any Project", + "fieldname": "project", + "fieldtype": "Link", + "label": "Project", + "options": "Project" } ], "icon": "fa fa-truck", "idx": 261, "is_submittable": 1, "links": [], - "modified": "2020-06-13 22:26:03.600092", + "modified": "2020-07-13 14:01:39.302238", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt", From 392f323d2de2a847e24d00ae000a9eca0174c8af Mon Sep 17 00:00:00 2001 From: marination Date: Tue, 14 Jul 2020 17:03:17 +0530 Subject: [PATCH 34/54] fix: Dont overwrite default warehouse in Material Request --- .../doctype/material_request/material_request.js | 16 ++++++++-------- erpnext/stock/get_item_details.py | 6 ++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index 3a8deb6d25..60f5ff3629 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -180,9 +180,8 @@ frappe.ui.form.on('Material Request', { }); }, - get_item_data: function(frm, item) { + get_item_data: function(frm, item, overwrite_warehouse=false) { if (item && !item.item_code) { return; } - frm.call({ method: "erpnext.stock.get_item_details.get_item_details", child: item, @@ -203,7 +202,8 @@ frappe.ui.form.on('Material Request', { plc_conversion_rate: 1, rate: item.rate, conversion_factor: item.conversion_factor - } + }, + overwrite_warehouse: overwrite_warehouse }, callback: function(r) { const d = item; @@ -354,29 +354,29 @@ frappe.ui.form.on("Material Request Item", { } const item = locals[doctype][name]; - frm.events.get_item_data(frm, item); + frm.events.get_item_data(frm, item, false); }, from_warehouse: function(frm, doctype, name) { const item = locals[doctype][name]; - frm.events.get_item_data(frm, item); + frm.events.get_item_data(frm, item, false); }, warehouse: function(frm, doctype, name) { const item = locals[doctype][name]; - frm.events.get_item_data(frm, item); + frm.events.get_item_data(frm, item, false); }, rate: function(frm, doctype, name) { const item = locals[doctype][name]; - frm.events.get_item_data(frm, item); + frm.events.get_item_data(frm, item, false); }, item_code: function(frm, doctype, name) { const item = locals[doctype][name]; item.rate = 0; set_schedule_date(frm); - frm.events.get_item_data(frm, item); + frm.events.get_item_data(frm, item, true); }, schedule_date: function(frm, cdt, cdn) { diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index b1a16149b2..b8554c83e2 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -47,6 +47,8 @@ def get_item_details(args, doc=None, for_validate=False, overwrite_warehouse=Tru """ args = process_args(args) + for_validate = process_string_args(for_validate) + overwrite_warehouse = process_string_args(overwrite_warehouse) item = frappe.get_cached_doc("Item", args.item_code) validate_item_details(args, item) @@ -166,6 +168,10 @@ def process_args(args): set_transaction_type(args) return args +def process_string_args(args): + if isinstance(args, string_types): + args = json.loads(args) + return args @frappe.whitelist() def get_item_code(barcode=None, serial_no=None): From c1636f8fab62472034169bccc24ac6ed9202421e Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Tue, 14 Jul 2020 18:58:02 +0530 Subject: [PATCH 35/54] fix: conversion rate as 1 if no conversion rate --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 59611bc74c..cd2313ab8f 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1029,14 +1029,14 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount= if bank_amount: received_amount = bank_amount else: - received_amount = paid_amount * doc.conversion_rate + received_amount = paid_amount * (doc.get('conversion_rate') or 1) else: received_amount = abs(outstanding_amount) if bank_amount: paid_amount = bank_amount else: # if party account currency and bank currency is different then populate paid amount as well - paid_amount = received_amount * doc.conversion_rate + paid_amount = received_amount * (doc.get('conversion_rate') or 1) pe = frappe.new_doc("Payment Entry") pe.payment_type = payment_type From 5beac7a0cca91d4dccff578f23363ba86c90e54c Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Wed, 15 Jul 2020 12:17:43 +0530 Subject: [PATCH 36/54] fix: Period list fixes in financial statements (#22677) --- erpnext/accounts/report/financial_statements.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index ee1d54a92e..3785ebf215 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -8,6 +8,7 @@ from __future__ import unicode_literals import re from past.builtins import cmp import functools +import math import frappe, erpnext from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency @@ -45,10 +46,7 @@ def get_period_list(from_fiscal_year, to_fiscal_year, period_start_date, period_ start_date = year_start_date months = get_months(year_start_date, year_end_date) - if (months // months_to_add) != (months / months_to_add): - months += months_to_add - - for i in range(months // months_to_add): + for i in range(math.ceil(months / months_to_add)): period = frappe._dict({ "from_date": start_date }) From e1b3f16abd9484d59ba54072f21758ada46a8b65 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 15 Jul 2020 12:28:19 +0530 Subject: [PATCH 37/54] fix: project field added two time in purchase receipt --- .../doctype/purchase_receipt/purchase_receipt.json | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json index 0cb85d32a6..df9eb50843 100755 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json @@ -108,7 +108,6 @@ "amended_from", "range", "column_break4", - "project", "per_billed", "is_internal_supplier", "inter_company_reference", @@ -933,6 +932,7 @@ "width": "50%" }, { + "description": "Track this Purchase Receipt against any Project", "fieldname": "project", "fieldtype": "Link", "label": "Project", @@ -1100,20 +1100,13 @@ "fieldtype": "Small Text", "label": "Billing Address", "read_only": 1 - }, - { - "description": "Track this Purchase Receipt against any Project", - "fieldname": "project", - "fieldtype": "Link", - "label": "Project", - "options": "Project" } ], "icon": "fa fa-truck", "idx": 261, "is_submittable": 1, "links": [], - "modified": "2020-07-13 14:01:39.302238", + "modified": "2020-07-15 10:01:39.302238", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt", From 34617744e1f4cd2fac9a6271639c4df7c00eb482 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 15 Jul 2020 16:37:21 +0530 Subject: [PATCH 38/54] fix: Show total row in print format of financial statement --- erpnext/accounts/report/financial_statements.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/financial_statements.html b/erpnext/accounts/report/financial_statements.html index 50947ecf5e..2bb09cf0dc 100644 --- a/erpnext/accounts/report/financial_statements.html +++ b/erpnext/accounts/report/financial_statements.html @@ -44,7 +44,7 @@ - {% for(let j=0, k=data.length-1; j Date: Wed, 15 Jul 2020 16:41:32 +0530 Subject: [PATCH 39/54] fix: patch update_actual_start_and_end_date_in_wo --- erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py b/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py index 331c5590e5..adfa20e368 100644 --- a/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py +++ b/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py @@ -6,7 +6,6 @@ from __future__ import unicode_literals import frappe from frappe.utils import add_to_date -from frappe.utils.dashboard import get_config, make_records def execute(): frappe.reload_doc("manufacturing", "doctype", "work_order") From e0de0ac61751216632ebbefdb666ffcf430e8712 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 15 Jul 2020 17:06:42 +0530 Subject: [PATCH 40/54] fix: not able to submit sales invoice --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index b2b4cb1ea7..bab5208370 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1113,7 +1113,10 @@ class SalesInvoice(SellingController): expiry_date=self.posting_date, include_expired_entry=True) if lp_details and getdate(lp_details.from_date) <= getdate(self.posting_date) and \ (not lp_details.to_date or getdate(lp_details.to_date) >= getdate(self.posting_date)): - points_earned = cint(eligible_amount/lp_details.collection_factor) + + collection_factor = lp_details.collection_factor if lp_details.collection_factor else 1.0 + points_earned = cint(eligible_amount/collection_factor) + doc = frappe.get_doc({ "doctype": "Loyalty Point Entry", "company": self.company, From 132376750c965b7d371f8c90e04d1e7a6dc9a670 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 10 Jul 2020 18:11:04 +0530 Subject: [PATCH 41/54] fix: incorrect balance qty in stock ledger report --- erpnext/stock/report/stock_ledger/stock_ledger.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py index abf959eb0b..a5f92e2c76 100644 --- a/erpnext/stock/report/stock_ledger/stock_ledger.py +++ b/erpnext/stock/report/stock_ledger/stock_ledger.py @@ -4,10 +4,10 @@ from __future__ import unicode_literals import frappe +from frappe.utils import cint, flt from erpnext.stock.utils import update_included_uom_in_report from frappe import _ - def execute(filters=None): include_uom = filters.get("include_uom") columns = get_columns() @@ -15,6 +15,7 @@ def execute(filters=None): sl_entries = get_stock_ledger_entries(filters, items) item_details = get_item_details(items, sl_entries, include_uom) opening_row = get_opening_balance(filters, columns) + precision = cint(frappe.db.get_single_value("System Settings", "float_precision")) data = [] conversion_factors = [] @@ -29,7 +30,7 @@ def execute(filters=None): sle.update(item_detail) if filters.get("batch_no"): - actual_qty += sle.actual_qty + actual_qty += flt(sle.actual_qty, precision) stock_value += sle.stock_value_difference if sle.voucher_type == 'Stock Reconciliation': From 0fa4143bac50fcca97505c2d4d8a545843273ff0 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 15 Jul 2020 18:17:38 +0530 Subject: [PATCH 42/54] fix: Cess amount in GSTR 3B report --- .../doctype/gstr_3b_report/gstr_3b_report.js | 4 + .../doctype/gstr_3b_report/gstr_3b_report.py | 78 ++++++++++--------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js index a1cea8f609..5170185158 100644 --- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js +++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js @@ -45,6 +45,10 @@ frappe.ui.form.on('GSTR 3B Report', { frm.set_df_property('year', 'options', options); }, + validate: function(frm) { + frm.dirty(); + }, + setup: function(frm) { frm.set_query('company_address', function(doc) { if(!doc.company) { diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py index 619734ff26..6d9b8dbe28 100644 --- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py +++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py @@ -243,20 +243,15 @@ class GSTR3BReport(Document): osup_det = self.report_dict["sup_details"]["osup_det"] - for d in inter_state_supply.get("Unregistered", []): - self.report_dict["inter_sup"]["unreg_details"].append(d) - osup_det["txval"] = flt(osup_det["txval"] + d["txval"], 2) - osup_det["iamt"] = flt(osup_det["iamt"] + d["iamt"], 2) + for key, value in iteritems(inter_state_supply): + if key[0] == "Unregistered": + self.report_dict["inter_sup"]["unreg_details"].append(value) - for d in inter_state_supply.get("Registered Composition", []): - self.report_dict["inter_sup"]["comp_details"].append(d) - osup_det["txval"] = flt(osup_det["txval"] + d["txval"], 2) - osup_det["iamt"] = flt(osup_det["iamt"] + d["iamt"], 2) + if key[0] == "Registered Composition": + self.report_dict["inter_sup"]["comp_details"].append(value) - for d in inter_state_supply.get("UIN Holders", []): - self.report_dict["inter_sup"]["uin_details"].append(d) - osup_det["txval"] = flt(osup_det["txval"] + d["txval"], 2) - osup_det["iamt"] = flt(osup_det["iamt"] + d["iamt"], 2) + if key[0] == "UIN Holders": + self.report_dict["inter_sup"]["uin_details"].append(value) def get_total_taxable_value(self, doctype, reverse_charge): @@ -301,41 +296,54 @@ class GSTR3BReport(Document): (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)[0].total def get_inter_state_supplies(self, state_number): - - inter_state_supply_taxable_value = frappe.db.sql(""" select sum(s.net_total) as total, s.place_of_supply, s.gst_category - from `tabSales Invoice` s where s.docstatus = 1 and month(s.posting_date) = %s and year(s.posting_date) = %s - and s.company = %s and s.company_gstin = %s and s.gst_category in ('Unregistered', 'Registered Composition', 'UIN Holders') - group by s.gst_category, s.place_of_supply""", (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1) - - inter_state_supply_tax = frappe.db.sql(""" select sum(t.tax_amount_after_discount_amount) as tax_amount, s.place_of_supply, s.gst_category - from `tabSales Invoice` s, `tabSales Taxes and Charges` t + inter_state_supply_tax = frappe.db.sql(""" select t.account_head, t.tax_amount_after_discount_amount as tax_amount, + s.name, s.net_total, s.place_of_supply, s.gst_category from `tabSales Invoice` s, `tabSales Taxes and Charges` t where t.parent = s.name and s.docstatus = 1 and month(s.posting_date) = %s and year(s.posting_date) = %s and s.company = %s and s.company_gstin = %s and s.gst_category in ('Unregistered', 'Registered Composition', 'UIN Holders') - group by s.gst_category, s.place_of_supply""", (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1) + """, (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1) - inter_state_supply_tax_mapping={} + inter_state_supply_tax_mapping = {} inter_state_supply_details = {} for d in inter_state_supply_tax: - inter_state_supply_tax_mapping.setdefault(d.place_of_supply, d.tax_amount) + inter_state_supply_tax_mapping.setdefault(d.name, { + 'place_of_supply': d.place_of_supply, + 'taxable_value': d.net_total, + 'camt': 0.0, + 'samt': 0.0, + 'iamt': 0.0, + 'csamt': 0.0 + }) - for d in inter_state_supply_taxable_value: - inter_state_supply_details.setdefault( - d.gst_category, [] - ) + if d.account_head in [d.cgst_account for d in self.account_heads]: + inter_state_supply_tax_mapping[d.name]['camt'] += d.tax_amount + if d.account_head in [d.sgst_account for d in self.account_heads]: + inter_state_supply_tax_mapping[d.name]['samt'] += d.tax_amount + + if d.account_head in [d.igst_account for d in self.account_heads]: + inter_state_supply_tax_mapping[d.name]['samt'] += d.tax_amount + + if d.account_head in [d.cess_account for d in self.account_heads]: + inter_state_supply_tax_mapping[d.name]['csamt'] += d.tax_amount + + for key, value in iteritems(inter_state_supply_tax_mapping): if d.place_of_supply: + osup_det = self.report_dict["sup_details"]["osup_det"] + osup_det["txval"] = flt(osup_det["txval"] + value['taxable_value'], 2) + osup_det["camt"] = flt(osup_det["camt"] + value['camt'], 2) + osup_det["samt"] = flt(osup_det["samt"] + value['samt'], 2) + osup_det["csamt"] = flt(osup_det["csamt"] + value['csamt'], 2) + if state_number != d.place_of_supply.split("-")[0]: - inter_state_supply_details[d.gst_category].append({ + inter_state_supply_details.setdefault((d.gst_category, d.place_of_supply), { + "txval": 0.0, "pos": d.place_of_supply.split("-")[0], - "txval": flt(d.total, 2), - "iamt": flt(inter_state_supply_tax_mapping.get(d.place_of_supply), 2) + "iamt": 0.0 }) - else: - osup_det = self.report_dict["sup_details"]["osup_det"] - osup_det["txval"] = flt(osup_det["txval"] + d.total, 2) - osup_det["camt"] = flt(osup_det["camt"] + inter_state_supply_tax_mapping.get(d.place_of_supply)/2, 2) - osup_det["samt"] = flt(osup_det["samt"] + inter_state_supply_tax_mapping.get(d.place_of_supply)/2, 2) + + inter_state_supply_details[(d.gst_category, d.place_of_supply)]['txval'] += value['taxable_value'] + inter_state_supply_details[(d.gst_category, d.place_of_supply)]['iamt'] += value['iamt'] return inter_state_supply_details From 2af43b3df60701e7545b95bb040e6e2f05a3fbff Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Wed, 15 Jul 2020 21:54:28 +0530 Subject: [PATCH 43/54] fix: linting --- .../crm/report/lead_owner_efficiency/lead_owner_efficiency.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py b/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py index 53fc8cd810..8fe16a2f4c 100644 --- a/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py +++ b/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py @@ -18,7 +18,7 @@ def get_columns(): "fieldname": "lead_owner", "label": _("Lead Owner"), "fieldtype": "Link", - "options":"User", + "options": "User", "width": "130" }, { @@ -69,4 +69,4 @@ def get_columns(): "fieldtype": "Float", "width": "100" } - ] \ No newline at end of file + ] From 52c319cfa793108162acd6046b000ffd71293b1b Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 15 Jul 2020 23:57:03 +0530 Subject: [PATCH 44/54] fix: Update RCM only for indian countries --- erpnext/regional/india/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index 24bb137e68..7d10892c4a 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -668,6 +668,11 @@ def get_gst_accounts(company, account_wise=False): return gst_accounts def update_grand_total_for_rcm(doc, method): + country = frappe.get_cached_value('Company', doc.company, 'country') + + if country != 'India': + return + if doc.reverse_charge == 'Y': gst_accounts = get_gst_accounts(doc.company) gst_account_list = gst_accounts.get('cgst_account') + gst_accounts.get('sgst_account') \ From 50902cf30ca34802c24ebd1616ab68492cca55f4 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Thu, 16 Jul 2020 12:21:46 +0530 Subject: [PATCH 45/54] Fix: Changes Requested --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index cd2313ab8f..962006553e 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1029,14 +1029,14 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount= if bank_amount: received_amount = bank_amount else: - received_amount = paid_amount * (doc.get('conversion_rate') or 1) + received_amount = paid_amount * doc.get('conversion_rate', 1) else: received_amount = abs(outstanding_amount) if bank_amount: paid_amount = bank_amount else: # if party account currency and bank currency is different then populate paid amount as well - paid_amount = received_amount * (doc.get('conversion_rate') or 1) + paid_amount = received_amount * doc.get('conversion_rate', 1) pe = frappe.new_doc("Payment Entry") pe.payment_type = payment_type From ac23ac6a025018e6e707fcb904256ae55f7cd876 Mon Sep 17 00:00:00 2001 From: Anurag Mishra <32095923+Anurag810@users.noreply.github.com> Date: Thu, 16 Jul 2020 13:10:43 +0530 Subject: [PATCH 46/54] fix: validation for additional salary (#22645) * fix: validation for additional salary * fix:changes requested Co-authored-by: Rucha Mahabal Co-authored-by: Rucha Mahabal --- .../doctype/additional_salary/additional_salary.js | 3 +-- .../doctype/additional_salary/additional_salary.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/erpnext/payroll/doctype/additional_salary/additional_salary.js b/erpnext/payroll/doctype/additional_salary/additional_salary.js index fb42b6f410..d56cd4e967 100644 --- a/erpnext/payroll/doctype/additional_salary/additional_salary.js +++ b/erpnext/payroll/doctype/additional_salary/additional_salary.js @@ -8,8 +8,7 @@ frappe.ui.form.on('Additional Salary', { frm.set_query("employee", function() { return { filters: { - company: frm.doc.company, - status: "Active" + company: frm.doc.company } }; }); diff --git a/erpnext/payroll/doctype/additional_salary/additional_salary.py b/erpnext/payroll/doctype/additional_salary/additional_salary.py index e369ba7cef..ef174bdea2 100644 --- a/erpnext/payroll/doctype/additional_salary/additional_salary.py +++ b/erpnext/payroll/doctype/additional_salary/additional_salary.py @@ -33,12 +33,16 @@ class AdditionalSalary(Document): frappe.throw(_("From Date can not be greater than To Date.")) if date_of_joining: - if getdate(self.payroll_date) < getdate(date_of_joining): + if self.payroll_date and getdate(self.payroll_date) < getdate(date_of_joining): frappe.throw(_("Payroll date can not be less than employee's joining date.")) - elif getdate(self.from_date) < getdate(date_of_joining): + elif self.from_date and getdate(self.from_date) < getdate(date_of_joining): frappe.throw(_("From date can not be less than employee's joining date.")) - elif relieving_date and getdate(self.to_date) > getdate(relieving_date): + + if relieving_date: + if self.to_date and getdate(self.to_date) > getdate(relieving_date): frappe.throw(_("To date can not be greater than employee's relieving date.")) + if self.payroll_date and getdate(self.payroll_date) > getdate(relieving_date): + frappe.throw(_("Payroll date can not be greater than employee's relieving date.")) def get_amount(self, sal_start_date, sal_end_date): start_date = getdate(sal_start_date) @@ -107,4 +111,4 @@ def get_additional_salary_component(employee, start_date, end_date, component_ty existing_salary_components.append(d.salary_component) - return salary_components_details, additional_salary_details \ No newline at end of file + return salary_components_details, additional_salary_details From ff6ba25386609781d72f8d02c359cc93e9c4bbe8 Mon Sep 17 00:00:00 2001 From: Karthikeyan S Date: Thu, 16 Jul 2020 13:33:38 +0530 Subject: [PATCH 47/54] fix: remove FE validation for log_type field --- erpnext/hr/doctype/employee_checkin/employee_checkin.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/erpnext/hr/doctype/employee_checkin/employee_checkin.js b/erpnext/hr/doctype/employee_checkin/employee_checkin.js index 43023b6034..c2403ca2bd 100644 --- a/erpnext/hr/doctype/employee_checkin/employee_checkin.js +++ b/erpnext/hr/doctype/employee_checkin/employee_checkin.js @@ -6,9 +6,5 @@ frappe.ui.form.on('Employee Checkin', { if(!frm.doc.time) { frm.set_value("time", frappe.datetime.now_datetime()); } - }, - refresh: (frm) => { - // make log type mandatory - frm.set_df_property('log_type', 'reqd', frm.doc.log_type ? 0 : 1); } }); From 6319073d819e44d607e32c4d44a423e7603f5259 Mon Sep 17 00:00:00 2001 From: marination Date: Thu, 16 Jul 2020 15:38:51 +0530 Subject: [PATCH 48/54] fix: Move Issue List actions under 'Actions' dropdown --- erpnext/support/doctype/issue/issue_list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/support/doctype/issue/issue_list.js b/erpnext/support/doctype/issue/issue_list.js index 6d702f6bdf..513a8dca22 100644 --- a/erpnext/support/doctype/issue/issue_list.js +++ b/erpnext/support/doctype/issue/issue_list.js @@ -8,11 +8,11 @@ frappe.listview_settings['Issue'] = { var method = "erpnext.support.doctype.issue.issue.set_multiple_status"; - listview.page.add_menu_item(__("Set as Open"), function() { + listview.page.add_action_item(__("Set as Open"), function() { listview.call_for_selected_items(method, {"status": "Open"}); }); - listview.page.add_menu_item(__("Set as Closed"), function() { + listview.page.add_action_item(__("Set as Closed"), function() { listview.call_for_selected_items(method, {"status": "Closed"}); }); }, From d02465a68f788f33c3fbe6bdd122b1b841a9fcf1 Mon Sep 17 00:00:00 2001 From: michellealva Date: Fri, 17 Jul 2020 10:35:16 +0530 Subject: [PATCH 49/54] fix: Update modified timestamp for Delivery Note Item --- .../stock/doctype/delivery_note_item/delivery_note_item.json | 2 +- erpnext/www/book-appointment/__init__.py | 0 erpnext/www/book-appointment/verify/__init__.py | 0 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 erpnext/www/book-appointment/__init__.py create mode 100644 erpnext/www/book-appointment/verify/__init__.py diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json index 7c92ac7dbb..3d57f47601 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -720,7 +720,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2020-03-11 12:25:06.177894", + "modified": "2020-07-20 12:25:06.177894", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note Item", diff --git a/erpnext/www/book-appointment/__init__.py b/erpnext/www/book-appointment/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/www/book-appointment/verify/__init__.py b/erpnext/www/book-appointment/verify/__init__.py new file mode 100644 index 0000000000..e69de29bb2 From 188273564cc593d3bf991901a1606b18e8a5c8af Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 17 Jul 2020 11:31:15 +0530 Subject: [PATCH 50/54] fix: Multiple fixes in GST --- .../doctype/gstr_3b_report/gstr_3b_report.js | 5 +- .../doctype/gstr_3b_report/gstr_3b_report.py | 3 +- erpnext/regional/india/utils.py | 3 +- erpnext/regional/report/gstr_1/gstr_1.py | 10 ++-- erpnext/regional/report/gstr_2/gstr_2.py | 46 +++++++++---------- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js index 5170185158..c7442667c2 100644 --- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js +++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js @@ -3,6 +3,7 @@ frappe.ui.form.on('GSTR 3B Report', { refresh : function(frm) { + frm.doc.__unsaved = 1; if(!frm.is_new()) { frm.set_intro(__("Please save the report again to rebuild or update")); frm.add_custom_button(__('Download JSON'), function() { @@ -45,10 +46,6 @@ frappe.ui.form.on('GSTR 3B Report', { frm.set_df_property('year', 'options', options); }, - validate: function(frm) { - frm.dirty(); - }, - setup: function(frm) { frm.set_query('company_address', function(doc) { if(!doc.company) { diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py index 6d9b8dbe28..2d306ba172 100644 --- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py +++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py @@ -322,7 +322,7 @@ class GSTR3BReport(Document): inter_state_supply_tax_mapping[d.name]['samt'] += d.tax_amount if d.account_head in [d.igst_account for d in self.account_heads]: - inter_state_supply_tax_mapping[d.name]['samt'] += d.tax_amount + inter_state_supply_tax_mapping[d.name]['iamt'] += d.tax_amount if d.account_head in [d.cess_account for d in self.account_heads]: inter_state_supply_tax_mapping[d.name]['csamt'] += d.tax_amount @@ -331,6 +331,7 @@ class GSTR3BReport(Document): if d.place_of_supply: osup_det = self.report_dict["sup_details"]["osup_det"] osup_det["txval"] = flt(osup_det["txval"] + value['taxable_value'], 2) + osup_det["iamt"] = flt(osup_det["iamt"] + value['iamt'], 2) osup_det["camt"] = flt(osup_det["camt"] + value['camt'], 2) osup_det["samt"] = flt(osup_det["samt"] + value['samt'], 2) osup_det["csamt"] = flt(osup_det["csamt"] + value['csamt'], 2) diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index 7d10892c4a..fe7e0c807c 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -704,9 +704,10 @@ def update_totals(gst_tax, doc): doc.rounding_adjustment += flt(doc.rounded_total - doc.grand_total, doc.precision("rounding_adjustment")) - doc.outstanding_amount = doc.base_rounded_total + doc.outstanding_amount = doc.rounded_total or doc.grand_total doc.in_words = money_in_words(doc.grand_total, doc.currency) + doc.set_payment_schedule() def make_regional_gl_entries(gl_entries, doc): country = frappe.get_cached_value('Company', doc.company, 'country') diff --git a/erpnext/regional/report/gstr_1/gstr_1.py b/erpnext/regional/report/gstr_1/gstr_1.py index 43b1ea83eb..8885b88c2a 100644 --- a/erpnext/regional/report/gstr_1/gstr_1.py +++ b/erpnext/regional/report/gstr_1/gstr_1.py @@ -118,7 +118,7 @@ class Gstr1Report(object): row.append(invoice_details.get(fieldname)) taxable_value = 0 - if invoice in self.cgst_igst_invoices: + if invoice in self.cgst_sgst_invoices: division_factor = 2 else: division_factor = 1 @@ -129,6 +129,8 @@ class Gstr1Report(object): taxable_value += abs(net_amount) elif not self.item_tax_rate.get(invoice): taxable_value += abs(net_amount) + elif tax_rate: + taxable_value += abs(net_amount) row += [tax_rate or 0, taxable_value] @@ -227,7 +229,7 @@ class Gstr1Report(object): self.items_based_on_tax_rate = {} self.invoice_cess = frappe._dict() - self.cgst_igst_invoices = [] + self.cgst_sgst_invoices = [] unidentified_gst_accounts = [] for parent, account, item_wise_tax_detail, tax_amount in self.tax_details: @@ -251,8 +253,8 @@ class Gstr1Report(object): tax_rate = tax_amounts[0] if cgst_or_sgst: tax_rate *= 2 - if parent not in self.cgst_igst_invoices: - self.cgst_igst_invoices.append(parent) + if parent not in self.cgst_sgst_invoices: + self.cgst_sgst_invoices.append(parent) rate_based_dict = self.items_based_on_tax_rate\ .setdefault(parent, {}).setdefault(tax_rate, []) diff --git a/erpnext/regional/report/gstr_2/gstr_2.py b/erpnext/regional/report/gstr_2/gstr_2.py index f326fe07ca..f899349ccc 100644 --- a/erpnext/regional/report/gstr_2/gstr_2.py +++ b/erpnext/regional/report/gstr_2/gstr_2.py @@ -44,30 +44,30 @@ class Gstr2Report(Gstr1Report): for inv, items_based_on_rate in self.items_based_on_tax_rate.items(): invoice_details = self.invoices.get(inv) for rate, items in items_based_on_rate.items(): - if inv not in self.igst_invoices: - rate = rate / 2 - row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items) - tax_amount = taxable_value * rate / 100 - row += [0, tax_amount, tax_amount] - else: - row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items) - tax_amount = taxable_value * rate / 100 - row += [tax_amount, 0, 0] + if rate: + if inv not in self.igst_invoices: + rate = rate / 2 + row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items) + tax_amount = taxable_value * rate / 100 + row += [0, tax_amount, tax_amount] + else: + row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items) + tax_amount = taxable_value * rate / 100 + row += [tax_amount, 0, 0] + row += [ + self.invoice_cess.get(inv), + invoice_details.get('eligibility_for_itc'), + invoice_details.get('itc_integrated_tax'), + invoice_details.get('itc_central_tax'), + invoice_details.get('itc_state_tax'), + invoice_details.get('itc_cess_amount') + ] + if self.filters.get("type_of_business") == "CDNR": + row.append("Y" if invoice_details.posting_date <= date(2017, 7, 1) else "N") + row.append("C" if invoice_details.return_against else "R") - row += [ - self.invoice_cess.get(inv), - invoice_details.get('eligibility_for_itc'), - invoice_details.get('itc_integrated_tax'), - invoice_details.get('itc_central_tax'), - invoice_details.get('itc_state_tax'), - invoice_details.get('itc_cess_amount') - ] - if self.filters.get("type_of_business") == "CDNR": - row.append("Y" if invoice_details.posting_date <= date(2017, 7, 1) else "N") - row.append("C" if invoice_details.return_against else "R") - - self.data.append(row) + self.data.append(row) def get_igst_invoices(self): self.igst_invoices = [] @@ -86,7 +86,7 @@ class Gstr2Report(Gstr1Report): conditions += opts[1] if self.filters.get("type_of_business") == "B2B": - conditions += "and ifnull(gst_category, '') != 'Overseas' and is_return != 1 " + conditions += "and ifnull(gst_category, '') in ('Registered Regular', 'Deemed Export', 'SEZ') and is_return != 1 " elif self.filters.get("type_of_business") == "CDNR": conditions += """ and is_return = 1 """ From 9be6787b80ca51318e22024d385c8004feba13d4 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Fri, 17 Jul 2020 12:51:49 +0530 Subject: [PATCH 51/54] fix(maintenance-visit): change fieldtype of status to select --- .../doctype/maintenance_visit/maintenance_visit.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json index c797b7ea77..11925681df 100644 --- a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json +++ b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json @@ -701,7 +701,7 @@ "columns": 0, "default": "Draft", "fieldname": "status", - "fieldtype": "Data", + "fieldtype": "Select", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -1001,7 +1001,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-08-21 14:44:44.911402", + "modified": "2020-07-15 14:44:44.911402", "modified_by": "Administrator", "module": "Maintenance", "name": "Maintenance Visit", From 848568d023a0af96b3916d9600380f99c1b7fc4d Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 17 Jul 2020 11:24:40 +0530 Subject: [PATCH 52/54] fix: currency symbol not showing as per company currency in stock balance --- .../stock/report/stock_balance/stock_balance.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py index 74a4f6ef14..042087a4a7 100644 --- a/erpnext/stock/report/stock_balance/stock_balance.py +++ b/erpnext/stock/report/stock_balance/stock_balance.py @@ -2,7 +2,7 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe +import frappe, erpnext from frappe import _ from frappe.utils import flt, cint, getdate, now, date_diff from erpnext.stock.utils import add_additional_uom_columns @@ -20,6 +20,11 @@ def execute(filters=None): from_date = filters.get('from_date') to_date = filters.get('to_date') + if filters.get("company"): + company_currency = erpnext.get_company_currency(filters.get("company")) + else: + company_currency = frappe.db.get_single_value("Global Defaults", "default_currency") + include_uom = filters.get("include_uom") columns = get_columns(filters) items = get_items(filters) @@ -52,6 +57,7 @@ def execute(filters=None): item_reorder_qty = item_reorder_detail_map[item + warehouse]["warehouse_reorder_qty"] report_data = { + 'currency': company_currency, 'item_code': item, 'warehouse': warehouse, 'company': company, @@ -89,7 +95,6 @@ def execute(filters=None): def get_columns(filters): """return columns""" - columns = [ {"label": _("Item"), "fieldname": "item_code", "fieldtype": "Link", "options": "Item", "width": 100}, {"label": _("Item Name"), "fieldname": "item_name", "width": 150}, @@ -97,14 +102,14 @@ def get_columns(filters): {"label": _("Warehouse"), "fieldname": "warehouse", "fieldtype": "Link", "options": "Warehouse", "width": 100}, {"label": _("Stock UOM"), "fieldname": "stock_uom", "fieldtype": "Link", "options": "UOM", "width": 90}, {"label": _("Balance Qty"), "fieldname": "bal_qty", "fieldtype": "Float", "width": 100, "convertible": "qty"}, - {"label": _("Balance Value"), "fieldname": "bal_val", "fieldtype": "Currency", "width": 100}, + {"label": _("Balance Value"), "fieldname": "bal_val", "fieldtype": "Currency", "width": 100, "options": "currency"}, {"label": _("Opening Qty"), "fieldname": "opening_qty", "fieldtype": "Float", "width": 100, "convertible": "qty"}, - {"label": _("Opening Value"), "fieldname": "opening_val", "fieldtype": "Float", "width": 110}, + {"label": _("Opening Value"), "fieldname": "opening_val", "fieldtype": "Currency", "width": 110, "options": "currency"}, {"label": _("In Qty"), "fieldname": "in_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"}, {"label": _("In Value"), "fieldname": "in_val", "fieldtype": "Float", "width": 80}, {"label": _("Out Qty"), "fieldname": "out_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"}, {"label": _("Out Value"), "fieldname": "out_val", "fieldtype": "Float", "width": 80}, - {"label": _("Valuation Rate"), "fieldname": "val_rate", "fieldtype": "Currency", "width": 90, "convertible": "rate"}, + {"label": _("Valuation Rate"), "fieldname": "val_rate", "fieldtype": "Currency", "width": 90, "convertible": "rate", "options": "currency"}, {"label": _("Reorder Level"), "fieldname": "reorder_level", "fieldtype": "Float", "width": 80, "convertible": "qty"}, {"label": _("Reorder Qty"), "fieldname": "reorder_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"}, {"label": _("Company"), "fieldname": "company", "fieldtype": "Link", "options": "Company", "width": 100} From 2347e69cb973112153acbc8336e42d89c29f6924 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 16 Jul 2020 22:13:00 +0530 Subject: [PATCH 53/54] fix: for past dated stock reco, batched item showing the current available qty instead of quantity as per posting date --- erpnext/stock/doctype/batch/batch.py | 9 +++++++-- .../stock_reconciliation/stock_reconciliation.js | 14 ++++++++++++++ .../stock_reconciliation/stock_reconciliation.py | 12 ++++++++++-- erpnext/stock/report/stock_ledger/stock_ledger.py | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index a091ac7fae..c8424f13e1 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -143,7 +143,7 @@ class Batch(Document): @frappe.whitelist() -def get_batch_qty(batch_no=None, warehouse=None, item_code=None): +def get_batch_qty(batch_no=None, warehouse=None, item_code=None, posting_date=None, posting_time=None): """Returns batch actual qty if warehouse is passed, or returns dict of qty by warehouse if warehouse is None @@ -155,9 +155,14 @@ def get_batch_qty(batch_no=None, warehouse=None, item_code=None): out = 0 if batch_no and warehouse: + cond = "" + if posting_date and posting_time: + cond = " and timestamp(posting_date, posting_time) <= timestamp('{0}', '{1}')".format(posting_date, + posting_time) + out = float(frappe.db.sql("""select sum(actual_qty) from `tabStock Ledger Entry` - where warehouse=%s and batch_no=%s""", + where warehouse=%s and batch_no=%s {0}""".format(cond), (warehouse, batch_no))[0][0] or 0) if batch_no and not warehouse: diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index dd284e4a96..ecee97ce86 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -74,6 +74,20 @@ frappe.ui.form.on("Stock Reconciliation", { , __("Get Items"), __("Update")); }, + posting_date: function(frm) { + frm.trigger("set_valuation_rate_and_qty_for_all_items"); + }, + + posting_time: function(frm) { + frm.trigger("set_valuation_rate_and_qty_for_all_items"); + }, + + set_valuation_rate_and_qty_for_all_items: function(frm) { + frm.doc.items.forEach(row => { + frm.events.set_valuation_rate_and_qty(frm, row.doctype, row.name); + }); + }, + set_valuation_rate_and_qty: function(frm, cdt, cdn) { var d = frappe.model.get_doc(cdt, cdn); diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 5e469c24d7..43fbc00466 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -184,8 +184,12 @@ class StockReconciliation(StockController): sl_entries = [] has_serial_no = False + has_batch_no = False for row in self.items: item = frappe.get_doc("Item", row.item_code) + if item.has_batch_no: + has_batch_no = True + if item.has_serial_no or item.has_batch_no: has_serial_no = True self.get_sle_for_serialized_items(row, sl_entries) @@ -222,7 +226,11 @@ class StockReconciliation(StockController): if has_serial_no: sl_entries = self.merge_similar_item_serial_nos(sl_entries) - self.make_sl_entries(sl_entries) + allow_negative_stock = False + if has_batch_no: + allow_negative_stock = True + + self.make_sl_entries(sl_entries, allow_negative_stock=allow_negative_stock) if has_serial_no and sl_entries: self.update_valuation_rate_for_serial_no() @@ -493,7 +501,7 @@ def get_stock_balance_for(item_code, warehouse, qty, rate = data if item_dict.get("has_batch_no"): - qty = get_batch_qty(batch_no, warehouse) or 0 + qty = get_batch_qty(batch_no, warehouse, posting_date=posting_date, posting_time=posting_time) or 0 return { 'qty': qty, diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py index a5f92e2c76..fe8ad71b73 100644 --- a/erpnext/stock/report/stock_ledger/stock_ledger.py +++ b/erpnext/stock/report/stock_ledger/stock_ledger.py @@ -33,7 +33,7 @@ def execute(filters=None): actual_qty += flt(sle.actual_qty, precision) stock_value += sle.stock_value_difference - if sle.voucher_type == 'Stock Reconciliation': + if sle.voucher_type == 'Stock Reconciliation' and not sle.actual_qty: actual_qty = sle.qty_after_transaction stock_value = sle.stock_value From 07f8e749be0ad5562f9944991c45dea30ebf4582 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 18 Jul 2020 19:47:33 +0530 Subject: [PATCH 54/54] fix: Period list api changes for custom cash flow report --- erpnext/accounts/report/cash_flow/custom_cash_flow.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/report/cash_flow/custom_cash_flow.py b/erpnext/accounts/report/cash_flow/custom_cash_flow.py index 8566f5375a..fe2bc725e0 100644 --- a/erpnext/accounts/report/cash_flow/custom_cash_flow.py +++ b/erpnext/accounts/report/cash_flow/custom_cash_flow.py @@ -334,10 +334,9 @@ def compute_data(filters, company_currency, profit_data, period_list, light_mapp def execute(filters=None): if not filters.periodicity: filters.periodicity = "Monthly" - period_list = get_period_list( - filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, - filters.accumulated_values, filters.company - ) + period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, + filters.period_start_date, filters.period_end_date, filters.filter_based_on, + filters.periodicity, company=filters.company) mappers = get_mappers_from_db() @@ -396,7 +395,7 @@ def _get_account_type_based_data(filters, account_names, period_list, accumulate gl_sum = frappe.db.sql_list(""" select sum(credit) - sum(debit) from `tabGL Entry` - where company=%s and posting_date >= %s and posting_date <= %s + where company=%s and posting_date >= %s and posting_date <= %s and voucher_type != 'Period Closing Voucher' and account in ( SELECT name FROM tabAccount WHERE name IN (%s) OR parent_account IN (%s)) @@ -405,7 +404,7 @@ def _get_account_type_based_data(filters, account_names, period_list, accumulate gl_sum = frappe.db.sql_list(""" select sum(credit) - sum(debit) from `tabGL Entry` - where company=%s and posting_date >= %s and posting_date <= %s + where company=%s and posting_date >= %s and posting_date <= %s and voucher_type != 'Period Closing Voucher' and account in ( SELECT name FROM tabAccount WHERE name IN (%s) OR parent_account IN (%s))