diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 8daf3f667f6..d3f142e12fc 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -40,7 +40,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte this._super(); cur_frm.dashboard.reset(); - + + this.frm.toggle_reqd("due_date", !this.frm.doc.is_return); + if(doc.docstatus==1) { cur_frm.add_custom_button('View Ledger', function() { frappe.route_options = { diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index b983d990244..bc6a2275f4a 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -156,7 +156,7 @@ "oldfieldtype": "Date", "permlevel": 0, "read_only": 0, - "reqd": 1, + "reqd": 0, "search_index": 0 }, { @@ -1275,7 +1275,7 @@ "icon": "icon-file-text", "idx": 1, "is_submittable": 1, - "modified": "2015-07-17 13:29:36.922418", + "modified": "2015-07-22 16:53:52.995407", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/accounts/print_format/credit_note/credit_note.json b/erpnext/accounts/print_format/credit_note/credit_note.json index de405e694f5..863d4aa6073 100644 --- a/erpnext/accounts/print_format/credit_note/credit_note.json +++ b/erpnext/accounts/print_format/credit_note/credit_note.json @@ -1,19 +1,19 @@ { - "creation": "2014-08-28 11:11:39.796473", - "disabled": 0, - "doc_type": "Journal Entry", - "docstatus": 0, - "doctype": "Print Format", - "html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n\n
\n {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n and doc.set(\"select_print_heading\", _(\"Credit Note\")) -%}{%- endif -%}\n {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n {%- for label, value in (\n (_(\"Credit To\"), doc.pay_to_recd_from),\n (_(\"Date\"), frappe.utils.formatdate(doc.voucher_date)),\n (_(\"Amount\"), \"\" + doc.get_formatted(\"total_amount\") + \"
\" + (doc.total_amount_in_words or \"\") + \"
\"),\n (_(\"Remarks\"), doc.remark)\n ) -%}\n\n
\n
\n
{{ value }}
\n
\n\n {%- endfor -%}\n\n
\n
\n

\n {{ _(\"For\") }} {{ doc.company }},
\n
\n
\n
\n {{ _(\"Authorized Signatory\") }}\n

\n
\n\n\n", - "idx": 2, - "modified": "2015-01-12 11:02:25.716825", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Credit Note", - "owner": "Administrator", - "parent": "Journal Entry", - "parentfield": "__print_formats", - "parenttype": "DocType", - "print_format_type": "Server", + "creation": "2014-08-28 11:11:39.796473", + "custom_format": 0, + "disabled": 0, + "doc_type": "Journal Entry", + "docstatus": 0, + "doctype": "Print Format", + "html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n\n
\n {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n and doc.set(\"select_print_heading\", _(\"Credit Note\")) -%}{%- endif -%}\n {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n {%- for label, value in (\n (_(\"Credit To\"), doc.pay_to_recd_from),\n (_(\"Date\"), frappe.utils.formatdate(doc.voucher_date)),\n (_(\"Amount\"), \"\" + doc.get_formatted(\"total_amount\") + \"
\" + (doc.total_amount_in_words or \"\") + \"
\"),\n (_(\"Remarks\"), doc.remark)\n ) -%}\n\n
\n
\n
{{ value }}
\n
\n\n {%- endfor -%}\n\n
\n
\n

\n {{ _(\"For\") }} {{ doc.company }},
\n
\n
\n
\n {{ _(\"Authorized Signatory\") }}\n

\n
\n\n\n", + "idx": 2, + "modified": "2015-07-22 17:42:01.560817", + "modified_by": "Administrator", + "name": "Credit Note", + "owner": "Administrator", + "parent": "Journal Entry", + "parentfield": "__print_formats", + "parenttype": "DocType", + "print_format_type": "Server", "standard": "Yes" -} +} \ No newline at end of file diff --git a/erpnext/accounts/print_format/credit_note___negative_invoice/__init__.py b/erpnext/accounts/print_format/credit_note___negative_invoice/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/accounts/print_format/credit_note___negative_invoice/credit_note___negative_invoice.json b/erpnext/accounts/print_format/credit_note___negative_invoice/credit_note___negative_invoice.json new file mode 100644 index 00000000000..e7d7eabaff1 --- /dev/null +++ b/erpnext/accounts/print_format/credit_note___negative_invoice/credit_note___negative_invoice.json @@ -0,0 +1,17 @@ +{ + "creation": "2015-07-22 17:45:22.220567", + "custom_format": 1, + "disabled": 0, + "doc_type": "Sales Invoice", + "docstatus": 0, + "doctype": "Print Format", + "font": "Default", + "html": "\n\n

\n\t{{ doc.company }}
\n\t{{ doc.select_print_heading or _(\"Credit Note\") }}
\n

\n\n
\n\n{%- for label, value in (\n (_(\"Receipt No\"), doc.name),\n (_(\"Date\"), doc.get_formatted(\"posting_date\")),\n\t(_(\"Customer\"), doc.customer_name),\n (_(\"Amount\"), \"\" + doc.get_formatted(\"grand_total\", absolute_value=True) + \"
\" + (doc.in_words or \"\")),\n\t(_(\"Against\"), doc.return_against),\n (_(\"Remarks\"), doc.remarks)\n) -%}\n\n\t\t
\n\t\t
\n\t\t
{{ value }}
\n\t\t
\n{%- endfor -%}\n\n
\n
\n

\n {{ _(\"For\") }} {{ doc.company }},
\n
\n
\n
\n {{ _(\"Authorized Signatory\") }}\n

", + "modified": "2015-07-22 17:45:22.220567", + "modified_by": "Administrator", + "name": "Credit Note - Negative Invoice", + "owner": "Administrator", + "print_format_builder": 0, + "print_format_type": "Server", + "standard": "Yes" +} \ No newline at end of file diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index eb7b73f7f26..c0947711893 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -173,6 +173,9 @@ class AccountsController(TransactionBase): def validate_due_date(self): from erpnext.accounts.party import validate_due_date if self.doctype == "Sales Invoice": + if not self.due_date: + frappe.throw(_("Due Date is mandatory")) + validate_due_date(self.posting_date, self.due_date, "Customer", self.customer, self.company) elif self.doctype == "Purchase Invoice": validate_due_date(self.posting_date, self.due_date, "Supplier", self.supplier, self.company) diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 01ef605b635..5ad0a25af36 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -110,15 +110,14 @@ class SellingController(StockController): from frappe.utils import money_in_words company_currency = get_company_currency(self.company) - disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, - "disable_rounded_total")) + disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total")) if self.meta.get_field("base_in_words"): self.base_in_words = money_in_words(disable_rounded_total and - self.base_grand_total or self.base_rounded_total, company_currency) + abs(self.base_grand_total) or abs(self.base_rounded_total), company_currency) if self.meta.get_field("in_words"): self.in_words = money_in_words(disable_rounded_total and - self.grand_total or self.rounded_total, self.currency) + abs(self.grand_total) or abs(self.rounded_total), self.currency) def calculate_commission(self): if self.meta.get_field("commission_rate"):