Fixes for recurring document
This commit is contained in:
parent
8370cb3e71
commit
1394509343
@ -232,42 +232,6 @@ cur_frm.fields_dict['entries'].grid.get_field('project_name').get_query = functi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.is_recurring = function(doc, dt, dn) {
|
|
||||||
// set default values for recurring invoices
|
|
||||||
if(doc.is_recurring) {
|
|
||||||
var owner_email = doc.owner=="Administrator"
|
|
||||||
? frappe.user_info("Administrator").email
|
|
||||||
: doc.owner;
|
|
||||||
|
|
||||||
doc.notification_email_address = $.map([cstr(owner_email),
|
|
||||||
cstr(doc.contact_email)], function(v) { return v || null; }).join(", ");
|
|
||||||
doc.repeat_on_day_of_month = frappe.datetime.str_to_obj(doc.posting_date).getDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh_many(["notification_email_address", "repeat_on_day_of_month"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.from_date = function(doc, dt, dn) {
|
|
||||||
// set to_date
|
|
||||||
if(doc.from_date) {
|
|
||||||
var recurring_type_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6,
|
|
||||||
'Yearly': 12};
|
|
||||||
|
|
||||||
var months = recurring_type_map[doc.recurring_type];
|
|
||||||
if(months) {
|
|
||||||
var to_date = frappe.datetime.add_months(doc.from_date,
|
|
||||||
months);
|
|
||||||
doc.to_date = frappe.datetime.add_days(to_date, -1);
|
|
||||||
refresh_field('to_date');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
|
cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
|
||||||
if(doc.select_print_heading){
|
if(doc.select_print_heading){
|
||||||
// print heading
|
// print heading
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,20 +5,14 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
from frappe.utils import add_days, cint, cstr, date_diff, formatdate, flt, getdate, nowdate, \
|
from frappe.utils import cint, cstr, formatdate, flt
|
||||||
get_first_day, get_last_day
|
|
||||||
from frappe.model.naming import make_autoname
|
|
||||||
|
|
||||||
from frappe import msgprint, _, throw
|
from frappe import msgprint, _, throw
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
|
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
|
|
||||||
from erpnext.controllers.buying_controller import BuyingController
|
from erpnext.controllers.buying_controller import BuyingController
|
||||||
from erpnext.accounts.party import get_party_account, get_due_date
|
from erpnext.accounts.party import get_party_account, get_due_date
|
||||||
|
|
||||||
from erpnext.controllers.recurring_document import *
|
|
||||||
|
|
||||||
form_grid_templates = {
|
form_grid_templates = {
|
||||||
"entries": "templates/form_grid/item_grid.html"
|
"entries": "templates/form_grid/item_grid.html"
|
||||||
}
|
}
|
||||||
@ -66,7 +60,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.validate_multiple_billing("Purchase Receipt", "pr_detail", "amount",
|
self.validate_multiple_billing("Purchase Receipt", "pr_detail", "amount",
|
||||||
"purchase_receipt_details")
|
"purchase_receipt_details")
|
||||||
self.create_remarks()
|
self.create_remarks()
|
||||||
validate_recurring_document(self)
|
|
||||||
|
|
||||||
def create_remarks(self):
|
def create_remarks(self):
|
||||||
if not self.remarks:
|
if not self.remarks:
|
||||||
@ -255,6 +248,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
reconcile_against_document(lst)
|
reconcile_against_document(lst)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
super(PurchaseInvoice, self).on_submit()
|
||||||
|
|
||||||
self.check_prev_docstatus()
|
self.check_prev_docstatus()
|
||||||
|
|
||||||
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
|
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
|
||||||
@ -265,11 +260,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.update_against_document_in_jv()
|
self.update_against_document_in_jv()
|
||||||
self.update_prevdoc_status()
|
self.update_prevdoc_status()
|
||||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||||
convert_to_recurring(self, self.posting_date)
|
|
||||||
|
|
||||||
def on_update_after_submit(self):
|
|
||||||
validate_recurring_document(self)
|
|
||||||
convert_to_recurring(self, self.posting_date)
|
|
||||||
|
|
||||||
def make_gl_entries(self):
|
def make_gl_entries(self):
|
||||||
auto_accounting_for_stock = \
|
auto_accounting_for_stock = \
|
||||||
|
@ -231,4 +231,8 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||||
where against_voucher=%s""", pi.name))
|
where against_voucher=%s""", pi.name))
|
||||||
|
|
||||||
|
def test_recurring_invoice(self):
|
||||||
|
from erpnext.controllers.tests.test_recurring_document import test_recurring_document
|
||||||
|
test_recurring_document(self, test_records)
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Purchase Invoice')
|
test_records = frappe.get_test_records('Purchase Invoice')
|
||||||
|
@ -399,37 +399,6 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.is_recurring = function(doc, dt, dn) {
|
|
||||||
// set default values for recurring invoices
|
|
||||||
if(doc.is_recurring) {
|
|
||||||
var owner_email = doc.owner=="Administrator"
|
|
||||||
? frappe.user_info("Administrator").email
|
|
||||||
: doc.owner;
|
|
||||||
|
|
||||||
doc.notification_email_address = $.map([cstr(owner_email),
|
|
||||||
cstr(doc.contact_email)], function(v) { return v || null; }).join(", ");
|
|
||||||
doc.repeat_on_day_of_month = frappe.datetime.str_to_obj(doc.posting_date).getDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh_many(["notification_email_address", "repeat_on_day_of_month"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.from_date = function(doc, dt, dn) {
|
|
||||||
// set to_date
|
|
||||||
if(doc.from_date) {
|
|
||||||
var recurring_type_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6,
|
|
||||||
'Yearly': 12};
|
|
||||||
|
|
||||||
var months = recurring_type_map[doc.recurring_type];
|
|
||||||
if(months) {
|
|
||||||
var to_date = frappe.datetime.add_months(doc.from_date,
|
|
||||||
months);
|
|
||||||
doc.to_date = frappe.datetime.add_days(to_date, -1);
|
|
||||||
refresh_field('to_date');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.send_sms = function() {
|
cur_frm.cscript.send_sms = function() {
|
||||||
frappe.require("assets/erpnext/js/sms_manager.js");
|
frappe.require("assets/erpnext/js/sms_manager.js");
|
||||||
var sms_man = new SMSManager(cur_frm.doc);
|
var sms_man = new SMSManager(cur_frm.doc);
|
||||||
|
@ -174,7 +174,7 @@
|
|||||||
"description": "Start date of current invoice's period",
|
"description": "Start date of current invoice's period",
|
||||||
"fieldname": "from_date",
|
"fieldname": "from_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "From",
|
"label": "From Date",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@ -186,7 +186,7 @@
|
|||||||
"description": "End date of current invoice's period",
|
"description": "End date of current invoice's period",
|
||||||
"fieldname": "to_date",
|
"fieldname": "to_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "To",
|
"label": "To Date",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@ -1192,7 +1192,7 @@
|
|||||||
"icon": "icon-file-text",
|
"icon": "icon-file-text",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2014-09-09 05:35:34.121045",
|
"modified": "2014-09-18 03:17:54.976732",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice",
|
"name": "Sales Invoice",
|
||||||
|
@ -4,18 +4,12 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
|
from frappe.utils import cint, cstr, flt
|
||||||
from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, \
|
|
||||||
get_first_day, get_last_day
|
|
||||||
from frappe.model.naming import make_autoname
|
|
||||||
from frappe import _, msgprint, throw
|
from frappe import _, msgprint, throw
|
||||||
|
|
||||||
from erpnext.accounts.party import get_party_account, get_due_date
|
from erpnext.accounts.party import get_party_account, get_due_date
|
||||||
from erpnext.controllers.stock_controller import update_gl_entries_after
|
from erpnext.controllers.stock_controller import update_gl_entries_after
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
from erpnext.controllers.recurring_document import *
|
|
||||||
|
|
||||||
from erpnext.controllers.selling_controller import SellingController
|
from erpnext.controllers.selling_controller import SellingController
|
||||||
|
|
||||||
form_grid_templates = {
|
form_grid_templates = {
|
||||||
@ -77,11 +71,12 @@ class SalesInvoice(SellingController):
|
|||||||
self.set_against_income_account()
|
self.set_against_income_account()
|
||||||
self.validate_c_form()
|
self.validate_c_form()
|
||||||
self.validate_time_logs_are_submitted()
|
self.validate_time_logs_are_submitted()
|
||||||
validate_recurring_document(self)
|
|
||||||
self.validate_multiple_billing("Delivery Note", "dn_detail", "amount",
|
self.validate_multiple_billing("Delivery Note", "dn_detail", "amount",
|
||||||
"delivery_note_details")
|
"delivery_note_details")
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
super(SalesInvoice, self).on_submit()
|
||||||
|
|
||||||
if cint(self.update_stock) == 1:
|
if cint(self.update_stock) == 1:
|
||||||
self.update_stock_ledger()
|
self.update_stock_ledger()
|
||||||
else:
|
else:
|
||||||
@ -104,7 +99,6 @@ class SalesInvoice(SellingController):
|
|||||||
self.update_against_document_in_jv()
|
self.update_against_document_in_jv()
|
||||||
|
|
||||||
self.update_time_log_batch(self.name)
|
self.update_time_log_batch(self.name)
|
||||||
convert_to_recurring(self, self.posting_date)
|
|
||||||
|
|
||||||
def before_cancel(self):
|
def before_cancel(self):
|
||||||
self.update_time_log_batch(None)
|
self.update_time_log_batch(None)
|
||||||
@ -145,14 +139,6 @@ class SalesInvoice(SellingController):
|
|||||||
'overflow_type': 'delivery'
|
'overflow_type': 'delivery'
|
||||||
})
|
})
|
||||||
|
|
||||||
def on_update_after_submit(self):
|
|
||||||
validate_recurring_document(self)
|
|
||||||
convert_to_recurring(self, self.posting_date)
|
|
||||||
|
|
||||||
def before_recurring(self):
|
|
||||||
self.aging_date = None
|
|
||||||
self.due_date = None
|
|
||||||
|
|
||||||
def get_portal_page(self):
|
def get_portal_page(self):
|
||||||
return "invoice" if self.docstatus==1 else None
|
return "invoice" if self.docstatus==1 else None
|
||||||
|
|
||||||
|
@ -206,39 +206,6 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.is_recurring = function(doc, dt, dn) {
|
|
||||||
// set default values for recurring orders
|
|
||||||
if(doc.is_recurring) {
|
|
||||||
var owner_email = doc.owner=="Administrator"
|
|
||||||
? frappe.user_info("Administrator").email
|
|
||||||
: doc.owner;
|
|
||||||
|
|
||||||
doc.notification_email_address = $.map([cstr(owner_email),
|
|
||||||
cstr(doc.contact_email)], function(v) { return v || null; }).join(", ");
|
|
||||||
doc.repeat_on_day_of_month = frappe.datetime.str_to_obj(doc.posting_date).getDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh_many(["notification_email_address", "repeat_on_day_of_month"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.from_date = function(doc, dt, dn) {
|
|
||||||
// set to_date
|
|
||||||
if(doc.from_date) {
|
|
||||||
var recurring_type_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6,
|
|
||||||
'Yearly': 12};
|
|
||||||
|
|
||||||
var months = recurring_type_map[doc.recurring_type];
|
|
||||||
if(months) {
|
|
||||||
var to_date = frappe.datetime.add_months(doc.from_date,
|
|
||||||
months);
|
|
||||||
doc.to_date = frappe.datetime.add_days(to_date, -1);
|
|
||||||
refresh_field('to_date');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.send_sms = function() {
|
cur_frm.cscript.send_sms = function() {
|
||||||
frappe.require("assets/erpnext/js/sms_manager.js");
|
frappe.require("assets/erpnext/js/sms_manager.js");
|
||||||
var sms_man = new SMSManager(cur_frm.doc);
|
var sms_man = new SMSManager(cur_frm.doc);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -6,9 +6,6 @@ import frappe
|
|||||||
from frappe.utils import cstr, flt
|
from frappe.utils import cstr, flt
|
||||||
from frappe import msgprint, _, throw
|
from frappe import msgprint, _, throw
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
from erpnext.controllers.recurring_document import convert_to_recurring, validate_recurring_document
|
|
||||||
|
|
||||||
from erpnext.controllers.buying_controller import BuyingController
|
from erpnext.controllers.buying_controller import BuyingController
|
||||||
|
|
||||||
form_grid_templates = {
|
form_grid_templates = {
|
||||||
@ -55,8 +52,6 @@ class PurchaseOrder(BuyingController):
|
|||||||
self.validate_for_subcontracting()
|
self.validate_for_subcontracting()
|
||||||
self.validate_minimum_order_qty()
|
self.validate_minimum_order_qty()
|
||||||
self.create_raw_materials_supplied("po_raw_material_details")
|
self.create_raw_materials_supplied("po_raw_material_details")
|
||||||
|
|
||||||
validate_recurring_document(self)
|
|
||||||
|
|
||||||
def validate_with_previous_doc(self):
|
def validate_with_previous_doc(self):
|
||||||
super(PurchaseOrder, self).validate_with_previous_doc(self.tname, {
|
super(PurchaseOrder, self).validate_with_previous_doc(self.tname, {
|
||||||
@ -167,6 +162,8 @@ class PurchaseOrder(BuyingController):
|
|||||||
msgprint(_("Status of {0} {1} is now {2}").format(self.doctype, self.name, status))
|
msgprint(_("Status of {0} {1} is now {2}").format(self.doctype, self.name, status))
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
super(PurchaseOrder, self).on_submit()
|
||||||
|
|
||||||
purchase_controller = frappe.get_doc("Purchase Common")
|
purchase_controller = frappe.get_doc("Purchase Common")
|
||||||
|
|
||||||
self.update_prevdoc_status()
|
self.update_prevdoc_status()
|
||||||
@ -178,8 +175,6 @@ class PurchaseOrder(BuyingController):
|
|||||||
purchase_controller.update_last_purchase_rate(self, is_submit = 1)
|
purchase_controller.update_last_purchase_rate(self, is_submit = 1)
|
||||||
|
|
||||||
frappe.db.set(self,'status','Submitted')
|
frappe.db.set(self,'status','Submitted')
|
||||||
|
|
||||||
convert_to_recurring(self, self.transaction_date)
|
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
pc_obj = frappe.get_doc('Purchase Common')
|
pc_obj = frappe.get_doc('Purchase Common')
|
||||||
@ -204,10 +199,6 @@ class PurchaseOrder(BuyingController):
|
|||||||
def on_update(self):
|
def on_update(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_update_after_submit(self):
|
|
||||||
validate_recurring_document(self)
|
|
||||||
convert_to_recurring(self, self.transaction_date)
|
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
target.ignore_pricing_rule = 1
|
target.ignore_pricing_rule = 1
|
||||||
target.run_method("set_missing_values")
|
target.run_method("set_missing_values")
|
||||||
|
@ -109,7 +109,6 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
|
|
||||||
def test_recurring_order(self):
|
def test_recurring_order(self):
|
||||||
from erpnext.controllers.tests.test_recurring_document import test_recurring_document
|
from erpnext.controllers.tests.test_recurring_document import test_recurring_document
|
||||||
|
|
||||||
test_recurring_document(self, test_records)
|
test_recurring_document(self, test_records)
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,12 +4,11 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, throw
|
from frappe import _, throw
|
||||||
from frappe.utils import add_days, cint, cstr, today, date_diff, flt, getdate, nowdate, \
|
from frappe.utils import cint, today, flt
|
||||||
get_first_day, get_last_day
|
|
||||||
from frappe.model.naming import make_autoname
|
|
||||||
from erpnext.setup.utils import get_company_currency, get_exchange_rate
|
from erpnext.setup.utils import get_company_currency, get_exchange_rate
|
||||||
from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from erpnext.utilities.transaction_base import TransactionBase
|
||||||
|
from erpnext.controllers.recurring_document import convert_to_recurring, validate_recurring_document
|
||||||
import json
|
import json
|
||||||
|
|
||||||
class AccountsController(TransactionBase):
|
class AccountsController(TransactionBase):
|
||||||
@ -24,6 +23,24 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
self.validate_for_freezed_account()
|
self.validate_for_freezed_account()
|
||||||
|
|
||||||
|
if self.meta.get_field("is_recurring"):
|
||||||
|
validate_recurring_document(self)
|
||||||
|
|
||||||
|
def on_submit(self):
|
||||||
|
if self.meta.get_field("is_recurring"):
|
||||||
|
convert_to_recurring(self, self.get("posting_date") or self.get("transaction_date"))
|
||||||
|
|
||||||
|
def on_update_after_submit(self):
|
||||||
|
if self.meta.get_field("is_recurring"):
|
||||||
|
validate_recurring_document(self)
|
||||||
|
convert_to_recurring(self, self.get("posting_date") or self.get("transaction_date"))
|
||||||
|
|
||||||
|
def before_recurring(self):
|
||||||
|
self.fiscal_year = None
|
||||||
|
for fieldname in ("due_date", "aging_date"):
|
||||||
|
if self.meta.get_field(fieldname):
|
||||||
|
self.set(fieldname, None)
|
||||||
|
|
||||||
def set_missing_values(self, for_validate=False):
|
def set_missing_values(self, for_validate=False):
|
||||||
for fieldname in ["posting_date", "transaction_date"]:
|
for fieldname in ["posting_date", "transaction_date"]:
|
||||||
if not self.get(fieldname) and self.meta.get_field(fieldname):
|
if not self.get(fieldname) and self.meta.get_field(fieldname):
|
||||||
@ -421,7 +438,6 @@ class AccountsController(TransactionBase):
|
|||||||
max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100)
|
max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100)
|
||||||
|
|
||||||
if total_billed_amt - max_allowed_amt > 0.01:
|
if total_billed_amt - max_allowed_amt > 0.01:
|
||||||
reduce_by = total_billed_amt - max_allowed_amt
|
|
||||||
frappe.throw(_("Cannot overbill for Item {0} in row {0} more than {1}. To allow overbilling, please set in Stock Settings").format(item.item_code, item.idx, max_allowed_amt))
|
frappe.throw(_("Cannot overbill for Item {0} in row {0} more than {1}. To allow overbilling, please set in Stock Settings").format(item.item_code, item.idx, max_allowed_amt))
|
||||||
|
|
||||||
def get_company_default(self, fieldname):
|
def get_company_default(self, fieldname):
|
||||||
|
@ -4,10 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, msgprint
|
from frappe import _, msgprint
|
||||||
|
from frappe.utils import flt, rounded
|
||||||
from frappe.utils import add_days, cint, cstr, today, date_diff, flt, rounded, getdate, nowdate, \
|
|
||||||
get_first_day, get_last_day
|
|
||||||
from frappe.model.naming import make_autoname
|
|
||||||
|
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
from erpnext.accounts.party import get_party_details
|
from erpnext.accounts.party import get_party_details
|
||||||
|
@ -12,6 +12,12 @@ from erpnext.accounts.party import get_party_account, get_due_date, get_party_de
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
||||||
|
date_field_map = {
|
||||||
|
"Sales Order": "transaction_date",
|
||||||
|
"Sales Invoice": "posting_date",
|
||||||
|
"Purchase Order": "transaction_date",
|
||||||
|
"Purchase Invoice": "posting_date"
|
||||||
|
}
|
||||||
|
|
||||||
def create_recurring_documents():
|
def create_recurring_documents():
|
||||||
manage_recurring_documents("Sales Order")
|
manage_recurring_documents("Sales Order")
|
||||||
@ -26,14 +32,7 @@ def manage_recurring_documents(doctype, next_date=None, commit=True):
|
|||||||
"""
|
"""
|
||||||
next_date = next_date or nowdate()
|
next_date = next_date or nowdate()
|
||||||
|
|
||||||
if doctype == "Sales Order":
|
date_field = date_field_map[doctype]
|
||||||
date_field = "transaction_date"
|
|
||||||
elif doctype == "Sales Invoice":
|
|
||||||
date_field = "posting_date"
|
|
||||||
elif doctype == "Purchase Order":
|
|
||||||
date_field = "transaction_date"
|
|
||||||
elif doctype == "Purchase Invoice":
|
|
||||||
date_field = "posting_date"
|
|
||||||
|
|
||||||
recurring_documents = frappe.db.sql("""select name, recurring_id
|
recurring_documents = frappe.db.sql("""select name, recurring_id
|
||||||
from `tab{}` where ifnull(is_recurring, 0)=1
|
from `tab{}` where ifnull(is_recurring, 0)=1
|
||||||
@ -60,9 +59,10 @@ def manage_recurring_documents(doctype, next_date=None, commit=True):
|
|||||||
|
|
||||||
frappe.db.begin()
|
frappe.db.begin()
|
||||||
frappe.db.sql("update `tab%s` \
|
frappe.db.sql("update `tab%s` \
|
||||||
set is_recurring = 0 where name = %s" % (doctype, '%s'),
|
set is_recurring = 0 where name = %s" % (doctype, '%s'),
|
||||||
(ref_document))
|
(ref_document))
|
||||||
notify_errors(ref_document, doctype, ref_wrapper.customer, ref_wrapper.owner)
|
notify_errors(ref_document, doctype, ref_wrapper.get("customer") or ref_wrapper.get("supplier"),
|
||||||
|
ref_wrapper.owner)
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
exception_list.append(frappe.get_traceback())
|
exception_list.append(frappe.get_traceback())
|
||||||
@ -129,7 +129,7 @@ def send_notification(new_rv):
|
|||||||
"fcontent": frappe.get_print_format(new_rv.doctype, new_rv.name, as_pdf=True)
|
"fcontent": frappe.get_print_format(new_rv.doctype, new_rv.name, as_pdf=True)
|
||||||
}])
|
}])
|
||||||
|
|
||||||
def notify_errors(doc, doctype, customer, owner):
|
def notify_errors(doc, doctype, party, owner):
|
||||||
from frappe.utils.user import get_system_managers
|
from frappe.utils.user import get_system_managers
|
||||||
recipients = get_system_managers(only_name=True)
|
recipients = get_system_managers(only_name=True)
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ def notify_errors(doc, doctype, customer, owner):
|
|||||||
message = frappe.get_template("templates/emails/recurring_document_failed.html").render({
|
message = frappe.get_template("templates/emails/recurring_document_failed.html").render({
|
||||||
"type": doctype,
|
"type": doctype,
|
||||||
"name": doc,
|
"name": doc,
|
||||||
"customer": customer
|
"party": party
|
||||||
}))
|
}))
|
||||||
|
|
||||||
assign_task_to_owner(doc, doctype, "Recurring Invoice Failed", recipients)
|
assign_task_to_owner(doc, doctype, "Recurring Invoice Failed", recipients)
|
||||||
|
@ -2,12 +2,8 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
import unittest, json, copy
|
|
||||||
from frappe.utils import flt
|
|
||||||
import frappe.permissions
|
import frappe.permissions
|
||||||
from erpnext.accounts.utils import get_stock_and_account_difference
|
from erpnext.controllers.recurring_document import date_field_map
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
|
||||||
from erpnext.projects.doctype.time_log_batch.test_time_log_batch import *
|
|
||||||
|
|
||||||
def test_recurring_document(obj, test_records):
|
def test_recurring_document(obj, test_records):
|
||||||
from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate, add_days
|
from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate, add_days
|
||||||
@ -27,34 +23,11 @@ def test_recurring_document(obj, test_records):
|
|||||||
"to_date": get_last_day(today)
|
"to_date": get_last_day(today)
|
||||||
})
|
})
|
||||||
|
|
||||||
if base_doc.doctype == "Sales Order":
|
date_field = date_field_map[base_doc.doctype]
|
||||||
base_doc.update({
|
base_doc.set(date_field, today)
|
||||||
"transaction_date": today,
|
|
||||||
"delivery_date": add_days(today, 15)
|
|
||||||
})
|
|
||||||
elif base_doc.doctype == "Sales Invoice":
|
|
||||||
base_doc.update({
|
|
||||||
"posting_date": today
|
|
||||||
})
|
|
||||||
|
|
||||||
if base_doc.doctype == "Sales Order":
|
if base_doc.doctype == "Sales Order":
|
||||||
date_field = "transaction_date"
|
base_doc.set("delivery_date", add_days(today, 15))
|
||||||
elif base_doc.doctype == "Sales Invoice":
|
|
||||||
date_field = "posting_date"
|
|
||||||
#for Purchase order/purchase invoice
|
|
||||||
if base_doc.doctype == "Purchase Order":
|
|
||||||
base_doc.update({
|
|
||||||
"transaction_date": today
|
|
||||||
})
|
|
||||||
elif base_doc.doctype == "Purchase Invoice":
|
|
||||||
base_doc.update({
|
|
||||||
"posting_date": today
|
|
||||||
})
|
|
||||||
|
|
||||||
if base_doc.doctype == "Purchase Order":
|
|
||||||
date_field = "transaction_date"
|
|
||||||
elif base_doc.doctype == "Purchase Invoice":
|
|
||||||
date_field = "posting_date"
|
|
||||||
|
|
||||||
# monthly
|
# monthly
|
||||||
doc1 = frappe.copy_doc(base_doc)
|
doc1 = frappe.copy_doc(base_doc)
|
||||||
@ -142,7 +115,7 @@ def _test_recurring_document(obj, base_doc, date_field, first_and_last_day):
|
|||||||
|
|
||||||
next_date = get_next_date(base_doc.get(date_field), no_of_months,
|
next_date = get_next_date(base_doc.get(date_field), no_of_months,
|
||||||
base_doc.repeat_on_day_of_month)
|
base_doc.repeat_on_day_of_month)
|
||||||
|
|
||||||
manage_recurring_documents(base_doc.doctype, next_date=next_date, commit=False)
|
manage_recurring_documents(base_doc.doctype, next_date=next_date, commit=False)
|
||||||
|
|
||||||
recurred_documents = frappe.db.sql("""select name from `tab%s`
|
recurred_documents = frappe.db.sql("""select name from `tab%s`
|
||||||
|
@ -155,7 +155,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
|||||||
project_name: item.project_name || me.frm.doc.project_name
|
project_name: item.project_name || me.frm.doc.project_name
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
|
me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
|
||||||
@ -827,4 +827,35 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
|||||||
.appendTo($(this.frm.fields_dict.other_charges_calculation.wrapper).empty());
|
.appendTo($(this.frm.fields_dict.other_charges_calculation.wrapper).empty());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
is_recurring: function() {
|
||||||
|
// set default values for recurring documents
|
||||||
|
if(this.frm.doc.is_recurring) {
|
||||||
|
var owner_email = this.frm.doc.owner=="Administrator"
|
||||||
|
? frappe.user_info("Administrator").email
|
||||||
|
: this.frm.doc.owner;
|
||||||
|
|
||||||
|
this.frm.doc.notification_email_address = $.map([cstr(owner_email),
|
||||||
|
cstr(this.frm.doc.contact_email)], function(v) { return v || null; }).join(", ");
|
||||||
|
this.frm.doc.repeat_on_day_of_month = frappe.datetime.str_to_obj(this.frm.doc.posting_date).getDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh_many(["notification_email_address", "repeat_on_day_of_month"]);
|
||||||
|
},
|
||||||
|
|
||||||
|
from_date: function() {
|
||||||
|
// set to_date
|
||||||
|
if(this.frm.doc.from_date) {
|
||||||
|
var recurring_type_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6,
|
||||||
|
'Yearly': 12};
|
||||||
|
|
||||||
|
var months = recurring_type_map[this.frm.doc.recurring_type];
|
||||||
|
if(months) {
|
||||||
|
var to_date = frappe.datetime.add_months(this.frm.doc.from_date,
|
||||||
|
months);
|
||||||
|
this.frm.doc.to_date = frappe.datetime.add_days(to_date, -1);
|
||||||
|
refresh_field('to_date');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@ -195,37 +195,6 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
cur_frm.cscript.is_recurring = function(doc, dt, dn) {
|
|
||||||
// set default values for recurring orders
|
|
||||||
if(doc.is_recurring) {
|
|
||||||
var owner_email = doc.owner=="Administrator"
|
|
||||||
? frappe.user_info("Administrator").email
|
|
||||||
: doc.owner;
|
|
||||||
|
|
||||||
doc.notification_email_address = $.map([cstr(owner_email),
|
|
||||||
cstr(doc.contact_email)], function(v) { return v || null; }).join(", ");
|
|
||||||
doc.repeat_on_day_of_month = frappe.datetime.str_to_obj(doc.posting_date).getDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh_many(["notification_email_address", "repeat_on_day_of_month"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.from_date = function(doc, dt, dn) {
|
|
||||||
// set to_date
|
|
||||||
if(doc.from_date) {
|
|
||||||
var recurring_type_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6,
|
|
||||||
'Yearly': 12};
|
|
||||||
|
|
||||||
var months = recurring_type_map[doc.recurring_type];
|
|
||||||
if(months) {
|
|
||||||
var to_date = frappe.datetime.add_months(doc.from_date,
|
|
||||||
months);
|
|
||||||
doc.to_date = frappe.datetime.add_days(to_date, -1);
|
|
||||||
refresh_field('to_date');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.send_sms = function() {
|
cur_frm.cscript.send_sms = function() {
|
||||||
frappe.require("assets/erpnext/js/sms_manager.js");
|
frappe.require("assets/erpnext/js/sms_manager.js");
|
||||||
var sms_man = new SMSManager(cur_frm.doc);
|
var sms_man = new SMSManager(cur_frm.doc);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -4,14 +4,10 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
import frappe.utils
|
import frappe.utils
|
||||||
|
|
||||||
from frappe.utils import cstr, flt, getdate, comma_and
|
from frappe.utils import cstr, flt, getdate, comma_and
|
||||||
|
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
from erpnext.controllers.recurring_document import convert_to_recurring, validate_recurring_document
|
|
||||||
|
|
||||||
from erpnext.controllers.selling_controller import SellingController
|
from erpnext.controllers.selling_controller import SellingController
|
||||||
|
|
||||||
form_grid_templates = {
|
form_grid_templates = {
|
||||||
@ -122,8 +118,6 @@ class SalesOrder(SellingController):
|
|||||||
if not self.billing_status: self.billing_status = 'Not Billed'
|
if not self.billing_status: self.billing_status = 'Not Billed'
|
||||||
if not self.delivery_status: self.delivery_status = 'Not Delivered'
|
if not self.delivery_status: self.delivery_status = 'Not Delivered'
|
||||||
|
|
||||||
validate_recurring_document(self)
|
|
||||||
|
|
||||||
def validate_warehouse(self):
|
def validate_warehouse(self):
|
||||||
from erpnext.stock.utils import validate_warehouse_company
|
from erpnext.stock.utils import validate_warehouse_company
|
||||||
|
|
||||||
@ -157,6 +151,8 @@ class SalesOrder(SellingController):
|
|||||||
doc.set_status(update=True)
|
doc.set_status(update=True)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
super(SalesOrder, self).on_submit()
|
||||||
|
|
||||||
self.update_stock_ledger(update_stock = 1)
|
self.update_stock_ledger(update_stock = 1)
|
||||||
|
|
||||||
self.check_credit(self.grand_total)
|
self.check_credit(self.grand_total)
|
||||||
@ -165,8 +161,6 @@ class SalesOrder(SellingController):
|
|||||||
|
|
||||||
self.update_prevdoc_status('submit')
|
self.update_prevdoc_status('submit')
|
||||||
frappe.db.set(self, 'status', 'Submitted')
|
frappe.db.set(self, 'status', 'Submitted')
|
||||||
|
|
||||||
convert_to_recurring(self, self.transaction_date)
|
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
# Cannot cancel stopped SO
|
# Cannot cancel stopped SO
|
||||||
@ -255,11 +249,6 @@ class SalesOrder(SellingController):
|
|||||||
def get_portal_page(self):
|
def get_portal_page(self):
|
||||||
return "order" if self.docstatus==1 else None
|
return "order" if self.docstatus==1 else None
|
||||||
|
|
||||||
def on_update_after_submit(self):
|
|
||||||
validate_recurring_document(self)
|
|
||||||
convert_to_recurring(self, self.transaction_date)
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_material_request(source_name, target_doc=None):
|
def make_material_request(source_name, target_doc=None):
|
||||||
def postprocess(source, doc):
|
def postprocess(source, doc):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<h2>Recurring {{ type }} Failed</h2>
|
<h2>Recurring {{ type }} Failed</h2>
|
||||||
|
|
||||||
<p>An error occured while creating recurring {{ type }} <b>{{ name }}</b> for <b>{{ customer }}</b>.</p>
|
<p>An error occured while creating recurring {{ type }} <b>{{ name }}</b> for <b>{{ party }}</b>.</p>
|
||||||
<p>This could be because of some invalid email ids in the {{ type }}.</p>
|
<p>This could be because of some invalid email ids in the {{ type }}.</p>
|
||||||
<p>To stop sending repetitive error notifications from the system, we have unchecked
|
<p>To stop sending repetitive error notifications from the system, we have unchecked
|
||||||
"Convert into Recurring" field in the {{ type }} {{ name }}.</p>
|
"Convert into Recurring" field in the {{ type }} {{ name }}.</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user