From ba47f897026a11d5c4d1c845213d8228c81724a1 Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Wed, 17 Apr 2019 11:24:04 +0530 Subject: [PATCH] fix: added a single value to fetch payment terms --- .../doctype/fetch_payment_terms/__init__.py | 0 .../fetch_payment_terms.js | 8 ++ .../fetch_payment_terms.json | 96 +++++++++++++++++++ .../fetch_payment_terms.py | 10 ++ .../test_fetch_payment_terms.js | 23 +++++ .../test_fetch_payment_terms.py | 10 ++ .../doctype/purchase_order/purchase_order.py | 16 ++-- erpnext/config/accounts.py | 8 +- 8 files changed, 164 insertions(+), 7 deletions(-) create mode 100644 erpnext/accounts/doctype/fetch_payment_terms/__init__.py create mode 100644 erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.js create mode 100644 erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.json create mode 100644 erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.py create mode 100644 erpnext/accounts/doctype/fetch_payment_terms/test_fetch_payment_terms.js create mode 100644 erpnext/accounts/doctype/fetch_payment_terms/test_fetch_payment_terms.py diff --git a/erpnext/accounts/doctype/fetch_payment_terms/__init__.py b/erpnext/accounts/doctype/fetch_payment_terms/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.js b/erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.js new file mode 100644 index 00000000000..faa011c9fe3 --- /dev/null +++ b/erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.js @@ -0,0 +1,8 @@ +// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Fetch Payment Terms', { + refresh: function(frm) { + + } +}); diff --git a/erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.json b/erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.json new file mode 100644 index 00000000000..c1f83459f81 --- /dev/null +++ b/erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.json @@ -0,0 +1,96 @@ +{ + "allow_copy": 0, + "allow_events_in_timeline": 0, + "allow_guest_to_view": 0, + "allow_import": 0, + "allow_rename": 0, + "beta": 0, + "creation": "2019-04-17 11:00:32.823034", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 0, + "engine": "InnoDB", + "fields": [ + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, + "fieldname": "fetch_payment_terms", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Always Fetch Payment Terms", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + } + ], + "has_web_view": 0, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "is_submittable": 0, + "issingle": 1, + "istable": 0, + "max_attachments": 0, + "modified": "2019-04-17 11:06:02.216048", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Fetch Payment Terms", + "name_case": "", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 0, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 0, + "role": "System Manager", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + } + ], + "quick_entry": 1, + "read_only": 0, + "read_only_onload": 0, + "show_name_in_global_search": 0, + "sort_field": "modified", + "sort_order": "ASC", + "track_changes": 1, + "track_seen": 0, + "track_views": 0 +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.py b/erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.py new file mode 100644 index 00000000000..c7bdd177e7e --- /dev/null +++ b/erpnext/accounts/doctype/fetch_payment_terms/fetch_payment_terms.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class FetchPaymentTerms(Document): + pass diff --git a/erpnext/accounts/doctype/fetch_payment_terms/test_fetch_payment_terms.js b/erpnext/accounts/doctype/fetch_payment_terms/test_fetch_payment_terms.js new file mode 100644 index 00000000000..80fd8e34f02 --- /dev/null +++ b/erpnext/accounts/doctype/fetch_payment_terms/test_fetch_payment_terms.js @@ -0,0 +1,23 @@ +/* eslint-disable */ +// rename this file from _test_[name] to test_[name] to activate +// and remove above this line + +QUnit.test("test: Fetch Payment Terms", function (assert) { + let done = assert.async(); + + // number of asserts + assert.expect(1); + + frappe.run_serially([ + // insert a new Fetch Payment Terms + () => frappe.tests.make('Fetch Payment Terms', [ + // values to be set + {key: 'value'} + ]), + () => { + assert.equal(cur_frm.doc.key, 'value'); + }, + () => done() + ]); + +}); diff --git a/erpnext/accounts/doctype/fetch_payment_terms/test_fetch_payment_terms.py b/erpnext/accounts/doctype/fetch_payment_terms/test_fetch_payment_terms.py new file mode 100644 index 00000000000..771a44c208e --- /dev/null +++ b/erpnext/accounts/doctype/fetch_payment_terms/test_fetch_payment_terms.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +class TestFetchPaymentTerms(unittest.TestCase): + pass diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index a669238689b..27bce5b828a 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -393,7 +393,7 @@ def make_purchase_invoice(source_name, target_doc=None): or item.get("buying_cost_center") or item_group.get("buying_cost_center")) - doc = get_mapped_doc("Purchase Order", source_name, { + fields = { "Purchase Order": { "doctype": "Purchase Invoice", "field_map": { @@ -416,12 +416,16 @@ def make_purchase_invoice(source_name, target_doc=None): "Purchase Taxes and Charges": { "doctype": "Purchase Taxes and Charges", "add_if_empty": True - }, - "Payment Schedule": { - "doctype": "Payment Schedule", - "add_if_empty": True } - }, target_doc, postprocess) + } + + if frappe.get_single("Fetch Payment Terms").fetch_payment_terms == 1: + fields["Payment Schedule"] = { + "doctype": "Payment Schedule", + "add_if_empty": True + } + + doc = get_mapped_doc("Purchase Order", source_name, fields, target_doc, postprocess) return doc diff --git a/erpnext/config/accounts.py b/erpnext/config/accounts.py index 42d0df0a06f..f3cf8a28880 100644 --- a/erpnext/config/accounts.py +++ b/erpnext/config/accounts.py @@ -297,7 +297,13 @@ def get_data(): "name": "C-Form", "description": _("C-Form records"), "country": "India" - } + }, + { + "type": "doctype", + "name": "Fetch Payment Terms", + "label": _("Fetch Payment Terms"), + "description": _("Fetch Payment Terms") + }, ] }, {