Merge branch 'develop' of https://github.com/sbkolate/erpnext into sbkolate-develop
This commit is contained in:
commit
8370cb3e71
@ -233,6 +233,41 @@ 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
|
||||||
|
@ -142,6 +142,24 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"description": "Start date of current invoice's period",
|
||||||
|
"fieldname": "from_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "From",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"description": "End date of current invoice's period",
|
||||||
|
"fieldname": "to_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "To",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "amended_from",
|
"fieldname": "amended_from",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@ -752,6 +770,117 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"reqd": 0
|
"reqd": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.docstatus<2",
|
||||||
|
"fieldname": "recurring_invoice",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Recurring Invoice",
|
||||||
|
"options": "icon-time",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_77",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"depends_on": "eval:doc.docstatus<2",
|
||||||
|
"description": "Check if recurring invoice, uncheck to stop recurring or put proper End Date",
|
||||||
|
"fieldname": "is_recurring",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Is Recurring",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"description": "Select the period when the invoice will be generated automatically",
|
||||||
|
"fieldname": "recurring_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Recurring Type",
|
||||||
|
"no_copy": 1,
|
||||||
|
"options": "Monthly\nQuarterly\nHalf-yearly\nYearly",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"description": "The day of the month on which auto invoice will be generated e.g. 05, 28 etc",
|
||||||
|
"fieldname": "repeat_on_day_of_month",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Repeat on Day of Month",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"description": "The date on which next invoice will be generated. It is generated on submit.",
|
||||||
|
"fieldname": "next_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Next Date",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_82",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"description": "The date on which recurring invoice will be stop",
|
||||||
|
"fieldname": "end_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "End Date",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"description": "The unique id for tracking all recurring invoices. It is generated on submit.",
|
||||||
|
"fieldname": "recurring_id",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Recurring Id",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"description": "Enter email id separated by commas, invoice will be mailed automatically on particular date",
|
||||||
|
"fieldname": "notification_email_address",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Notification Email Address",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against_income_account",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Against Income Account",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"report_hide": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-file-text",
|
"icon": "icon-file-text",
|
||||||
|
@ -4,7 +4,10 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cint, cstr, flt, formatdate
|
|
||||||
|
from frappe.utils import add_days, cint, cstr, date_diff, formatdate, 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.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
@ -14,6 +17,8 @@ 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"
|
||||||
}
|
}
|
||||||
@ -61,6 +66,7 @@ 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:
|
||||||
@ -259,6 +265,11 @@ 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 = \
|
||||||
|
@ -104,7 +104,7 @@ 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, "RECINV.#####", self.posting_date)
|
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)
|
||||||
@ -147,7 +147,7 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
def on_update_after_submit(self):
|
def on_update_after_submit(self):
|
||||||
validate_recurring_document(self)
|
validate_recurring_document(self)
|
||||||
convert_to_recurring(self, "RECINV.#####", self.posting_date)
|
convert_to_recurring(self, self.posting_date)
|
||||||
|
|
||||||
def before_recurring(self):
|
def before_recurring(self):
|
||||||
self.aging_date = None
|
self.aging_date = None
|
||||||
|
@ -206,6 +206,39 @@ 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);
|
||||||
|
@ -102,6 +102,24 @@
|
|||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"description": "Start date of current order's period",
|
||||||
|
"fieldname": "from_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "From",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"description": "End date of current order's period",
|
||||||
|
"fieldname": "to_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "To",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
"fieldname": "amended_from",
|
"fieldname": "amended_from",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -652,6 +670,111 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "recurring_order",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Recurring Order",
|
||||||
|
"options": "icon-time",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"label": "Column Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"depends_on": "eval:doc.docstatus<2",
|
||||||
|
"description": "Check if recurring order, uncheck to stop recurring or put proper End Date",
|
||||||
|
"fieldname": "is_recurring",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Is Recurring",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"fieldname": "recurring_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Recurring Type",
|
||||||
|
"no_copy": 1,
|
||||||
|
"options": "Monthly\nQuarterly\nHalf-yearly\nYearly",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"description": "The day of the month on which auto order will be generated e.g. 05, 28 etc",
|
||||||
|
"fieldname": "repeat_on_day_of_month",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Repeat on Day of Month",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"description": "The date on which next invoice will be generated. It is generated on submit.",
|
||||||
|
"fieldname": "next_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Next Date",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"description": "The date on which recurring order will be stop",
|
||||||
|
"fieldname": "end_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "End Date",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break83",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"label": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"fieldname": "recurring_id",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Recurring Id",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"depends_on": "eval:doc.is_recurring==1",
|
||||||
|
"description": "Enter email id separated by commas, order will be mailed automatically on particular date",
|
||||||
|
"fieldname": "notification_email_address",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Notification Email Address",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against_income_account",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Against Income Account",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"report_hide": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-file-text",
|
"icon": "icon-file-text",
|
||||||
@ -730,3 +853,4 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC"
|
"sort_order": "DESC"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ 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 = {
|
||||||
@ -53,6 +56,8 @@ class PurchaseOrder(BuyingController):
|
|||||||
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, {
|
||||||
"Supplier Quotation": {
|
"Supplier Quotation": {
|
||||||
@ -174,6 +179,8 @@ class PurchaseOrder(BuyingController):
|
|||||||
|
|
||||||
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')
|
||||||
self.check_for_stopped_status(pc_obj)
|
self.check_for_stopped_status(pc_obj)
|
||||||
@ -197,6 +204,10 @@ 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")
|
||||||
|
@ -107,6 +107,11 @@ class TestPurchaseOrder(unittest.TestCase):
|
|||||||
po.get("po_details")[0].qty = 3.4
|
po.get("po_details")[0].qty = 3.4
|
||||||
self.assertRaises(UOMMustBeIntegerError, po.insert)
|
self.assertRaises(UOMMustBeIntegerError, po.insert)
|
||||||
|
|
||||||
|
def test_recurring_order(self):
|
||||||
|
from erpnext.controllers.tests.test_recurring_document import test_recurring_document
|
||||||
|
|
||||||
|
test_recurring_document(self, test_records)
|
||||||
|
|
||||||
|
|
||||||
test_dependencies = ["BOM"]
|
test_dependencies = ["BOM"]
|
||||||
|
|
||||||
|
@ -4,7 +4,11 @@
|
|||||||
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
|
||||||
|
|
||||||
|
@ -2,15 +2,22 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import frappe.utils
|
import frappe.utils
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from frappe.utils import cint, cstr, getdate, nowdate, get_first_day, get_last_day
|
|
||||||
|
from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, \
|
||||||
|
get_first_day, get_last_day, comma_and
|
||||||
from frappe.model.naming import make_autoname
|
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, get_party_details
|
||||||
|
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}
|
||||||
|
|
||||||
def create_recurring_documents():
|
def create_recurring_documents():
|
||||||
manage_recurring_documents("Sales Order")
|
manage_recurring_documents("Sales Order")
|
||||||
manage_recurring_documents("Sales Invoice")
|
manage_recurring_documents("Sales Invoice")
|
||||||
|
manage_recurring_documents("Purchase Order")
|
||||||
|
manage_recurring_documents("Purchase Invoice")
|
||||||
|
|
||||||
def manage_recurring_documents(doctype, next_date=None, commit=True):
|
def manage_recurring_documents(doctype, next_date=None, commit=True):
|
||||||
"""
|
"""
|
||||||
@ -23,6 +30,10 @@ def manage_recurring_documents(doctype, next_date=None, commit=True):
|
|||||||
date_field = "transaction_date"
|
date_field = "transaction_date"
|
||||||
elif doctype == "Sales Invoice":
|
elif doctype == "Sales Invoice":
|
||||||
date_field = "posting_date"
|
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
|
||||||
@ -155,18 +166,18 @@ def validate_recurring_document(doc):
|
|||||||
elif not (doc.from_date and doc.to_date):
|
elif not (doc.from_date and doc.to_date):
|
||||||
throw(_("Period From and Period To dates mandatory for recurring %s") % doc.doctype)
|
throw(_("Period From and Period To dates mandatory for recurring %s") % doc.doctype)
|
||||||
|
|
||||||
def convert_to_recurring(doc, autoname, posting_date):
|
#
|
||||||
|
def convert_to_recurring(doc, posting_date):
|
||||||
if doc.is_recurring:
|
if doc.is_recurring:
|
||||||
if not doc.recurring_id:
|
if not doc.recurring_id:
|
||||||
frappe.db.set(doc, "recurring_id",
|
frappe.db.set(doc, "recurring_id", doc.name)
|
||||||
make_autoname(autoname))
|
|
||||||
|
|
||||||
set_next_date(doc, posting_date)
|
set_next_date(doc, posting_date)
|
||||||
|
|
||||||
elif doc.recurring_id:
|
elif doc.recurring_id:
|
||||||
frappe.db.sql("""update `tab%s`
|
frappe.db.sql("""update `tab%s` set is_recurring = 0
|
||||||
set is_recurring = 0
|
|
||||||
where recurring_id = %s""" % (doc.doctype, '%s'), (doc.recurring_id))
|
where recurring_id = %s""" % (doc.doctype, '%s'), (doc.recurring_id))
|
||||||
|
#
|
||||||
|
|
||||||
def validate_notification_email_id(doc):
|
def validate_notification_email_id(doc):
|
||||||
if doc.notification_email_address:
|
if doc.notification_email_address:
|
||||||
|
@ -41,6 +41,20 @@ def test_recurring_document(obj, test_records):
|
|||||||
date_field = "transaction_date"
|
date_field = "transaction_date"
|
||||||
elif base_doc.doctype == "Sales Invoice":
|
elif base_doc.doctype == "Sales Invoice":
|
||||||
date_field = "posting_date"
|
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)
|
||||||
|
@ -166,7 +166,7 @@ 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, "SO/REC/.#####", self.transaction_date)
|
convert_to_recurring(self, self.transaction_date)
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
# Cannot cancel stopped SO
|
# Cannot cancel stopped SO
|
||||||
@ -257,7 +257,7 @@ class SalesOrder(SellingController):
|
|||||||
|
|
||||||
def on_update_after_submit(self):
|
def on_update_after_submit(self):
|
||||||
validate_recurring_document(self)
|
validate_recurring_document(self)
|
||||||
convert_to_recurring(self, "SO/REC/.#####", self.transaction_date)
|
convert_to_recurring(self, self.transaction_date)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user