[mapper-pull] for sales / purchae

This commit is contained in:
Rushabh Mehta
2013-07-08 18:01:46 +05:30
parent 304a4a66b4
commit d9e7070f2d
20 changed files with 154 additions and 688 deletions

View File

@@ -369,7 +369,7 @@ class DocType(SellingController):
@webnotes.whitelist()
def make_sales_invoice(source_name, target_doclist=None):
def update_item(obj, target, source_parent):
target.export_amount = flt(obj.amount) - flt(obj.billed_amt)
target.export_amount = flt(obj.amount)
target.amount = target.export_amount / flt(source_parent.conversion_rate)
target.qty = obj.basic_rate and target.amount / flt(obj.basic_rate) or obj.qty
@@ -393,8 +393,7 @@ def make_sales_invoice(source_name, target_doclist=None):
"prevdoc_docname": "sales_order",
"serial_no": "serial_no"
},
"postprocess": update_item,
"condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.export_amount
"postprocess": update_item
},
"Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges",

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:09",
"docstatus": 0,
"modified": "2013-07-08 16:34:21",
"modified": "2013-07-08 17:46:45",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -899,33 +899,6 @@
"search_index": 1,
"width": "150px"
},
{
"depends_on": "eval:!doc.__islocal",
"description": "% of materials billed against this Delivery Note",
"doctype": "DocField",
"fieldname": "per_billed",
"fieldtype": "Percent",
"in_filter": 1,
"in_list_view": 1,
"label": "% Amount Billed",
"no_copy": 1,
"oldfieldname": "per_billed",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "billing_status",
"fieldtype": "Select",
"hidden": 1,
"label": "Billing Status",
"no_copy": 1,
"options": "\nNot Billed\nPartly Billed\nFully Billed",
"print_hide": 1,
"read_only": 0
},
{
"depends_on": "eval:!doc.__islocal",
"description": "% of materials delivered against this Delivery Note",

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-04-22 13:15:44",
"docstatus": 0,
"modified": "2013-05-22 12:15:32",
"modified": "2013-07-08 17:46:21",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -308,18 +308,6 @@
"read_only": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "billed_amt",
"fieldtype": "Currency",
"label": "Billed Amt",
"no_copy": 1,
"options": "currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "installed_qty",

View File

@@ -35,6 +35,22 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
}
cur_frm.add_custom_button(wn._('From Purchase Order'),
function() {
wn.model.map_current_doc({
method: "buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
source_doctype: "Purchase Order",
get_query_filters: {
supplier: cur_frm.doc.supplier || undefined,
docstatus: 1,
status: ["!=", "Stopped"],
per_received: ["<", 99.99],
company: cur_frm.doc.company
}
})
});
if(wn.boot.control_panel.country == 'India') {
unhide_field(['challan_no', 'challan_date']);
}
@@ -85,14 +101,11 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
source_name: cur_frm.doc.name
})
},
pull_purchase_order_details: function() {
wn.model.map_current_doc({
method: "buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
source_name: cur_frm.doc.purchase_order_no,
})
}
tc_name: function() {
this.get_terms();
},
});
// for backward compatibility: combine new and previous states
@@ -146,57 +159,10 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn)
return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
}
cur_frm.fields_dict['purchase_order_no'].get_query = function(doc) {
if (doc.supplier)
return 'SELECT DISTINCT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`supplier` = "' +doc.supplier + '" and`tabPurchase Order`.`docstatus` = 1 and `tabPurchase Order`.`status` != "Stopped" and ifnull(`tabPurchase Order`.`per_received`, 0) < 99.99 and `tabPurchase Order`.`currency` = ifnull("' +doc.currency+ '","") and `tabPurchase Order`.company = "'+ doc.company +'" and `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50';
else
return 'SELECT DISTINCT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`docstatus` = 1 and `tabPurchase Order`.`company` = "'+ doc.company +'" and `tabPurchase Order`.`status` != "Stopped" and ifnull(`tabPurchase Order`.`per_received`, 0) < 99.99 and `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50';
}
cur_frm.fields_dict.purchase_receipt_details.grid.get_field("qa_no").get_query = function(doc) {
return 'SELECT `tabQuality Inspection`.name FROM `tabQuality Inspection` WHERE `tabQuality Inspection`.docstatus = 1 AND `tabQuality Inspection`.%(key)s LIKE "%s"';
}
cur_frm.pformat.purchase_order_no = function(doc, cdt, cdn){
//function to make row of table
var make_row = function(title,val1, val2, bold){
var bstart = '<b>'; var bend = '</b>';
return '<tr><td style="width:39%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
+'<td style="width:61%;text-align:left;">'+val1+(val2?' ('+dateutil.str_to_user(val2)+')':'')+'</td>'
+'</tr>'
}
out ='';
var cl = getchildren('Purchase Receipt Item',doc.name,'purchase_receipt_details');
// outer table
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 50%"></td><td>';
// main table
out +='<table class="noborder" style="width:100%">';
// add rows
if(cl.length){
prevdoc_list = new Array();
for(var i=0;i<cl.length;i++){
if(cl[i].prevdoc_doctype == 'Purchase Order' && cl[i].prevdoc_docname && prevdoc_list.indexOf(cl[i].prevdoc_docname) == -1) {
prevdoc_list.push(cl[i].prevdoc_docname);
if(prevdoc_list.length ==1)
out += make_row(cl[i].prevdoc_doctype, cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
else
out += make_row('', cl[i].prevdoc_docname, cl[i].prevdoc_date,0);
}
}
}
out +='</table></td></tr></table></div>';
return out;
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
if(cint(wn.boot.notification_settings.purchase_receipt)) {
cur_frm.email_doc(wn.boot.notification_settings.purchase_receipt_message);

View File

@@ -348,9 +348,10 @@ def make_purchase_invoice(source_name, target_doclist=None):
def update_item(obj, target, source_parent):
target.conversion_factor = 1
target.import_amount = flt(obj.import_amount) - flt(obj.billed_amt)
target.import_amount = flt(obj.import_amount)
target.amount = target.import_amount / flt(source_parent.conversion_rate)
target.qty = target.amount / flt(obj.purchase_rate)
if flt(obj.purchase_rate):
target.qty = target.amount / flt(obj.purchase_rate)
doclist = get_mapped_doclist("Purchase Receipt", source_name, {
"Purchase Receipt": {
@@ -368,8 +369,7 @@ def make_purchase_invoice(source_name, target_doclist=None):
"prevdoc_docname": "purchase_order",
"purchase_rate": "rate"
},
"postprocess": update_item,
"condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.import_amount
"postprocess": update_item
},
"Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges",

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-07-05 14:52:08",
"modified": "2013-07-08 17:46:13",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -32,6 +32,7 @@
"parent": "Purchase Receipt",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1
},
@@ -241,32 +242,6 @@
"label": "Re-Calculate Values",
"oldfieldtype": "Button"
},
{
"doctype": "DocField",
"fieldname": "section_break_20",
"fieldtype": "Section Break"
},
{
"description": "You can make a purchase receipt from multiple purchase orders. Select purchase orders one by one and click on the button below.",
"doctype": "DocField",
"fieldname": "purchase_order_no",
"fieldtype": "Link",
"in_list_view": 0,
"label": "Purchase Order",
"no_copy": 1,
"oldfieldname": "purchase_order_no",
"oldfieldtype": "Link",
"options": "Purchase Order",
"print_hide": 0
},
{
"doctype": "DocField",
"fieldname": "pull_purchase_order_details",
"fieldtype": "Button",
"label": "Pull Purchase Order Details",
"oldfieldtype": "Button",
"print_hide": 1
},
{
"doctype": "DocField",
"fieldname": "currency_price_list",
@@ -556,13 +531,6 @@
"options": "Terms and Conditions",
"print_hide": 1
},
{
"doctype": "DocField",
"fieldname": "get_terms",
"fieldtype": "Button",
"label": "Get Terms and Conditions",
"oldfieldtype": "Button"
},
{
"doctype": "DocField",
"fieldname": "terms",
@@ -626,20 +594,6 @@
"search_index": 1,
"width": "150px"
},
{
"depends_on": "eval:!doc.__islocal",
"description": "% of materials billed against this Purchase Receipt",
"doctype": "DocField",
"fieldname": "per_billed",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "% Billed",
"no_copy": 1,
"oldfieldname": "per_billed",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 1
},
{
"default": "No",
"description": "Select \"Yes\" for sub - contracting items",
@@ -878,42 +832,20 @@
"print_hide": 1,
"read_only": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"role": "Material Manager",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"role": "Material Manager",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"role": "Material User",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"role": "Material User",
"submit": 1,
"write": 1
@@ -923,24 +855,13 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"role": "Purchase User",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"role": "Purchase User",
"submit": 0
},
{
"doctype": "DocPerm",
"match": "supplier",
"permlevel": 0,
"role": "Supplier"
}
]

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:10",
"docstatus": 0,
"modified": "2013-07-08 13:52:28",
"modified": "2013-07-08 17:46:17",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -452,16 +452,6 @@
"search_index": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "billed_amt",
"fieldtype": "Currency",
"label": "Billed Amt",
"no_copy": 1,
"options": "currency",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "valuation_rate",