Merge branch 'develop' into project-link-for-all-accounts
diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
index 4ff4212..d2f7de3 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/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
index 2473d71..5593466 100644
--- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
+++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
@@ -20,7 +20,6 @@
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 @@
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/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index 14d0531..c0aac18 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -75,12 +75,6 @@
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/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py
index 6996c77..23ad1ee 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 @@
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,45 @@
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_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'
+ })
- def test_jv_account_and_party_balance_for_enable_allow_cost_center_in_entry_of_bs_account(self):
+ 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
- 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 +288,6 @@
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/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index a453e95..ed9ed01 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -6,7 +6,7 @@
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
@@ -602,7 +602,7 @@
.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 = {
diff --git a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py
index a25e0e3..afa58c3 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 @@
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 @@
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 @@
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 @@
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/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 3cd988c..8c4fad5 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 0283d30..0d0516e 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -463,7 +463,8 @@
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)
)
@@ -503,6 +504,7 @@
"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))
@@ -512,6 +514,7 @@
"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))
@@ -535,7 +538,7 @@
"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)
)
@@ -548,7 +551,7 @@
"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
@@ -561,6 +564,7 @@
"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))
@@ -579,7 +583,7 @@
"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
@@ -592,7 +596,7 @@
"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({
@@ -601,7 +605,7 @@
"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
@@ -627,7 +631,8 @@
"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)
)
@@ -656,7 +661,8 @@
"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:
@@ -666,6 +672,7 @@
"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
@@ -682,7 +689,8 @@
"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)):
@@ -693,6 +701,7 @@
"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)
@@ -708,7 +717,7 @@
"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({
@@ -717,7 +726,7 @@
"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
@@ -752,7 +761,7 @@
"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)
)
@@ -844,7 +853,8 @@
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)
)
@@ -876,7 +886,8 @@
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/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index e41ad42..af0eddf 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 @@
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 @@
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")
@@ -849,7 +840,45 @@
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/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
index 9c97426..5e073f8 100644
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
@@ -777,7 +777,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2020-04-01 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/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 82aedb6..be7b57b 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -790,7 +790,8 @@
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)
)
@@ -845,7 +846,8 @@
"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)
)
@@ -926,7 +928,8 @@
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)
)
@@ -959,7 +962,8 @@
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/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 0e54b62..2692465 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 @@
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")
@@ -1662,14 +1659,47 @@
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
- accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
- accounts_settings.save()
+ 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'
+ })
- 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()
+ 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"
si = create_sales_invoice(debit_to="Debtors - _TC")
@@ -1692,9 +1722,6 @@
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/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
index b2294e4..9bc2466 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 4789063..4f4c086 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -124,14 +124,12 @@
# 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 @@
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/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py
index 522c1fe..ad671ba 100644
--- a/erpnext/assets/doctype/asset/depreciation.py
+++ b/erpnext/assets/doctype/asset/depreciation.py
@@ -10,7 +10,7 @@
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:
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 4037f2f..2f276a6 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -92,6 +92,7 @@
"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",
@@ -102,6 +103,7 @@
"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/crm/doctype/opportunity/test_records.json b/erpnext/crm/doctype/opportunity/test_records.json
index a1e0ad9..0a6c29b 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 2087f49..224dc8d 100644
--- a/erpnext/healthcare/setup.py
+++ b/erpnext/healthcare/setup.py
@@ -198,7 +198,8 @@
{
"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 25730f9..3913268 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/projects/doctype/project/test_project.py b/erpnext/projects/doctype/project/test_project.py
index 06c62b6..0c4f6f1 100644
--- a/erpnext/projects/doctype/project/test_project.py
+++ b/erpnext/projects/doctype/project/test_project.py
@@ -7,7 +7,7 @@
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 @@
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 efcb2ea..2c5831a 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 @@
]
)).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
diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py
index e4986e3..6e7fc32 100644
--- a/erpnext/setup/setup_wizard/operations/install_fixtures.py
+++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py
@@ -436,7 +436,6 @@
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/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
index 47a72b2..c15fada 100644
--- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
@@ -557,11 +557,8 @@
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")
@@ -587,13 +584,8 @@
}
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/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
index 782ac84..475a819 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 e38bb38..6d68b50 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",
@@ -106,6 +105,7 @@
"amended_from",
"range",
"column_break4",
+ "project",
"per_billed",
"is_internal_supplier",
"inter_company_reference",
@@ -927,6 +927,12 @@
"width": "50%"
},
{
+ "fieldname": "project",
+ "fieldtype": "Link",
+ "label": "Project",
+ "options": "Project"
+ },
+ {
"fieldname": "per_billed",
"fieldtype": "Percent",
"label": "% Amount Billed",
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index 113da9f..9d41b45 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -403,11 +403,8 @@
pr_return.submit()
- 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")
@@ -435,14 +432,7 @@
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',