Merge pull request #22615 from aerele/fix_mandatory_error
fix: log type mandatory error while exposing api call to employee checkin.
diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
index e4b96ae..8ca8b71 100644
--- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
+++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
@@ -19,7 +19,6 @@
"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",
"deferred_accounting_settings_section",
@@ -114,12 +113,6 @@
"label": "Book Asset Depreciation Entry Automatically"
},
{
- "default": "0",
- "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",
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 645da34..def9ed6 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -72,12 +72,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/invoice_discounting/invoice_discounting.py b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
index 594b4d4..8083b21 100644
--- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
+++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
@@ -3,7 +3,7 @@
# For license information, please see license.txt
from __future__ import unicode_literals
-import frappe, json
+import frappe, json, erpnext
from frappe import _
from frappe.utils import flt, getdate, nowdate, add_days
from erpnext.controllers.accounts_controller import AccountsController
@@ -134,16 +134,19 @@
je.append("accounts", {
"account": self.bank_account,
"debit_in_account_currency": flt(self.total_amount) - flt(self.bank_charges),
+ "cost_center": erpnext.get_default_cost_center(self.company)
})
je.append("accounts", {
"account": self.bank_charges_account,
- "debit_in_account_currency": flt(self.bank_charges)
+ "debit_in_account_currency": flt(self.bank_charges),
+ "cost_center": erpnext.get_default_cost_center(self.company)
})
je.append("accounts", {
"account": self.short_term_loan,
"credit_in_account_currency": flt(self.total_amount),
+ "cost_center": erpnext.get_default_cost_center(self.company),
"reference_type": "Invoice Discounting",
"reference_name": self.name
})
@@ -151,6 +154,7 @@
je.append("accounts", {
"account": self.accounts_receivable_discounted,
"debit_in_account_currency": flt(d.outstanding_amount),
+ "cost_center": erpnext.get_default_cost_center(self.company),
"reference_type": "Invoice Discounting",
"reference_name": self.name,
"party_type": "Customer",
@@ -160,6 +164,7 @@
je.append("accounts", {
"account": self.accounts_receivable_credit,
"credit_in_account_currency": flt(d.outstanding_amount),
+ "cost_center": erpnext.get_default_cost_center(self.company),
"reference_type": "Invoice Discounting",
"reference_name": self.name,
"party_type": "Customer",
@@ -177,13 +182,15 @@
je.append("accounts", {
"account": self.short_term_loan,
"debit_in_account_currency": flt(self.total_amount),
+ "cost_center": erpnext.get_default_cost_center(self.company),
"reference_type": "Invoice Discounting",
"reference_name": self.name,
})
je.append("accounts", {
"account": self.bank_account,
- "credit_in_account_currency": flt(self.total_amount)
+ "credit_in_account_currency": flt(self.total_amount),
+ "cost_center": erpnext.get_default_cost_center(self.company)
})
if getdate(self.loan_end_date) > getdate(nowdate()):
@@ -193,6 +200,7 @@
je.append("accounts", {
"account": self.accounts_receivable_discounted,
"credit_in_account_currency": flt(outstanding_amount),
+ "cost_center": erpnext.get_default_cost_center(self.company),
"reference_type": "Invoice Discounting",
"reference_name": self.name,
"party_type": "Customer",
@@ -202,6 +210,7 @@
je.append("accounts", {
"account": self.accounts_receivable_unpaid,
"debit_in_account_currency": flt(outstanding_amount),
+ "cost_center": erpnext.get_default_cost_center(self.company),
"reference_type": "Invoice Discounting",
"reference_name": self.name,
"party_type": "Customer",
diff --git a/erpnext/accounts/doctype/item_tax_template/test_records.json b/erpnext/accounts/doctype/item_tax_template/test_records.json
index db540e8..4d9537d 100644
--- a/erpnext/accounts/doctype/item_tax_template/test_records.json
+++ b/erpnext/accounts/doctype/item_tax_template/test_records.json
@@ -2,6 +2,7 @@
{
"doctype": "Item Tax Template",
"title": "_Test Account Excise Duty @ 10",
+ "company": "_Test Company",
"taxes": [
{
"doctype": "Item Tax Template Detail",
@@ -14,6 +15,7 @@
{
"doctype": "Item Tax Template",
"title": "_Test Account Excise Duty @ 12",
+ "company": "_Test Company",
"taxes": [
{
"doctype": "Item Tax Template Detail",
@@ -26,6 +28,7 @@
{
"doctype": "Item Tax Template",
"title": "_Test Account Excise Duty @ 15",
+ "company": "_Test Company",
"taxes": [
{
"doctype": "Item Tax Template Detail",
@@ -38,6 +41,7 @@
{
"doctype": "Item Tax Template",
"title": "_Test Account Excise Duty @ 20",
+ "company": "_Test Company",
"taxes": [
{
"doctype": "Item Tax Template Detail",
@@ -50,6 +54,7 @@
{
"doctype": "Item Tax Template",
"title": "_Test Item Tax Template 1",
+ "company": "_Test Company",
"taxes": [
{
"doctype": "Item Tax Template Detail",
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 59611bc..1cecab7 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
@@ -658,7 +658,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 = {
@@ -1029,14 +1029,14 @@
if bank_amount:
received_amount = bank_amount
else:
- received_amount = paid_amount * doc.conversion_rate
+ received_amount = paid_amount * doc.get('conversion_rate', 1)
else:
received_amount = abs(outstanding_amount)
if bank_amount:
paid_amount = bank_amount
else:
# if party account currency and bank currency is different then populate paid amount as well
- paid_amount = received_amount * doc.conversion_rate
+ paid_amount = received_amount * doc.get('conversion_rate', 1)
pe = frappe.new_doc("Payment Entry")
pe.payment_type = payment_type
diff --git a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py
index 8bb741f..772fc1a 100644
--- a/erpnext/accounts/doctype/payment_entry/test_payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/test_payment_entry.py
@@ -460,11 +460,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")
@@ -499,39 +496,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")
@@ -566,40 +532,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")
@@ -630,9 +565,6 @@
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()
-
def create_payment_terms_template():
create_payment_term('Basic Amount Receivable')
@@ -665,4 +597,4 @@
frappe.get_doc({
'doctype': 'Payment Term',
'payment_term_name': name
- }).insert()
\ No newline at end of file
+ }).insert()
diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
index 8eaad7a..35d8d34 100644
--- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
+++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
@@ -281,7 +281,8 @@
'party_type': d.party_type,
d.dr_or_cr: abs(d.allocated_amount),
'reference_type': d.against_voucher_type,
- 'reference_name': d.against_voucher
+ 'reference_name': d.against_voucher,
+ 'cost_center': erpnext.get_default_cost_center(company)
},
{
'account': d.account,
@@ -290,7 +291,8 @@
reconcile_dr_or_cr: (abs(d.allocated_amount)
if abs(d.unadjusted_amount) > abs(d.allocated_amount) else abs(d.unadjusted_amount)),
'reference_type': d.voucher_type,
- 'reference_name': d.voucher_no
+ 'reference_name': d.voucher_no,
+ 'cost_center': erpnext.get_default_cost_center(company)
}
]
})
diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py
index 53115f9..ad98383 100644
--- a/erpnext/accounts/doctype/pricing_rule/utils.py
+++ b/erpnext/accounts/doctype/pricing_rule/utils.py
@@ -319,7 +319,9 @@
filtered_rules = []
for field in field_set:
if args.get(field):
- filtered_rules = filter(lambda x: x[field]==args[field], pricing_rules)
+ # filter function always returns a filter object even if empty
+ # list conversion is necessary to check for an empty result
+ filtered_rules = list(filter(lambda x: x.get(field)==args.get(field), pricing_rules))
if filtered_rules: break
return filtered_rules or pricing_rules
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 829c34d..eb1ccd9 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -26,6 +26,7 @@
"accounting_dimensions_section",
"cost_center",
"dimension_col_break",
+ "project",
"supplier_invoice_details",
"bill_no",
"column_break_15",
@@ -1599,6 +1600,12 @@
"show_seconds": 1
},
{
+ "fieldname": "project",
+ "fieldtype": "Link",
+ "label": "Project",
+ "options": "Project"
+ },
+ {
"fieldname": "tax_withholding_category",
"fieldtype": "Link",
"hidden": 1,
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 3cd57d4..7b1062f 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -438,6 +438,8 @@
self.make_tax_gl_entries(gl_entries)
+ gl_entries = make_regional_gl_entries(gl_entries, self)
+
gl_entries = merge_similar_entries(gl_entries)
self.make_payment_gl_entries(gl_entries)
@@ -476,6 +478,7 @@
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,
+ "project": self.project,
"cost_center": self.cost_center
}, self.party_account_currency, item=self)
)
@@ -516,6 +519,7 @@
"account": warehouse_account[item.warehouse]['account'],
"against": warehouse_account[item.from_warehouse]["account"],
"cost_center": item.cost_center,
+ "project": item.project or self.project,
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
"debit": warehouse_debit_amount,
}, warehouse_account[item.warehouse]["account_currency"], item=item))
@@ -525,6 +529,7 @@
"account": warehouse_account[item.from_warehouse]['account'],
"against": warehouse_account[item.warehouse]["account"],
"cost_center": item.cost_center,
+ "project": item.project or self.project,
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
"debit": -1 * flt(item.base_net_amount, item.precision("base_net_amount")),
}, warehouse_account[item.from_warehouse]["account_currency"], item=item))
@@ -548,7 +553,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)
)
@@ -561,7 +566,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
@@ -574,6 +579,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))
@@ -606,7 +612,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
@@ -619,7 +625,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({
@@ -628,7 +634,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
@@ -654,7 +660,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)
)
@@ -683,7 +690,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:
@@ -693,6 +701,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
@@ -709,7 +718,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)):
@@ -720,6 +730,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)
@@ -735,7 +746,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({
@@ -744,7 +755,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
@@ -779,7 +790,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)
)
@@ -871,7 +882,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, item=self)
)
@@ -903,7 +915,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, item=self)
)
gl_entries.append(
@@ -1097,6 +1110,10 @@
})
return list_context
+@erpnext.allow_regional
+def make_regional_gl_entries(gl_entries, doc):
+ return gl_entries
+
@frappe.whitelist()
def make_debit_note(source_name, target_doc=None):
from erpnext.controllers.sales_and_purchase_return import make_return_doc
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index b5955ca..9a666bf 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -14,6 +14,7 @@
from erpnext.controllers.accounts_controller import get_payment_terms
from erpnext.exceptions import InvalidCurrency
from erpnext.stock.doctype.stock_entry.test_stock_entry import get_qty_after_transaction
+from erpnext.projects.doctype.project.test_project import make_project
from erpnext.accounts.doctype.account.test_account import get_inventory_account, create_account
from erpnext.stock.doctype.item.test_item import create_item
@@ -435,6 +436,8 @@
)
def test_total_purchase_cost_for_project(self):
+ make_project({'project_name':'_Test Project'})
+
existing_purchase_cost = frappe.db.sql("""select sum(base_net_amount)
from `tabPurchase Invoice Item` where project = '_Test Project' and docstatus=1""")
existing_purchase_cost = existing_purchase_cost and existing_purchase_cost[0][0] or 0
@@ -808,11 +811,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")
@@ -838,13 +838,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")
@@ -867,6 +861,43 @@
for gle in gl_entries:
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 test_deferred_expense_via_journal_entry(self):
deferred_account = create_account(account_name="Deferred Expense",
parent_account="Current Assets - _TC", company="_Test Company")
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 5e8279b..bab5208 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, item=self)
)
@@ -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, item=self)
)
@@ -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, item=self)
)
gl_entries.append(
@@ -1109,7 +1113,10 @@
expiry_date=self.posting_date, include_expired_entry=True)
if lp_details and getdate(lp_details.from_date) <= getdate(self.posting_date) and \
(not lp_details.to_date or getdate(lp_details.to_date) >= getdate(self.posting_date)):
- points_earned = cint(eligible_amount/lp_details.collection_factor)
+
+ collection_factor = lp_details.collection_factor if lp_details.collection_factor else 1.0
+ points_earned = cint(eligible_amount/collection_factor)
+
doc = frappe.get_doc({
"doctype": "Loyalty Point Entry",
"company": self.company,
diff --git a/erpnext/accounts/doctype/sales_invoice/test_records.json b/erpnext/accounts/doctype/sales_invoice/test_records.json
index ebe6e3d..11ebe6a 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_records.json
+++ b/erpnext/accounts/doctype/sales_invoice/test_records.json
@@ -3,6 +3,7 @@
"company": "_Test Company",
"conversion_rate": 1.0,
"currency": "INR",
+ "cost_center": "_Test Cost Center - _TC",
"customer": "_Test Customer",
"customer_name": "_Test Customer",
"debit_to": "_Test Receivable - _TC",
@@ -37,7 +38,8 @@
"charge_type": "On Net Total",
"description": "VAT",
"doctype": "Sales Taxes and Charges",
- "parentfield": "taxes",
+ "parentfield": "taxes",
+ "cost_center": "_Test Cost Center - _TC",
"rate": 6
},
{
@@ -45,7 +47,8 @@
"charge_type": "On Net Total",
"description": "Service Tax",
"doctype": "Sales Taxes and Charges",
- "parentfield": "taxes",
+ "parentfield": "taxes",
+ "cost_center": "_Test Cost Center - _TC",
"rate": 6.36
}
],
@@ -76,6 +79,7 @@
"customer_name": "_Test Customer",
"debit_to": "_Test Receivable - _TC",
"doctype": "Sales Invoice",
+ "cost_center": "_Test Cost Center - _TC",
"items": [
{
"amount": 500.0,
@@ -107,7 +111,8 @@
"charge_type": "On Net Total",
"description": "VAT",
"doctype": "Sales Taxes and Charges",
- "parentfield": "taxes",
+ "parentfield": "taxes",
+ "cost_center": "_Test Cost Center - _TC",
"rate": 16
},
{
@@ -115,7 +120,8 @@
"charge_type": "On Net Total",
"description": "Service Tax",
"doctype": "Sales Taxes and Charges",
- "parentfield": "taxes",
+ "parentfield": "taxes",
+ "cost_center": "_Test Cost Center - _TC",
"rate": 10
}
],
@@ -132,6 +138,7 @@
"customer_name": "_Test Customer",
"debit_to": "_Test Receivable - _TC",
"doctype": "Sales Invoice",
+ "cost_center": "_Test Cost Center - _TC",
"items": [
{
"cost_center": "_Test Cost Center - _TC",
@@ -259,6 +266,7 @@
"customer_name": "_Test Customer",
"debit_to": "_Test Receivable - _TC",
"doctype": "Sales Invoice",
+ "cost_center": "_Test Cost Center - _TC",
"items": [
{
"cost_center": "_Test Cost Center - _TC",
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 311cc12..ff4d613 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -1640,11 +1640,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")
@@ -1669,14 +1666,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")
@@ -1699,9 +1729,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/report/financial_statements.html b/erpnext/accounts/report/financial_statements.html
index 50947ec..2bb09cf 100644
--- a/erpnext/accounts/report/financial_statements.html
+++ b/erpnext/accounts/report/financial_statements.html
@@ -44,7 +44,7 @@
</tr>
</thead>
<tbody>
- {% for(let j=0, k=data.length-1; j<k; j++) { %}
+ {% for(let j=0, k=data.length; j<k; j++) { %}
{%
var row = data[j];
var row_class = data[j].parent_account ? "" : "financial-statements-important";
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index ee1d54a..3785ebf 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -8,6 +8,7 @@
import re
from past.builtins import cmp
import functools
+import math
import frappe, erpnext
from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency
@@ -45,10 +46,7 @@
start_date = year_start_date
months = get_months(year_start_date, year_end_date)
- if (months // months_to_add) != (months / months_to_add):
- months += months_to_add
-
- for i in range(months // months_to_add):
+ for i in range(math.ceil(months / months_to_add)):
period = frappe._dict({
"from_date": start_date
})
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 69866e1..013c30d 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -144,14 +144,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 (
@@ -897,11 +895,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..8f0afb4 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:
@@ -58,7 +58,8 @@
"account": accumulated_depreciation_account,
"credit_in_account_currency": d.depreciation_amount,
"reference_type": "Asset",
- "reference_name": asset.name
+ "reference_name": asset.name,
+ "cost_center": ""
}
debit_entry = {
@@ -196,12 +197,14 @@
{
"account": fixed_asset_account,
"credit_in_account_currency": asset.gross_purchase_amount,
- "credit": asset.gross_purchase_amount
+ "credit": asset.gross_purchase_amount,
+ "cost_center": depreciation_cost_center
},
{
"account": accumulated_depr_account,
"debit_in_account_currency": accumulated_depr_amount,
- "debit": accumulated_depr_amount
+ "debit": accumulated_depr_amount,
+ "cost_center": depreciation_cost_center
}
]
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
index 97aa922..5cd8e6f 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json
@@ -1,4 +1,5 @@
{
+ "actions": "",
"allow_import": 1,
"autoname": "naming_series:",
"creation": "2016-02-25 01:24:07.224790",
@@ -28,7 +29,6 @@
"letter_head",
"more_info",
"status",
- "fiscal_year",
"column_break3",
"amended_from"
],
@@ -219,17 +219,6 @@
"search_index": 1
},
{
- "fieldname": "fiscal_year",
- "fieldtype": "Link",
- "label": "Fiscal Year",
- "oldfieldname": "fiscal_year",
- "oldfieldtype": "Select",
- "options": "Fiscal Year",
- "print_hide": 1,
- "reqd": 1,
- "search_index": 1
- },
- {
"fieldname": "column_break3",
"fieldtype": "Column Break"
},
@@ -245,7 +234,8 @@
],
"icon": "fa fa-shopping-cart",
"is_submittable": 1,
- "modified": "2019-09-24 15:08:32.750661",
+ "links": [],
+ "modified": "2020-06-25 14:37:21.140194",
"modified_by": "Administrator",
"module": "Buying",
"name": "Request for Quotation",
diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py
index c7204a1..44ab767 100644
--- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py
+++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py
@@ -67,4 +67,5 @@
"expected_delivery_date": date_obj,
"actual_delivery_date": date_obj
}
+
return expected_data
\ No newline at end of file
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 759c6cd..e8483da 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -96,6 +96,7 @@
"account": warehouse_account[sle.warehouse]["account"],
"against": item_row.expense_account,
"cost_center": item_row.cost_center,
+ "project": item_row.project or self.get('project'),
"remarks": self.get("remarks") or "Accounting Entry for Stock",
"debit": flt(sle.stock_value_difference, precision),
"is_opening": item_row.get("is_opening") or self.get("is_opening") or "No",
@@ -106,6 +107,7 @@
"account": item_row.expense_account,
"against": warehouse_account[sle.warehouse]["account"],
"cost_center": item_row.cost_center,
+ "project": item_row.project or self.get('project'),
"remarks": self.get("remarks") or "Accounting Entry for Stock",
"credit": flt(sle.stock_value_difference, precision),
"project": item_row.get("project") or self.get("project"),
diff --git a/erpnext/controllers/tests/test_mapper.py b/erpnext/controllers/tests/test_mapper.py
index 8839e00..66459fd 100644
--- a/erpnext/controllers/tests/test_mapper.py
+++ b/erpnext/controllers/tests/test_mapper.py
@@ -13,14 +13,12 @@
'''Test mapping of multiple source docs on a single target doc'''
make_test_records("Item")
- items = frappe.get_all("Item", fields = ["name", "item_code"], filters = {'is_sales_item': 1, 'has_variants': 0, 'disabled': 0})
- customers = frappe.get_all("Customer")
- if items and customers:
- # Make source docs (quotations) and a target doc (sales order)
- customer = random.choice(customers).name
- qtn1, item_list_1 = self.make_quotation(items, customer)
- qtn2, item_list_2 = self.make_quotation(items, customer)
- so, item_list_3 = self.make_sales_order()
+ items = ['_Test Item', '_Test Item 2', '_Test FG Item']
+
+ # Make source docs (quotations) and a target doc (sales order)
+ qtn1, item_list_1 = self.make_quotation(items, '_Test Customer')
+ qtn2, item_list_2 = self.make_quotation(items, '_Test Customer')
+ so, item_list_3 = self.make_sales_order()
# Map source docs to target with corresponding mapper method
method = "erpnext.selling.doctype.quotation.quotation.make_sales_order"
@@ -28,18 +26,12 @@
# Assert that all inserted items are present in updated sales order
src_items = item_list_1 + item_list_2 + item_list_3
- self.assertEqual(set([d.item_code for d in src_items]),
+ self.assertEqual(set([d for d in src_items]),
set([d.item_code for d in updated_so.items]))
- def get_random_items(self, items, limit):
- '''Get a number of random items from a list of given items'''
- random_items = []
- for i in range(0, limit):
- random_items.append(random.choice(items))
- return random_items
- def make_quotation(self, items, customer):
- item_list = self.get_random_items(items, 3)
+ def make_quotation(self, item_list, customer):
+
qtn = frappe.get_doc({
"doctype": "Quotation",
"quotation_to": "Customer",
@@ -49,7 +41,7 @@
"valid_till" : add_months(nowdate(), 1)
})
for item in item_list:
- qtn.append("items", {"qty": "2", "item_code": item.item_code})
+ qtn.append("items", {"qty": "2", "item_code": item})
qtn.submit()
return qtn, item_list
@@ -60,7 +52,7 @@
"base_rate": 100.0,
"description": "CPU",
"doctype": "Sales Order Item",
- "item_code": "_Test Item Home Desktop 100",
+ "item_code": "_Test Item",
"item_name": "CPU",
"parentfield": "items",
"qty": 10.0,
@@ -72,4 +64,4 @@
})
so = frappe.get_doc(frappe.get_test_records('Sales Order')[0])
so.insert(ignore_permissions=True)
- return so, [item]
+ return so, [item.item_code]
diff --git a/erpnext/controllers/tests/test_qty_based_taxes.py b/erpnext/controllers/tests/test_qty_based_taxes.py
index fd9936b..aaeac5d 100644
--- a/erpnext/controllers/tests/test_qty_based_taxes.py
+++ b/erpnext/controllers/tests/test_qty_based_taxes.py
@@ -30,6 +30,7 @@
self.item_tax_template = frappe.get_doc({
'doctype': 'Item Tax Template',
'title': uuid4(),
+ 'company': self.company.name,
'taxes': [
{
'tax_type': self.account.name,
diff --git a/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py b/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py
index 6172a75..8fe16a2 100644
--- a/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py
+++ b/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py
@@ -17,7 +17,8 @@
{
"fieldname": "lead_owner",
"label": _("Lead Owner"),
- "fieldtype": "Data",
+ "fieldtype": "Link",
+ "options": "User",
"width": "130"
},
{
@@ -68,4 +69,4 @@
"fieldtype": "Float",
"width": "100"
}
- ]
\ No newline at end of file
+ ]
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 70217dc..e8dda20 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -246,7 +246,7 @@
"on_trash": "erpnext.regional.check_deletion_permission"
},
"Purchase Invoice": {
- "on_submit": "erpnext.regional.india.utils.make_reverse_charge_entries"
+ "validate": "erpnext.regional.india.utils.update_grand_total_for_rcm"
},
"Payment Entry": {
"on_submit": ["erpnext.regional.create_transaction_log", "erpnext.accounts.doctype.payment_request.payment_request.update_payment_req_status"],
@@ -374,7 +374,8 @@
'erpnext.controllers.taxes_and_totals.get_itemised_tax_breakup_data': 'erpnext.regional.india.utils.get_itemised_tax_breakup_data',
'erpnext.accounts.party.get_regional_address_details': 'erpnext.regional.india.utils.get_regional_address_details',
'erpnext.hr.utils.calculate_annual_eligible_hra_exemption': 'erpnext.regional.india.utils.calculate_annual_eligible_hra_exemption',
- 'erpnext.hr.utils.calculate_hra_exemption_for_period': 'erpnext.regional.india.utils.calculate_hra_exemption_for_period'
+ 'erpnext.hr.utils.calculate_hra_exemption_for_period': 'erpnext.regional.india.utils.calculate_hra_exemption_for_period',
+ 'erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_regional_gl_entries': 'erpnext.regional.india.utils.make_regional_gl_entries'
},
'United Arab Emirates': {
'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.united_arab_emirates.utils.update_itemised_tax_data'
diff --git a/erpnext/hr/doctype/employee_advance/employee_advance.py b/erpnext/hr/doctype/employee_advance/employee_advance.py
index 7619581..3c435b8 100644
--- a/erpnext/hr/doctype/employee_advance/employee_advance.py
+++ b/erpnext/hr/doctype/employee_advance/employee_advance.py
@@ -120,12 +120,14 @@
"reference_type": "Employee Advance",
"reference_name": doc.name,
"party_type": "Employee",
+ "cost_center": erpnext.get_default_cost_center(doc.company),
"party": doc.employee,
"is_advance": "Yes"
})
je.append("accounts", {
"account": payment_account.account,
+ "cost_center": erpnext.get_default_cost_center(doc.company),
"credit_in_account_currency": flt(doc.advance_amount),
"account_currency": payment_account.account_currency,
"account_type": payment_account.account_type
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py
index 5563c24..bf893d5 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.py
@@ -295,7 +295,7 @@
je = frappe.new_doc("Journal Entry")
je.voucher_type = 'Bank Entry'
je.company = expense_claim.company
- je.remark = 'Payment against Expense Claim: ' + dn;
+ je.remark = 'Payment against Expense Claim: ' + dn
je.append("accounts", {
"account": expense_claim.payable_account,
@@ -303,6 +303,7 @@
"reference_type": "Expense Claim",
"party_type": "Employee",
"party": expense_claim.employee,
+ "cost_center": erpnext.get_default_cost_center(expense_claim.company),
"reference_name": expense_claim.name
})
@@ -313,6 +314,7 @@
"reference_name": expense_claim.name,
"balance": default_bank_cash_account.balance,
"account_currency": default_bank_cash_account.account_currency,
+ "cost_center": erpnext.get_default_cost_center(expense_claim.company),
"account_type": default_bank_cash_account.account_type
})
diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
index b58f999..add7bbf 100644
--- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
+++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
@@ -44,7 +44,7 @@
for d in self.get('items'):
if d.serial_no:
serial_nos = get_valid_serial_nos(d.serial_no)
- self.validate_serial_no(serial_nos, d.start_date)
+ self.validate_serial_no(d.item_code, serial_nos, d.start_date)
self.update_amc_date(serial_nos, d.end_date)
no_email_sp = []
@@ -178,14 +178,18 @@
serial_no_doc.amc_expiry_date = amc_expiry_date
serial_no_doc.save()
- def validate_serial_no(self, serial_nos, amc_start_date):
+ def validate_serial_no(self, item_code, serial_nos, amc_start_date):
for serial_no in serial_nos:
sr_details = frappe.db.get_value("Serial No", serial_no,
- ["warranty_expiry_date", "amc_expiry_date", "warehouse", "delivery_date"], as_dict=1)
+ ["warranty_expiry_date", "amc_expiry_date", "warehouse", "delivery_date", "item_code"], as_dict=1)
if not sr_details:
frappe.throw(_("Serial No {0} not found").format(serial_no))
+ if sr_details.get("item_code") != item_code:
+ frappe.throw(_("Serial No {0} does not belong to Item {1}")
+ .format(frappe.bold(serial_no), frappe.bold(item_code)), title="Invalid")
+
if sr_details.warranty_expiry_date \
and getdate(sr_details.warranty_expiry_date) >= getdate(amc_start_date):
throw(_("Serial No {0} is under warranty upto {1}")
diff --git a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json
index c797b7e..1192568 100644
--- a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json
+++ b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json
@@ -701,7 +701,7 @@
"columns": 0,
"default": "Draft",
"fieldname": "status",
- "fieldtype": "Data",
+ "fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -1001,7 +1001,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-08-21 14:44:44.911402",
+ "modified": "2020-07-15 14:44:44.911402",
"modified_by": "Administrator",
"module": "Maintenance",
"name": "Maintenance Visit",
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 256c957..8062342 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -494,7 +494,7 @@
'image' : d.image,
'stock_uom' : d.stock_uom,
'stock_qty' : flt(d.stock_qty),
- 'rate' : d.base_rate,
+ 'rate' : flt(d.base_rate) / flt(d.conversion_factor),
'include_item_in_manufacturing': d.include_item_in_manufacturing
}))
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index cd4a221..566b979 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -697,6 +697,7 @@
erpnext.patches.v12_0.update_uom_conversion_factor
erpnext.patches.v13_0.delete_old_purchase_reports
erpnext.patches.v12_0.set_italian_import_supplier_invoice_permissions
+erpnext.patches.v12_0.unhide_cost_center_field
erpnext.patches.v13_0.update_sla_enhancements
erpnext.patches.v12_0.update_address_template_for_india
erpnext.patches.v13_0.update_deferred_settings
diff --git a/erpnext/patches/v12_0/unhide_cost_center_field.py b/erpnext/patches/v12_0/unhide_cost_center_field.py
new file mode 100644
index 0000000..6005ab7
--- /dev/null
+++ b/erpnext/patches/v12_0/unhide_cost_center_field.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ frappe.db.sql("""
+ DELETE FROM `tabProperty Setter`
+ WHERE doc_type in ('Sales Invoice', 'Purchase Invoice', 'Payment Entry')
+ AND field_name = 'cost_center'
+ AND property = 'hidden'
+ """)
\ No newline at end of file
diff --git a/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py b/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py
index 331c559..adfa20e 100644
--- a/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py
+++ b/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py
@@ -6,7 +6,6 @@
import frappe
from frappe.utils import add_to_date
-from frappe.utils.dashboard import get_config, make_records
def execute():
frappe.reload_doc("manufacturing", "doctype", "work_order")
diff --git a/erpnext/payroll/doctype/additional_salary/additional_salary.js b/erpnext/payroll/doctype/additional_salary/additional_salary.js
index fb42b6f..d56cd4e 100644
--- a/erpnext/payroll/doctype/additional_salary/additional_salary.js
+++ b/erpnext/payroll/doctype/additional_salary/additional_salary.js
@@ -8,8 +8,7 @@
frm.set_query("employee", function() {
return {
filters: {
- company: frm.doc.company,
- status: "Active"
+ company: frm.doc.company
}
};
});
diff --git a/erpnext/payroll/doctype/additional_salary/additional_salary.py b/erpnext/payroll/doctype/additional_salary/additional_salary.py
index e369ba7..ef174bd 100644
--- a/erpnext/payroll/doctype/additional_salary/additional_salary.py
+++ b/erpnext/payroll/doctype/additional_salary/additional_salary.py
@@ -33,12 +33,16 @@
frappe.throw(_("From Date can not be greater than To Date."))
if date_of_joining:
- if getdate(self.payroll_date) < getdate(date_of_joining):
+ if self.payroll_date and getdate(self.payroll_date) < getdate(date_of_joining):
frappe.throw(_("Payroll date can not be less than employee's joining date."))
- elif getdate(self.from_date) < getdate(date_of_joining):
+ elif self.from_date and getdate(self.from_date) < getdate(date_of_joining):
frappe.throw(_("From date can not be less than employee's joining date."))
- elif relieving_date and getdate(self.to_date) > getdate(relieving_date):
+
+ if relieving_date:
+ if self.to_date and getdate(self.to_date) > getdate(relieving_date):
frappe.throw(_("To date can not be greater than employee's relieving date."))
+ if self.payroll_date and getdate(self.payroll_date) > getdate(relieving_date):
+ frappe.throw(_("Payroll date can not be greater than employee's relieving date."))
def get_amount(self, sal_start_date, sal_end_date):
start_date = getdate(sal_start_date)
@@ -107,4 +111,4 @@
existing_salary_components.append(d.salary_component)
- return salary_components_details, additional_salary_details
\ No newline at end of file
+ return salary_components_details, additional_salary_details
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/projects/doctype/task/task.js b/erpnext/projects/doctype/task/task.js
index a044e1d..8c6a9cf 100644
--- a/erpnext/projects/doctype/task/task.js
+++ b/erpnext/projects/doctype/task/task.js
@@ -29,10 +29,16 @@
filters: filters
};
})
- },
- refresh: function (frm) {
- frm.set_query("parent_task", { "is_group": 1 });
+ frm.set_query("parent_task", function () {
+ let filters = {
+ "is_group": 1
+ };
+ if (frm.doc.project) filters["project"] = frm.doc.project;
+ return {
+ filters: filters
+ }
+ });
},
is_group: function (frm) {
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index 3b75cf4..4bdda68 100755
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -9,7 +9,7 @@
from frappe import _, throw
from frappe.desk.form.assign_to import clear, close_all_assignments
from frappe.model.mapper import get_mapped_doc
-from frappe.utils import add_days, cstr, date_diff, get_link_to_form, getdate, today
+from frappe.utils import add_days, cstr, date_diff, get_link_to_form, getdate, today, flt
from frappe.utils.nestedset import NestedSet
@@ -63,10 +63,10 @@
close_all_assignments(self.doctype, self.name)
def validate_progress(self):
- if (self.progress or 0) > 100:
+ if flt(self.progress or 0) > 100:
frappe.throw(_("Progress % for a task cannot be more than 100."))
- if self.progress == 100:
+ if flt(self.progress) == 100:
self.status = 'Completed'
if self.status == 'Completed':
diff --git a/erpnext/public/js/help_links.js b/erpnext/public/js/help_links.js
index 17b726e..66ff464 100644
--- a/erpnext/public/js/help_links.js
+++ b/erpnext/public/js/help_links.js
@@ -450,7 +450,7 @@
]
frappe.help.help_links['Form/Address'] = [
- { label: 'Address', url: docsUrl + 'user/manual/en/CRM/contact' },
+ { label: 'Address', url: docsUrl + 'user/manual/en/CRM/address' },
]
frappe.help.help_links['Form/Contact'] = [
diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js
index a1cea8f..c744266 100644
--- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js
+++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js
@@ -3,6 +3,7 @@
frappe.ui.form.on('GSTR 3B Report', {
refresh : function(frm) {
+ frm.doc.__unsaved = 1;
if(!frm.is_new()) {
frm.set_intro(__("Please save the report again to rebuild or update"));
frm.add_custom_button(__('Download JSON'), function() {
diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py
index 619734f..2d306ba 100644
--- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py
+++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py
@@ -243,20 +243,15 @@
osup_det = self.report_dict["sup_details"]["osup_det"]
- for d in inter_state_supply.get("Unregistered", []):
- self.report_dict["inter_sup"]["unreg_details"].append(d)
- osup_det["txval"] = flt(osup_det["txval"] + d["txval"], 2)
- osup_det["iamt"] = flt(osup_det["iamt"] + d["iamt"], 2)
+ for key, value in iteritems(inter_state_supply):
+ if key[0] == "Unregistered":
+ self.report_dict["inter_sup"]["unreg_details"].append(value)
- for d in inter_state_supply.get("Registered Composition", []):
- self.report_dict["inter_sup"]["comp_details"].append(d)
- osup_det["txval"] = flt(osup_det["txval"] + d["txval"], 2)
- osup_det["iamt"] = flt(osup_det["iamt"] + d["iamt"], 2)
+ if key[0] == "Registered Composition":
+ self.report_dict["inter_sup"]["comp_details"].append(value)
- for d in inter_state_supply.get("UIN Holders", []):
- self.report_dict["inter_sup"]["uin_details"].append(d)
- osup_det["txval"] = flt(osup_det["txval"] + d["txval"], 2)
- osup_det["iamt"] = flt(osup_det["iamt"] + d["iamt"], 2)
+ if key[0] == "UIN Holders":
+ self.report_dict["inter_sup"]["uin_details"].append(value)
def get_total_taxable_value(self, doctype, reverse_charge):
@@ -301,41 +296,55 @@
(self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)[0].total
def get_inter_state_supplies(self, state_number):
-
- inter_state_supply_taxable_value = frappe.db.sql(""" select sum(s.net_total) as total, s.place_of_supply, s.gst_category
- from `tabSales Invoice` s where s.docstatus = 1 and month(s.posting_date) = %s and year(s.posting_date) = %s
- and s.company = %s and s.company_gstin = %s and s.gst_category in ('Unregistered', 'Registered Composition', 'UIN Holders')
- group by s.gst_category, s.place_of_supply""", (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
-
- inter_state_supply_tax = frappe.db.sql(""" select sum(t.tax_amount_after_discount_amount) as tax_amount, s.place_of_supply, s.gst_category
- from `tabSales Invoice` s, `tabSales Taxes and Charges` t
+ inter_state_supply_tax = frappe.db.sql(""" select t.account_head, t.tax_amount_after_discount_amount as tax_amount,
+ s.name, s.net_total, s.place_of_supply, s.gst_category from `tabSales Invoice` s, `tabSales Taxes and Charges` t
where t.parent = s.name and s.docstatus = 1 and month(s.posting_date) = %s and year(s.posting_date) = %s
and s.company = %s and s.company_gstin = %s and s.gst_category in ('Unregistered', 'Registered Composition', 'UIN Holders')
- group by s.gst_category, s.place_of_supply""", (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
+ """, (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
- inter_state_supply_tax_mapping={}
+ inter_state_supply_tax_mapping = {}
inter_state_supply_details = {}
for d in inter_state_supply_tax:
- inter_state_supply_tax_mapping.setdefault(d.place_of_supply, d.tax_amount)
+ inter_state_supply_tax_mapping.setdefault(d.name, {
+ 'place_of_supply': d.place_of_supply,
+ 'taxable_value': d.net_total,
+ 'camt': 0.0,
+ 'samt': 0.0,
+ 'iamt': 0.0,
+ 'csamt': 0.0
+ })
- for d in inter_state_supply_taxable_value:
- inter_state_supply_details.setdefault(
- d.gst_category, []
- )
+ if d.account_head in [d.cgst_account for d in self.account_heads]:
+ inter_state_supply_tax_mapping[d.name]['camt'] += d.tax_amount
+ if d.account_head in [d.sgst_account for d in self.account_heads]:
+ inter_state_supply_tax_mapping[d.name]['samt'] += d.tax_amount
+
+ if d.account_head in [d.igst_account for d in self.account_heads]:
+ inter_state_supply_tax_mapping[d.name]['iamt'] += d.tax_amount
+
+ if d.account_head in [d.cess_account for d in self.account_heads]:
+ inter_state_supply_tax_mapping[d.name]['csamt'] += d.tax_amount
+
+ for key, value in iteritems(inter_state_supply_tax_mapping):
if d.place_of_supply:
+ osup_det = self.report_dict["sup_details"]["osup_det"]
+ osup_det["txval"] = flt(osup_det["txval"] + value['taxable_value'], 2)
+ osup_det["iamt"] = flt(osup_det["iamt"] + value['iamt'], 2)
+ osup_det["camt"] = flt(osup_det["camt"] + value['camt'], 2)
+ osup_det["samt"] = flt(osup_det["samt"] + value['samt'], 2)
+ osup_det["csamt"] = flt(osup_det["csamt"] + value['csamt'], 2)
+
if state_number != d.place_of_supply.split("-")[0]:
- inter_state_supply_details[d.gst_category].append({
+ inter_state_supply_details.setdefault((d.gst_category, d.place_of_supply), {
+ "txval": 0.0,
"pos": d.place_of_supply.split("-")[0],
- "txval": flt(d.total, 2),
- "iamt": flt(inter_state_supply_tax_mapping.get(d.place_of_supply), 2)
+ "iamt": 0.0
})
- else:
- osup_det = self.report_dict["sup_details"]["osup_det"]
- osup_det["txval"] = flt(osup_det["txval"] + d.total, 2)
- osup_det["camt"] = flt(osup_det["camt"] + inter_state_supply_tax_mapping.get(d.place_of_supply)/2, 2)
- osup_det["samt"] = flt(osup_det["samt"] + inter_state_supply_tax_mapping.get(d.place_of_supply)/2, 2)
+
+ inter_state_supply_details[(d.gst_category, d.place_of_supply)]['txval'] += value['taxable_value']
+ inter_state_supply_details[(d.gst_category, d.place_of_supply)]['iamt'] += value['iamt']
return inter_state_supply_details
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 05ffa87..fe7e0c8 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import frappe, re, json
from frappe import _
-from frappe.utils import cstr, flt, date_diff, nowdate
+from frappe.utils import cstr, flt, date_diff, nowdate, round_based_on_smallest_currency_fraction, money_in_words
from erpnext.regional.india import states, state_numbers
from erpnext.controllers.taxes_and_totals import get_itemised_tax, get_itemised_taxable_amount
from erpnext.controllers.accounts_controller import get_taxes_and_charges
@@ -458,19 +458,23 @@
@frappe.whitelist()
def download_ewb_json():
- data = frappe._dict(frappe.local.form_dict)
-
- frappe.local.response.filecontent = json.dumps(data['data'], indent=4, sort_keys=True)
+ data = json.loads(frappe.local.form_dict.data)
+ frappe.local.response.filecontent = json.dumps(data, indent=4, sort_keys=True)
frappe.local.response.type = 'download'
- billList = json.loads(data['data'])['billLists']
+ filename_prefix = 'Bulk'
+ docname = frappe.local.form_dict.docname
+ if docname:
+ if docname.startswith('['):
+ docname = json.loads(docname)
+ if len(docname) == 1:
+ docname = docname[0]
- if len(billList) > 1:
- doc_name = 'Bulk'
- else:
- doc_name = data['docname']
+ if not isinstance(docname, list):
+ # removes characters not allowed in a filename (https://stackoverflow.com/a/38766141/4767738)
+ filename_prefix = re.sub('[^\w_.)( -]', '', docname)
- frappe.local.response.filename = '{0}_e-WayBill_Data_{1}.json'.format(doc_name, frappe.utils.random_string(5))
+ frappe.local.response.filename = '{0}_e-WayBill_Data_{1}.json'.format(filename_prefix, frappe.utils.random_string(5))
@frappe.whitelist()
def get_gstins_for_company(company):
@@ -644,6 +648,7 @@
else:
return int(state_code)
+@frappe.whitelist()
def get_gst_accounts(company, account_wise=False):
gst_accounts = frappe._dict()
gst_settings_accounts = frappe.get_all("GST Account",
@@ -662,14 +667,55 @@
return gst_accounts
-def make_reverse_charge_entries(doc, method):
+def update_grand_total_for_rcm(doc, method):
country = frappe.get_cached_value('Company', doc.company, 'country')
if country != 'India':
return
if doc.reverse_charge == 'Y':
- gl_entries = []
+ gst_accounts = get_gst_accounts(doc.company)
+ gst_account_list = gst_accounts.get('cgst_account') + gst_accounts.get('sgst_account') \
+ + gst_accounts.get('igst_account')
+
+ gst_tax = 0
+ for tax in doc.get('taxes'):
+ if tax.category not in ("Total", "Valuation and Total"):
+ continue
+
+ if flt(tax.base_tax_amount_after_discount_amount) and tax.account_head in gst_account_list:
+ gst_tax += tax.base_tax_amount_after_discount_amount
+
+ doc.taxes_and_charges_added -= gst_tax
+ doc.total_taxes_and_charges -= gst_tax
+
+ update_totals(gst_tax, doc)
+
+def update_totals(gst_tax, doc):
+ doc.grand_total -= gst_tax
+
+ if doc.meta.get_field("rounded_total"):
+ if doc.is_rounded_total_disabled():
+ doc.outstanding_amount = doc.grand_total
+ else:
+ doc.rounded_total = round_based_on_smallest_currency_fraction(doc.grand_total,
+ doc.currency, doc.precision("rounded_total"))
+
+ doc.rounding_adjustment += flt(doc.rounded_total - doc.grand_total,
+ doc.precision("rounding_adjustment"))
+
+ doc.outstanding_amount = doc.rounded_total or doc.grand_total
+
+ doc.in_words = money_in_words(doc.grand_total, doc.currency)
+ doc.set_payment_schedule()
+
+def make_regional_gl_entries(gl_entries, doc):
+ country = frappe.get_cached_value('Company', doc.company, 'country')
+
+ if country != 'India':
+ return
+
+ if doc.reverse_charge == 'Y':
gst_accounts = get_gst_accounts(doc.company)
gst_account_list = gst_accounts.get('cgst_account') + gst_accounts.get('sgst_account') \
+ gst_accounts.get('igst_account')
@@ -694,19 +740,4 @@
}, account_currency, item=tax)
)
- gl_entries.append(doc.get_gl_dict(
- {
- "account": doc.credit_to if doc.doctype == 'Purchase Invoice' else doc.debit_to,
- "cost_center": doc.cost_center,
- "posting_date": doc.posting_date,
- "party_type": 'Supplier',
- "party": doc.supplier,
- "against": tax.account_head,
- "debit": tax.base_tax_amount_after_discount_amount,
- "debit_in_account_currency": tax.base_tax_amount_after_discount_amount \
- if account_currency==doc.company_currency \
- else tax.tax_amount_after_discount_amount
- }, account_currency, item=doc)
- )
-
- make_gl_entries(gl_entries)
\ No newline at end of file
+ return gl_entries
\ No newline at end of file
diff --git a/erpnext/regional/report/datev/datev.js b/erpnext/regional/report/datev/datev.js
index d8638ab..55f12cf 100644
--- a/erpnext/regional/report/datev/datev.js
+++ b/erpnext/regional/report/datev/datev.js
@@ -30,7 +30,7 @@
}
],
onload: function(query_report) {
- query_report.page.add_inner_button("Download DATEV Export", () => {
+ query_report.page.add_menu_item(__("Download DATEV File"), () => {
const filters = JSON.stringify(query_report.get_values());
window.open(`/api/method/erpnext.regional.report.datev.datev.download_datev_csv?filters=${filters}`);
});
diff --git a/erpnext/regional/report/datev/test_datev.py b/erpnext/regional/report/datev/test_datev.py
index 3cc65fe..eed62a8 100644
--- a/erpnext/regional/report/datev/test_datev.py
+++ b/erpnext/regional/report/datev/test_datev.py
@@ -90,7 +90,7 @@
if not frappe.db.exists("Customer", customer_name):
customer = frappe.get_doc({
- "doctype": "Customer",
+ "doctype": "Customer",
"customer_name": customer_name,
"customer_type": "Company",
"accounts": [{
@@ -155,17 +155,17 @@
setup_fiscal_year()
warehouse = frappe.db.get_value("Item Default", {
- "parent": item.name,
+ "parent": item.name,
"company": self.company.name
}, "default_warehouse")
income_account = frappe.db.get_value("Account", {
- "account_number": "4200",
+ "account_number": "4200",
"company": self.company.name
}, "name")
tax_account = frappe.db.get_value("Account", {
- "account_number": "3806",
+ "account_number": "3806",
"company": self.company.name
}, "name")
@@ -186,9 +186,12 @@
"charge_type": "On Net Total",
"account_head": tax_account,
"description": "Umsatzsteuer 19 %",
- "rate": 19
+ "rate": 19,
+ "cost_center": self.company.cost_center
})
+ si.cost_center = self.company.cost_center
+
si.save()
si.submit()
@@ -196,7 +199,7 @@
def is_subset(get_data, allowed_keys):
"""
Validate that the dict contains only allowed keys.
-
+
Params:
get_data -- Function that returns a list of dicts.
allowed_keys -- List of allowed keys
diff --git a/erpnext/regional/report/gstr_1/gstr_1.py b/erpnext/regional/report/gstr_1/gstr_1.py
index 43b1ea8..8885b88 100644
--- a/erpnext/regional/report/gstr_1/gstr_1.py
+++ b/erpnext/regional/report/gstr_1/gstr_1.py
@@ -118,7 +118,7 @@
row.append(invoice_details.get(fieldname))
taxable_value = 0
- if invoice in self.cgst_igst_invoices:
+ if invoice in self.cgst_sgst_invoices:
division_factor = 2
else:
division_factor = 1
@@ -129,6 +129,8 @@
taxable_value += abs(net_amount)
elif not self.item_tax_rate.get(invoice):
taxable_value += abs(net_amount)
+ elif tax_rate:
+ taxable_value += abs(net_amount)
row += [tax_rate or 0, taxable_value]
@@ -227,7 +229,7 @@
self.items_based_on_tax_rate = {}
self.invoice_cess = frappe._dict()
- self.cgst_igst_invoices = []
+ self.cgst_sgst_invoices = []
unidentified_gst_accounts = []
for parent, account, item_wise_tax_detail, tax_amount in self.tax_details:
@@ -251,8 +253,8 @@
tax_rate = tax_amounts[0]
if cgst_or_sgst:
tax_rate *= 2
- if parent not in self.cgst_igst_invoices:
- self.cgst_igst_invoices.append(parent)
+ if parent not in self.cgst_sgst_invoices:
+ self.cgst_sgst_invoices.append(parent)
rate_based_dict = self.items_based_on_tax_rate\
.setdefault(parent, {}).setdefault(tax_rate, [])
diff --git a/erpnext/regional/report/gstr_2/gstr_2.py b/erpnext/regional/report/gstr_2/gstr_2.py
index f326fe0..f899349 100644
--- a/erpnext/regional/report/gstr_2/gstr_2.py
+++ b/erpnext/regional/report/gstr_2/gstr_2.py
@@ -44,30 +44,30 @@
for inv, items_based_on_rate in self.items_based_on_tax_rate.items():
invoice_details = self.invoices.get(inv)
for rate, items in items_based_on_rate.items():
- if inv not in self.igst_invoices:
- rate = rate / 2
- row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
- tax_amount = taxable_value * rate / 100
- row += [0, tax_amount, tax_amount]
- else:
- row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
- tax_amount = taxable_value * rate / 100
- row += [tax_amount, 0, 0]
+ if rate:
+ if inv not in self.igst_invoices:
+ rate = rate / 2
+ row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
+ tax_amount = taxable_value * rate / 100
+ row += [0, tax_amount, tax_amount]
+ else:
+ row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
+ tax_amount = taxable_value * rate / 100
+ row += [tax_amount, 0, 0]
+ row += [
+ self.invoice_cess.get(inv),
+ invoice_details.get('eligibility_for_itc'),
+ invoice_details.get('itc_integrated_tax'),
+ invoice_details.get('itc_central_tax'),
+ invoice_details.get('itc_state_tax'),
+ invoice_details.get('itc_cess_amount')
+ ]
+ if self.filters.get("type_of_business") == "CDNR":
+ row.append("Y" if invoice_details.posting_date <= date(2017, 7, 1) else "N")
+ row.append("C" if invoice_details.return_against else "R")
- row += [
- self.invoice_cess.get(inv),
- invoice_details.get('eligibility_for_itc'),
- invoice_details.get('itc_integrated_tax'),
- invoice_details.get('itc_central_tax'),
- invoice_details.get('itc_state_tax'),
- invoice_details.get('itc_cess_amount')
- ]
- if self.filters.get("type_of_business") == "CDNR":
- row.append("Y" if invoice_details.posting_date <= date(2017, 7, 1) else "N")
- row.append("C" if invoice_details.return_against else "R")
-
- self.data.append(row)
+ self.data.append(row)
def get_igst_invoices(self):
self.igst_invoices = []
@@ -86,7 +86,7 @@
conditions += opts[1]
if self.filters.get("type_of_business") == "B2B":
- conditions += "and ifnull(gst_category, '') != 'Overseas' and is_return != 1 "
+ conditions += "and ifnull(gst_category, '') in ('Registered Regular', 'Deemed Export', 'SEZ') and is_return != 1 "
elif self.filters.get("type_of_business") == "CDNR":
conditions += """ and is_return = 1 """
diff --git a/erpnext/selling/doctype/quotation/quotation_list.js b/erpnext/selling/doctype/quotation/quotation_list.js
index 802c0ba..f425acf 100644
--- a/erpnext/selling/doctype/quotation/quotation_list.js
+++ b/erpnext/selling/doctype/quotation/quotation_list.js
@@ -3,13 +3,15 @@
"company", "currency", 'valid_till'],
onload: function(listview) {
- listview.page.fields_dict.quotation_to.get_query = function() {
- return {
- "filters": {
- "name": ["in", ["Customer", "Lead"]],
- }
+ if (listview.page.fields_dict.quotation_to) {
+ listview.page.fields_dict.quotation_to.get_query = function() {
+ return {
+ "filters": {
+ "name": ["in", ["Customer", "Lead"]],
+ }
+ };
};
- };
+ }
},
get_indicator: function(doc) {
diff --git a/erpnext/selling/doctype/sales_order/test_records.json b/erpnext/selling/doctype/sales_order/test_records.json
index 6cbd6c2..8a090e6 100644
--- a/erpnext/selling/doctype/sales_order/test_records.json
+++ b/erpnext/selling/doctype/sales_order/test_records.json
@@ -1,39 +1,39 @@
[
{
"advance_paid": 0.0,
- "company": "_Test Company",
- "conversion_rate": 1.0,
- "currency": "INR",
- "customer": "_Test Customer",
- "customer_group": "_Test Customer Group",
- "customer_name": "_Test Customer",
- "doctype": "Sales Order",
- "base_grand_total": 1000.0,
- "grand_total": 1000.0,
- "naming_series": "_T-Sales Order-",
- "order_type": "Sales",
- "plc_conversion_rate": 1.0,
- "price_list_currency": "INR",
+ "company": "_Test Company",
+ "conversion_rate": 1.0,
+ "currency": "INR",
+ "customer": "_Test Customer",
+ "customer_group": "_Test Customer Group",
+ "customer_name": "_Test Customer",
+ "doctype": "Sales Order",
+ "base_grand_total": 1000.0,
+ "grand_total": 1000.0,
+ "naming_series": "_T-Sales Order-",
+ "order_type": "Sales",
+ "plc_conversion_rate": 1.0,
+ "price_list_currency": "INR",
"items": [
{
- "base_amount": 1000.0,
- "base_rate": 100.0,
- "description": "CPU",
- "doctype": "Sales Order Item",
- "item_code": "_Test Item Home Desktop 100",
- "item_name": "CPU",
- "delivery_date": "2013-02-23",
- "parentfield": "items",
- "qty": 10.0,
- "rate": 100.0,
+ "base_amount": 1000.0,
+ "base_rate": 100.0,
+ "description": "CPU",
+ "doctype": "Sales Order Item",
+ "item_code": "_Test Item",
+ "item_name": "_Test Item 1",
+ "delivery_date": "2013-02-23",
+ "parentfield": "items",
+ "qty": 10.0,
+ "rate": 100.0,
"warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM",
"conversion_factor": 1.0,
"uom": "_Test UOM"
}
- ],
- "selling_price_list": "_Test Price List",
- "territory": "_Test Territory",
+ ],
+ "selling_price_list": "_Test Price List",
+ "territory": "_Test Territory",
"transaction_date": "2013-02-21"
}
]
\ No newline at end of file
diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py
index a091ac7..c8424f1 100644
--- a/erpnext/stock/doctype/batch/batch.py
+++ b/erpnext/stock/doctype/batch/batch.py
@@ -143,7 +143,7 @@
@frappe.whitelist()
-def get_batch_qty(batch_no=None, warehouse=None, item_code=None):
+def get_batch_qty(batch_no=None, warehouse=None, item_code=None, posting_date=None, posting_time=None):
"""Returns batch actual qty if warehouse is passed,
or returns dict of qty by warehouse if warehouse is None
@@ -155,9 +155,14 @@
out = 0
if batch_no and warehouse:
+ cond = ""
+ if posting_date and posting_time:
+ cond = " and timestamp(posting_date, posting_time) <= timestamp('{0}', '{1}')".format(posting_date,
+ posting_time)
+
out = float(frappe.db.sql("""select sum(actual_qty)
from `tabStock Ledger Entry`
- where warehouse=%s and batch_no=%s""",
+ where warehouse=%s and batch_no=%s {0}""".format(cond),
(warehouse, batch_no))[0][0] or 0)
if batch_no and not warehouse:
diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
index a921a56..4b04a0a 100644
--- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
@@ -537,11 +537,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")
@@ -567,13 +564,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_cost_center_with_balance_sheet_account(self):
cost_center = "Main - TCP1"
company = frappe.db.get_value('Warehouse', 'Stores - TCP1', 'company')
@@ -583,7 +575,11 @@
make_stock_entry(target="Stores - TCP1", qty=5, basic_rate=100)
stock_in_hand_account = get_inventory_account('_Test Company with perpetual inventory')
- dn = create_delivery_note(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', cost_center = 'Main - TCP1', expense_account = "Cost of Goods Sold - TCP1")
+ dn = create_delivery_note(company='_Test Company with perpetual inventory', warehouse='Stores - TCP1', cost_center = 'Main - TCP1', expense_account = "Cost of Goods Sold - TCP1",
+ do_not_submit=1)
+
+ dn.get('items')[0].cost_center = None
+ dn.submit()
gl_entries = get_gl_entries("Delivery Note", dn.name)
@@ -593,7 +589,7 @@
"cost_center": cost_center
},
stock_in_hand_account: {
- "cost_center": None
+ "cost_center": cost_center
}
}
for i, gle in enumerate(gl_entries):
diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
index 7ea2de2..3d57f47 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",
@@ -82,6 +81,7 @@
"accounting_dimensions_section",
"cost_center",
"dimension_col_break",
+ "project",
"section_break_72",
"page_break"
],
@@ -702,6 +702,12 @@
"fieldtype": "Column Break"
},
{
+ "fieldname": "project",
+ "fieldtype": "Link",
+ "label": "Project",
+ "options": "Project"
+ },
+ {
"fieldname": "dn_detail",
"fieldtype": "Data",
"hidden": 1,
@@ -714,7 +720,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2020-03-05 14:18:33.131672",
+ "modified": "2020-07-20 12:25:06.177894",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note Item",
diff --git a/erpnext/stock/doctype/item/test_records.json b/erpnext/stock/doctype/item/test_records.json
index 6c1a559..9ca887c 100644
--- a/erpnext/stock/doctype/item/test_records.json
+++ b/erpnext/stock/doctype/item/test_records.json
@@ -92,8 +92,7 @@
{
"doctype": "Item Tax",
"parentfield": "taxes",
- "item_tax_template": "_Test Account Excise Duty @ 10",
- "tax_category": ""
+ "item_tax_template": "_Test Account Excise Duty @ 10"
}
],
"stock_uom": "_Test UOM 1"
@@ -371,8 +370,7 @@
{
"doctype": "Item Tax",
"parentfield": "taxes",
- "item_tax_template": "_Test Account Excise Duty @ 10",
- "tax_category": ""
+ "item_tax_template": "_Test Account Excise Duty @ 10"
},
{
"doctype": "Item Tax",
@@ -451,14 +449,13 @@
{
"doctype": "Item Tax",
"parentfield": "taxes",
- "item_tax_template": "_Test Account Excise Duty @ 20",
- "tax_category": ""
+ "item_tax_template": "_Test Account Excise Duty @ 20"
},
{
"doctype": "Item Tax",
"parentfield": "taxes",
- "item_tax_template": "_Test Item Tax Template 1",
- "tax_category": "_Test Tax Category 1"
+ "tax_category": "_Test Tax Category 1",
+ "item_tax_template": "_Test Item Tax Template 1"
}
]
}
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 3a8deb6..60f5ff3 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -180,9 +180,8 @@
});
},
- get_item_data: function(frm, item) {
+ get_item_data: function(frm, item, overwrite_warehouse=false) {
if (item && !item.item_code) { return; }
-
frm.call({
method: "erpnext.stock.get_item_details.get_item_details",
child: item,
@@ -203,7 +202,8 @@
plc_conversion_rate: 1,
rate: item.rate,
conversion_factor: item.conversion_factor
- }
+ },
+ overwrite_warehouse: overwrite_warehouse
},
callback: function(r) {
const d = item;
@@ -354,29 +354,29 @@
}
const item = locals[doctype][name];
- frm.events.get_item_data(frm, item);
+ frm.events.get_item_data(frm, item, false);
},
from_warehouse: function(frm, doctype, name) {
const item = locals[doctype][name];
- frm.events.get_item_data(frm, item);
+ frm.events.get_item_data(frm, item, false);
},
warehouse: function(frm, doctype, name) {
const item = locals[doctype][name];
- frm.events.get_item_data(frm, item);
+ frm.events.get_item_data(frm, item, false);
},
rate: function(frm, doctype, name) {
const item = locals[doctype][name];
- frm.events.get_item_data(frm, item);
+ frm.events.get_item_data(frm, item, false);
},
item_code: function(frm, doctype, name) {
const item = locals[doctype][name];
item.rate = 0;
set_schedule_date(frm);
- frm.events.get_item_data(frm, item);
+ frm.events.get_item_data(frm, item, true);
},
schedule_date: function(frm, cdt, cdn) {
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
index 44d5f69..df9eb50 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",
@@ -104,6 +103,7 @@
"bill_no",
"bill_date",
"more_info",
+ "project",
"status",
"amended_from",
"range",
@@ -132,17 +132,13 @@
{
"fieldname": "supplier_section",
"fieldtype": "Section Break",
- "options": "fa fa-user",
- "show_days": 1,
- "show_seconds": 1
+ "options": "fa fa-user"
},
{
"fieldname": "column_break0",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_width": "50%",
- "show_days": 1,
- "show_seconds": 1,
"width": "50%"
},
{
@@ -153,9 +149,7 @@
"hidden": 1,
"label": "Title",
"no_copy": 1,
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "naming_series",
@@ -167,9 +161,7 @@
"options": "MAT-PRE-.YYYY.-",
"print_hide": 1,
"reqd": 1,
- "set_only_once": 1,
- "show_days": 1,
- "show_seconds": 1
+ "set_only_once": 1
},
{
"bold": 1,
@@ -184,8 +176,6 @@
"print_width": "150px",
"reqd": 1,
"search_index": 1,
- "show_days": 1,
- "show_seconds": 1,
"width": "150px"
},
{
@@ -196,24 +186,18 @@
"fieldtype": "Data",
"in_global_search": 1,
"label": "Supplier Name",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "supplier_delivery_note",
"fieldtype": "Data",
- "label": "Supplier Delivery Note",
- "show_days": 1,
- "show_seconds": 1
+ "label": "Supplier Delivery Note"
},
{
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_width": "50%",
- "show_days": 1,
- "show_seconds": 1,
"width": "50%"
},
{
@@ -228,8 +212,6 @@
"print_width": "100px",
"reqd": 1,
"search_index": 1,
- "show_days": 1,
- "show_seconds": 1,
"width": "100px"
},
{
@@ -243,8 +225,6 @@
"print_hide": 1,
"print_width": "100px",
"reqd": 1,
- "show_days": 1,
- "show_seconds": 1,
"width": "100px"
},
{
@@ -253,9 +233,7 @@
"fieldname": "set_posting_time",
"fieldtype": "Check",
"label": "Edit Posting Date and Time",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "company",
@@ -269,8 +247,6 @@
"print_width": "150px",
"remember_last_selected_value": 1,
"reqd": 1,
- "show_days": 1,
- "show_seconds": 1,
"width": "150px"
},
{
@@ -280,9 +256,7 @@
"label": "Is Return",
"no_copy": 1,
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"depends_on": "is_return",
@@ -292,60 +266,46 @@
"no_copy": 1,
"options": "Purchase Receipt",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"collapsible": 1,
"fieldname": "section_addresses",
"fieldtype": "Section Break",
- "label": "Address and Contact",
- "show_days": 1,
- "show_seconds": 1
+ "label": "Address and Contact"
},
{
"fieldname": "supplier_address",
"fieldtype": "Link",
"label": "Select Supplier Address",
"options": "Address",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "contact_person",
"fieldtype": "Link",
"label": "Contact Person",
"options": "Contact",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "address_display",
"fieldtype": "Small Text",
"label": "Address",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "contact_display",
"fieldtype": "Small Text",
"in_global_search": 1,
"label": "Contact",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "contact_mobile",
"fieldtype": "Small Text",
"label": "Mobile No",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "contact_email",
@@ -353,42 +313,32 @@
"label": "Contact Email",
"options": "Email",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "col_break_address",
- "fieldtype": "Column Break",
- "show_days": 1,
- "show_seconds": 1
+ "fieldtype": "Column Break"
},
{
"fieldname": "shipping_address",
"fieldtype": "Link",
"label": "Select Shipping Address",
"options": "Address",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "shipping_address_display",
"fieldtype": "Small Text",
"label": "Shipping Address",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"collapsible": 1,
"fieldname": "currency_and_price_list",
"fieldtype": "Section Break",
"label": "Currency and Price List",
- "options": "fa fa-tag",
- "show_days": 1,
- "show_seconds": 1
+ "options": "fa fa-tag"
},
{
"fieldname": "currency",
@@ -398,9 +348,7 @@
"oldfieldtype": "Select",
"options": "Currency",
"print_hide": 1,
- "reqd": 1,
- "show_days": 1,
- "show_seconds": 1
+ "reqd": 1
},
{
"description": "Rate at which supplier's currency is converted to company's base currency",
@@ -411,17 +359,13 @@
"oldfieldtype": "Currency",
"precision": "9",
"print_hide": 1,
- "reqd": 1,
- "show_days": 1,
- "show_seconds": 1
+ "reqd": 1
},
{
"fieldname": "column_break2",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_width": "50%",
- "show_days": 1,
- "show_seconds": 1,
"width": "50%"
},
{
@@ -429,9 +373,7 @@
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"depends_on": "buying_price_list",
@@ -440,9 +382,7 @@
"label": "Price List Currency",
"options": "Currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"depends_on": "buying_price_list",
@@ -450,9 +390,7 @@
"fieldtype": "Float",
"label": "Price List Exchange Rate",
"precision": "9",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"default": "0",
@@ -461,15 +399,11 @@
"label": "Ignore Pricing Rule",
"no_copy": 1,
"permlevel": 1,
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "sec_warehouse",
- "fieldtype": "Section Break",
- "show_days": 1,
- "show_seconds": 1
+ "fieldtype": "Section Break"
},
{
"description": "Sets 'Accepted Warehouse' in each row of the items table.",
@@ -477,9 +411,7 @@
"fieldtype": "Link",
"label": "Accepted Warehouse",
"options": "Warehouse",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"description": "Sets 'Rejected Warehouse' in each row of the items table.",
@@ -490,15 +422,11 @@
"oldfieldname": "rejected_warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "col_break_warehouse",
- "fieldtype": "Column Break",
- "show_days": 1,
- "show_seconds": 1
+ "fieldtype": "Column Break"
},
{
"default": "No",
@@ -508,9 +436,7 @@
"oldfieldname": "is_subcontracted",
"oldfieldtype": "Select",
"options": "No\nYes",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"depends_on": "eval:doc.is_subcontracted==\"Yes\"",
@@ -523,17 +449,13 @@
"options": "Warehouse",
"print_hide": 1,
"print_width": "50px",
- "show_days": 1,
- "show_seconds": 1,
"width": "50px"
},
{
"fieldname": "items_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-shopping-cart",
- "show_days": 1,
- "show_seconds": 1
+ "options": "fa fa-shopping-cart"
},
{
"allow_bulk_edit": 1,
@@ -543,26 +465,20 @@
"oldfieldname": "purchase_receipt_details",
"oldfieldtype": "Table",
"options": "Purchase Receipt Item",
- "reqd": 1,
- "show_days": 1,
- "show_seconds": 1
+ "reqd": 1
},
{
"collapsible": 1,
"fieldname": "pricing_rule_details",
"fieldtype": "Section Break",
- "label": "Pricing Rules",
- "show_days": 1,
- "show_seconds": 1
+ "label": "Pricing Rules"
},
{
"fieldname": "pricing_rules",
"fieldtype": "Table",
"label": "Pricing Rule Detail",
"options": "Pricing Rule Detail",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"depends_on": "supplied_items",
@@ -571,9 +487,7 @@
"label": "Get Current Stock",
"oldfieldtype": "Button",
"options": "get_current_stock",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"collapsible": 1,
@@ -584,9 +498,7 @@
"oldfieldtype": "Section Break",
"options": "fa fa-table",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "supplied_items",
@@ -597,24 +509,18 @@
"oldfieldtype": "Table",
"options": "Purchase Receipt Item Supplied",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "section_break0",
"fieldtype": "Section Break",
- "oldfieldtype": "Section Break",
- "show_days": 1,
- "show_seconds": 1
+ "oldfieldtype": "Section Break"
},
{
"fieldname": "total_qty",
"fieldtype": "Float",
"label": "Total Quantity",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "base_total",
@@ -622,9 +528,7 @@
"label": "Total (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "base_net_total",
@@ -637,24 +541,18 @@
"print_width": "150px",
"read_only": 1,
"reqd": 1,
- "show_days": 1,
- "show_seconds": 1,
"width": "150px"
},
{
"fieldname": "column_break_27",
- "fieldtype": "Column Break",
- "show_days": 1,
- "show_seconds": 1
+ "fieldtype": "Column Break"
},
{
"fieldname": "total",
"fieldtype": "Currency",
"label": "Total",
"options": "currency",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "net_total",
@@ -664,56 +562,42 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "total_net_weight",
"fieldtype": "Float",
"label": "Total Net Weight",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"description": "Add / Edit Taxes and Charges",
"fieldname": "taxes_charges_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money",
- "show_days": 1,
- "show_seconds": 1
+ "options": "fa fa-money"
},
{
"fieldname": "tax_category",
"fieldtype": "Link",
"label": "Tax Category",
"options": "Tax Category",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "shipping_col",
- "fieldtype": "Column Break",
- "show_days": 1,
- "show_seconds": 1
+ "fieldtype": "Column Break"
},
{
"fieldname": "shipping_rule",
"fieldtype": "Link",
"label": "Shipping Rule",
- "options": "Shipping Rule",
- "show_days": 1,
- "show_seconds": 1
+ "options": "Shipping Rule"
},
{
"fieldname": "taxes_section",
- "fieldtype": "Section Break",
- "show_days": 1,
- "show_seconds": 1
+ "fieldtype": "Section Break"
},
{
"fieldname": "taxes_and_charges",
@@ -722,9 +606,7 @@
"oldfieldname": "purchase_other_charges",
"oldfieldtype": "Link",
"options": "Purchase Taxes and Charges Template",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "taxes",
@@ -732,17 +614,13 @@
"label": "Purchase Taxes and Charges",
"oldfieldname": "purchase_tax_details",
"oldfieldtype": "Table",
- "options": "Purchase Taxes and Charges",
- "show_days": 1,
- "show_seconds": 1
+ "options": "Purchase Taxes and Charges"
},
{
"collapsible": 1,
"fieldname": "sec_tax_breakup",
"fieldtype": "Section Break",
- "label": "Tax Breakup",
- "show_days": 1,
- "show_seconds": 1
+ "label": "Tax Breakup"
},
{
"fieldname": "other_charges_calculation",
@@ -751,17 +629,13 @@
"no_copy": 1,
"oldfieldtype": "HTML",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "totals",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money",
- "show_days": 1,
- "show_seconds": 1
+ "options": "fa fa-money"
},
{
"fieldname": "base_taxes_and_charges_added",
@@ -771,9 +645,7 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "base_taxes_and_charges_deducted",
@@ -783,9 +655,7 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "base_total_taxes_and_charges",
@@ -795,16 +665,12 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "column_break3",
"fieldtype": "Column Break",
"print_width": "50%",
- "show_days": 1,
- "show_seconds": 1,
"width": "50%"
},
{
@@ -815,9 +681,7 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "taxes_and_charges_deducted",
@@ -827,9 +691,7 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "total_taxes_and_charges",
@@ -837,18 +699,14 @@
"label": "Total Taxes and Charges",
"options": "currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "discount_amount",
"fieldname": "section_break_42",
"fieldtype": "Section Break",
- "label": "Additional Discount",
- "show_days": 1,
- "show_seconds": 1
+ "label": "Additional Discount"
},
{
"default": "Grand Total",
@@ -856,9 +714,7 @@
"fieldtype": "Select",
"label": "Apply Additional Discount On",
"options": "\nGrand Total\nNet Total",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "base_discount_amount",
@@ -866,38 +722,28 @@
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "column_break_44",
- "fieldtype": "Column Break",
- "show_days": 1,
- "show_seconds": 1
+ "fieldtype": "Column Break"
},
{
"fieldname": "additional_discount_percentage",
"fieldtype": "Float",
"label": "Additional Discount Percentage",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "discount_amount",
"fieldtype": "Currency",
"label": "Additional Discount Amount",
"options": "currency",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "section_break_46",
- "fieldtype": "Section Break",
- "show_days": 1,
- "show_seconds": 1
+ "fieldtype": "Section Break"
},
{
"fieldname": "base_grand_total",
@@ -907,9 +753,7 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "base_rounding_adjustment",
@@ -918,9 +762,7 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "base_in_words",
@@ -929,9 +771,7 @@
"oldfieldname": "in_words",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "base_rounded_total",
@@ -941,15 +781,11 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "column_break_50",
- "fieldtype": "Column Break",
- "show_days": 1,
- "show_seconds": 1
+ "fieldtype": "Column Break"
},
{
"fieldname": "grand_total",
@@ -959,9 +795,7 @@
"oldfieldname": "grand_total_import",
"oldfieldtype": "Currency",
"options": "currency",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "rounding_adjustment",
@@ -970,9 +804,7 @@
"no_copy": 1,
"options": "currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"depends_on": "eval:!doc.disable_rounded_total",
@@ -982,9 +814,7 @@
"no_copy": 1,
"options": "currency",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "in_words",
@@ -993,17 +823,13 @@
"oldfieldname": "in_words_import",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"default": "0",
"fieldname": "disable_rounded_total",
"fieldtype": "Check",
- "label": "Disable Rounded Total",
- "show_days": 1,
- "show_seconds": 1
+ "label": "Disable Rounded Total"
},
{
"collapsible": 1,
@@ -1012,9 +838,7 @@
"fieldtype": "Section Break",
"label": "Terms and Conditions",
"oldfieldtype": "Section Break",
- "options": "fa fa-legal",
- "show_days": 1,
- "show_seconds": 1
+ "options": "fa fa-legal"
},
{
"fieldname": "tc_name",
@@ -1023,18 +847,14 @@
"oldfieldname": "tc_name",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "terms",
"fieldtype": "Text Editor",
"label": "Terms and Conditions",
"oldfieldname": "terms",
- "oldfieldtype": "Text Editor",
- "show_days": 1,
- "show_seconds": 1
+ "oldfieldtype": "Text Editor"
},
{
"fieldname": "bill_no",
@@ -1043,9 +863,7 @@
"label": "Bill No",
"oldfieldname": "bill_no",
"oldfieldtype": "Data",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "bill_date",
@@ -1054,9 +872,7 @@
"label": "Bill Date",
"oldfieldname": "bill_date",
"oldfieldtype": "Date",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"collapsible": 1,
@@ -1064,9 +880,7 @@
"fieldtype": "Section Break",
"label": "More Information",
"oldfieldtype": "Section Break",
- "options": "fa fa-file-text",
- "show_days": 1,
- "show_seconds": 1
+ "options": "fa fa-file-text"
},
{
"default": "Draft",
@@ -1083,8 +897,6 @@
"read_only": 1,
"reqd": 1,
"search_index": 1,
- "show_days": 1,
- "show_seconds": 1,
"width": "150px"
},
{
@@ -1100,8 +912,6 @@
"print_hide": 1,
"print_width": "150px",
"read_only": 1,
- "show_days": 1,
- "show_seconds": 1,
"width": "150px"
},
{
@@ -1111,9 +921,7 @@
"label": "Range",
"oldfieldname": "range",
"oldfieldtype": "Data",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "column_break4",
@@ -1121,26 +929,27 @@
"oldfieldtype": "Column Break",
"print_hide": 1,
"print_width": "50%",
- "show_days": 1,
- "show_seconds": 1,
"width": "50%"
},
{
+ "description": "Track this Purchase Receipt against any Project",
+ "fieldname": "project",
+ "fieldtype": "Link",
+ "label": "Project",
+ "options": "Project"
+ },
+ {
"fieldname": "per_billed",
"fieldtype": "Percent",
"label": "% Amount Billed",
"no_copy": 1,
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "subscription_detail",
"fieldtype": "Section Break",
- "label": "Auto Repeat Detail",
- "show_days": 1,
- "show_seconds": 1
+ "label": "Auto Repeat Detail"
},
{
"fieldname": "auto_repeat",
@@ -1149,17 +958,13 @@
"no_copy": 1,
"options": "Auto Repeat",
"print_hide": 1,
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"collapsible": 1,
"fieldname": "printing_settings",
"fieldtype": "Section Break",
- "label": "Printing Settings",
- "show_days": 1,
- "show_seconds": 1
+ "label": "Printing Settings"
},
{
"allow_on_submit": 1,
@@ -1167,9 +972,7 @@
"fieldtype": "Link",
"label": "Letter Head",
"options": "Letter Head",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"allow_on_submit": 1,
@@ -1181,17 +984,13 @@
"oldfieldtype": "Link",
"options": "Print Heading",
"print_hide": 1,
- "report_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "report_hide": 1
},
{
"fieldname": "language",
"fieldtype": "Data",
"label": "Print Language",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"allow_on_submit": 1,
@@ -1199,15 +998,11 @@
"fieldname": "group_same_items",
"fieldtype": "Check",
"label": "Group same items",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"fieldname": "column_break_97",
- "fieldtype": "Column Break",
- "show_days": 1,
- "show_seconds": 1
+ "fieldtype": "Column Break"
},
{
"fieldname": "other_details",
@@ -1218,8 +1013,6 @@
"options": "<div class=\"columnHeading\">Other Details</div>",
"print_hide": 1,
"print_width": "30%",
- "show_days": 1,
- "show_seconds": 1,
"width": "30%"
},
{
@@ -1227,17 +1020,13 @@
"fieldtype": "Small Text",
"label": "Instructions",
"oldfieldname": "instructions",
- "oldfieldtype": "Text",
- "show_days": 1,
- "show_seconds": 1
+ "oldfieldtype": "Text"
},
{
"fieldname": "remarks",
"fieldtype": "Small Text",
"label": "Remarks",
- "print_hide": 1,
- "show_days": 1,
- "show_seconds": 1
+ "print_hide": 1
},
{
"collapsible": 1,
@@ -1245,25 +1034,19 @@
"fieldname": "transporter_info",
"fieldtype": "Section Break",
"label": "Transporter Details",
- "options": "fa fa-truck",
- "show_days": 1,
- "show_seconds": 1
+ "options": "fa fa-truck"
},
{
"fieldname": "transporter_name",
"fieldtype": "Data",
"label": "Transporter Name",
"oldfieldname": "transporter_name",
- "oldfieldtype": "Data",
- "show_days": 1,
- "show_seconds": 1
+ "oldfieldtype": "Data"
},
{
"fieldname": "column_break5",
"fieldtype": "Column Break",
"print_width": "50%",
- "show_days": 1,
- "show_seconds": 1,
"width": "50%"
},
{
@@ -1274,8 +1057,6 @@
"oldfieldname": "lr_no",
"oldfieldtype": "Data",
"print_width": "100px",
- "show_days": 1,
- "show_seconds": 1,
"width": "100px"
},
{
@@ -1286,8 +1067,6 @@
"oldfieldname": "lr_date",
"oldfieldtype": "Date",
"print_width": "100px",
- "show_days": 1,
- "show_seconds": 1,
"width": "100px"
},
{
@@ -1296,48 +1075,38 @@
"fieldname": "is_internal_supplier",
"fieldtype": "Check",
"label": "Is Internal Supplier",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "inter_company_reference",
"fieldtype": "Link",
"label": "Inter Company Reference",
"options": "Delivery Note",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
},
{
"fieldname": "scan_barcode",
"fieldtype": "Data",
- "label": "Scan Barcode",
- "show_days": 1,
- "show_seconds": 1
+ "label": "Scan Barcode"
},
{
"fieldname": "billing_address",
"fieldtype": "Link",
"label": "Select Billing Address",
- "options": "Address",
- "show_days": 1,
- "show_seconds": 1
+ "options": "Address"
},
{
"fieldname": "billing_address_display",
"fieldtype": "Small Text",
"label": "Billing Address",
- "read_only": 1,
- "show_days": 1,
- "show_seconds": 1
+ "read_only": 1
}
],
"icon": "fa fa-truck",
"idx": 261,
"is_submittable": 1,
"links": [],
- "modified": "2020-06-13 22:26:03.600092",
+ "modified": "2020-07-15 10:01:39.302238",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt",
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index 649cfdc..d97b9e8 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_cost_center_with_balance_sheet_account(self):
if not frappe.db.exists('Location', 'Test Location'):
frappe.get_doc({
'doctype': 'Location',
@@ -454,13 +444,14 @@
gl_entries = get_gl_entries("Purchase Receipt", pr.name)
self.assertTrue(gl_entries)
+ cost_center = pr.get('items')[0].cost_center
expected_values = {
"Stock Received But Not Billed - TCP1": {
- "cost_center": None
+ "cost_center": cost_center
},
stock_in_hand_account: {
- "cost_center": None
+ "cost_center": cost_center
}
}
for i, gle in enumerate(gl_entries):
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index dd284e4..ecee97c 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -74,6 +74,20 @@
, __("Get Items"), __("Update"));
},
+ posting_date: function(frm) {
+ frm.trigger("set_valuation_rate_and_qty_for_all_items");
+ },
+
+ posting_time: function(frm) {
+ frm.trigger("set_valuation_rate_and_qty_for_all_items");
+ },
+
+ set_valuation_rate_and_qty_for_all_items: function(frm) {
+ frm.doc.items.forEach(row => {
+ frm.events.set_valuation_rate_and_qty(frm, row.doctype, row.name);
+ });
+ },
+
set_valuation_rate_and_qty: function(frm, cdt, cdn) {
var d = frappe.model.get_doc(cdt, cdn);
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 5e469c2..43fbc00 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -184,8 +184,12 @@
sl_entries = []
has_serial_no = False
+ has_batch_no = False
for row in self.items:
item = frappe.get_doc("Item", row.item_code)
+ if item.has_batch_no:
+ has_batch_no = True
+
if item.has_serial_no or item.has_batch_no:
has_serial_no = True
self.get_sle_for_serialized_items(row, sl_entries)
@@ -222,7 +226,11 @@
if has_serial_no:
sl_entries = self.merge_similar_item_serial_nos(sl_entries)
- self.make_sl_entries(sl_entries)
+ allow_negative_stock = False
+ if has_batch_no:
+ allow_negative_stock = True
+
+ self.make_sl_entries(sl_entries, allow_negative_stock=allow_negative_stock)
if has_serial_no and sl_entries:
self.update_valuation_rate_for_serial_no()
@@ -493,7 +501,7 @@
qty, rate = data
if item_dict.get("has_batch_no"):
- qty = get_batch_qty(batch_no, warehouse) or 0
+ qty = get_batch_qty(batch_no, warehouse, posting_date=posting_date, posting_time=posting_time) or 0
return {
'qty': qty,
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 1f30f5a..b8554c8 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -47,6 +47,8 @@
"""
args = process_args(args)
+ for_validate = process_string_args(for_validate)
+ overwrite_warehouse = process_string_args(overwrite_warehouse)
item = frappe.get_cached_doc("Item", args.item_code)
validate_item_details(args, item)
@@ -166,6 +168,10 @@
set_transaction_type(args)
return args
+def process_string_args(args):
+ if isinstance(args, string_types):
+ args = json.loads(args)
+ return args
@frappe.whitelist()
def get_item_code(barcode=None, serial_no=None):
@@ -638,7 +644,7 @@
if args.get('transaction_date'):
conditions += """ and %(transaction_date)s between
ifnull(valid_from, '2000-01-01') and ifnull(valid_upto, '2500-12-31')"""
-
+
if args.get('posting_date'):
conditions += """ and %(posting_date)s between
ifnull(valid_from, '2000-01-01') and ifnull(valid_upto, '2500-12-31')"""
diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py
index 74a4f6e..042087a 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.py
+++ b/erpnext/stock/report/stock_balance/stock_balance.py
@@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import frappe
+import frappe, erpnext
from frappe import _
from frappe.utils import flt, cint, getdate, now, date_diff
from erpnext.stock.utils import add_additional_uom_columns
@@ -20,6 +20,11 @@
from_date = filters.get('from_date')
to_date = filters.get('to_date')
+ if filters.get("company"):
+ company_currency = erpnext.get_company_currency(filters.get("company"))
+ else:
+ company_currency = frappe.db.get_single_value("Global Defaults", "default_currency")
+
include_uom = filters.get("include_uom")
columns = get_columns(filters)
items = get_items(filters)
@@ -52,6 +57,7 @@
item_reorder_qty = item_reorder_detail_map[item + warehouse]["warehouse_reorder_qty"]
report_data = {
+ 'currency': company_currency,
'item_code': item,
'warehouse': warehouse,
'company': company,
@@ -89,7 +95,6 @@
def get_columns(filters):
"""return columns"""
-
columns = [
{"label": _("Item"), "fieldname": "item_code", "fieldtype": "Link", "options": "Item", "width": 100},
{"label": _("Item Name"), "fieldname": "item_name", "width": 150},
@@ -97,14 +102,14 @@
{"label": _("Warehouse"), "fieldname": "warehouse", "fieldtype": "Link", "options": "Warehouse", "width": 100},
{"label": _("Stock UOM"), "fieldname": "stock_uom", "fieldtype": "Link", "options": "UOM", "width": 90},
{"label": _("Balance Qty"), "fieldname": "bal_qty", "fieldtype": "Float", "width": 100, "convertible": "qty"},
- {"label": _("Balance Value"), "fieldname": "bal_val", "fieldtype": "Currency", "width": 100},
+ {"label": _("Balance Value"), "fieldname": "bal_val", "fieldtype": "Currency", "width": 100, "options": "currency"},
{"label": _("Opening Qty"), "fieldname": "opening_qty", "fieldtype": "Float", "width": 100, "convertible": "qty"},
- {"label": _("Opening Value"), "fieldname": "opening_val", "fieldtype": "Float", "width": 110},
+ {"label": _("Opening Value"), "fieldname": "opening_val", "fieldtype": "Currency", "width": 110, "options": "currency"},
{"label": _("In Qty"), "fieldname": "in_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("In Value"), "fieldname": "in_val", "fieldtype": "Float", "width": 80},
{"label": _("Out Qty"), "fieldname": "out_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("Out Value"), "fieldname": "out_val", "fieldtype": "Float", "width": 80},
- {"label": _("Valuation Rate"), "fieldname": "val_rate", "fieldtype": "Currency", "width": 90, "convertible": "rate"},
+ {"label": _("Valuation Rate"), "fieldname": "val_rate", "fieldtype": "Currency", "width": 90, "convertible": "rate", "options": "currency"},
{"label": _("Reorder Level"), "fieldname": "reorder_level", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("Reorder Qty"), "fieldname": "reorder_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("Company"), "fieldname": "company", "fieldtype": "Link", "options": "Company", "width": 100}
diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py
index abf959e..fe8ad71 100644
--- a/erpnext/stock/report/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/report/stock_ledger/stock_ledger.py
@@ -4,10 +4,10 @@
from __future__ import unicode_literals
import frappe
+from frappe.utils import cint, flt
from erpnext.stock.utils import update_included_uom_in_report
from frappe import _
-
def execute(filters=None):
include_uom = filters.get("include_uom")
columns = get_columns()
@@ -15,6 +15,7 @@
sl_entries = get_stock_ledger_entries(filters, items)
item_details = get_item_details(items, sl_entries, include_uom)
opening_row = get_opening_balance(filters, columns)
+ precision = cint(frappe.db.get_single_value("System Settings", "float_precision"))
data = []
conversion_factors = []
@@ -29,10 +30,10 @@
sle.update(item_detail)
if filters.get("batch_no"):
- actual_qty += sle.actual_qty
+ actual_qty += flt(sle.actual_qty, precision)
stock_value += sle.stock_value_difference
- if sle.voucher_type == 'Stock Reconciliation':
+ if sle.voucher_type == 'Stock Reconciliation' and not sle.actual_qty:
actual_qty = sle.qty_after_transaction
stock_value = sle.stock_value
diff --git a/erpnext/support/doctype/issue/issue_list.js b/erpnext/support/doctype/issue/issue_list.js
index 6d702f6..513a8dc 100644
--- a/erpnext/support/doctype/issue/issue_list.js
+++ b/erpnext/support/doctype/issue/issue_list.js
@@ -8,11 +8,11 @@
var method = "erpnext.support.doctype.issue.issue.set_multiple_status";
- listview.page.add_menu_item(__("Set as Open"), function() {
+ listview.page.add_action_item(__("Set as Open"), function() {
listview.call_for_selected_items(method, {"status": "Open"});
});
- listview.page.add_menu_item(__("Set as Closed"), function() {
+ listview.page.add_action_item(__("Set as Closed"), function() {
listview.call_for_selected_items(method, {"status": "Closed"});
});
},
diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
index c692315..70c4696 100644
--- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
+++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
@@ -6,7 +6,7 @@
import frappe
from frappe.model.document import Document
from frappe import _
-from frappe.utils import getdate, get_weekdays
+from frappe.utils import getdate, get_weekdays, get_link_to_form
class ServiceLevelAgreement(Document):
@@ -21,8 +21,8 @@
for priority in self.priorities:
# Check if response and resolution time is set for every priority
- if not (priority.response_time or priority.resolution_time):
- frappe.throw(_("Set Response Time and Resolution for Priority {0} at index {1}.").format(priority.priority, priority.idx))
+ if not priority.response_time or not priority.resolution_time:
+ frappe.throw(_("Set Response Time and Resolution Time for Priority {0} in row {1}.").format(priority.priority, priority.idx))
priorities.append(priority.priority)
@@ -33,7 +33,7 @@
resolution = priority.resolution_time
if response > resolution:
- frappe.throw(_("Response Time for {0} at index {1} can't be greater than Resolution Time.").format(priority.priority, priority.idx))
+ frappe.throw(_("Response Time for {0} priority in row {1} can't be greater than Resolution Time.").format(priority.priority, priority.idx))
# Check if repeated priority
if not len(set(priorities)) == len(priorities):
@@ -73,8 +73,9 @@
frappe.throw(_("Workday {0} has been repeated.").format(repeated_days))
def validate_doc(self):
- if not frappe.db.get_single_value("Support Settings", "track_service_level_agreement"):
- frappe.throw(_("Service Level Agreement tracking is not enabled."))
+ if not frappe.db.get_single_value("Support Settings", "track_service_level_agreement") and self.enable:
+ frappe.throw(_("{0} is not enabled in {1}").format(frappe.bold("Track Service Level Agreement"),
+ get_link_to_form("Support Settings", "Support Settings")))
if self.default_service_level_agreement:
if frappe.db.exists("Service Level Agreement", {"default_service_level_agreement": "1", "name": ["!=", self.name]}):
diff --git a/requirements.txt b/requirements.txt
index cfd0ab8..912d61f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,7 +2,7 @@
frappe
gocardless-pro==1.11.0
googlemaps==3.1.1
-pandas==0.24.2
+pandas==1.0.5
plaid-python==3.4.0
pycountry==19.8.18
PyGithub==1.44.1