diff --git a/.travis.yml b/.travis.yml index 7e5f21d48a..6eab0e4af6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ install: - sudo apt-get update - sudo apt-get purge -y mysql-common - sudo apt-get install mariadb-server mariadb-common libmariadbclient-dev - - CFLAGS=-O0 pip install git+https://github.com/frappe/frappe.git@$TRAVIS_BRANCH && + - CFLAGS=-O0 pip install git+https://github.com/frappe/frappe.git@$develop && - pip install --editable . before_script: diff --git a/erpnext/accounts/doctype/c_form/c_form.py b/erpnext/accounts/doctype/c_form/c_form.py index e0f008f8ad..88ced9a813 100644 --- a/erpnext/accounts/doctype/c_form/c_form.py +++ b/erpnext/accounts/doctype/c_form/c_form.py @@ -55,12 +55,12 @@ class CForm(Document): def get_invoice_details(self, invoice_no): """ Pull details from invoices for referrence """ - - inv = frappe.db.get_value("Sales Invoice", invoice_no, - ["posting_date", "territory", "net_total", "grand_total"], as_dict=True) - return { - 'invoice_date' : inv.posting_date, - 'territory' : inv.territory, - 'net_total' : inv.net_total, - 'grand_total' : inv.grand_total - } + if invoice_no: + inv = frappe.db.get_value("Sales Invoice", invoice_no, + ["posting_date", "territory", "net_total", "grand_total"], as_dict=True) + return { + 'invoice_date' : inv.posting_date, + 'territory' : inv.territory, + 'net_total' : inv.net_total, + 'grand_total' : inv.grand_total + } diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.json b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json index dcd5a7608c..0f7aefd312 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.json +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json @@ -55,7 +55,7 @@ ], "icon": "icon-calendar", "idx": 1, - "modified": "2014-05-27 03:49:10.942338", + "modified": "2014-07-14 05:30:56.843180", "modified_by": "Administrator", "module": "Accounts", "name": "Fiscal Year", @@ -82,5 +82,7 @@ "read": 1, "role": "All" } - ] + ], + "sort_field": "name", + "sort_order": "DESC" } \ No newline at end of file diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 9141697a77..9a3b3121f4 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -183,7 +183,7 @@ def get_pricing_rules(args): group_condition = _get_tree_conditions(parenttype) if group_condition: conditions += " and " + group_condition - + if not args.price_list: args.price_list = None conditions += " and ifnull(for_price_list, '') in (%(price_list)s, '')" if args.get("transaction_date"): diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 80aa73a197..74a9628209 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -30,6 +30,7 @@ class PurchaseInvoice(BuyingController): 'target_ref_field': 'amount', 'source_field': 'amount', 'percent_join_field': 'purchase_order', + 'overflow_type': 'billing' }] def validate(self): diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 834865bcd6..0f6737cc87 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -36,7 +36,8 @@ class SalesInvoice(SellingController): 'join_field': 'so_detail', 'percent_join_field': 'sales_order', 'status_field': 'billing_status', - 'keyword': 'Billed' + 'keyword': 'Billed', + 'overflow_type': 'billing' }] def validate(self): @@ -134,7 +135,8 @@ class SalesInvoice(SellingController): 'keyword':'Delivered', 'second_source_dt': 'Delivery Note Item', 'second_source_field': 'qty', - 'second_join_field': 'prevdoc_detail_docname' + 'second_join_field': 'prevdoc_detail_docname', + 'overflow_type': 'delivery' }) def on_update_after_submit(self): @@ -339,8 +341,8 @@ class SalesInvoice(SellingController): def validate_pos(self): if not self.cash_bank_account and flt(self.paid_amount): - msgprint(_("Cash or Bank Account is mandatory for making payment entry")) - raise Exception + frappe.throw(_("Cash or Bank Account is mandatory for making payment entry")) + if flt(self.paid_amount) + flt(self.write_off_amount) \ - flt(self.grand_total) > 1/(10**(self.precision("grand_total") + 1)): frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total""")) @@ -431,9 +433,8 @@ class SalesInvoice(SellingController): submitted = frappe.db.sql("""select name from `tabSales Order` where docstatus = 1 and name = %s""", d.sales_order) if not submitted: - msgprint(_("Sales Order {0} is not submitted").format(d.sales_order)) - raise Exception - + frappe.throw(_("Sales Order {0} is not submitted").format(d.sales_order)) + if d.delivery_note: submitted = frappe.db.sql("""select name from `tabDelivery Note` where docstatus = 1 and name = %s""", d.delivery_note) @@ -682,7 +683,7 @@ def manage_recurring_invoices(next_date=None, commit=True): if exception_list: exception_message = "\n\n".join([cstr(d) for d in exception_list]) - raise Exception, exception_message + frappe.throw(exception_message) def make_new_invoice(ref_wrapper, posting_date): from erpnext.accounts.utils import get_fiscal_year diff --git a/erpnext/accounts/doctype/sales_invoice/test_records.json b/erpnext/accounts/doctype/sales_invoice/test_records.json index b0828f5c7e..eb86672ccd 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_records.json +++ b/erpnext/accounts/doctype/sales_invoice/test_records.json @@ -1,385 +1,385 @@ [ { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "debit_to": "_Test Customer - _TC", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-01-23", "entries": [ { - "amount": 500.0, - "base_amount": 500.0, - "base_rate": 500.0, - "cost_center": "_Test Cost Center - _TC", - "description": "138-CMS Shoe", - "doctype": "Sales Invoice Item", - "income_account": "Sales - _TC", - "item_name": "138-CMS Shoe", - "parentfield": "entries", - "qty": 1.0, + "amount": 500.0, + "base_amount": 500.0, + "base_rate": 500.0, + "cost_center": "_Test Cost Center - _TC", + "description": "138-CMS Shoe", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_name": "138-CMS Shoe", + "parentfield": "entries", + "qty": 1.0, "rate": 500.0 } - ], - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total": 561.8, - "grand_total_export": 561.8, - "is_pos": 0, - "naming_series": "_T-Sales Invoice-", - "net_total": 500.0, + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 561.8, + "grand_total_export": 561.8, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", + "net_total": 500.0, "other_charges": [ { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 6 - }, + }, { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account Service Tax - _TC", + "charge_type": "On Net Total", + "description": "Service Tax", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 6.36 } - ], - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-01-23", + "price_list_currency": "INR", "sales_team": [ { - "allocated_percentage": 65.5, - "doctype": "Sales Team", - "parentfield": "sales_team", + "allocated_percentage": 65.5, + "doctype": "Sales Team", + "parentfield": "sales_team", "sales_person": "_Test Sales Person 1" - }, + }, { - "allocated_percentage": 34.5, - "doctype": "Sales Team", - "parentfield": "sales_team", + "allocated_percentage": 34.5, + "doctype": "Sales Team", + "parentfield": "sales_team", "sales_person": "_Test Sales Person 2" } - ], - "selling_price_list": "_Test Price List", + ], + "selling_price_list": "_Test Price List", "territory": "_Test Territory" - }, + }, { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "debit_to": "_Test Customer - _TC", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-03-07", "entries": [ { - "amount": 500.0, - "base_amount": 500.0, - "base_rate": 500.0, - "cost_center": "_Test Cost Center - _TC", - "description": "_Test Item", - "doctype": "Sales Invoice Item", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "income_account": "Sales - _TC", - "item_code": "_Test Item", - "item_name": "_Test Item", - "parentfield": "entries", - "price_list_rate": 500.0, + "amount": 500.0, + "base_amount": 500.0, + "base_rate": 500.0, + "cost_center": "_Test Cost Center - _TC", + "description": "_Test Item", + "doctype": "Sales Invoice Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "income_account": "Sales - _TC", + "item_code": "_Test Item", + "item_name": "_Test Item", + "parentfield": "entries", + "price_list_rate": 500.0, "qty": 1.0 } - ], - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total": 630.0, - "grand_total_export": 630.0, - "is_pos": 0, - "naming_series": "_T-Sales Invoice-", - "net_total": 500.0, + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 630.0, + "grand_total_export": 630.0, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", + "net_total": 500.0, "other_charges": [ { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 16 - }, + }, { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account Service Tax - _TC", + "charge_type": "On Net Total", + "description": "Service Tax", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 10 } - ], - "plc_conversion_rate": 1.0, - "posting_date": "2013-03-07", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-03-07", + "price_list_currency": "INR", + "selling_price_list": "_Test Price List", "territory": "_Test Territory" - }, + }, { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "debit_to": "_Test Customer - _TC", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-01-23", "entries": [ { - "cost_center": "_Test Cost Center - _TC", - "doctype": "Sales Invoice Item", - "income_account": "Sales - _TC", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", - "parentfield": "entries", - "price_list_rate": 50, - "qty": 10, - "rate": 50, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", + "parentfield": "entries", + "price_list_rate": 50, + "qty": 10, + "rate": 50, "stock_uom": "_Test UOM" - }, + }, { - "cost_center": "_Test Cost Center - _TC", - "doctype": "Sales Invoice Item", - "income_account": "Sales - _TC", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "parentfield": "entries", - "price_list_rate": 150, - "qty": 5, - "rate": 150, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 200", + "item_name": "_Test Item Home Desktop 200", + "parentfield": "entries", + "price_list_rate": 150, + "qty": 5, + "rate": 150, "stock_uom": "_Test UOM" } - ], - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total_export": 0, - "is_pos": 0, - "naming_series": "_T-Sales Invoice-", + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total_export": 0, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", "other_charges": [ { - "account_head": "_Test Account Shipping Charges - _TC", - "charge_type": "Actual", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account Shipping Charges - _TC", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "Shipping Charges", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 100 - }, + }, { - "account_head": "_Test Account Customs Duty - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account Customs Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Customs Duty", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 10 - }, + }, { - "account_head": "_Test Account Excise Duty - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account Excise Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Excise Duty", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 12 - }, + }, { - "account_head": "_Test Account Education Cess - _TC", - "charge_type": "On Previous Row Amount", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 2, + "account_head": "_Test Account Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "Education Cess", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 2, "row_id": 3 - }, + }, { - "account_head": "_Test Account S&H Education Cess - _TC", - "charge_type": "On Previous Row Amount", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 1, + "account_head": "_Test Account S&H Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "S&H Education Cess", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 1, "row_id": 3 - }, + }, { - "account_head": "_Test Account CST - _TC", - "charge_type": "On Previous Row Total", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 2, + "account_head": "_Test Account CST - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "CST", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 2, "row_id": 5 - }, + }, { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 12.5 - }, + }, { - "account_head": "_Test Account Discount - _TC", - "charge_type": "On Previous Row Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": -10, + "account_head": "_Test Account Discount - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Discount", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": -10, "row_id": 7 } - ], - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-01-23", + "price_list_currency": "INR", + "selling_price_list": "_Test Price List", "territory": "_Test Territory" - }, + }, { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "debit_to": "_Test Customer - _TC", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-01-23", "entries": [ { - "cost_center": "_Test Cost Center - _TC", - "doctype": "Sales Invoice Item", - "income_account": "Sales - _TC", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", - "parentfield": "entries", - "price_list_rate": 62.5, - "qty": 10, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", + "parentfield": "entries", + "price_list_rate": 62.5, + "qty": 10, "stock_uom": "_Test UOM" - }, + }, { - "cost_center": "_Test Cost Center - _TC", - "doctype": "Sales Invoice Item", - "income_account": "Sales - _TC", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "parentfield": "entries", - "price_list_rate": 190.66, - "qty": 5, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 200", + "item_name": "_Test Item Home Desktop 200", + "parentfield": "entries", + "price_list_rate": 190.66, + "qty": 5, "stock_uom": "_Test UOM" } - ], - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total_export": 0, - "is_pos": 0, - "naming_series": "_T-Sales Invoice-", + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total_export": 0, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", "other_charges": [ { - "account_head": "_Test Account Excise Duty - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "doctype": "Sales Taxes and Charges", - "idx": 1, - "included_in_print_rate": 1, - "parentfield": "other_charges", + "account_head": "_Test Account Excise Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Excise Duty", + "doctype": "Sales Taxes and Charges", + "idx": 1, + "included_in_print_rate": 1, + "parentfield": "other_charges", "rate": 12 - }, + }, { - "account_head": "_Test Account Education Cess - _TC", - "charge_type": "On Previous Row Amount", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "doctype": "Sales Taxes and Charges", - "idx": 2, - "included_in_print_rate": 1, - "parentfield": "other_charges", - "rate": 2, + "account_head": "_Test Account Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "Education Cess", + "doctype": "Sales Taxes and Charges", + "idx": 2, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 2, "row_id": 1 - }, + }, { - "account_head": "_Test Account S&H Education Cess - _TC", - "charge_type": "On Previous Row Amount", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "doctype": "Sales Taxes and Charges", - "idx": 3, - "included_in_print_rate": 1, - "parentfield": "other_charges", - "rate": 1, + "account_head": "_Test Account S&H Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "S&H Education Cess", + "doctype": "Sales Taxes and Charges", + "idx": 3, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 1, "row_id": 1 - }, + }, { - "account_head": "_Test Account CST - _TC", - "charge_type": "On Previous Row Total", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "doctype": "Sales Taxes and Charges", - "idx": 4, - "included_in_print_rate": 1, - "parentfield": "other_charges", - "rate": 2, + "account_head": "_Test Account CST - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "CST", + "doctype": "Sales Taxes and Charges", + "idx": 4, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 2, "row_id": 3 - }, + }, { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "idx": 5, - "included_in_print_rate": 1, - "parentfield": "other_charges", + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "idx": 5, + "included_in_print_rate": 1, + "parentfield": "other_charges", "rate": 12.5 - }, + }, { - "account_head": "_Test Account Customs Duty - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "doctype": "Sales Taxes and Charges", - "idx": 6, - "parentfield": "other_charges", + "account_head": "_Test Account Customs Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Customs Duty", + "doctype": "Sales Taxes and Charges", + "idx": 6, + "parentfield": "other_charges", "rate": 10 - }, + }, { - "account_head": "_Test Account Shipping Charges - _TC", - "charge_type": "Actual", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "doctype": "Sales Taxes and Charges", - "idx": 7, - "parentfield": "other_charges", + "account_head": "_Test Account Shipping Charges - _TC", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "Shipping Charges", + "doctype": "Sales Taxes and Charges", + "idx": 7, + "parentfield": "other_charges", "rate": 100 - }, + }, { - "account_head": "_Test Account Discount - _TC", - "charge_type": "On Previous Row Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "doctype": "Sales Taxes and Charges", - "idx": 8, - "parentfield": "other_charges", - "rate": -10, + "account_head": "_Test Account Discount - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Discount", + "doctype": "Sales Taxes and Charges", + "idx": 8, + "parentfield": "other_charges", + "rate": -10, "row_id": 7 } - ], - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-01-23", + "price_list_currency": "INR", + "selling_price_list": "_Test Price List", "territory": "_Test Territory" } -] \ No newline at end of file +] diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 85e57822e2..1d22e0930a 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -674,6 +674,7 @@ class TestSalesInvoice(unittest.TestCase): "notification_email_address": "test@example.com, test1@example.com, test2@example.com", "repeat_on_day_of_month": getdate(today).day, "posting_date": today, + "due_date": None, "fiscal_year": get_fiscal_year(today)[0], "invoice_period_from_date": get_first_day(today), "invoice_period_to_date": get_last_day(today) diff --git a/erpnext/accounts/report/balance_sheet/__init__.py b/erpnext/accounts/report/balance_sheet/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.html b/erpnext/accounts/report/balance_sheet/balance_sheet.html new file mode 100644 index 0000000000..d4ae54d4f3 --- /dev/null +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.html @@ -0,0 +1 @@ +{% include "accounts/report/financial_statements.html" %} diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.js b/erpnext/accounts/report/balance_sheet/balance_sheet.js new file mode 100644 index 0000000000..a28008e9b6 --- /dev/null +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.js @@ -0,0 +1,6 @@ +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt + +frappe.require("assets/erpnext/js/financial_statements.js"); + +frappe.query_reports["Balance Sheet"] = erpnext.financial_statements; diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.json b/erpnext/accounts/report/balance_sheet/balance_sheet.json new file mode 100644 index 0000000000..af299bb29c --- /dev/null +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.json @@ -0,0 +1,15 @@ +{ + "apply_user_permissions": 1, + "creation": "2014-07-14 05:24:20.385279", + "docstatus": 0, + "doctype": "Report", + "is_standard": "Yes", + "modified": "2014-07-14 05:24:20.385279", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Balance Sheet", + "owner": "Administrator", + "ref_doctype": "GL Entry", + "report_name": "Balance Sheet", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py new file mode 100644 index 0000000000..4edc9b9515 --- /dev/null +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py @@ -0,0 +1,53 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe import _ +from frappe.utils import flt +from erpnext.accounts.report.financial_statements import (process_filters, get_period_list, get_columns, get_data) + +def execute(filters=None): + process_filters(filters) + period_list = get_period_list(filters.fiscal_year, filters.periodicity, from_beginning=True) + + asset = get_data(filters.company, "Asset", "Debit", period_list, filters.depth) + liability = get_data(filters.company, "Liability", "Credit", period_list, filters.depth) + equity = get_data(filters.company, "Equity", "Credit", period_list, filters.depth) + provisional_profit_loss = get_provisional_profit_loss(asset, liability, equity, period_list) + + data = [] + data.extend(asset or []) + data.extend(liability or []) + data.extend(equity or []) + if provisional_profit_loss: + data.append(provisional_profit_loss) + + columns = get_columns(period_list) + + return columns, data + +def get_provisional_profit_loss(asset, liability, equity, period_list): + if asset and (liability or equity): + provisional_profit_loss = { + "account_name": _("Provisional Profit / Loss (Credit)"), + "account": None, + "is_profit_loss": True + } + + has_value = False + + for period in period_list: + effective_liability = 0.0 + if liability: + effective_liability += flt(liability[-2][period.key]) + if equity: + effective_liability += flt(equity[-2][period.key]) + + provisional_profit_loss[period.key] = flt(asset[-2][period.key]) - effective_liability + + if provisional_profit_loss[period.key]: + has_value = True + + if has_value: + return provisional_profit_loss diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html new file mode 100644 index 0000000000..1a401f5e68 --- /dev/null +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html @@ -0,0 +1,49 @@ +
+ {%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %} +
+

{%= __("Bank Reconciliation Statement") %}

+

{%= filters.account %}

+
+ + + + + + + + + + + + {% for(var i=0, l=data.length; i + + + + + + + {% } else { %} + + + + + + + + {% } %} + {% } %} + +
{%= __("Posting Date") %}{%= __("Journal Voucher") %}{%= __("Reference") %}{%= __("Debit") %}{%= __("Credit") %}
{%= dateutil.str_to_user(data[i].posting_date) %}{%= data[i].journal_voucher %}{%= __("Against") %}: {%= data[i].against_account %} + {% if (data[i].reference) { %} +
{%= __("Reference") %}: {%= data[i].reference %} + {% if (data[i].ref_date) { %} +
{%= __("Reference Date") %}: {%= dateutil.str_to_user(data[i].ref_date) %} + {% } %} + {% } %} + {% if (data[i].clearance_date) { %} +
{%= __("Clearance Date") %}: {%= dateutil.str_to_user(data[i].clearance_date) %} + {% } %} +
{%= format_currency(data[i].debit) %}{%= format_currency(data[i].credit) %}
{%= data[i].journal_voucher %}{%= format_currency(data[i].debit) %}{%= format_currency(data[i].credit) %}
+

Printed On {%= dateutil.str_to_user(dateutil.get_datetime_as_string()) %}

diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py index e87fbd3226..119de09e41 100644 --- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py @@ -19,28 +19,29 @@ def execute(filters=None): total_debit, total_credit = 0,0 for d in data: - total_debit += flt(d[4]) - total_credit += flt(d[5]) + total_debit += flt(d[2]) + total_credit += flt(d[3]) bank_bal = flt(balance_as_per_company) - flt(total_debit) + flt(total_credit) data += [ get_balance_row("Balance as per company books", balance_as_per_company), - ["", "", "", "Amounts not reflected in bank", total_debit, total_credit], + ["", "Amounts not reflected in bank", total_debit, total_credit, "", "", "", ""], get_balance_row("Balance as per bank", bank_bal) ] return columns, data def get_columns(): - return ["Journal Voucher:Link/Journal Voucher:140", "Posting Date:Date:100", - "Clearance Date:Date:110", "Against Account:Link/Account:200", - "Debit:Currency:120", "Credit:Currency:120" + return ["Posting Date:Date:100", "Journal Voucher:Link/Journal Voucher:200", + "Debit:Currency:120", "Credit:Currency:120", + "Against Account:Link/Account:200", "Reference::100", "Ref Date:Date:110", "Clearance Date:Date:110" ] def get_entries(filters): entries = frappe.db.sql("""select - jv.name, jv.posting_date, jv.clearance_date, jvd.against_account, jvd.debit, jvd.credit + jv.posting_date, jv.name, jvd.debit, jvd.credit, + jvd.against_account, jv.cheque_no, jv.cheque_date, jv.clearance_date from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv where jvd.parent = jv.name and jv.docstatus=1 @@ -52,6 +53,6 @@ def get_entries(filters): def get_balance_row(label, amount): if amount > 0: - return ["", "", "", label, amount, 0] + return ["", label, amount, 0, "", "", "", ""] else: - return ["", "", "", label, 0, amount] + return ["", label, 0, amount, "", "", "", ""] diff --git a/erpnext/accounts/report/financial_statements.html b/erpnext/accounts/report/financial_statements.html new file mode 100644 index 0000000000..403e67e5bb --- /dev/null +++ b/erpnext/accounts/report/financial_statements.html @@ -0,0 +1,53 @@ +{% + if (report.columns.length > 6) { + frappe.throw(__("Too many columns. Export the report and print it using a spreadsheet application.")); + } +%} + + + +

{%= __(report.report_name) %}

+

{%= filters.company %}

+

{%= filters.fiscal_year %}

+
+ + + + + {% for(var i=2, l=report.columns.length; i{%= report.columns[i].label %} + {% } %} + + + + {% for(var j=0, k=data.length; j + + {% for(var i=2, l=report.columns.length; i + {% var fieldname = report.columns[i].field; %} + {% if (!is_null(row[fieldname])) { %} + {%= format_currency(row[fieldname]) %} + {% } %} + + {% } %} + + {% } %} + +
+ {%= row.account_name %} +
+

Printed On {%= dateutil.str_to_user(dateutil.get_datetime_as_string()) %}

diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py new file mode 100644 index 0000000000..45d5b3a737 --- /dev/null +++ b/erpnext/accounts/report/financial_statements.py @@ -0,0 +1,255 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe import _, _dict +from frappe.utils import (flt, cint, getdate, get_first_day, get_last_day, + add_months, add_days, formatdate) + +def process_filters(filters): + filters.depth = cint(filters.depth) or 3 + if not filters.periodicity: + filters.periodicity = "Yearly" + +def get_period_list(fiscal_year, periodicity, from_beginning=False): + """Get a list of dict {"to_date": to_date, "key": key, "label": label} + Periodicity can be (Yearly, Quarterly, Monthly)""" + + start_date, end_date = frappe.db.get_value("Fiscal Year", fiscal_year, ["year_start_date", "year_end_date"]) + start_date = getdate(start_date) + end_date = getdate(end_date) + + if periodicity == "Yearly": + period_list = [_dict({"to_date": end_date, "key": fiscal_year, "label": fiscal_year})] + else: + months_to_add = { + "Half-yearly": 6, + "Quarterly": 3, + "Monthly": 1 + }[periodicity] + + period_list = [] + + # start with first day, so as to avoid year to_dates like 2-April if ever they occur + to_date = get_first_day(start_date) + + for i in xrange(12 / months_to_add): + to_date = add_months(to_date, months_to_add) + + if to_date == get_first_day(to_date): + # if to_date is the first day, get the last day of previous month + to_date = add_days(to_date, -1) + else: + # to_date should be the last day of the new to_date's month + to_date = get_last_day(to_date) + + if to_date <= end_date: + # the normal case + period_list.append(_dict({ "to_date": to_date })) + + # if it ends before a full year + if to_date == end_date: + break + + else: + # if a fiscal year ends before a 12 month period + period_list.append(_dict({ "to_date": end_date })) + break + + # common processing + for opts in period_list: + key = opts["to_date"].strftime("%b_%Y").lower() + label = formatdate(opts["to_date"], "MMM YYYY") + opts.update({ + "key": key.replace(" ", "_").replace("-", "_"), + "label": label, + "year_start_date": start_date, + "year_end_date": end_date + }) + + if from_beginning: + # set start date as None for all fiscal periods, used in case of Balance Sheet + opts["from_date"] = None + else: + opts["from_date"] = start_date + + return period_list + +def get_data(company, root_type, balance_must_be, period_list, depth, ignore_closing_entries=False): + accounts = get_accounts(company, root_type) + if not accounts: + return None + + accounts, accounts_by_name = filter_accounts(accounts, depth) + gl_entries_by_account = get_gl_entries(company, root_type, period_list[0]["from_date"], period_list[-1]["to_date"], + accounts[0].lft, accounts[0].rgt, ignore_closing_entries=ignore_closing_entries) + + calculate_values(accounts, gl_entries_by_account, period_list) + accumulate_values_into_parents(accounts, accounts_by_name, period_list) + out = prepare_data(accounts, balance_must_be, period_list) + + if out: + add_total_row(out, balance_must_be, period_list) + + return out + +def calculate_values(accounts, gl_entries_by_account, period_list): + for d in accounts: + for name in ([d.name] + (d.collapsed_children or [])): + for entry in gl_entries_by_account.get(name, []): + for period in period_list: + entry.posting_date = getdate(entry.posting_date) + + # check if posting date is within the period + if entry.posting_date <= period.to_date: + d[period.key] = d.get(period.key, 0.0) + flt(entry.debit) - flt(entry.credit) + + +def accumulate_values_into_parents(accounts, accounts_by_name, period_list): + """accumulate children's values in parent accounts""" + for d in reversed(accounts): + if d.parent_account: + for period in period_list: + accounts_by_name[d.parent_account][period.key] = accounts_by_name[d.parent_account].get(period.key, 0.0) + \ + d.get(period.key, 0.0) + +def prepare_data(accounts, balance_must_be, period_list): + out = [] + year_start_date = period_list[0]["year_start_date"].strftime("%Y-%m-%d") + year_end_date = period_list[-1]["year_end_date"].strftime("%Y-%m-%d") + + for d in accounts: + # add to output + has_value = False + row = { + "account_name": d.account_name, + "account": d.name, + "parent_account": d.parent_account, + "indent": flt(d.indent), + "year_start_date": year_start_date, + "year_end_date": year_end_date + } + for period in period_list: + if d.get(period.key): + # change sign based on Debit or Credit, since calculation is done using (debit - credit) + d[period.key] *= (1 if balance_must_be=="Debit" else -1) + + row[period.key] = flt(d.get(period.key, 0.0), 3) + + if abs(row[period.key]) >= 0.005: + # ignore zero values + has_value = True + + if has_value: + out.append(row) + + return out + +def add_total_row(out, balance_must_be, period_list): + row = { + "account_name": _("Total ({0})").format(balance_must_be), + "account": None + } + for period in period_list: + row[period.key] = out[0].get(period.key, 0.0) + out[0][period.key] = "" + + out.append(row) + + # blank row after Total + out.append({}) + +def get_accounts(company, root_type): + # root lft, rgt + root_account = frappe.db.sql("""select lft, rgt from `tabAccount` + where company=%s and root_type=%s order by lft limit 1""", + (company, root_type), as_dict=True) + + if not root_account: + return None + + lft, rgt = root_account[0].lft, root_account[0].rgt + + accounts = frappe.db.sql("""select * from `tabAccount` + where company=%(company)s and lft >= %(lft)s and rgt <= %(rgt)s order by lft""", + { "company": company, "lft": lft, "rgt": rgt }, as_dict=True) + + return accounts + +def filter_accounts(accounts, depth): + parent_children_map = {} + accounts_by_name = {} + for d in accounts: + accounts_by_name[d.name] = d + parent_children_map.setdefault(d.parent_account or None, []).append(d) + + filtered_accounts = [] + def add_to_list(parent, level): + if level < depth: + for child in (parent_children_map.get(parent) or []): + child.indent = level + filtered_accounts.append(child) + add_to_list(child.name, level + 1) + + else: + # include all children at level lower than the depth + parent_account = accounts_by_name[parent] + parent_account["collapsed_children"] = [] + for d in accounts: + if d.lft > parent_account.lft and d.rgt < parent_account.rgt: + parent_account["collapsed_children"].append(d.name) + + add_to_list(None, 0) + + return filtered_accounts, accounts_by_name + +def get_gl_entries(company, root_type, from_date, to_date, root_lft, root_rgt, ignore_closing_entries=False): + """Returns a dict like { "account": [gl entries], ... }""" + additional_conditions = [] + + if ignore_closing_entries: + additional_conditions.append("and ifnull(voucher_type, '')!='Period Closing Voucher'") + + if from_date: + additional_conditions.append("and posting_date >= %(from_date)s") + + gl_entries = frappe.db.sql("""select * from `tabGL Entry` + where company=%(company)s + {additional_conditions} + and posting_date <= %(to_date)s + and account in (select name from `tabAccount` + where lft >= %(lft)s and rgt <= %(rgt)s) + order by account, posting_date""".format(additional_conditions="\n".join(additional_conditions)), + { + "company": company, + "from_date": from_date, + "to_date": to_date, + "lft": root_lft, + "rgt": root_rgt + }, + as_dict=True) + + gl_entries_by_account = {} + for entry in gl_entries: + gl_entries_by_account.setdefault(entry.account, []).append(entry) + + return gl_entries_by_account + +def get_columns(period_list): + columns = [{ + "fieldname": "account", + "label": _("Account"), + "fieldtype": "Link", + "options": "Account", + "width": 300 + }] + for period in period_list: + columns.append({ + "fieldname": period.key, + "label": period.label, + "fieldtype": "Currency", + "width": 150 + }) + + return columns diff --git a/erpnext/accounts/report/general_ledger/general_ledger.html b/erpnext/accounts/report/general_ledger/general_ledger.html index 63cd1a19d2..0fc02b16d0 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.html +++ b/erpnext/accounts/report/general_ledger/general_ledger.html @@ -1,5 +1,13 @@ +
+ {%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %} +

{%= __("Statement of Account") %}

-

{%= filters.account || "General Ledger" %}

+

{%= filters.account || "General Ledger" %}

+
+ {%= dateutil.str_to_user(filters.from_date) %} + {%= __("to") %} + {%= dateutil.str_to_user(filters.to_date) %} +

@@ -19,7 +27,7 @@ diff --git a/erpnext/accounts/report/profit_and_loss_statement/__init__.py b/erpnext/accounts/report/profit_and_loss_statement/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.html b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.html new file mode 100644 index 0000000000..d4ae54d4f3 --- /dev/null +++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.html @@ -0,0 +1 @@ +{% include "accounts/report/financial_statements.html" %} diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js new file mode 100644 index 0000000000..d047fea5fb --- /dev/null +++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js @@ -0,0 +1,6 @@ +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt + +frappe.require("assets/erpnext/js/financial_statements.js"); + +frappe.query_reports["Profit and Loss Statement"] = erpnext.financial_statements; diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.json b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.json new file mode 100644 index 0000000000..a7608d8cae --- /dev/null +++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.json @@ -0,0 +1,17 @@ +{ + "add_total_row": 0, + "apply_user_permissions": 1, + "creation": "2014-07-18 11:43:33.173207", + "disabled": 0, + "docstatus": 0, + "doctype": "Report", + "is_standard": "Yes", + "modified": "2014-07-18 11:43:33.173207", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Profit and Loss Statement", + "owner": "Administrator", + "ref_doctype": "GL Entry", + "report_name": "Profit and Loss Statement", + "report_type": "Script Report" +} \ No newline at end of file diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py new file mode 100644 index 0000000000..3a3123fc36 --- /dev/null +++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py @@ -0,0 +1,39 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe import _ +from frappe.utils import flt +from erpnext.accounts.report.financial_statements import (process_filters, get_period_list, get_columns, get_data) + +def execute(filters=None): + process_filters(filters) + period_list = get_period_list(filters.fiscal_year, filters.periodicity) + + income = get_data(filters.company, "Income", "Credit", period_list, filters.depth, ignore_closing_entries=True) + expense = get_data(filters.company, "Expense", "Debit", period_list, filters.depth, ignore_closing_entries=True) + net_profit_loss = get_net_profit_loss(income, expense, period_list) + + data = [] + data.extend(income or []) + data.extend(expense or []) + if net_profit_loss: + data.append(net_profit_loss) + + columns = get_columns(period_list) + + return columns, data + +def get_net_profit_loss(income, expense, period_list): + if income and expense: + net_profit_loss = { + "account_name": _("Net Profit / Loss"), + "account": None, + "is_profit_loss": True + } + + for period in period_list: + net_profit_loss[period.key] = flt(income[-2][period.key] - expense[-2][period.key], 3) + + return net_profit_loss diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index 2109d72aa2..f9f5103726 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -24,6 +24,7 @@ class PurchaseOrder(BuyingController): 'target_ref_field': 'qty', 'source_field': 'qty', 'percent_join_field': 'prevdoc_docname', + 'overflow_type': 'order' }] def validate(self): diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index 99d0e4e9f5..c2b29a4a17 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -69,7 +69,8 @@ cur_frm.cscript.make_address = function() { page_length: 5, new_doctype: "Address", get_query: function() { - return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where supplier='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc" + return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where supplier='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_address desc" }, as_dict: 1, no_results_message: __('No addresses created'), @@ -87,7 +88,8 @@ cur_frm.cscript.make_contact = function() { page_length: 5, new_doctype: "Contact", get_query: function() { - return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where supplier='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc" + return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where supplier='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_contact desc" }, as_dict: 1, no_results_message: __('No contacts created'), diff --git a/erpnext/config/accounts.py b/erpnext/config/accounts.py index 2d757f1ef5..722bf77f83 100644 --- a/erpnext/config/accounts.py +++ b/erpnext/config/accounts.py @@ -195,6 +195,18 @@ def get_data(): "doctype": "Purchase Invoice", "is_query_report": True }, + { + "type": "report", + "name": "Balance Sheet", + "doctype": "GL Entry", + "is_query_report": True + }, + { + "type": "report", + "name": "Profit and Loss Statement", + "doctype": "GL Entry", + "is_query_report": True + }, { "type": "page", "name": "financial-analytics", diff --git a/erpnext/config/buying.py b/erpnext/config/buying.py index bc6251982b..1b9e5a23b0 100644 --- a/erpnext/config/buying.py +++ b/erpnext/config/buying.py @@ -150,7 +150,7 @@ def get_data(): { "type": "report", "is_query_report": True, - "name": "Supplier Addresses And Contacts", + "name": "Supplier Addresses and Contacts", "doctype": "Supplier" }, { diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py index 200ab6d4ba..c95f15aa83 100644 --- a/erpnext/config/selling.py +++ b/erpnext/config/selling.py @@ -206,7 +206,7 @@ def get_data(): { "type": "report", "is_query_report": True, - "name": "Customer Addresses And Contacts", + "name": "Customer Addresses and Contacts", "doctype": "Contact" }, { diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index afccdfa0e3..acb00245e6 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -17,6 +17,7 @@ class BuyingController(StockController): self.supplier_name = frappe.db.get_value("Supplier", self.supplier, "supplier_name") self.is_item_table_empty() + self.set_qty_as_per_stock_uom() self.validate_stock_or_nonstock_items() self.validate_warehouse() @@ -317,3 +318,10 @@ class BuyingController(StockController): def is_item_table_empty(self): if not len(self.get(self.fname)): frappe.throw(_("Item table can not be blank")) + + def set_qty_as_per_stock_uom(self): + for d in self.get(self.fname): + if d.meta.get_field("stock_qty") and not d.stock_qty: + if not d.conversion_factor: + frappe.throw(_("Row {0}: Conversion Factor is mandatory")) + d.stock_qty = flt(d.qty) * flt(d.conversion_factor) \ No newline at end of file diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 16d27d47fc..4a30eed652 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -32,34 +32,46 @@ def employee_query(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select name, employee_name from `tabEmployee` where status = 'Active' and docstatus < 2 - and (%(key)s like "%(txt)s" - or employee_name like "%(txt)s") - %(mcond)s + and ({key} like %(txt)s + or employee_name like %(txt)s) + {mcond} order by - if(locate("%(_txt)s", name), locate("%(_txt)s", name), 99999), - if(locate("%(_txt)s", employee_name), locate("%(_txt)s", employee_name), 99999), + if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), + if(locate(%(_txt)s, employee_name), locate(%(_txt)s, employee_name), 99999), name, employee_name - limit %(start)s, %(page_len)s""" % {'key': searchfield, 'txt': "%%%s%%" % txt, - '_txt': txt.replace("%", ""), - 'mcond':get_match_cond(doctype), 'start': start, 'page_len': page_len}) + limit %(start)s, %(page_len)s""".format(**{ + 'key': searchfield, + 'mcond': get_match_cond(doctype) + }), { + 'txt': "%%%s%%" % txt, + '_txt': txt.replace("%", ""), + 'start': start, + 'page_len': page_len + }) # searches for leads which are not converted def lead_query(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select name, lead_name, company_name from `tabLead` where docstatus < 2 and ifnull(status, '') != 'Converted' - and (%(key)s like "%(txt)s" - or lead_name like "%(txt)s" - or company_name like "%(txt)s") - %(mcond)s + and ({key} like %(txt)s + or lead_name like %(txt)s + or company_name like %(txt)s) + {mcond} order by - if(locate("%(_txt)s", name), locate("%(_txt)s", name), 99999), - if(locate("%(_txt)s", lead_name), locate("%(_txt)s", lead_name), 99999), - if(locate("%(_txt)s", company_name), locate("%(_txt)s", company_name), 99999), + if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), + if(locate(%(_txt)s, lead_name), locate(%(_txt)s, lead_name), 99999), + if(locate(%(_txt)s, company_name), locate(%(_txt)s, company_name), 99999), name, lead_name - limit %(start)s, %(page_len)s""" % {'key': searchfield, 'txt': "%%%s%%" % txt, - '_txt': txt.replace("%", ""), - 'mcond':get_match_cond(doctype), 'start': start, 'page_len': page_len}) + limit %(start)s, %(page_len)s""".format(**{ + 'key': searchfield, + 'mcond':get_match_cond(doctype) + }), { + 'txt': "%%%s%%" % txt, + '_txt': txt.replace("%", ""), + 'start': start, + 'page_len': page_len + }) # searches for customer def customer_query(doctype, txt, searchfield, start, page_len, filters): @@ -72,19 +84,25 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters): fields = ", ".join(fields) - return frappe.db.sql("""select %(field)s from `tabCustomer` + return frappe.db.sql("""select {fields} from `tabCustomer` where docstatus < 2 - and (%(key)s like "%(txt)s" - or customer_name like "%(txt)s") - %(mcond)s + and ({key} like %(txt)s + or customer_name like %(txt)s) + {mcond} order by - if(locate("%(_txt)s", name), locate("%(_txt)s", name), 99999), - if(locate("%(_txt)s", customer_name), locate("%(_txt)s", customer_name), 99999), + if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), + if(locate(%(_txt)s, customer_name), locate(%(_txt)s, customer_name), 99999), name, customer_name - limit %(start)s, %(page_len)s""" % {'field': fields,'key': searchfield, - 'txt': "%%%s%%" % txt, '_txt': txt.replace("%", ""), - 'mcond':get_match_cond(doctype), - 'start': start, 'page_len': page_len}) + limit %(start)s, %(page_len)s""".format(**{ + "fields": fields, + "key": searchfield, + "mcond": get_match_cond(doctype) + }), { + 'txt': "%%%s%%" % txt, + '_txt': txt.replace("%", ""), + 'start': start, + 'page_len': page_len + }) # searches for supplier def supplier_query(doctype, txt, searchfield, start, page_len, filters): @@ -95,19 +113,25 @@ def supplier_query(doctype, txt, searchfield, start, page_len, filters): fields = ["name", "supplier_name", "supplier_type"] fields = ", ".join(fields) - return frappe.db.sql("""select %(field)s from `tabSupplier` + return frappe.db.sql("""select {field} from `tabSupplier` where docstatus < 2 - and (%(key)s like "%(txt)s" - or supplier_name like "%(txt)s") - %(mcond)s + and ({key} like %(txt)s + or supplier_name like %(txt)s) + {mcond} order by - if(locate("%(_txt)s", name), locate("%(_txt)s", name), 99999), - if(locate("%(_txt)s", supplier_name), locate("%(_txt)s", supplier_name), 99999), + if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), + if(locate(%(_txt)s, supplier_name), locate(%(_txt)s, supplier_name), 99999), name, supplier_name - limit %(start)s, %(page_len)s """ % {'field': fields,'key': searchfield, - 'txt': "%%%s%%" % txt, '_txt': txt.replace("%", ""), - 'mcond':get_match_cond(doctype), 'start': start, - 'page_len': page_len}) + limit %(start)s, %(page_len)s """.format(**{ + 'field': fields, + 'key': searchfield, + 'mcond':get_match_cond(doctype) + }), { + 'txt': "%%%s%%" % txt, + '_txt': txt.replace("%", ""), + 'start': start, + 'page_len': page_len + }) def tax_account_query(doctype, txt, searchfield, start, page_len, filters): tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount @@ -143,7 +167,8 @@ def item_query(doctype, txt, searchfield, start, page_len, filters): where tabItem.docstatus < 2 and (tabItem.end_of_life > %(today)s or ifnull(tabItem.end_of_life, '0000-00-00')='0000-00-00') and (tabItem.`{key}` LIKE %(txt)s - or tabItem.item_name LIKE %(txt)s) + or tabItem.item_name LIKE %(txt)s + or tabItem.description LIKE %(txt)s) {fcond} {mcond} order by if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 90eacd9820..6a2dce00fc 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -132,11 +132,12 @@ class StatusUpdater(Document): if not item[args['target_ref_field']]: msgprint(_("Note: System will not check over-delivery and over-booking for Item {0} as quantity or amount is 0").format(item.item_code)) elif args.get('no_tolerance'): - item['reduce_by'] = item[args['target_field']] - \ - item[args['target_ref_field']] + item['reduce_by'] = item[args['target_field']] - item[args['target_ref_field']] if item['reduce_by'] > .01: - msgprint(_("Allowance for over-delivery / over-billing crossed for Item {0}").format(item.item_code)) - throw(_("{0} must be less than or equal to {1}").format(_(item.target_ref_field), item[args["target_ref_field"]])) + msgprint(_("Allowance for over-{0} crossed for Item {1}") + .format(args["overflow_type"], item.item_code)) + throw(_("{0} must be reduced by {1} or you should increase overflow tolerance") + .format(_(item.target_ref_field.title()), item["reduce_by"])) else: self.check_overflow_with_tolerance(item, args) @@ -156,8 +157,10 @@ class StatusUpdater(Document): item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100) item['reduce_by'] = item[args['target_field']] - item['max_allowed'] - msgprint(_("Allowance for over-delivery / over-billing crossed for Item {0}.").format(item["item_code"])) - throw(_("{0} must be less than or equal to {1}").format(item["target_ref_field"].title(), item["max_allowed"])) + msgprint(_("Allowance for over-{0} crossed for Item {1}.") + .format(args["overflow_type"], item["item_code"])) + throw(_("{0} must be reduced by {1} or you should increase overflow tolerance") + .format(_(item["target_ref_field"].title()), item["reduce_by"])) def update_qty(self, change_modified=True): """ @@ -263,8 +266,7 @@ def get_tolerance_for(item_code, item_tolerance={}, global_tolerance=None): if not tolerance: if global_tolerance == None: - global_tolerance = flt(frappe.db.get_value('Global Defaults', None, - 'tolerance')) + global_tolerance = flt(frappe.db.get_value('Stock Settings', None, 'tolerance')) tolerance = global_tolerance item_tolerance[item_code] = tolerance diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index bb3ab69ca1..27437a396a 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -240,7 +240,7 @@ class StockController(AccountsController): else: is_expense_account = frappe.db.get_value("Account", item.get("expense_account"), "report_type")=="Profit and Loss" - if self.doctype != "Purchase Receipt" and not is_expense_account: + if self.doctype not in ("Purchase Receipt", "Stock Reconciliation") and not is_expense_account: frappe.throw(_("Expense / Difference account ({0}) must be a 'Profit or Loss' account") .format(item.get("expense_account"))) if is_expense_account and not item.get("cost_center"): diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 1dde6386d2..df15916f7a 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -7,6 +7,8 @@ app_icon = "icon-th" app_color = "#e74c3c" app_version = __version__ +error_report_email = "support@erpnext.com" + app_include_js = "assets/js/erpnext.min.js" app_include_css = "assets/css/erpnext.css" web_include_js = "assets/js/erpnext-web.min.js" diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 2d41d0a6a4..1486d2a684 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -39,16 +39,16 @@ class ProductionOrder(Document): def validate_sales_order(self): if self.sales_order: so = frappe.db.sql("""select name, delivery_date from `tabSales Order` - where name=%s and docstatus = 1""", self.sales_order, as_dict=1)[0] + where name=%s and docstatus = 1""", self.sales_order, as_dict=1) - if not so.name: + if len(so): + if not self.expected_delivery_date: + self.expected_delivery_date = so[0].delivery_date + + self.validate_production_order_against_so() + else: frappe.throw(_("Sales Order {0} is not valid") % self.sales_order) - if not self.expected_delivery_date: - self.expected_delivery_date = so.delivery_date - - self.validate_production_order_against_so() - def validate_warehouse(self): from erpnext.stock.utils import validate_warehouse_company diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js index 0415c911e1..d57f639f7f 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js @@ -37,8 +37,8 @@ cur_frm.fields_dict['pp_details'].grid.get_field('item_code').get_query = functi }); } -cur_frm.fields_dict['pp_details'].grid.get_field('bom_no').get_query = function(doc) { - var d = locals[this.doctype][this.docname]; +cur_frm.fields_dict['pp_details'].grid.get_field('bom_no').get_query = function(doc, cdt, cdn) { + var d = locals[cdt][cdn]; if (d.item_code) { return { query: "erpnext.controllers.queries.bom", diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 1c2112d7b8..1a903de743 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -67,4 +67,5 @@ erpnext.patches.v4_0.set_naming_series_property_setter erpnext.patches.v4_1.set_outgoing_email_footer erpnext.patches.v4_1.fix_jv_remarks erpnext.patches.v4_1.fix_sales_order_delivered_status -erpnext.patches.v4_1.fix_delivery_and_billing_status_for_draft_so \ No newline at end of file +erpnext.patches.v4_1.fix_delivery_and_billing_status +execute:frappe.db.sql("update `tabAccount` set root_type='Liability' where root_type='Income' and report_type='Balance Sheet'") \ No newline at end of file diff --git a/erpnext/patches/v4_1/fix_delivery_and_billing_status_for_draft_so.py b/erpnext/patches/v4_1/fix_delivery_and_billing_status.py similarity index 80% rename from erpnext/patches/v4_1/fix_delivery_and_billing_status_for_draft_so.py rename to erpnext/patches/v4_1/fix_delivery_and_billing_status.py index 8d38338e04..2dbc825085 100644 --- a/erpnext/patches/v4_1/fix_delivery_and_billing_status_for_draft_so.py +++ b/erpnext/patches/v4_1/fix_delivery_and_billing_status.py @@ -5,8 +5,8 @@ from __future__ import unicode_literals import frappe def execute(): - frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' - where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and docstatus = 0""") + frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' + where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""") - frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' - where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and docstatus = 0""") \ No newline at end of file + frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' + where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""") diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index bce9c52688..4a14c55c3a 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -55,7 +55,7 @@ class Project(Document): "event_type": "Private", "ref_type": self.doctype, "ref_name": self.name - }).insert() + }).insert(ignore_permissions=True) def on_trash(self): delete_events(self.doctype, self.name) diff --git a/erpnext/public/js/financial_statements.js b/erpnext/public/js/financial_statements.js new file mode 100644 index 0000000000..5e3ba0e116 --- /dev/null +++ b/erpnext/public/js/financial_statements.js @@ -0,0 +1,75 @@ +frappe.provide("erpnext.financial_statements"); + +erpnext.financial_statements = { + "filters": [ + { + "fieldname":"company", + "label": __("Company"), + "fieldtype": "Link", + "options": "Company", + "default": frappe.defaults.get_user_default("company"), + "reqd": 1 + }, + { + "fieldname":"fiscal_year", + "label": __("Fiscal Year"), + "fieldtype": "Link", + "options": "Fiscal Year", + "default": frappe.defaults.get_user_default("fiscal_year"), + "reqd": 1 + }, + { + "fieldname": "periodicity", + "label": __("Periodicity"), + "fieldtype": "Select", + "options": "Yearly\nHalf-yearly\nQuarterly\nMonthly", + "default": "Yearly", + "reqd": 1 + }, + { + "fieldname": "depth", + "label": __("Depth"), + "fieldtype": "Select", + "options": "3\n4\n5", + "default": "3" + } + ], + "formatter": function(row, cell, value, columnDef, dataContext) { + if (columnDef.df.fieldname=="account") { + var link = $("") + .text(dataContext.account_name) + .attr("onclick", "erpnext.financial_statements.open_general_ledger(" + JSON.stringify(dataContext) + ")"); + + var span = $("") + .css("padding-left", (cint(dataContext.indent) * 21) + "px") + .append(link); + + value = span.wrap("

").parent().html(); + + } else { + value = erpnext.financial_statements.default_formatter(row, cell, value, columnDef, dataContext); + } + + if (!dataContext.parent_account) { + var $value = $(value).css("font-weight", "bold"); + if (dataContext.is_profit_loss && dataContext[columnDef.df.fieldname] < 0) { + $value.addClass("text-danger"); + } + + value = $value.wrap("

").parent().html(); + } + + return value; + }, + "open_general_ledger": function(data) { + if (!data.account) return; + + frappe.route_options = { + "account": data.account, + "company": frappe.query_report.filters_by_name.company.get_value(), + "from_date": data.year_start_date, + "to_date": data.year_end_date + }; + frappe.set_route("query-report", "General Ledger"); + } +}; diff --git a/erpnext/public/js/queries.js b/erpnext/public/js/queries.js index b57b765ad6..4bb3302bd8 100644 --- a/erpnext/public/js/queries.js +++ b/erpnext/public/js/queries.js @@ -71,7 +71,7 @@ $.extend(erpnext.queries, { warehouse: function(doc) { return { - filters: [["Warehouse", "company", "in", ["", doc.company]]] + filters: [["Warehouse", "company", "in", ["", cstr(doc.company)]]] } } }); diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 1790a47252..ae5864d491 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -20,16 +20,13 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ currency: currency, price_list_currency: currency, status: "Draft", - fiscal_year: frappe.defaults.get_user_default("fiscal_year"), is_subcontracted: "No", }, function(fieldname, value) { if(me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname]) me.frm.set_value(fieldname, value); }); - if(!this.frm.doc.company) { - this.frm.set_value("company", frappe.defaults.get_user_default("company")); - } else { + if(this.frm.doc.company) { cur_frm.script_manager.trigger("company"); } } @@ -332,7 +329,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ method: "erpnext.accounts.doctype.pricing_rule.pricing_rule.apply_pricing_rule", args: { args: this._get_args(item) }, callback: function(r) { - if (!r.exc) { + if (!r.exc && r.message) { me._set_values_for_item_list(r.message); if(calculate_taxes_and_totals) me.calculate_taxes_and_totals(); } diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index e8407581d1..9a4a356d17 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -86,7 +86,8 @@ cur_frm.cscript.make_address = function() { page_length: 5, new_doctype: "Address", get_query: function() { - return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where customer='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc" + return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where customer='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_address desc" }, as_dict: 1, no_results_message: __('No addresses created'), @@ -104,7 +105,8 @@ cur_frm.cscript.make_contact = function() { page_length: 5, new_doctype: "Contact", get_query: function() { - return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where customer='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc" + return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where customer='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_contact desc" }, as_dict: 1, no_results_message: __('No contacts created'), diff --git a/erpnext/selling/doctype/installation_note/installation_note.py b/erpnext/selling/doctype/installation_note/installation_note.py index 7d2d3d0663..0477abc265 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.py +++ b/erpnext/selling/doctype/installation_note/installation_note.py @@ -28,7 +28,8 @@ class InstallationNote(TransactionBase): 'source_field': 'qty', 'percent_join_field': 'prevdoc_docname', 'status_field': 'installation_status', - 'keyword': 'Installed' + 'keyword': 'Installed', + 'overflow_type': 'installation' }] def validate(self): diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index ebe1d84eda..bb5211312c 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -420,7 +420,7 @@ "label": "Taxes and Charges Calculation", "oldfieldtype": "HTML", "permlevel": 0, - "print_hide": 0 + "print_hide": 1 }, { "fieldname": "section_break_43", @@ -883,7 +883,7 @@ "idx": 1, "is_submittable": 1, "issingle": 0, - "modified": "2014-07-07 17:47:40.089520", + "modified": "2014-07-10 02:43:45.504009", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order", diff --git a/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json b/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json index 9bde272c61..deb90b71cd 100644 --- a/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json +++ b/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json @@ -1,17 +1,17 @@ { - "apply_user_permissions": 1, - "creation": "2012-10-04 18:45:27", - "docstatus": 0, - "doctype": "Report", - "idx": 1, - "is_standard": "Yes", - "modified": "2014-06-03 07:18:17.006732", - "modified_by": "Administrator", - "module": "Selling", - "name": "Customer Addresses And Contacts", - "owner": "Administrator", - "query": "SELECT\n\t`tabCustomer`.name as customer_id,\n\t`tabCustomer`.customer_name,\n\t`tabCustomer`.customer_group,\n\t`tabAddress`.address_line1,\n\t`tabAddress`.address_line2,\n\t`tabAddress`.city,\n\t`tabAddress`.state,\n\t`tabAddress`.pincode,\n\t`tabAddress`.country,\n\t`tabAddress`.is_primary_address, \n\t`tabContact`.first_name,\n\t`tabContact`.last_name,\n\t`tabContact`.phone,\n\t`tabContact`.mobile_no,\n\t`tabContact`.email_id,\n\t`tabContact`.is_primary_contact\nFROM\n\t`tabCustomer`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.customer=`tabCustomer`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.customer=`tabCustomer`.name\n\t)\nWHERE\n\t`tabCustomer`.docstatus<2\nORDER BY\n\t`tabCustomer`.name asc", - "ref_doctype": "Customer", - "report_name": "Customer Addresses And Contacts", + "apply_user_permissions": 1, + "creation": "2012-10-04 18:45:27", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-07-14 07:18:17.006732", + "modified_by": "Administrator", + "module": "Selling", + "name": "Customer Addresses and Contacts", + "owner": "Administrator", + "query": "SELECT\n\t`tabCustomer`.name as customer_id,\n\t`tabCustomer`.customer_name,\n\t`tabCustomer`.customer_group,\n\t`tabAddress`.address_line1,\n\t`tabAddress`.address_line2,\n\t`tabAddress`.city,\n\t`tabAddress`.state,\n\t`tabAddress`.pincode,\n\t`tabAddress`.country,\n\t`tabAddress`.is_primary_address, \n\t`tabContact`.first_name,\n\t`tabContact`.last_name,\n\t`tabContact`.phone,\n\t`tabContact`.mobile_no,\n\t`tabContact`.email_id,\n\t`tabContact`.is_primary_contact\nFROM\n\t`tabCustomer`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.customer=`tabCustomer`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.customer=`tabCustomer`.name\n\t)\nWHERE\n\t`tabCustomer`.docstatus<2\nORDER BY\n\t`tabCustomer`.name asc", + "ref_doctype": "Customer", + "report_name": "Customer Addresses And Contacts", "report_type": "Query Report" -} \ No newline at end of file +} diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 51a1ac5ede..4209e7d770 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -53,6 +53,15 @@ "permlevel": 0, "reqd": 0 }, + { + "fieldname": "country", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Country", + "options": "Country", + "permlevel": 0, + "reqd": 1 + }, { "fieldname": "charts_section", "fieldtype": "Section Break", @@ -60,18 +69,10 @@ "label": "Chart of Accounts", "permlevel": 0 }, - { - "fieldname": "country", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Country", - "options": "Country", - "permlevel": 0, - "reqd": 0 - }, { "fieldname": "chart_of_accounts", "fieldtype": "Link", + "hidden": 0, "ignore_user_permissions": 1, "label": "Chart of Accounts", "options": "Chart of Accounts", @@ -348,7 +349,7 @@ ], "icon": "icon-building", "idx": 1, - "modified": "2014-05-27 03:49:08.597191", + "modified": "2014-07-17 19:30:24.487672", "modified_by": "Administrator", "module": "Setup", "name": "Company", diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index d24c7e78e2..f8e043a927 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -241,7 +241,7 @@ class Company(Document): [_('Sales'),_('Direct Income'),'Ledger','Income Account','Profit and Loss', None, 'Income'], [_('Service'),_('Direct Income'),'Ledger','Income Account','Profit and Loss', None, 'Income'], [_('Indirect Income'),_('Income'),'Group','Income Account','Profit and Loss', None, 'Income'], - [_('Source of Funds (Liabilities)'), None,'Group', None,'Balance Sheet', None, 'Income'], + [_('Source of Funds (Liabilities)'), None,'Group', None,'Balance Sheet', None, 'Liability'], [_('Capital Account'),_('Source of Funds (Liabilities)'),'Group', None,'Balance Sheet', None, 'Liability'], [_('Reserves and Surplus'),_('Capital Account'),'Ledger', None,'Balance Sheet', None, 'Liability'], [_('Shareholders Funds'),_('Capital Account'),'Ledger', None,'Balance Sheet', None, 'Liability'], diff --git a/erpnext/setup/doctype/company/fixtures/india/__init__.py b/erpnext/setup/doctype/company/fixtures/india/__init__.py index fa45ab0364..d52b30402e 100644 --- a/erpnext/setup/doctype/company/fixtures/india/__init__.py +++ b/erpnext/setup/doctype/company/fixtures/india/__init__.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ def install(company): docs = [ @@ -27,44 +28,45 @@ def install(company): 'group_or_ledger': 2, 'account_type': 3, 'report_type': 4, - 'tax_rate': 5 + 'tax_rate': 5, + 'root_type': 6 } acc_list_india = [ - ['CENVAT Capital Goods','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT Service Tax','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT Service Tax Cess 1','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT Service Tax Cess 2','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT Edu Cess','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT SHE Cess','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['Excise Duty 4','Tax Assets','Ledger','Tax','Balance Sheet','4.00'], - ['Excise Duty 8','Tax Assets','Ledger','Tax','Balance Sheet','8.00'], - ['Excise Duty 10','Tax Assets','Ledger','Tax','Balance Sheet','10.00'], - ['Excise Duty 14','Tax Assets','Ledger','Tax','Balance Sheet','14.00'], - ['Excise Duty Edu Cess 2','Tax Assets','Ledger','Tax','Balance Sheet','2.00'], - ['Excise Duty SHE Cess 1','Tax Assets','Ledger','Tax','Balance Sheet','1.00'], - ['P L A','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['P L A - Cess Portion','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['Edu. Cess on Excise','Duties and Taxes','Ledger','Tax','Balance Sheet','2.00'], - ['Edu. Cess on Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet','2.00'], - ['Edu. Cess on TDS','Duties and Taxes','Ledger','Tax','Balance Sheet','2.00'], - ['Excise Duty @ 4','Duties and Taxes','Ledger','Tax','Balance Sheet','4.00'], - ['Excise Duty @ 8','Duties and Taxes','Ledger','Tax','Balance Sheet','8.00'], - ['Excise Duty @ 10','Duties and Taxes','Ledger','Tax','Balance Sheet','10.00'], - ['Excise Duty @ 14','Duties and Taxes','Ledger','Tax','Balance Sheet','14.00'], - ['Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet','10.3'], - ['SHE Cess on Excise','Duties and Taxes','Ledger','Tax','Balance Sheet','1.00'], - ['SHE Cess on Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet','1.00'], - ['SHE Cess on TDS','Duties and Taxes','Ledger','Tax','Balance Sheet','1.00'], - ['Professional Tax','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['VAT','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Advertisement)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Commission)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Contractor)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Interest)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Rent)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Salary)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None] + [_('CENVAT Capital Goods'),_(_('Tax Assets')),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT Service Tax'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT Service Tax Cess 1'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT Service Tax Cess 2'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT Edu Cess'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT SHE Cess'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('Excise Duty 4'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','4.00', 'Asset'], + [_('Excise Duty 8'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','8.00', 'Asset'], + [_('Excise Duty 10'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','10.00', 'Asset'], + [_('Excise Duty 14'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','14.00', 'Asset'], + [_('Excise Duty Edu Cess 2'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','2.00', 'Asset'], + [_('Excise Duty SHE Cess 1'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','1.00', 'Asset'], + [_('P L A'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('P L A - Cess Portion'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('Edu. Cess on Excise'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','2.00', 'Liability'], + [_('Edu. Cess on Service Tax'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','2.00', 'Liability'], + [_('Edu. Cess on TDS'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','2.00', 'Liability'], + [_('Excise Duty @ 4'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','4.00', 'Liability'], + [_('Excise Duty @ 8'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','8.00', 'Liability'], + [_('Excise Duty @ 10'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','10.00', 'Liability'], + [_('Excise Duty @ 14'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','14.00', 'Liability'], + [_('Service Tax'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','10.3', 'Liability'], + [_('SHE Cess on Excise'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','1.00', 'Liability'], + [_('SHE Cess on Service Tax'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','1.00', 'Liability'], + [_('SHE Cess on TDS'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','1.00', 'Liability'], + [_('Professional Tax'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('VAT'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Advertisement)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Commission)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Contractor)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Interest)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Rent)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Salary)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'] ] for lst in acc_list_india: diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 745345e58a..c6f49a1546 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -82,7 +82,7 @@ def get_child_groups(item_group_name): def get_item_for_list_in_html(context): # add missing absolute link in files # user may forget it during upload - if context.get("website_image", "").startswith("files/"): + if (context.get("website_image") or "").startswith("files/"): context["website_image"] = "/" + context["website_image"] return frappe.get_template("templates/includes/product_in_grid.html").render(context) diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.js b/erpnext/setup/doctype/sales_partner/sales_partner.js index 02af9f7276..64c4e2106c 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.js +++ b/erpnext/setup/doctype/sales_partner/sales_partner.js @@ -41,7 +41,8 @@ cur_frm.cscript.make_address = function() { frappe.set_route("Form", "Address", address.name); }, get_query: function() { - return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where sales_partner='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc" + return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where sales_partner='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_address desc" }, as_dict: 1, no_results_message: __('No addresses created'), @@ -64,7 +65,8 @@ cur_frm.cscript.make_contact = function() { frappe.set_route("Form", "Contact", contact.name); }, get_query: function() { - return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where sales_partner='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc" + return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where sales_partner='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_contact desc" }, as_dict: 1, no_results_message: __('No contacts created'), diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py index ca52efb119..343cba56c4 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.py +++ b/erpnext/setup/page/setup_wizard/setup_wizard.py @@ -113,9 +113,11 @@ def update_user_name(args): last_name=%(last_name)s WHERE name=%(name)s""", args) if args.get("attach_user"): - filename, filetype, content = args.get("attach_user").split(",") - fileurl = save_file(filename, content, "User", args.get("name"), decode=True).file_url - frappe.db.set_value("User", args.get("name"), "user_image", fileurl) + attach_user = args.get("attach_user").split(",") + if len(attach_user)==3: + filename, filetype, content = attach_user + fileurl = save_file(filename, content, "User", args.get("name"), decode=True).file_url + frappe.db.set_value("User", args.get("name"), "user_image", fileurl) add_all_roles_to(args.get("name")) @@ -319,9 +321,11 @@ def create_items(args): }).insert() if args.get("item_img_" + str(i)): - filename, filetype, content = args.get("item_img_" + str(i)).split(",") - fileurl = save_file(filename, content, "Item", item, decode=True).file_url - frappe.db.set_value("Item", item, "image", fileurl) + item_image = args.get("item_img_" + str(i)).split(",") + if len(item_image)==3: + filename, filetype, content = item_image + fileurl = save_file(filename, content, "Item", item, decode=True).file_url + frappe.db.set_value("Item", item, "image", fileurl) def create_customers(args): for i in xrange(1,6): @@ -374,17 +378,21 @@ def create_letter_head(args): "is_default": 1 }).insert() - filename, filetype, content = args.get("attach_letterhead").split(",") - fileurl = save_file(filename, content, "Letter Head", _("Standard"), decode=True).file_url - frappe.db.set_value("Letter Head", _("Standard"), "content", "" % fileurl) + attach_letterhead = args.get("attach_letterhead").split(",") + if len(attach_letterhead)==3: + filename, filetype, content = attach_letterhead + fileurl = save_file(filename, content, "Letter Head", _("Standard"), decode=True).file_url + frappe.db.set_value("Letter Head", _("Standard"), "content", "" % fileurl) def create_logo(args): if args.get("attach_logo"): - filename, filetype, content = args.get("attach_logo").split(",") - fileurl = save_file(filename, content, "Website Settings", "Website Settings", - decode=True).file_url - frappe.db.set_value("Website Settings", "Website Settings", "banner_html", - "" % fileurl) + attach_logo = args.get("attach_logo").split(",") + if len(attach_logo)==3: + filename, filetype, content = attach_logo + fileurl = save_file(filename, content, "Website Settings", "Website Settings", + decode=True).file_url + frappe.db.set_value("Website Settings", "Website Settings", "banner_html", + "" % fileurl) def add_all_roles_to(name): user = frappe.get_doc("User", name) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json index f1dc5a390e..9b43a71934 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.json +++ b/erpnext/stock/doctype/delivery_note/delivery_note.json @@ -427,6 +427,7 @@ "label": "Taxes and Charges Calculation", "oldfieldtype": "HTML", "permlevel": 0, + "print_hide": 1, "read_only": 0 }, { @@ -1008,7 +1009,7 @@ "idx": 1, "in_create": 0, "is_submittable": 1, - "modified": "2014-06-23 07:55:47.859869", + "modified": "2014-07-10 02:45:47.673011", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note", diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index c1ddf63a44..13da9078b0 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -29,7 +29,8 @@ class DeliveryNote(SellingController): 'source_field': 'qty', 'percent_join_field': 'against_sales_order', 'status_field': 'delivery_status', - 'keyword': 'Delivered' + 'keyword': 'Delivered', + 'overflow_type': 'delivery' }] def onload(self): diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index e53a92aad7..7a47765a2c 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -11,8 +11,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten this._super(); this.frm.set_query("item_code", this.frm.cscript.fname, function() { return { - query: "erpnext.controllers.queries.item_query", - filters: {'is_stock_item': 'Yes'} + query: "erpnext.controllers.queries.item_query" } }); }, diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 71c07eba02..74f1198752 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -27,6 +27,7 @@ class PurchaseReceipt(BuyingController): 'target_ref_field': 'qty', 'source_field': 'qty', 'percent_join_field': 'prevdoc_docname', + 'overflow_type': 'receipt' }] def onload(self): diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 10241983ad..dfcf07f506 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -92,7 +92,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ set_default_account: function() { var me = this; - if(cint(frappe.defaults.get_default("auto_accounting_for_stock"))) { + if(cint(frappe.defaults.get_default("auto_accounting_for_stock")) && this.frm.doc.company) { var account_for = "stock_adjustment_account"; if (this.frm.doc.purpose == "Purchase Return") @@ -230,6 +230,36 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ if(!row.t_warehouse) row.t_warehouse = this.frm.doc.to_warehouse; }, + source_mandatory: ["Material Issue", "Material Transfer", "Purchase Return"], + target_mandatory: ["Material Receipt", "Material Transfer", "Sales Return"], + + from_warehouse: function(doc) { + var me = this; + this.set_warehouse_if_missing("s_warehouse", doc.from_warehouse, function(row) { + return me.source_mandatory.indexOf(me.frm.doc.purpose)!==-1; + }); + }, + + to_warehouse: function(doc) { + var me = this; + this.set_warehouse_if_missing("t_warehouse", doc.to_warehouse, function(row) { + return me.target_mandatory.indexOf(me.frm.doc.purpose)!==-1; + }); + }, + + set_warehouse_if_missing: function(fieldname, value, condition) { + for (var i=0, l=(this.frm.doc.mtn_details || []).length; i curdate()))""", - as_dict=True) + _reorder_item() - for bin in bin_list: - #check if re-order is required - item_reorder = frappe.db.get("Item Reorder", - {"parent": bin.item_code, "warehouse": bin.warehouse}) - if item_reorder: - reorder_level = item_reorder.warehouse_reorder_level - reorder_qty = item_reorder.warehouse_reorder_qty - material_request_type = item_reorder.material_request_type or "Purchase" - else: - reorder_level, reorder_qty = frappe.db.get_value("Item", bin.item_code, - ["re_order_level", "re_order_qty"]) - material_request_type = "Purchase" +def _reorder_item(): + # {"Purchase": {"Company": [{"item_code": "", "warehouse": "", "reorder_qty": 0.0}]}, "Transfer": {...}} + material_requests = {"Purchase": {}, "Transfer": {}} - if flt(reorder_level) and flt(bin.projected_qty) < flt(reorder_level): - if flt(reorder_level) - flt(bin.projected_qty) > flt(reorder_qty): - reorder_qty = flt(reorder_level) - flt(bin.projected_qty) + item_warehouse_projected_qty = get_item_warehouse_projected_qty() + warehouse_company = frappe._dict(frappe.db.sql("""select name, company from `tabWarehouse`""")) + default_company = (frappe.defaults.get_defaults().get("company") or + frappe.db.sql("""select name from tabCompany limit 1""")[0][0]) - company = frappe.db.get_value("Warehouse", bin.warehouse, "company") or \ - frappe.defaults.get_defaults()["company"] or \ - frappe.db.sql("""select name from tabCompany limit 1""")[0][0] + def add_to_material_request(item_code, warehouse, reorder_level, reorder_qty, material_request_type): + if warehouse not in item_warehouse_projected_qty[item_code]: + # likely a disabled warehouse or a warehouse where BIN does not exist + return - material_requests.setdefault(material_request_type, frappe._dict()).setdefault( - company, []).append(frappe._dict({ - "item_code": bin.item_code, - "warehouse": bin.warehouse, - "reorder_qty": reorder_qty - }) - ) + reorder_level = flt(reorder_level) + reorder_qty = flt(reorder_qty) + projected_qty = item_warehouse_projected_qty[item_code][warehouse] - if material_requests: - create_material_request(material_requests) + if reorder_level and projected_qty < reorder_level: + deficiency = reorder_level - projected_qty + if deficiency > reorder_qty: + reorder_qty = deficiency + + company = warehouse_company.get(warehouse) or default_company + + material_requests[material_request_type].setdefault(company, []).append({ + "item_code": item_code, + "warehouse": warehouse, + "reorder_qty": reorder_qty + }) + + for item_code in item_warehouse_projected_qty: + item = frappe.get_doc("Item", item_code) + if item.get("item_reorder"): + for d in item.get("item_reorder"): + add_to_material_request(item_code, d.warehouse, d.warehouse_reorder_level, + d.warehouse_reorder_qty, d.material_request_type) + + else: + # raise for default warehouse + add_to_material_request(item_code, item.default_warehouse, item.re_order_level, item.re_order_qty, "Purchase") + + if material_requests: + create_material_request(material_requests) + +def get_item_warehouse_projected_qty(): + item_warehouse_projected_qty = {} + + for item_code, warehouse, projected_qty in frappe.db.sql("""select item_code, warehouse, projected_qty + from tabBin where ifnull(item_code, '') != '' and ifnull(warehouse, '') != '' + and exists (select name from `tabItem` + where `tabItem`.name = `tabBin`.item_code and + is_stock_item='Yes' and (is_purchase_item='Yes' or is_sub_contracted_item='Yes') and + (ifnull(end_of_life, '0000-00-00')='0000-00-00' or end_of_life > %s)) + and exists (select name from `tabWarehouse` + where `tabWarehouse`.name = `tabBin`.warehouse + and ifnull(disabled, 0)=0)""", nowdate()): + + item_warehouse_projected_qty.setdefault(item_code, {})[warehouse] = flt(projected_qty) + + return item_warehouse_projected_qty def create_material_request(material_requests): """ Create indent on reaching reorder level """ @@ -263,6 +285,7 @@ def create_material_request(material_requests): }) for d in items: + d = frappe._dict(d) item = frappe.get_doc("Item", d.item_code) mr.append("indent_details", { "doctype": "Material Request Item", diff --git a/erpnext/support/doctype/support_ticket/support_ticket.py b/erpnext/support/doctype/support_ticket/support_ticket.py index 9517ea48de..4cdc20ac0f 100644 --- a/erpnext/support/doctype/support_ticket/support_ticket.py +++ b/erpnext/support/doctype/support_ticket/support_ticket.py @@ -8,31 +8,31 @@ from erpnext.utilities.transaction_base import TransactionBase from frappe.utils import now, extract_email_id class SupportTicket(TransactionBase): - + def get_sender(self, comm): return frappe.db.get_value('Support Email Settings',None,'support_email') def get_subject(self, comm): return '[' + self.name + '] ' + (comm.subject or 'No Subject Specified') - + def get_content(self, comm): signature = frappe.db.get_value('Support Email Settings',None,'support_signature') content = comm.content if signature: content += '

' + signature + '

' return content - + def get_portal_page(self): return "ticket" - + def validate(self): self.update_status() self.set_lead_contact(self.raised_by) - + if self.status == "Closed": from frappe.widgets.form.assign_to import clear clear(self.doctype, self.name) - + def set_lead_contact(self, email_id): import email.utils email_id = email.utils.parseaddr(email_id) @@ -41,8 +41,8 @@ class SupportTicket(TransactionBase): self.lead = frappe.db.get_value("Lead", {"email_id": email_id}) if not self.contact: self.contact = frappe.db.get_value("Contact", {"email_id": email_id}) - - if not self.company: + + if not self.company: self.company = frappe.db.get_value("Lead", self.lead, "company") or \ frappe.db.get_default("company") @@ -53,15 +53,16 @@ class SupportTicket(TransactionBase): if self.status=="Closed" and status !="Closed": self.resolution_date = now() if self.status=="Open" and status !="Open": - self.resolution_date = "" + # if no date, it should be set as None and not a blank string "", as per mysql strict config + self.resolution_date = None @frappe.whitelist() def set_status(name, status): st = frappe.get_doc("Support Ticket", name) st.status = status st.save() - + def auto_close_tickets(): - frappe.db.sql("""update `tabSupport Ticket` set status = 'Closed' - where status = 'Replied' + frappe.db.sql("""update `tabSupport Ticket` set status = 'Closed' + where status = 'Replied' and date_sub(curdate(),interval 15 Day) > modified""") diff --git a/erpnext/utilities/doctype/note/note.json b/erpnext/utilities/doctype/note/note.json index 2ee6d9ad4f..6cf756c3aa 100644 --- a/erpnext/utilities/doctype/note/note.json +++ b/erpnext/utilities/doctype/note/note.json @@ -12,7 +12,8 @@ "in_list_view": 1, "label": "Title", "permlevel": 0, - "print_hide": 1 + "print_hide": 1, + "reqd": 1 }, { "description": "Help: To link to another record in the system, use \"#Form/Note/[Note Name]\" as the Link URL. (don't use \"http://\")", @@ -48,7 +49,7 @@ ], "icon": "icon-file-text", "idx": 1, - "modified": "2014-05-27 03:49:13.934698", + "modified": "2014-07-09 12:54:11.897597", "modified_by": "Administrator", "module": "Utilities", "name": "Note", diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py index e4028b69f6..159825a495 100644 --- a/erpnext/utilities/repost_stock.py +++ b/erpnext/utilities/repost_stock.py @@ -190,3 +190,22 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin "posting_date": posting_date, "posting_time": posting_time }) + +def reset_serial_no_status_and_warehouse(serial_nos=None): + if not serial_nos: + serial_nos = frappe.db.sql_list("""select name from `tabSerial No` where status != 'Not in Use' + and docstatus = 0""") + for serial_no in serial_nos: + try: + sr = frappe.get_doc("Serial No", serial_no) + last_sle = sr.get_last_sle() + if flt(last_sle.actual_qty) > 0: + sr.warehouse = last_sle.warehouse + + sr.via_stock_ledger = True + sr.save() + except: + pass + + frappe.db.sql("""update `tabSerial No` set warehouse='' where status in ('Delivered', 'Purchase Returned')""") + \ No newline at end of file
{%= data[i].voucher_type%}
{%= data[i].voucher_no %}
{%= data[i].account %} -
{%= __("Against") %}: {%= data[i].account %} +
{%= __("Against") %}: {%= data[i].against_account %}
{%= __("Remarks") %}: {%= data[i].remarks %}
{%= format_currency(data[i].debit) %} {%= format_currency(data[i].credit) %}