Merge branch 'develop' into home-onboarding
diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py
index 2a923f0..ddb833f 100644
--- a/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py
+++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/opening_invoice_creation_tool.py
@@ -159,7 +159,8 @@
frappe.scrub(row.party_type): row.party,
"is_pos": 0,
"doctype": "Sales Invoice" if self.invoice_type == "Sales" else "Purchase Invoice",
- "update_stock": 0
+ "update_stock": 0,
+ "invoice_number": row.invoice_number
})
accounting_dimension = get_accounting_dimensions()
@@ -200,10 +201,13 @@
names = []
for idx, d in enumerate(invoices):
try:
+ invoice_number = None
+ if d.invoice_number:
+ invoice_number = d.invoice_number
publish(idx, len(invoices), d.doctype)
doc = frappe.get_doc(d)
doc.flags.ignore_mandatory = True
- doc.insert()
+ doc.insert(set_name=invoice_number)
doc.submit()
frappe.db.commit()
names.append(doc.name)
diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py b/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py
index c795e83..07c72bd 100644
--- a/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py
+++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py
@@ -18,10 +18,10 @@
if not frappe.db.exists("Company", "_Test Opening Invoice Company"):
make_company()
- def make_invoices(self, invoice_type="Sales", company=None, party_1=None, party_2=None):
+ def make_invoices(self, invoice_type="Sales", company=None, party_1=None, party_2=None, invoice_number=None):
doc = frappe.get_single("Opening Invoice Creation Tool")
args = get_opening_invoice_creation_dict(invoice_type=invoice_type, company=company,
- party_1=party_1, party_2=party_2)
+ party_1=party_1, party_2=party_2, invoice_number=invoice_number)
doc.update(args)
return doc.make_invoices()
@@ -92,6 +92,20 @@
# teardown
frappe.db.set_value("Company", company, "default_receivable_account", old_default_receivable_account)
+ def test_renaming_of_invoice_using_invoice_number_field(self):
+ company = "_Test Opening Invoice Company"
+ party_1, party_2 = make_customer("Customer A"), make_customer("Customer B")
+ self.make_invoices(company=company, party_1=party_1, party_2=party_2, invoice_number="TEST-NEW-INV-11")
+
+ sales_inv1 = frappe.get_all('Sales Invoice', filters={'customer':'Customer A'})[0].get("name")
+ sales_inv2 = frappe.get_all('Sales Invoice', filters={'customer':'Customer B'})[0].get("name")
+ self.assertEqual(sales_inv1, "TEST-NEW-INV-11")
+
+ #teardown
+ for inv in [sales_inv1, sales_inv2]:
+ doc = frappe.get_doc('Sales Invoice', inv)
+ doc.cancel()
+
def get_opening_invoice_creation_dict(**args):
party = "Customer" if args.get("invoice_type", "Sales") == "Sales" else "Supplier"
company = args.get("company", "_Test Company")
@@ -107,7 +121,8 @@
"item_name": "Opening Item",
"due_date": "2016-09-10",
"posting_date": "2016-09-05",
- "temporary_opening_account": get_temporary_opening_account(company)
+ "temporary_opening_account": get_temporary_opening_account(company),
+ "invoice_number": args.get("invoice_number")
},
{
"qty": 2.0,
@@ -116,7 +131,8 @@
"item_name": "Opening Item",
"due_date": "2016-09-10",
"posting_date": "2016-09-05",
- "temporary_opening_account": get_temporary_opening_account(company)
+ "temporary_opening_account": get_temporary_opening_account(company),
+ "invoice_number": None
}
]
})
diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.json b/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.json
index 4ce8cb9..040624f 100644
--- a/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.json
+++ b/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.json
@@ -1,9 +1,11 @@
{
+ "actions": [],
"creation": "2017-08-29 04:26:36.159247",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
+ "invoice_number",
"party_type",
"party",
"temporary_opening_account",
@@ -103,10 +105,17 @@
{
"fieldname": "dimension_col_break",
"fieldtype": "Column Break"
+ },
+ {
+ "description": "Reference number of the invoice from the previous system",
+ "fieldname": "invoice_number",
+ "fieldtype": "Data",
+ "label": "Invoice Number"
}
],
"istable": 1,
- "modified": "2019-07-25 15:00:00.460695",
+ "links": [],
+ "modified": "2021-12-13 18:15:41.295007",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Opening Invoice Creation Tool Item",
diff --git a/erpnext/accounts/doctype/subscription_plan/subscription_plan.json b/erpnext/accounts/doctype/subscription_plan/subscription_plan.json
index 878ae09..563df79 100644
--- a/erpnext/accounts/doctype/subscription_plan/subscription_plan.json
+++ b/erpnext/accounts/doctype/subscription_plan/subscription_plan.json
@@ -75,7 +75,8 @@
"fieldname": "cost",
"fieldtype": "Currency",
"in_list_view": 1,
- "label": "Cost"
+ "label": "Cost",
+ "options": "currency"
},
{
"depends_on": "eval:doc.price_determination==\"Based On Price List\"",
@@ -147,7 +148,7 @@
}
],
"links": [],
- "modified": "2021-08-13 10:53:44.205774",
+ "modified": "2021-12-10 15:24:15.794477",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Subscription Plan",
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 6654048..93a2731 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -888,9 +888,11 @@
function set_time_to_resolve_and_response(frm, apply_sla_for_resolution) {
frm.dashboard.clear_headline();
- let time_to_respond = get_status(frm.doc.response_by);
+ let time_to_respond;
if (!frm.doc.first_responded_on) {
time_to_respond = get_time_left(frm.doc.response_by, frm.doc.agreement_status);
+ } else {
+ time_to_respond = get_status(frm.doc.response_by, frm.doc.first_responded_on);
}
let alert = `
@@ -903,9 +905,11 @@
if (apply_sla_for_resolution) {
- let time_to_resolve = get_status(frm.doc.resolution_by);
+ let time_to_resolve;
if (!frm.doc.resolution_date) {
time_to_resolve = get_time_left(frm.doc.resolution_by, frm.doc.agreement_status);
+ } else {
+ time_to_resolve = get_status(frm.doc.resolution_by, frm.doc.resolution_date);
}
alert += `
@@ -928,8 +932,8 @@
return {'diff_display': diff_display, 'indicator': indicator};
}
-function get_status(timestamp) {
- const time_left = moment(timestamp).diff(moment());
+function get_status(expected, actual) {
+ const time_left = moment(expected).diff(moment(actual));
if (time_left >= 0) {
return {'diff_display': 'Fulfilled', 'indicator': 'green'};
} else {