From b161eea793fbc1fd9707fbed5c156655f2710c99 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Jun 2014 12:51:16 +0530 Subject: [PATCH 1/7] Account balance must be debit / credit, validate if balance already in credit / debit. Fixes #1442 --- erpnext/accounts/doctype/account/account.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index c551a62aaa..e5e2e41feb 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -30,6 +30,7 @@ class Account(Document): self.validate_mandatory() self.validate_warehouse_account() self.validate_frozen_accounts_modifier() + self.validate_balance_must_be_settings() def validate_master_name(self): if self.master_type in ('Customer', 'Supplier') or self.account_type == "Warehouse": @@ -69,6 +70,15 @@ class Account(Document): frozen_accounts_modifier not in frappe.user.get_roles(): throw(_("You are not authorized to set Frozen value")) + def validate_balance_must_be_settings(self): + from erpnext.accounts.utils import get_balance_on + account_balance = get_balance_on(self.name) + + if account_balance > 0 and self.balance_must_be == "Credit": + frappe.throw(_("Account balance already in Debit, you are not allowed to set 'Balance Must Be' as 'Credit'")) + elif account_balance < 0 and self.balance_must_be == "Debit": + frappe.throw(_("Account balance already in Credit, you are not allowed to set 'Balance Must Be' as 'Debit'")) + def convert_group_to_ledger(self): if self.check_if_child_exists(): throw(_("Account with child nodes cannot be converted to ledger")) From 19d1e499c3d4cd3c1a385abbcf0724cecd7381ec Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Jun 2014 15:18:24 +0530 Subject: [PATCH 2/7] Removed Purchase in transit report #1435 --- erpnext/config/buying.py | 6 ------ erpnext/config/stock.py | 6 ------ erpnext/patches.txt | 1 + .../report/purchase_in_transit/__init__.py | 0 .../purchase_in_transit.json | 17 ----------------- 5 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 erpnext/stock/report/purchase_in_transit/__init__.py delete mode 100644 erpnext/stock/report/purchase_in_transit/purchase_in_transit.json diff --git a/erpnext/config/buying.py b/erpnext/config/buying.py index c8a74be2e5..bc6251982b 100644 --- a/erpnext/config/buying.py +++ b/erpnext/config/buying.py @@ -129,12 +129,6 @@ def get_data(): "name": "Material Requests for which Supplier Quotations are not created", "doctype": "Material Request" }, - { - "type": "report", - "is_query_report": True, - "name": "Purchase In Transit", - "doctype": "Purchase Order" - }, { "type": "report", "is_query_report": True, diff --git a/erpnext/config/stock.py b/erpnext/config/stock.py index 0f53288b95..ace83fc447 100644 --- a/erpnext/config/stock.py +++ b/erpnext/config/stock.py @@ -211,12 +211,6 @@ def get_data(): "name": "Serial No Warranty Expiry", "doctype": "Serial No" }, - { - "type": "report", - "is_query_report": True, - "name": "Purchase In Transit", - "doctype": "Purchase Order" - }, { "type": "report", "is_query_report": True, diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e5e9e0ad15..b5e66d4b1a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -44,3 +44,4 @@ execute:frappe.db.sql("delete from `tabWebsite Item Group` where ifnull(item_gro execute:frappe.delete_doc("Print Format", "SalesInvoice") execute:import frappe.defaults;frappe.defaults.clear_default("price_list_currency") erpnext.patches.v4_0.update_account_root_type +execute:frappe.delete_doc("Report", "Purchase In Transit") diff --git a/erpnext/stock/report/purchase_in_transit/__init__.py b/erpnext/stock/report/purchase_in_transit/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/stock/report/purchase_in_transit/purchase_in_transit.json b/erpnext/stock/report/purchase_in_transit/purchase_in_transit.json deleted file mode 100644 index 7ef63d4a9d..0000000000 --- a/erpnext/stock/report/purchase_in_transit/purchase_in_transit.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "apply_user_permissions": 1, - "creation": "2013-05-06 12:09:05", - "docstatus": 0, - "doctype": "Report", - "idx": 1, - "is_standard": "Yes", - "modified": "2014-06-03 07:18:17.234173", - "modified_by": "Administrator", - "module": "Stock", - "name": "Purchase In Transit", - "owner": "Administrator", - "query": "SELECT\n pi.name as \"Purchase Invoice:Link/Purchase Invoice:120\",\n\tpi.posting_date as \"Posting Date:Date:100\",\n\tpi.credit_to as \"Supplier Account:Link/Account:120\",\n\tpi_item.item_code as \"Item Code:Link/Item:120\",\n\tpi_item.description as \"Description:Data:140\",\n\tpi_item.qty as \"Qty:Float:120\",\n\tpi_item.base_amount as \"Amount:Currency:120\",\n\tpi_item.purchase_order as \"Purchase Order:Link/Purchase Order:120\",\n\tpi_item.purchase_receipt as \"Purchase Receipt:Link/Purchase Receipt:120\",\n\tpr.posting_date as \"PR Posting Date:Date:130\",\n\tpi.company as \"Company:Link/Company:120\"\nFROM\n\t`tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item, `tabPurchase Receipt` pr\nWHERE\n\tpi.name = pi_item.parent and pi_item.purchase_receipt = pr.name\n\tand pi.docstatus = 1 and pr.posting_date > pi.posting_date\nORDER BY\n\tpi.name desc", - "ref_doctype": "Purchase Receipt", - "report_name": "Purchase In Transit", - "report_type": "Query Report" -} \ No newline at end of file From 1055139c8305b69d5c7a8c579ba3d61982783267 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Jun 2014 16:40:29 +0530 Subject: [PATCH 3/7] get accounts for opening entry --- erpnext/accounts/doctype/journal_voucher/journal_voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py index 70bee90016..d75101d0e1 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py @@ -410,7 +410,7 @@ def get_opening_accounts(company): """get all balance sheet accounts for opening entry""" from erpnext.accounts.utils import get_balance_on accounts = frappe.db.sql_list("""select name from tabAccount - where group_or_ledger='Ledger' and report_type='Profit and Loss' and company=%s""", company) + where group_or_ledger='Ledger' and report_type='Balance Sheet' and company=%s""", company) return [{"account": a, "balance": get_balance_on(a)} for a in accounts] From c3d1d6a9460ca0d07d90b07208853529feacea84 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Jun 2014 16:41:22 +0530 Subject: [PATCH 4/7] cleanup raw materials supplied table for sub-contraction. Fixes #1743 --- erpnext/controllers/buying_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index ad56d8fe94..accaeb4498 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -267,7 +267,7 @@ class BuyingController(StockController): for d in self.get(raw_material_table): if [d.main_item_code, d.reference_name] not in parent_items: # mark for deletion from doclist - delete_list.append([d.main_item_code, d.reference_name]) + delete_list.append(d) # delete from doclist if delete_list: From deb6e06336f49bf0d0aa754e71819a89bd6abd7a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Jun 2014 17:09:58 +0530 Subject: [PATCH 5/7] minor fix --- erpnext/accounts/doctype/account/account.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index e5e2e41feb..4cd4efe86d 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -72,12 +72,13 @@ class Account(Document): def validate_balance_must_be_settings(self): from erpnext.accounts.utils import get_balance_on - account_balance = get_balance_on(self.name) + if not self.get("__islocal") and self.balance_must_be: + account_balance = get_balance_on(self.name) - if account_balance > 0 and self.balance_must_be == "Credit": - frappe.throw(_("Account balance already in Debit, you are not allowed to set 'Balance Must Be' as 'Credit'")) - elif account_balance < 0 and self.balance_must_be == "Debit": - frappe.throw(_("Account balance already in Credit, you are not allowed to set 'Balance Must Be' as 'Debit'")) + if account_balance > 0 and self.balance_must_be == "Credit": + frappe.throw(_("Account balance already in Debit, you are not allowed to set 'Balance Must Be' as 'Credit'")) + elif account_balance < 0 and self.balance_must_be == "Debit": + frappe.throw(_("Account balance already in Credit, you are not allowed to set 'Balance Must Be' as 'Debit'")) def convert_group_to_ledger(self): if self.check_if_child_exists(): From 4d4df03f883abef46052efae896f4e6e4c948a08 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Jun 2014 18:02:16 +0530 Subject: [PATCH 6/7] Added total debit / credit row in trial balance. Fixes #1313 --- .../financial_analytics.js | 3 --- .../page/trial_balance/trial_balance.js | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js index df30d83861..52298bbf18 100644 --- a/erpnext/accounts/page/financial_analytics/financial_analytics.js +++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js @@ -256,9 +256,6 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({ } }); this.data.push(net_profit); - // $.each(me.data, function(i, v) { - // if(v.report_type=="Profit and Loss") console.log(v) - // }) } }, add_balance: function(field, account, gl) { diff --git a/erpnext/accounts/page/trial_balance/trial_balance.js b/erpnext/accounts/page/trial_balance/trial_balance.js index e73e1d4f3a..2edf82240e 100644 --- a/erpnext/accounts/page/trial_balance/trial_balance.js +++ b/erpnext/accounts/page/trial_balance/trial_balance.js @@ -29,6 +29,7 @@ frappe.pages['trial-balance'].onload = function(wrapper) { this.with_period_closing_entry = this.wrapper .find(".with_period_closing_entry input:checked").length; this._super(); + this.add_total_debit_credit(); }, update_balances: function(account, posting_date, v) { @@ -42,6 +43,32 @@ frappe.pages['trial-balance'].onload = function(wrapper) { this._super(account, posting_date, v); } }, + + add_total_debit_credit: function() { + var me = this; + + var total_row = { + company: me.company, + id: "Total Debit / Credit", + name: "Total Debit / Credit", + indent: 0, + opening_dr: "NA", + opening_cr: "NA", + debit: 0, + credit: 0, + checked: false, + }; + me.item_by_name[total_row.name] = total_row; + + $.each(this.data, function(i, account) { + if((account.group_or_ledger == "Ledger") || (account.rgt - account.lft == 1)) { + total_row["debit"] += account.debit; + total_row["credit"] += account.credit; + } + }); + + this.data.push(total_row); + } }) erpnext.trial_balance = new TrialBalance(wrapper, 'Trial Balance'); From c8be8ba42cdaee909df29b9be14557bd9db7452f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 5 Jun 2014 15:18:10 +0530 Subject: [PATCH 7/7] function renamed --- erpnext/accounts/doctype/account/account.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 4cd4efe86d..b1edaf4df4 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -30,7 +30,7 @@ class Account(Document): self.validate_mandatory() self.validate_warehouse_account() self.validate_frozen_accounts_modifier() - self.validate_balance_must_be_settings() + self.validate_balance_must_be_debit_or_credit() def validate_master_name(self): if self.master_type in ('Customer', 'Supplier') or self.account_type == "Warehouse": @@ -70,7 +70,7 @@ class Account(Document): frozen_accounts_modifier not in frappe.user.get_roles(): throw(_("You are not authorized to set Frozen value")) - def validate_balance_must_be_settings(self): + def validate_balance_must_be_debit_or_credit(self): from erpnext.accounts.utils import get_balance_on if not self.get("__islocal") and self.balance_must_be: account_balance = get_balance_on(self.name)