fix: Project link not set in accounts other than profit and loss accounts (#22049)
* fix: project link not set in accounts other than profilt and loss accounts * fix: cannot find get_allow_cost_center_in_entry_of_bs_account * fix: remove enable_allow_cost_center_in_entry_of_bs_account * chore: add tests and remove test based on allow_cost_center_for_bs_accounts * fix: travis * fix: Test Cases * fix: Patch to remove Property Setter * fix: Test Cases * fix: Remove v13 patch * fix: Procurement Tracker test case * fix: Proccurement tracker report test * fix: Codacy * fix: Remove duplicate project field Co-authored-by: Saqib Ansari <nextchamp.saqib@gmail.com> Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -1,210 +1,210 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-06-24 15:49:57",
|
"creation": "2013-06-24 15:49:57",
|
||||||
"description": "Settings for Accounts",
|
"description": "Settings for Accounts",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "Other",
|
"document_type": "Other",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"auto_accounting_for_stock",
|
"auto_accounting_for_stock",
|
||||||
"acc_frozen_upto",
|
"acc_frozen_upto",
|
||||||
"frozen_accounts_modifier",
|
"frozen_accounts_modifier",
|
||||||
"determine_address_tax_category_from",
|
"determine_address_tax_category_from",
|
||||||
"over_billing_allowance",
|
"over_billing_allowance",
|
||||||
"column_break_4",
|
"column_break_4",
|
||||||
"credit_controller",
|
"credit_controller",
|
||||||
"check_supplier_invoice_uniqueness",
|
"check_supplier_invoice_uniqueness",
|
||||||
"make_payment_via_journal_entry",
|
"make_payment_via_journal_entry",
|
||||||
"unlink_payment_on_cancellation_of_invoice",
|
"unlink_payment_on_cancellation_of_invoice",
|
||||||
"unlink_advance_payment_on_cancelation_of_order",
|
"unlink_advance_payment_on_cancelation_of_order",
|
||||||
"book_asset_depreciation_entry_automatically",
|
"book_asset_depreciation_entry_automatically",
|
||||||
"allow_cost_center_in_entry_of_bs_account",
|
"add_taxes_from_item_tax_template",
|
||||||
"add_taxes_from_item_tax_template",
|
"automatically_fetch_payment_terms",
|
||||||
"automatically_fetch_payment_terms",
|
"print_settings",
|
||||||
"print_settings",
|
"show_inclusive_tax_in_print",
|
||||||
"show_inclusive_tax_in_print",
|
"column_break_12",
|
||||||
"column_break_12",
|
"show_payment_schedule_in_print",
|
||||||
"show_payment_schedule_in_print",
|
"currency_exchange_section",
|
||||||
"currency_exchange_section",
|
"allow_stale",
|
||||||
"allow_stale",
|
"stale_days",
|
||||||
"stale_days",
|
"report_settings_sb",
|
||||||
"report_settings_sb",
|
"use_custom_cash_flow"
|
||||||
"use_custom_cash_flow"
|
],
|
||||||
],
|
"fields": [
|
||||||
"fields": [
|
{
|
||||||
{
|
"default": "1",
|
||||||
"default": "1",
|
"description": "If enabled, the system will post accounting entries for inventory automatically.",
|
||||||
"description": "If enabled, the system will post accounting entries for inventory automatically.",
|
"fieldname": "auto_accounting_for_stock",
|
||||||
"fieldname": "auto_accounting_for_stock",
|
"fieldtype": "Check",
|
||||||
"fieldtype": "Check",
|
"hidden": 1,
|
||||||
"hidden": 1,
|
"in_list_view": 1,
|
||||||
"in_list_view": 1,
|
"label": "Make Accounting Entry For Every Stock Movement"
|
||||||
"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.",
|
||||||
"description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.",
|
"fieldname": "acc_frozen_upto",
|
||||||
"fieldname": "acc_frozen_upto",
|
"fieldtype": "Date",
|
||||||
"fieldtype": "Date",
|
"in_list_view": 1,
|
||||||
"in_list_view": 1,
|
"label": "Accounts Frozen Upto"
|
||||||
"label": "Accounts Frozen Upto"
|
},
|
||||||
},
|
{
|
||||||
{
|
"description": "Users with this role are allowed to set frozen accounts and create / modify accounting entries against frozen accounts",
|
||||||
"description": "Users with this role are allowed to set frozen accounts and create / modify accounting entries against frozen accounts",
|
"fieldname": "frozen_accounts_modifier",
|
||||||
"fieldname": "frozen_accounts_modifier",
|
"fieldtype": "Link",
|
||||||
"fieldtype": "Link",
|
"in_list_view": 1,
|
||||||
"in_list_view": 1,
|
"label": "Role Allowed to Set Frozen Accounts & Edit Frozen Entries",
|
||||||
"label": "Role Allowed to Set Frozen Accounts & Edit Frozen Entries",
|
"options": "Role"
|
||||||
"options": "Role"
|
},
|
||||||
},
|
{
|
||||||
{
|
"default": "Billing Address",
|
||||||
"default": "Billing Address",
|
"description": "Address used to determine Tax Category in transactions.",
|
||||||
"description": "Address used to determine Tax Category in transactions.",
|
"fieldname": "determine_address_tax_category_from",
|
||||||
"fieldname": "determine_address_tax_category_from",
|
"fieldtype": "Select",
|
||||||
"fieldtype": "Select",
|
"label": "Determine Address Tax Category From",
|
||||||
"label": "Determine Address Tax Category From",
|
"options": "Billing Address\nShipping Address"
|
||||||
"options": "Billing Address\nShipping Address"
|
},
|
||||||
},
|
{
|
||||||
{
|
"fieldname": "column_break_4",
|
||||||
"fieldname": "column_break_4",
|
"fieldtype": "Column Break"
|
||||||
"fieldtype": "Column Break"
|
},
|
||||||
},
|
{
|
||||||
{
|
"description": "Role that is allowed to submit transactions that exceed credit limits set.",
|
||||||
"description": "Role that is allowed to submit transactions that exceed credit limits set.",
|
"fieldname": "credit_controller",
|
||||||
"fieldname": "credit_controller",
|
"fieldtype": "Link",
|
||||||
"fieldtype": "Link",
|
"in_list_view": 1,
|
||||||
"in_list_view": 1,
|
"label": "Credit Controller",
|
||||||
"label": "Credit Controller",
|
"options": "Role"
|
||||||
"options": "Role"
|
},
|
||||||
},
|
{
|
||||||
{
|
"default": "0",
|
||||||
"fieldname": "check_supplier_invoice_uniqueness",
|
"fieldname": "check_supplier_invoice_uniqueness",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Check Supplier Invoice Number Uniqueness"
|
"label": "Check Supplier Invoice Number Uniqueness"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "make_payment_via_journal_entry",
|
"default": "0",
|
||||||
"fieldtype": "Check",
|
"fieldname": "make_payment_via_journal_entry",
|
||||||
"label": "Make Payment via Journal Entry"
|
"fieldtype": "Check",
|
||||||
},
|
"label": "Make Payment via Journal Entry"
|
||||||
{
|
},
|
||||||
"default": "1",
|
{
|
||||||
"fieldname": "unlink_payment_on_cancellation_of_invoice",
|
"default": "1",
|
||||||
"fieldtype": "Check",
|
"fieldname": "unlink_payment_on_cancellation_of_invoice",
|
||||||
"label": "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",
|
"default": "1",
|
||||||
"fieldtype": "Check",
|
"fieldname": "unlink_advance_payment_on_cancelation_of_order",
|
||||||
"label": "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",
|
"default": "1",
|
||||||
"fieldtype": "Check",
|
"fieldname": "book_asset_depreciation_entry_automatically",
|
||||||
"label": "Book Asset Depreciation Entry Automatically"
|
"fieldtype": "Check",
|
||||||
},
|
"label": "Book Asset Depreciation Entry Automatically"
|
||||||
{
|
},
|
||||||
"fieldname": "allow_cost_center_in_entry_of_bs_account",
|
{
|
||||||
"fieldtype": "Check",
|
"default": "1",
|
||||||
"label": "Allow Cost Center In Entry of Balance Sheet Account"
|
"fieldname": "add_taxes_from_item_tax_template",
|
||||||
},
|
"fieldtype": "Check",
|
||||||
{
|
"label": "Automatically Add Taxes and Charges from Item Tax Template"
|
||||||
"default": "1",
|
},
|
||||||
"fieldname": "add_taxes_from_item_tax_template",
|
{
|
||||||
"fieldtype": "Check",
|
"fieldname": "print_settings",
|
||||||
"label": "Automatically Add Taxes and Charges from Item Tax Template"
|
"fieldtype": "Section Break",
|
||||||
},
|
"label": "Print Settings"
|
||||||
{
|
},
|
||||||
"fieldname": "print_settings",
|
{
|
||||||
"fieldtype": "Section Break",
|
"default": "0",
|
||||||
"label": "Print Settings"
|
"fieldname": "show_inclusive_tax_in_print",
|
||||||
},
|
"fieldtype": "Check",
|
||||||
{
|
"label": "Show Inclusive Tax In Print"
|
||||||
"fieldname": "show_inclusive_tax_in_print",
|
},
|
||||||
"fieldtype": "Check",
|
{
|
||||||
"label": "Show Inclusive Tax In Print"
|
"fieldname": "column_break_12",
|
||||||
},
|
"fieldtype": "Column Break"
|
||||||
{
|
},
|
||||||
"fieldname": "column_break_12",
|
{
|
||||||
"fieldtype": "Column Break"
|
"default": "0",
|
||||||
},
|
"fieldname": "show_payment_schedule_in_print",
|
||||||
{
|
"fieldtype": "Check",
|
||||||
"fieldname": "show_payment_schedule_in_print",
|
"label": "Show Payment Schedule in Print"
|
||||||
"fieldtype": "Check",
|
},
|
||||||
"label": "Show Payment Schedule in Print"
|
{
|
||||||
},
|
"fieldname": "currency_exchange_section",
|
||||||
{
|
"fieldtype": "Section Break",
|
||||||
"fieldname": "currency_exchange_section",
|
"label": "Currency Exchange Settings"
|
||||||
"fieldtype": "Section Break",
|
},
|
||||||
"label": "Currency Exchange Settings"
|
{
|
||||||
},
|
"default": "1",
|
||||||
{
|
"fieldname": "allow_stale",
|
||||||
"default": "1",
|
"fieldtype": "Check",
|
||||||
"fieldname": "allow_stale",
|
"in_list_view": 1,
|
||||||
"fieldtype": "Check",
|
"label": "Allow Stale Exchange Rates"
|
||||||
"in_list_view": 1,
|
},
|
||||||
"label": "Allow Stale Exchange Rates"
|
{
|
||||||
},
|
"default": "1",
|
||||||
{
|
"depends_on": "eval:doc.allow_stale==0",
|
||||||
"default": "1",
|
"fieldname": "stale_days",
|
||||||
"depends_on": "eval:doc.allow_stale==0",
|
"fieldtype": "Int",
|
||||||
"fieldname": "stale_days",
|
"label": "Stale Days"
|
||||||
"fieldtype": "Int",
|
},
|
||||||
"label": "Stale Days"
|
{
|
||||||
},
|
"fieldname": "report_settings_sb",
|
||||||
{
|
"fieldtype": "Section Break",
|
||||||
"fieldname": "report_settings_sb",
|
"label": "Report Settings"
|
||||||
"fieldtype": "Section Break",
|
},
|
||||||
"label": "Report Settings"
|
{
|
||||||
},
|
"default": "0",
|
||||||
{
|
"description": "Only select if you have setup Cash Flow Mapper documents",
|
||||||
"default": "0",
|
"fieldname": "use_custom_cash_flow",
|
||||||
"description": "Only select if you have setup Cash Flow Mapper documents",
|
"fieldtype": "Check",
|
||||||
"fieldname": "use_custom_cash_flow",
|
"label": "Use Custom Cash Flow Format"
|
||||||
"fieldtype": "Check",
|
},
|
||||||
"label": "Use Custom Cash Flow Format"
|
{
|
||||||
},
|
"default": "0",
|
||||||
{
|
"fieldname": "automatically_fetch_payment_terms",
|
||||||
"fieldname": "automatically_fetch_payment_terms",
|
"fieldtype": "Check",
|
||||||
"fieldtype": "Check",
|
"label": "Automatically Fetch Payment Terms"
|
||||||
"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.",
|
||||||
"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",
|
||||||
"fieldname": "over_billing_allowance",
|
"fieldtype": "Currency",
|
||||||
"fieldtype": "Currency",
|
"label": "Over Billing Allowance (%)"
|
||||||
"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
|
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"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
|
||||||
|
}
|
||||||
@@ -20,7 +20,6 @@ class AccountsSettings(Document):
|
|||||||
|
|
||||||
self.validate_stale_days()
|
self.validate_stale_days()
|
||||||
self.enable_payment_schedule_in_print()
|
self.enable_payment_schedule_in_print()
|
||||||
self.enable_fields_for_cost_center_settings()
|
|
||||||
|
|
||||||
def validate_stale_days(self):
|
def validate_stale_days(self):
|
||||||
if not self.allow_stale and cint(self.stale_days) <= 0:
|
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"):
|
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, "due_date", "print_hide", show_in_print, "Check")
|
||||||
make_property_setter(doctype, "payment_schedule", "print_hide", 0 if show_in_print else 1, "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")
|
|
||||||
|
|||||||
@@ -75,12 +75,6 @@ class GLEntry(Document):
|
|||||||
if not self.cost_center and self.voucher_type != 'Period Closing Voucher':
|
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.")
|
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))
|
.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):
|
def validate_dimensions_for_pl_and_bs(self):
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, json
|
import frappe, json, erpnext
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import flt, getdate, nowdate, add_days
|
from frappe.utils import flt, getdate, nowdate, add_days
|
||||||
from erpnext.controllers.accounts_controller import AccountsController
|
from erpnext.controllers.accounts_controller import AccountsController
|
||||||
@@ -134,16 +134,19 @@ class InvoiceDiscounting(AccountsController):
|
|||||||
je.append("accounts", {
|
je.append("accounts", {
|
||||||
"account": self.bank_account,
|
"account": self.bank_account,
|
||||||
"debit_in_account_currency": flt(self.total_amount) - flt(self.bank_charges),
|
"debit_in_account_currency": flt(self.total_amount) - flt(self.bank_charges),
|
||||||
|
"cost_center": erpnext.get_default_cost_center(self.company)
|
||||||
})
|
})
|
||||||
|
|
||||||
je.append("accounts", {
|
je.append("accounts", {
|
||||||
"account": self.bank_charges_account,
|
"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", {
|
je.append("accounts", {
|
||||||
"account": self.short_term_loan,
|
"account": self.short_term_loan,
|
||||||
"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),
|
||||||
"reference_type": "Invoice Discounting",
|
"reference_type": "Invoice Discounting",
|
||||||
"reference_name": self.name
|
"reference_name": self.name
|
||||||
})
|
})
|
||||||
@@ -151,6 +154,7 @@ class InvoiceDiscounting(AccountsController):
|
|||||||
je.append("accounts", {
|
je.append("accounts", {
|
||||||
"account": self.accounts_receivable_discounted,
|
"account": self.accounts_receivable_discounted,
|
||||||
"debit_in_account_currency": flt(d.outstanding_amount),
|
"debit_in_account_currency": flt(d.outstanding_amount),
|
||||||
|
"cost_center": erpnext.get_default_cost_center(self.company),
|
||||||
"reference_type": "Invoice Discounting",
|
"reference_type": "Invoice Discounting",
|
||||||
"reference_name": self.name,
|
"reference_name": self.name,
|
||||||
"party_type": "Customer",
|
"party_type": "Customer",
|
||||||
@@ -160,6 +164,7 @@ class InvoiceDiscounting(AccountsController):
|
|||||||
je.append("accounts", {
|
je.append("accounts", {
|
||||||
"account": self.accounts_receivable_credit,
|
"account": self.accounts_receivable_credit,
|
||||||
"credit_in_account_currency": flt(d.outstanding_amount),
|
"credit_in_account_currency": flt(d.outstanding_amount),
|
||||||
|
"cost_center": erpnext.get_default_cost_center(self.company),
|
||||||
"reference_type": "Invoice Discounting",
|
"reference_type": "Invoice Discounting",
|
||||||
"reference_name": self.name,
|
"reference_name": self.name,
|
||||||
"party_type": "Customer",
|
"party_type": "Customer",
|
||||||
@@ -177,13 +182,15 @@ class InvoiceDiscounting(AccountsController):
|
|||||||
je.append("accounts", {
|
je.append("accounts", {
|
||||||
"account": self.short_term_loan,
|
"account": self.short_term_loan,
|
||||||
"debit_in_account_currency": flt(self.total_amount),
|
"debit_in_account_currency": flt(self.total_amount),
|
||||||
|
"cost_center": erpnext.get_default_cost_center(self.company),
|
||||||
"reference_type": "Invoice Discounting",
|
"reference_type": "Invoice Discounting",
|
||||||
"reference_name": self.name,
|
"reference_name": self.name,
|
||||||
})
|
})
|
||||||
|
|
||||||
je.append("accounts", {
|
je.append("accounts", {
|
||||||
"account": self.bank_account,
|
"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()):
|
if getdate(self.loan_end_date) > getdate(nowdate()):
|
||||||
@@ -193,6 +200,7 @@ class InvoiceDiscounting(AccountsController):
|
|||||||
je.append("accounts", {
|
je.append("accounts", {
|
||||||
"account": self.accounts_receivable_discounted,
|
"account": self.accounts_receivable_discounted,
|
||||||
"credit_in_account_currency": flt(outstanding_amount),
|
"credit_in_account_currency": flt(outstanding_amount),
|
||||||
|
"cost_center": erpnext.get_default_cost_center(self.company),
|
||||||
"reference_type": "Invoice Discounting",
|
"reference_type": "Invoice Discounting",
|
||||||
"reference_name": self.name,
|
"reference_name": self.name,
|
||||||
"party_type": "Customer",
|
"party_type": "Customer",
|
||||||
@@ -202,6 +210,7 @@ class InvoiceDiscounting(AccountsController):
|
|||||||
je.append("accounts", {
|
je.append("accounts", {
|
||||||
"account": self.accounts_receivable_unpaid,
|
"account": self.accounts_receivable_unpaid,
|
||||||
"debit_in_account_currency": flt(outstanding_amount),
|
"debit_in_account_currency": flt(outstanding_amount),
|
||||||
|
"cost_center": erpnext.get_default_cost_center(self.company),
|
||||||
"reference_type": "Invoice Discounting",
|
"reference_type": "Invoice Discounting",
|
||||||
"reference_name": self.name,
|
"reference_name": self.name,
|
||||||
"party_type": "Customer",
|
"party_type": "Customer",
|
||||||
|
|||||||
@@ -204,11 +204,8 @@ class TestJournalEntry(unittest.TestCase):
|
|||||||
self.assertEqual(jv.inter_company_journal_entry_reference, "")
|
self.assertEqual(jv.inter_company_journal_entry_reference, "")
|
||||||
self.assertEqual(jv1.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
|
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"
|
cost_center = "_Test Cost Center for BS Account - _TC"
|
||||||
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
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)
|
jv = make_journal_entry("_Test Cash - _TC", "_Test Bank - _TC", 100, cost_center = cost_center, save=False)
|
||||||
@@ -237,15 +234,45 @@ class TestJournalEntry(unittest.TestCase):
|
|||||||
for gle in gl_entries:
|
for gle in gl_entries:
|
||||||
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
||||||
|
|
||||||
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
|
def test_jv_with_project(self):
|
||||||
accounts_settings.save()
|
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.doctype.cost_center.test_cost_center import create_cost_center
|
||||||
from erpnext.accounts.utils import get_balance_on
|
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"
|
cost_center = "_Test Cost Center for BS Account - _TC"
|
||||||
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
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)
|
jv = make_journal_entry("_Test Cash - _TC", "_Test Bank - _TC", 100, cost_center = cost_center, save=False)
|
||||||
@@ -261,9 +288,6 @@ class TestJournalEntry(unittest.TestCase):
|
|||||||
account_balance = get_balance_on(account="_Test Bank - _TC", cost_center=cost_center)
|
account_balance = get_balance_on(account="_Test Bank - _TC", cost_center=cost_center)
|
||||||
self.assertEqual(expected_account_balance, account_balance)
|
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):
|
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:
|
if not cost_center:
|
||||||
cost_center = "_Test Cost Center - _TC"
|
cost_center = "_Test Cost Center - _TC"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe, erpnext, json
|
import frappe, erpnext, json
|
||||||
from frappe import _, scrub, ValidationError
|
from frappe import _, scrub, ValidationError
|
||||||
from frappe.utils import flt, comma_or, nowdate, getdate
|
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.party import get_party_account
|
||||||
from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account
|
from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account
|
||||||
from erpnext.setup.utils import get_exchange_rate
|
from erpnext.setup.utils import get_exchange_rate
|
||||||
@@ -657,7 +657,7 @@ def get_outstanding_reference_documents(args):
|
|||||||
.format(frappe.db.escape(args["voucher_type"]), frappe.db.escape(args["voucher_no"]))
|
.format(frappe.db.escape(args["voucher_type"]), frappe.db.escape(args["voucher_no"]))
|
||||||
|
|
||||||
# Add cost center condition
|
# 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")
|
condition += " and cost_center='%s'" % args.get("cost_center")
|
||||||
|
|
||||||
date_fields_dict = {
|
date_fields_dict = {
|
||||||
|
|||||||
@@ -462,11 +462,8 @@ class TestPaymentEntry(unittest.TestCase):
|
|||||||
outstanding_amount = flt(frappe.db.get_value("Sales Invoice", si.name, "outstanding_amount"))
|
outstanding_amount = flt(frappe.db.get_value("Sales Invoice", si.name, "outstanding_amount"))
|
||||||
self.assertEqual(outstanding_amount, 0)
|
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
|
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"
|
cost_center = "_Test Cost Center for BS Account - _TC"
|
||||||
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
||||||
|
|
||||||
@@ -501,39 +498,8 @@ class TestPaymentEntry(unittest.TestCase):
|
|||||||
for gle in gl_entries:
|
for gle in gl_entries:
|
||||||
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
||||||
|
|
||||||
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
|
def test_payment_entry_against_purchase_invoice_with_cost_center(self):
|
||||||
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):
|
|
||||||
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
|
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"
|
cost_center = "_Test Cost Center for BS Account - _TC"
|
||||||
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
||||||
|
|
||||||
@@ -568,40 +534,9 @@ class TestPaymentEntry(unittest.TestCase):
|
|||||||
for gle in gl_entries:
|
for gle in gl_entries:
|
||||||
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
||||||
|
|
||||||
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
|
def test_payment_entry_account_and_party_balance_with_cost_center(self):
|
||||||
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):
|
|
||||||
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
|
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
|
||||||
from erpnext.accounts.utils import get_balance_on
|
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"
|
cost_center = "_Test Cost Center for BS Account - _TC"
|
||||||
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
||||||
|
|
||||||
@@ -632,9 +567,6 @@ class TestPaymentEntry(unittest.TestCase):
|
|||||||
self.assertEqual(expected_party_balance, party_balance)
|
self.assertEqual(expected_party_balance, party_balance)
|
||||||
self.assertEqual(expected_party_account_balance, party_account_balance)
|
self.assertEqual(expected_party_account_balance, party_account_balance)
|
||||||
|
|
||||||
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
|
|
||||||
accounts_settings.save()
|
|
||||||
|
|
||||||
def create_payment_terms_template():
|
def create_payment_terms_template():
|
||||||
|
|
||||||
create_payment_term('Basic Amount Receivable')
|
create_payment_term('Basic Amount Receivable')
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
"accounting_dimensions_section",
|
"accounting_dimensions_section",
|
||||||
"cost_center",
|
"cost_center",
|
||||||
"dimension_col_break",
|
"dimension_col_break",
|
||||||
|
"project",
|
||||||
"sb_14",
|
"sb_14",
|
||||||
"on_hold",
|
"on_hold",
|
||||||
"release_date",
|
"release_date",
|
||||||
@@ -1288,6 +1289,12 @@
|
|||||||
"fieldname": "dimension_col_break",
|
"fieldname": "dimension_col_break",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "project",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Project",
|
||||||
|
"options": "Project"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "tax_withholding_category",
|
"fieldname": "tax_withholding_category",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
|||||||
@@ -453,7 +453,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
if self.party_account_currency==self.company_currency else grand_total,
|
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": self.return_against if cint(self.is_return) and self.return_against else self.name,
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center
|
"cost_center": self.cost_center,
|
||||||
|
"project": self.project
|
||||||
}, self.party_account_currency, item=self)
|
}, self.party_account_currency, item=self)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -494,7 +495,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"debit": warehouse_debit_amount,
|
"debit": warehouse_debit_amount,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"project": item.project
|
"project": item.project or self.project
|
||||||
}, account_currency, item=item)
|
}, account_currency, item=item)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -507,7 +508,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"credit": flt(amount),
|
"credit": flt(amount),
|
||||||
"project": item.project
|
"project": item.project or self.project
|
||||||
}, item=item))
|
}, item=item))
|
||||||
|
|
||||||
# sub-contracting warehouse
|
# sub-contracting warehouse
|
||||||
@@ -520,6 +521,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"account": supplier_warehouse_account,
|
"account": supplier_warehouse_account,
|
||||||
"against": item.expense_account,
|
"against": item.expense_account,
|
||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
|
"project": item.project or self.project,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"credit": flt(item.rm_supp_cost)
|
"credit": flt(item.rm_supp_cost)
|
||||||
}, warehouse_account[self.supplier_warehouse]["account_currency"], item=item))
|
}, warehouse_account[self.supplier_warehouse]["account_currency"], item=item))
|
||||||
@@ -538,7 +540,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"against": self.supplier,
|
"against": self.supplier,
|
||||||
"debit": amount,
|
"debit": amount,
|
||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"project": item.project
|
"project": item.project or self.project
|
||||||
}, account_currency, item=item))
|
}, account_currency, item=item))
|
||||||
|
|
||||||
# If asset is bought through this document and not linked to PR
|
# If asset is bought through this document and not linked to PR
|
||||||
@@ -551,7 +553,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"credit": flt(item.landed_cost_voucher_amount),
|
"credit": flt(item.landed_cost_voucher_amount),
|
||||||
"project": item.project
|
"project": item.project or self.project
|
||||||
}, item=item))
|
}, item=item))
|
||||||
|
|
||||||
gl_entries.append(self.get_gl_dict({
|
gl_entries.append(self.get_gl_dict({
|
||||||
@@ -560,7 +562,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"debit": flt(item.landed_cost_voucher_amount),
|
"debit": flt(item.landed_cost_voucher_amount),
|
||||||
"project": item.project
|
"project": item.project or self.project
|
||||||
}, item=item))
|
}, item=item))
|
||||||
|
|
||||||
# update gross amount of asset bought through this document
|
# update gross amount of asset bought through this document
|
||||||
@@ -586,7 +588,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"against": self.supplier,
|
"against": self.supplier,
|
||||||
"debit": flt(item.item_tax_amount, item.precision("item_tax_amount")),
|
"debit": flt(item.item_tax_amount, item.precision("item_tax_amount")),
|
||||||
"remarks": self.remarks or "Accounting Entry for Stock",
|
"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)
|
}, item=item)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -615,7 +618,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"debit": base_asset_amount,
|
"debit": base_asset_amount,
|
||||||
"debit_in_account_currency": (base_asset_amount
|
"debit_in_account_currency": (base_asset_amount
|
||||||
if arbnb_currency == self.company_currency else 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))
|
}, item=item))
|
||||||
|
|
||||||
if item.item_tax_amount:
|
if item.item_tax_amount:
|
||||||
@@ -625,6 +629,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"against": self.supplier,
|
"against": self.supplier,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
|
"project": item.project or self.project,
|
||||||
"credit": item.item_tax_amount,
|
"credit": item.item_tax_amount,
|
||||||
"credit_in_account_currency": (item.item_tax_amount
|
"credit_in_account_currency": (item.item_tax_amount
|
||||||
if asset_eiiav_currency == self.company_currency else
|
if asset_eiiav_currency == self.company_currency else
|
||||||
@@ -641,7 +646,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"debit": base_asset_amount,
|
"debit": base_asset_amount,
|
||||||
"debit_in_account_currency": (base_asset_amount
|
"debit_in_account_currency": (base_asset_amount
|
||||||
if cwip_account_currency == self.company_currency else 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))
|
}, item=item))
|
||||||
|
|
||||||
if item.item_tax_amount and not cint(erpnext.is_perpetual_inventory_enabled(self.company)):
|
if item.item_tax_amount and not cint(erpnext.is_perpetual_inventory_enabled(self.company)):
|
||||||
@@ -652,6 +658,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
|
||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"credit": item.item_tax_amount,
|
"credit": item.item_tax_amount,
|
||||||
|
"project": item.project or self.project,
|
||||||
"credit_in_account_currency": (item.item_tax_amount
|
"credit_in_account_currency": (item.item_tax_amount
|
||||||
if asset_eiiav_currency == self.company_currency else
|
if asset_eiiav_currency == self.company_currency else
|
||||||
item.item_tax_amount / self.conversion_rate)
|
item.item_tax_amount / self.conversion_rate)
|
||||||
@@ -667,7 +674,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"credit": flt(item.landed_cost_voucher_amount),
|
"credit": flt(item.landed_cost_voucher_amount),
|
||||||
"project": item.project
|
"project": item.project or self.project
|
||||||
}, item=item))
|
}, item=item))
|
||||||
|
|
||||||
gl_entries.append(self.get_gl_dict({
|
gl_entries.append(self.get_gl_dict({
|
||||||
@@ -676,7 +683,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"debit": flt(item.landed_cost_voucher_amount),
|
"debit": flt(item.landed_cost_voucher_amount),
|
||||||
"project": item.project
|
"project": item.project or self.project
|
||||||
}, item=item))
|
}, item=item))
|
||||||
|
|
||||||
# update gross amount of assets bought through this document
|
# update gross amount of assets bought through this document
|
||||||
@@ -711,7 +718,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"debit": stock_adjustment_amt,
|
"debit": stock_adjustment_amt,
|
||||||
"remarks": self.get("remarks") or _("Stock Adjustment"),
|
"remarks": self.get("remarks") or _("Stock Adjustment"),
|
||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"project": item.project
|
"project": item.project or self.project
|
||||||
}, account_currency, item=item)
|
}, account_currency, item=item)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -803,7 +810,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
if self.party_account_currency==self.company_currency else self.paid_amount,
|
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": self.return_against if cint(self.is_return) and self.return_against else self.name,
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center
|
"cost_center": self.cost_center,
|
||||||
|
"project": self.project
|
||||||
}, self.party_account_currency, item=self)
|
}, self.party_account_currency, item=self)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -835,7 +843,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
if self.party_account_currency==self.company_currency else self.write_off_amount,
|
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": self.return_against if cint(self.is_return) and self.return_against else self.name,
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center
|
"cost_center": self.cost_center,
|
||||||
|
"project": self.project
|
||||||
}, self.party_account_currency, item=self)
|
}, self.party_account_currency, item=self)
|
||||||
)
|
)
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ from erpnext.controllers.accounts_controller import get_payment_terms
|
|||||||
from erpnext.exceptions import InvalidCurrency
|
from erpnext.exceptions import InvalidCurrency
|
||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import get_qty_after_transaction
|
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.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_dependencies = ["Item", "Cost Center", "Payment Term", "Payment Terms Template"]
|
||||||
test_ignore = ["Serial No"]
|
test_ignore = ["Serial No"]
|
||||||
@@ -434,6 +435,8 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_total_purchase_cost_for_project(self):
|
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)
|
existing_purchase_cost = frappe.db.sql("""select sum(base_net_amount)
|
||||||
from `tabPurchase Invoice Item` where project = '_Test Project' and docstatus=1""")
|
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
|
existing_purchase_cost = existing_purchase_cost and existing_purchase_cost[0][0] or 0
|
||||||
@@ -807,11 +810,8 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
pi_doc = frappe.get_doc('Purchase Invoice', pi.name)
|
pi_doc = frappe.get_doc('Purchase Invoice', pi.name)
|
||||||
self.assertEqual(pi_doc.outstanding_amount, 0)
|
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
|
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"
|
cost_center = "_Test Cost Center for BS Account - _TC"
|
||||||
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
||||||
|
|
||||||
@@ -837,13 +837,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
for gle in gl_entries:
|
for gle in gl_entries:
|
||||||
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
||||||
|
|
||||||
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
|
def test_purchase_invoice_without_cost_center(self):
|
||||||
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()
|
|
||||||
cost_center = "_Test Cost Center - _TC"
|
cost_center = "_Test Cost Center - _TC"
|
||||||
pi = make_purchase_invoice(credit_to="Creditors - _TC")
|
pi = make_purchase_invoice(credit_to="Creditors - _TC")
|
||||||
|
|
||||||
@@ -866,6 +860,42 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
for gle in gl_entries:
|
for gle in gl_entries:
|
||||||
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
||||||
|
|
||||||
|
def test_purchase_invoice_with_project_link(self):
|
||||||
|
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):
|
def unlink_payment_on_cancel_of_invoice(enable=1):
|
||||||
accounts_settings = frappe.get_doc("Accounts Settings")
|
accounts_settings = frappe.get_doc("Accounts Settings")
|
||||||
|
|||||||
@@ -786,7 +786,8 @@ class SalesInvoice(SellingController):
|
|||||||
if self.party_account_currency==self.company_currency else grand_total,
|
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": self.return_against if cint(self.is_return) and self.return_against else self.name,
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center
|
"cost_center": self.cost_center,
|
||||||
|
"project": self.project
|
||||||
}, self.party_account_currency, item=self)
|
}, self.party_account_currency, item=self)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -841,7 +842,8 @@ class SalesInvoice(SellingController):
|
|||||||
"credit_in_account_currency": (flt(item.base_net_amount, item.precision("base_net_amount"))
|
"credit_in_account_currency": (flt(item.base_net_amount, item.precision("base_net_amount"))
|
||||||
if account_currency==self.company_currency
|
if account_currency==self.company_currency
|
||||||
else flt(item.net_amount, item.precision("net_amount"))),
|
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)
|
}, account_currency, item=item)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -922,7 +924,8 @@ class SalesInvoice(SellingController):
|
|||||||
if self.party_account_currency==self.company_currency else flt(self.change_amount),
|
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": self.return_against if cint(self.is_return) and self.return_against else self.name,
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center
|
"cost_center": self.cost_center,
|
||||||
|
"project": self.project
|
||||||
}, self.party_account_currency, item=self)
|
}, self.party_account_currency, item=self)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -955,7 +958,8 @@ class SalesInvoice(SellingController):
|
|||||||
else flt(self.write_off_amount, self.precision("write_off_amount"))),
|
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": self.return_against if cint(self.is_return) else self.name,
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center
|
"cost_center": self.cost_center,
|
||||||
|
"project": self.project
|
||||||
}, self.party_account_currency, item=self)
|
}, self.party_account_currency, item=self)
|
||||||
)
|
)
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"company": "_Test Company",
|
"company": "_Test Company",
|
||||||
"conversion_rate": 1.0,
|
"conversion_rate": 1.0,
|
||||||
"currency": "INR",
|
"currency": "INR",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"customer": "_Test Customer",
|
"customer": "_Test Customer",
|
||||||
"customer_name": "_Test Customer",
|
"customer_name": "_Test Customer",
|
||||||
"debit_to": "_Test Receivable - _TC",
|
"debit_to": "_Test Receivable - _TC",
|
||||||
@@ -37,7 +38,8 @@
|
|||||||
"charge_type": "On Net Total",
|
"charge_type": "On Net Total",
|
||||||
"description": "VAT",
|
"description": "VAT",
|
||||||
"doctype": "Sales Taxes and Charges",
|
"doctype": "Sales Taxes and Charges",
|
||||||
"parentfield": "taxes",
|
"parentfield": "taxes",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"rate": 6
|
"rate": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -45,7 +47,8 @@
|
|||||||
"charge_type": "On Net Total",
|
"charge_type": "On Net Total",
|
||||||
"description": "Service Tax",
|
"description": "Service Tax",
|
||||||
"doctype": "Sales Taxes and Charges",
|
"doctype": "Sales Taxes and Charges",
|
||||||
"parentfield": "taxes",
|
"parentfield": "taxes",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"rate": 6.36
|
"rate": 6.36
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -76,6 +79,7 @@
|
|||||||
"customer_name": "_Test Customer",
|
"customer_name": "_Test Customer",
|
||||||
"debit_to": "_Test Receivable - _TC",
|
"debit_to": "_Test Receivable - _TC",
|
||||||
"doctype": "Sales Invoice",
|
"doctype": "Sales Invoice",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"amount": 500.0,
|
"amount": 500.0,
|
||||||
@@ -107,7 +111,8 @@
|
|||||||
"charge_type": "On Net Total",
|
"charge_type": "On Net Total",
|
||||||
"description": "VAT",
|
"description": "VAT",
|
||||||
"doctype": "Sales Taxes and Charges",
|
"doctype": "Sales Taxes and Charges",
|
||||||
"parentfield": "taxes",
|
"parentfield": "taxes",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"rate": 16
|
"rate": 16
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -115,7 +120,8 @@
|
|||||||
"charge_type": "On Net Total",
|
"charge_type": "On Net Total",
|
||||||
"description": "Service Tax",
|
"description": "Service Tax",
|
||||||
"doctype": "Sales Taxes and Charges",
|
"doctype": "Sales Taxes and Charges",
|
||||||
"parentfield": "taxes",
|
"parentfield": "taxes",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"rate": 10
|
"rate": 10
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -132,6 +138,7 @@
|
|||||||
"customer_name": "_Test Customer",
|
"customer_name": "_Test Customer",
|
||||||
"debit_to": "_Test Receivable - _TC",
|
"debit_to": "_Test Receivable - _TC",
|
||||||
"doctype": "Sales Invoice",
|
"doctype": "Sales Invoice",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
@@ -259,6 +266,7 @@
|
|||||||
"customer_name": "_Test Customer",
|
"customer_name": "_Test Customer",
|
||||||
"debit_to": "_Test Receivable - _TC",
|
"debit_to": "_Test Receivable - _TC",
|
||||||
"doctype": "Sales Invoice",
|
"doctype": "Sales Invoice",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
|||||||
@@ -1575,11 +1575,8 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
si_doc = frappe.get_doc('Sales Invoice', si.name)
|
si_doc = frappe.get_doc('Sales Invoice', si.name)
|
||||||
self.assertEqual(si_doc.outstanding_amount, 0)
|
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
|
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"
|
cost_center = "_Test Cost Center for BS Account - _TC"
|
||||||
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company")
|
||||||
|
|
||||||
@@ -1605,13 +1602,46 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
for gle in gl_entries:
|
for gle in gl_entries:
|
||||||
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
||||||
|
|
||||||
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
|
def test_sales_invoice_with_project_link(self):
|
||||||
accounts_settings.save()
|
from erpnext.projects.doctype.project.test_project import make_project
|
||||||
|
|
||||||
def test_sales_invoice_for_disable_allow_cost_center_in_entry_of_bs_account(self):
|
project = make_project({
|
||||||
accounts_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings')
|
'project_name': 'Sales Invoice Project',
|
||||||
accounts_settings.allow_cost_center_in_entry_of_bs_account = 1
|
'project_template_name': 'Test Project Template',
|
||||||
accounts_settings.save()
|
'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"
|
cost_center = "_Test Cost Center - _TC"
|
||||||
si = create_sales_invoice(debit_to="Debtors - _TC")
|
si = create_sales_invoice(debit_to="Debtors - _TC")
|
||||||
|
|
||||||
@@ -1634,9 +1664,6 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
for gle in gl_entries:
|
for gle in gl_entries:
|
||||||
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
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):
|
def test_deferred_revenue(self):
|
||||||
deferred_account = create_account(account_name="Deferred Revenue",
|
deferred_account = create_account(account_name="Deferred Revenue",
|
||||||
parent_account="Current Liabilities - _TC", company="_Test Company")
|
parent_account="Current Liabilities - _TC", company="_Test Company")
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"accounting_dimensions_section",
|
"accounting_dimensions_section",
|
||||||
"cost_center",
|
"cost_center",
|
||||||
"dimension_col_break",
|
"dimension_col_break",
|
||||||
|
"project",
|
||||||
"section_break_54",
|
"section_break_54",
|
||||||
"page_break"
|
"page_break"
|
||||||
],
|
],
|
||||||
@@ -784,6 +785,12 @@
|
|||||||
"label": "Finance Book",
|
"label": "Finance Book",
|
||||||
"options": "Finance Book"
|
"options": "Finance Book"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "project",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Project",
|
||||||
|
"options": "Project"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:parent.update_stock == 1",
|
"depends_on": "eval:parent.update_stock == 1",
|
||||||
"fieldname": "sales_invoice_item",
|
"fieldname": "sales_invoice_item",
|
||||||
|
|||||||
@@ -124,14 +124,12 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company
|
|||||||
# hence, assuming balance as 0.0
|
# hence, assuming balance as 0.0
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
allow_cost_center_in_entry_of_bs_account = get_allow_cost_center_in_entry_of_bs_account()
|
|
||||||
|
|
||||||
if account:
|
if account:
|
||||||
report_type = acc.report_type
|
report_type = acc.report_type
|
||||||
else:
|
else:
|
||||||
report_type = ""
|
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)
|
cc = frappe.get_doc("Cost Center", cost_center)
|
||||||
if cc.is_group:
|
if cc.is_group:
|
||||||
cond.append(""" exists (
|
cond.append(""" exists (
|
||||||
@@ -879,11 +877,6 @@ def get_coa(doctype, parent, is_root, chart=None):
|
|||||||
|
|
||||||
return accounts
|
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):
|
def get_stock_accounts(company):
|
||||||
return frappe.get_all("Account", filters = {
|
return frappe.get_all("Account", filters = {
|
||||||
"account_type": "Stock",
|
"account_type": "Stock",
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ def make_depreciation_entry(asset_name, date=None):
|
|||||||
"account": accumulated_depreciation_account,
|
"account": accumulated_depreciation_account,
|
||||||
"credit_in_account_currency": d.depreciation_amount,
|
"credit_in_account_currency": d.depreciation_amount,
|
||||||
"reference_type": "Asset",
|
"reference_type": "Asset",
|
||||||
"reference_name": asset.name
|
"reference_name": asset.name,
|
||||||
|
"cost_center": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
debit_entry = {
|
debit_entry = {
|
||||||
@@ -196,12 +197,14 @@ def get_gl_entries_on_asset_disposal(asset, selling_amount=0, finance_book=None)
|
|||||||
{
|
{
|
||||||
"account": fixed_asset_account,
|
"account": fixed_asset_account,
|
||||||
"credit_in_account_currency": asset.gross_purchase_amount,
|
"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,
|
"account": accumulated_depr_account,
|
||||||
"debit_in_account_currency": accumulated_depr_amount,
|
"debit_in_account_currency": accumulated_depr_amount,
|
||||||
"debit": accumulated_depr_amount
|
"debit": accumulated_depr_amount,
|
||||||
|
"cost_center": depreciation_cost_center
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -67,4 +67,5 @@ class TestProcurementTracker(unittest.TestCase):
|
|||||||
"expected_delivery_date": date_obj,
|
"expected_delivery_date": date_obj,
|
||||||
"actual_delivery_date": date_obj
|
"actual_delivery_date": date_obj
|
||||||
}
|
}
|
||||||
|
|
||||||
return expected_data
|
return expected_data
|
||||||
@@ -94,6 +94,7 @@ class StockController(AccountsController):
|
|||||||
"account": warehouse_account[sle.warehouse]["account"],
|
"account": warehouse_account[sle.warehouse]["account"],
|
||||||
"against": item_row.expense_account,
|
"against": item_row.expense_account,
|
||||||
"cost_center": item_row.cost_center,
|
"cost_center": item_row.cost_center,
|
||||||
|
"project": item_row.project or self.get('project'),
|
||||||
"remarks": self.get("remarks") or "Accounting Entry for Stock",
|
"remarks": self.get("remarks") or "Accounting Entry for Stock",
|
||||||
"debit": flt(sle.stock_value_difference, precision),
|
"debit": flt(sle.stock_value_difference, precision),
|
||||||
"is_opening": item_row.get("is_opening") or self.get("is_opening") or "No",
|
"is_opening": item_row.get("is_opening") or self.get("is_opening") or "No",
|
||||||
@@ -104,6 +105,7 @@ class StockController(AccountsController):
|
|||||||
"account": item_row.expense_account,
|
"account": item_row.expense_account,
|
||||||
"against": warehouse_account[sle.warehouse]["account"],
|
"against": warehouse_account[sle.warehouse]["account"],
|
||||||
"cost_center": item_row.cost_center,
|
"cost_center": item_row.cost_center,
|
||||||
|
"project": item_row.project or self.get('project'),
|
||||||
"remarks": self.get("remarks") or "Accounting Entry for Stock",
|
"remarks": self.get("remarks") or "Accounting Entry for Stock",
|
||||||
"credit": flt(sle.stock_value_difference, precision),
|
"credit": flt(sle.stock_value_difference, precision),
|
||||||
"project": item_row.get("project") or self.get("project"),
|
"project": item_row.get("project") or self.get("project"),
|
||||||
|
|||||||
@@ -119,12 +119,14 @@ def make_bank_entry(dt, dn):
|
|||||||
"reference_type": "Employee Advance",
|
"reference_type": "Employee Advance",
|
||||||
"reference_name": doc.name,
|
"reference_name": doc.name,
|
||||||
"party_type": "Employee",
|
"party_type": "Employee",
|
||||||
|
"cost_center": erpnext.get_default_cost_center(doc.company),
|
||||||
"party": doc.employee,
|
"party": doc.employee,
|
||||||
"is_advance": "Yes"
|
"is_advance": "Yes"
|
||||||
})
|
})
|
||||||
|
|
||||||
je.append("accounts", {
|
je.append("accounts", {
|
||||||
"account": payment_account.account,
|
"account": payment_account.account,
|
||||||
|
"cost_center": erpnext.get_default_cost_center(doc.company),
|
||||||
"credit_in_account_currency": flt(doc.advance_amount),
|
"credit_in_account_currency": flt(doc.advance_amount),
|
||||||
"account_currency": payment_account.account_currency,
|
"account_currency": payment_account.account_currency,
|
||||||
"account_type": payment_account.account_type
|
"account_type": payment_account.account_type
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe, erpnext
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import get_fullname, flt, cstr
|
from frappe.utils import get_fullname, flt, cstr
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
@@ -285,7 +285,7 @@ def make_bank_entry(dt, dn):
|
|||||||
je = frappe.new_doc("Journal Entry")
|
je = frappe.new_doc("Journal Entry")
|
||||||
je.voucher_type = 'Bank Entry'
|
je.voucher_type = 'Bank Entry'
|
||||||
je.company = expense_claim.company
|
je.company = expense_claim.company
|
||||||
je.remark = 'Payment against Expense Claim: ' + dn;
|
je.remark = 'Payment against Expense Claim: ' + dn
|
||||||
|
|
||||||
je.append("accounts", {
|
je.append("accounts", {
|
||||||
"account": expense_claim.payable_account,
|
"account": expense_claim.payable_account,
|
||||||
@@ -293,6 +293,7 @@ def make_bank_entry(dt, dn):
|
|||||||
"reference_type": "Expense Claim",
|
"reference_type": "Expense Claim",
|
||||||
"party_type": "Employee",
|
"party_type": "Employee",
|
||||||
"party": expense_claim.employee,
|
"party": expense_claim.employee,
|
||||||
|
"cost_center": erpnext.get_default_cost_center(expense_claim.company),
|
||||||
"reference_name": expense_claim.name
|
"reference_name": expense_claim.name
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -303,6 +304,7 @@ def make_bank_entry(dt, dn):
|
|||||||
"reference_name": expense_claim.name,
|
"reference_name": expense_claim.name,
|
||||||
"balance": default_bank_cash_account.balance,
|
"balance": default_bank_cash_account.balance,
|
||||||
"account_currency": default_bank_cash_account.account_currency,
|
"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
|
"account_type": default_bank_cash_account.account_type
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -670,6 +670,7 @@ erpnext.patches.v12_0.set_serial_no_status #2020-05-21
|
|||||||
erpnext.patches.v12_0.update_price_list_currency_in_bom
|
erpnext.patches.v12_0.update_price_list_currency_in_bom
|
||||||
erpnext.patches.v12_0.update_uom_conversion_factor
|
erpnext.patches.v12_0.update_uom_conversion_factor
|
||||||
erpnext.patches.v12_0.set_italian_import_supplier_invoice_permissions
|
erpnext.patches.v12_0.set_italian_import_supplier_invoice_permissions
|
||||||
|
erpnext.patches.v12_0.unhide_cost_center_field
|
||||||
execute:frappe.reload_doc("HR", "doctype", "Employee Advance")
|
execute:frappe.reload_doc("HR", "doctype", "Employee Advance")
|
||||||
erpnext.patches.v12_0.move_due_advance_amount_to_pending_amount
|
erpnext.patches.v12_0.move_due_advance_amount_to_pending_amount
|
||||||
erpnext.patches.v12_0.set_multi_uom_in_rfq
|
erpnext.patches.v12_0.set_multi_uom_in_rfq
|
||||||
|
|||||||
13
erpnext/patches/v12_0/unhide_cost_center_field.py
Normal file
13
erpnext/patches/v12_0/unhide_cost_center_field.py
Normal file
@@ -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'
|
||||||
|
""")
|
||||||
@@ -7,7 +7,7 @@ import frappe, unittest
|
|||||||
test_records = frappe.get_test_records('Project')
|
test_records = frappe.get_test_records('Project')
|
||||||
test_ignore = ["Sales Order"]
|
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 erpnext.projects.doctype.project.project import set_project_status
|
||||||
|
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
@@ -44,3 +44,23 @@ def get_project(name):
|
|||||||
)).insert()
|
)).insert()
|
||||||
|
|
||||||
return project
|
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
|
||||||
@@ -27,3 +27,22 @@ def get_project_template():
|
|||||||
)).insert()
|
)).insert()
|
||||||
|
|
||||||
return frappe.get_doc('Project Template', 'Test Project Template')
|
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)
|
||||||
@@ -88,7 +88,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
|
|
||||||
# check stock in hand balance
|
# check stock in hand balance
|
||||||
bal = get_balance_on(stock_in_hand_account)
|
bal = get_balance_on(stock_in_hand_account)
|
||||||
self.assertEqual(bal, prev_bal - stock_value_difference)
|
self.assertEqual(flt(bal, 2), flt(prev_bal - stock_value_difference, 2))
|
||||||
|
|
||||||
# back dated incoming entry
|
# back dated incoming entry
|
||||||
make_stock_entry(posting_date=add_days(nowdate(), -2), target="Stores - TCP1",
|
make_stock_entry(posting_date=add_days(nowdate(), -2), target="Stores - TCP1",
|
||||||
@@ -548,11 +548,8 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
dt = make_delivery_trip(dn.name)
|
dt = make_delivery_trip(dn.name)
|
||||||
self.assertEqual(dn.name, dt.delivery_stops[0].delivery_note)
|
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
|
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"
|
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")
|
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company with perpetual inventory")
|
||||||
|
|
||||||
@@ -578,13 +575,8 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
for i, gle in enumerate(gl_entries):
|
for i, gle in enumerate(gl_entries):
|
||||||
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
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):
|
def test_delivery_note_cost_center_with_balance_sheet_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()
|
|
||||||
cost_center = "Main - TCP1"
|
cost_center = "Main - TCP1"
|
||||||
|
|
||||||
company = frappe.db.get_value('Warehouse', 'Stores - TCP1', 'company')
|
company = frappe.db.get_value('Warehouse', 'Stores - TCP1', 'company')
|
||||||
@@ -594,7 +586,11 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
make_stock_entry(target="Stores - TCP1", qty=5, basic_rate=100)
|
make_stock_entry(target="Stores - TCP1", qty=5, basic_rate=100)
|
||||||
|
|
||||||
stock_in_hand_account = get_inventory_account('_Test Company with perpetual inventory')
|
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)
|
gl_entries = get_gl_entries("Delivery Note", dn.name)
|
||||||
|
|
||||||
@@ -604,7 +600,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
"cost_center": cost_center
|
"cost_center": cost_center
|
||||||
},
|
},
|
||||||
stock_in_hand_account: {
|
stock_in_hand_account: {
|
||||||
"cost_center": None
|
"cost_center": cost_center
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i, gle in enumerate(gl_entries):
|
for i, gle in enumerate(gl_entries):
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
|
||||||
"autoname": "hash",
|
"autoname": "hash",
|
||||||
"creation": "2013-04-22 13:15:44",
|
"creation": "2013-04-22 13:15:44",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
@@ -82,6 +81,7 @@
|
|||||||
"accounting_dimensions_section",
|
"accounting_dimensions_section",
|
||||||
"cost_center",
|
"cost_center",
|
||||||
"dimension_col_break",
|
"dimension_col_break",
|
||||||
|
"project",
|
||||||
"reason_for_return_section_break",
|
"reason_for_return_section_break",
|
||||||
"reason_for_return",
|
"reason_for_return",
|
||||||
"section_break_72",
|
"section_break_72",
|
||||||
@@ -703,6 +703,12 @@
|
|||||||
"fieldname": "dimension_col_break",
|
"fieldname": "dimension_col_break",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "project",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Project",
|
||||||
|
"options": "Project"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:parent.is_return==1",
|
"depends_on": "eval:parent.is_return==1",
|
||||||
"fieldname": "reason_for_return",
|
"fieldname": "reason_for_return",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"autoname": "naming_series:",
|
"autoname": "naming_series:",
|
||||||
"creation": "2013-05-21 16:16:39",
|
"creation": "2013-05-21 16:16:39",
|
||||||
|
|||||||
@@ -402,11 +402,8 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
|
|
||||||
pr_return.submit()
|
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
|
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"
|
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")
|
create_cost_center(cost_center_name="_Test Cost Center for BS Account", company="_Test Company with perpetual inventory")
|
||||||
|
|
||||||
@@ -434,14 +431,7 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
for i, gle in enumerate(gl_entries):
|
for i, gle in enumerate(gl_entries):
|
||||||
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
self.assertEqual(expected_values[gle.account]["cost_center"], gle.cost_center)
|
||||||
|
|
||||||
accounts_settings.allow_cost_center_in_entry_of_bs_account = 0
|
def test_purchase_receipt_cost_center_with_balance_sheet_account(self):
|
||||||
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()
|
|
||||||
|
|
||||||
if not frappe.db.exists('Location', 'Test Location'):
|
if not frappe.db.exists('Location', 'Test Location'):
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
'doctype': 'Location',
|
'doctype': 'Location',
|
||||||
@@ -453,13 +443,14 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
gl_entries = get_gl_entries("Purchase Receipt", pr.name)
|
gl_entries = get_gl_entries("Purchase Receipt", pr.name)
|
||||||
|
|
||||||
self.assertTrue(gl_entries)
|
self.assertTrue(gl_entries)
|
||||||
|
cost_center = pr.get('items')[0].cost_center
|
||||||
|
|
||||||
expected_values = {
|
expected_values = {
|
||||||
"Stock Received But Not Billed - TCP1": {
|
"Stock Received But Not Billed - TCP1": {
|
||||||
"cost_center": None
|
"cost_center": cost_center
|
||||||
},
|
},
|
||||||
stock_in_hand_account: {
|
stock_in_hand_account: {
|
||||||
"cost_center": None
|
"cost_center": cost_center
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i, gle in enumerate(gl_entries):
|
for i, gle in enumerate(gl_entries):
|
||||||
|
|||||||
Reference in New Issue
Block a user