merge
This commit is contained in:
commit
861b3d6092
@ -23,17 +23,11 @@ from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
self.entries = []
|
||||
|
||||
def get_company_currency(self,arg=''):
|
||||
dcc = TransactionBase().get_company_currency(arg)
|
||||
return dcc
|
||||
|
||||
def get_period_difference(self,arg, cost_center =''):
|
||||
# used in General Ledger Page Report
|
||||
# used for Budget where cost center passed as extra argument
|
||||
|
@ -18,15 +18,14 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getdate
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import addchild, make_autoname
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import form, msgprint
|
||||
from webnotes import msgprint
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
@ -238,7 +237,7 @@ class DocType:
|
||||
self.doc.pay_to_recd_from = webnotes.conn.get_value(master_type, ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name')
|
||||
|
||||
if acc_type == 'Bank or Cash':
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
dcc = get_company_currency(self.doc.company)
|
||||
amt = cint(d.debit) and d.debit or d.credit
|
||||
self.doc.total_amount = dcc +' '+ cstr(amt)
|
||||
self.doc.total_amount_in_words = get_obj('Sales Common').get_total_in_words(dcc, cstr(amt))
|
||||
|
@ -20,41 +20,42 @@ cur_frm.cscript.other_fname = "purchase_tax_details";
|
||||
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
|
||||
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||
|
||||
erpnext.buying.PurchaseInvoiceController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function(doc) {
|
||||
this._super();
|
||||
|
||||
// Show / Hide button
|
||||
if(doc.docstatus==1 && doc.outstanding_amount > 0)
|
||||
cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry);
|
||||
}
|
||||
|
||||
cur_frm.cscript.is_opening(doc);
|
||||
}
|
||||
});
|
||||
|
||||
var new_cscript = new erpnext.buying.PurchaseInvoiceController({frm: cur_frm});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
$.extend(cur_frm.cscript, new_cscript);
|
||||
|
||||
|
||||
cur_frm.cscript.onload = function(doc,dt,dn) {
|
||||
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
var callback = function(doc, dt, dn) {
|
||||
var callback1 = function(doc, dt, dn) {
|
||||
if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc,dt,dn);
|
||||
}
|
||||
|
||||
// defined in purchase_common.js
|
||||
cur_frm.cscript.update_item_details(doc, dt, dn, callback1);
|
||||
if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc,dt,dn);
|
||||
}
|
||||
cur_frm.cscript.dynamic_label(doc, dt, dn, callback);
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
// defined in purchase_common.js
|
||||
cur_frm.cscript.update_item_details(doc, dt, dn, callback);
|
||||
|
||||
cur_frm.clear_custom_buttons();
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
if (!cur_frm.cscript.is_onload) cur_frm.cscript.dynamic_label(doc, dt, dn);
|
||||
|
||||
|
||||
// Show / Hide button
|
||||
if(doc.docstatus==1 && doc.outstanding_amount > 0)
|
||||
cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry);
|
||||
}
|
||||
cur_frm.cscript.is_opening(doc, dt, dn);
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.supplier = function(doc,dt,dn) {
|
||||
var callback = function(r,rt) {
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
@ -162,13 +163,6 @@ cur_frm.cscript.get_items = function(doc, dt, dn) {
|
||||
$c_obj(make_doclist(dt,dn),'pull_details','',callback);
|
||||
}
|
||||
|
||||
cur_frm.cscript.item_code = function(doc,cdt,cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.item_code){
|
||||
get_server_fields('get_item_details',d.item_code,'entries',doc,cdt,cdn,1);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.allocated_amount = function(doc,cdt,cdn) {
|
||||
calc_total_advance(doc, cdt, cdn);
|
||||
}
|
||||
|
@ -18,28 +18,20 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, cint, cstr, flt, formatdate, get_defaults
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, make_autoname
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import form, msgprint
|
||||
from webnotes import msgprint
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType(TransactionBase):
|
||||
from controllers.buying_controller import BuyingController
|
||||
class DocType(BuyingController):
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
self.tname = 'Purchase Invoice Item'
|
||||
self.fname = 'entries'
|
||||
|
||||
# Autoname
|
||||
# ---------
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.naming_series+'.####')
|
||||
|
||||
|
||||
# ************************** Trigger Functions ****************************
|
||||
|
||||
@ -106,64 +98,7 @@ class DocType(TransactionBase):
|
||||
item = webnotes.conn.sql("select purchase_account, cost_center from tabItem where name = '%s'" %(d.item_code), as_dict=1)
|
||||
d.expense_head = item and item[0]['purchase_account'] or ''
|
||||
d.cost_center = item and item[0]['cost_center'] or ''
|
||||
|
||||
|
||||
# Get Item Details
|
||||
# -----------------
|
||||
def get_item_details(self, arg=None):
|
||||
if arg:
|
||||
return self.get_pv_details(arg)
|
||||
else:
|
||||
for doc in self.doclist:
|
||||
if doc.fields.get('item_code'):
|
||||
ret = self.get_pv_details(doc.item_code)
|
||||
for r in ret:
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = ret[r]
|
||||
|
||||
|
||||
def get_pv_details(self, arg):
|
||||
import json
|
||||
item_det = sql("select item_name, brand, description, item_group, purchase_account, cost_center, stock_uom from tabItem where name=%s",arg,as_dict=1)
|
||||
|
||||
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , arg)
|
||||
t = {}
|
||||
for x in tax: t[x[0]] = flt(x[1])
|
||||
ret = {
|
||||
'item_name': item_det and item_det[0]['item_name'] or '',
|
||||
'brand': item_det and item_det[0]['brand'] or '',
|
||||
'description': item_det and item_det[0]['description'] or '',
|
||||
'item_group': item_det and item_det[0]['item_group'] or '',
|
||||
'rate': 0.00,
|
||||
'purchase_ref_rate': 0.00,
|
||||
'import_ref_rate': 0.00,
|
||||
'import_rate': 0.00,
|
||||
'qty': 0.00,
|
||||
'amount': 0.00,
|
||||
'discount_rate': 0.00,
|
||||
'expense_head': item_det and item_det[0]['purchase_account'] or '',
|
||||
'cost_center': item_det and item_det[0]['cost_center'] or '',
|
||||
'item_tax_rate': json.dumps(t),
|
||||
'uom': item_det and item_det[0]['stock_uom'] or ''
|
||||
}
|
||||
|
||||
# get last purchase rate
|
||||
last_purchase_details, last_purchase_date = get_obj('Purchase Common').get_last_purchase_details(arg, self.doc.name)
|
||||
if last_purchase_details:
|
||||
purchase_ref_rate = last_purchase_details['purchase_ref_rate']
|
||||
purchase_rate = last_purchase_details['purchase_rate']
|
||||
conversion_rate = self.doc.conversion_rate or 1.0
|
||||
ret.update({
|
||||
'purchase_ref_rate': purchase_ref_rate,
|
||||
'discount_rate': last_purchase_details['discount_rate'],
|
||||
'rate': purchase_rate,
|
||||
'import_ref_rate': purchase_ref_rate / conversion_rate,
|
||||
'import_rate': purchase_rate / conversion_rate,
|
||||
})
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
# Advance Allocation
|
||||
# -------------------
|
||||
def get_advances(self):
|
||||
@ -225,7 +160,7 @@ class DocType(TransactionBase):
|
||||
# Check Conversion Rate
|
||||
# ----------------------
|
||||
def check_conversion_rate(self):
|
||||
default_currency = TransactionBase().get_company_currency(self.doc.company)
|
||||
default_currency = get_company_currency(self.doc.company)
|
||||
if not default_currency:
|
||||
msgprint('Message: Please enter default currency in Company Master')
|
||||
raise Exception
|
||||
@ -394,6 +329,8 @@ class DocType(TransactionBase):
|
||||
# VALIDATE
|
||||
# ====================================================================================
|
||||
def validate(self):
|
||||
super(DocType, self).validate()
|
||||
|
||||
self.po_required()
|
||||
self.pr_required()
|
||||
self.check_active_purchase_items()
|
||||
@ -434,7 +371,7 @@ class DocType(TransactionBase):
|
||||
pc_obj = get_obj(dt='Purchase Common')
|
||||
|
||||
# get total in words
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
dcc = get_company_currency(self.doc.company)
|
||||
self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
|
||||
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency,
|
||||
self.doc.grand_total_import)
|
||||
|
@ -2,14 +2,14 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-12-03 17:26:39",
|
||||
"creation": "2013-01-18 12:46:57",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-04 17:15:28"
|
||||
"modified": "2013-01-18 13:25:16"
|
||||
},
|
||||
{
|
||||
"is_submittable": 1,
|
||||
"autoname": "naming_series:",
|
||||
"allow_attach": 1,
|
||||
"is_submittable": 1,
|
||||
"search_fields": "posting_date, credit_to, fiscal_year, bill_no, grand_total, outstanding_amount",
|
||||
"module": "Accounts",
|
||||
"doctype": "DocType",
|
||||
@ -48,7 +48,6 @@
|
||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Series",
|
||||
"oldfieldname": "naming_series",
|
||||
@ -67,7 +66,6 @@
|
||||
"label": "Credit To",
|
||||
"oldfieldname": "credit_to",
|
||||
"permlevel": 0,
|
||||
"trigger": "Client",
|
||||
"fieldname": "credit_to",
|
||||
"fieldtype": "Link",
|
||||
"search_index": 1,
|
||||
@ -196,35 +194,83 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Will be calculated automatically when you enter the details",
|
||||
"oldfieldtype": "Currency",
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total",
|
||||
"oldfieldname": "net_total",
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
"label": "Recalculate",
|
||||
"fieldname": "recalculate",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"options": "Simple",
|
||||
"fieldname": "section_break_17",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"description": "Select Items from Purchase Order",
|
||||
"oldfieldtype": "Link",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total (Import)",
|
||||
"oldfieldname": "net_total_import",
|
||||
"fieldname": "net_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
"label": "Purchase Order",
|
||||
"oldfieldname": "purchase_order_main",
|
||||
"options": "Purchase Order",
|
||||
"fieldname": "purchase_order_main",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Select Items from Purchase Receipt",
|
||||
"oldfieldtype": "Link",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Receipt",
|
||||
"oldfieldname": "purchase_receipt_main",
|
||||
"options": "Purchase Receipt",
|
||||
"fieldname": "purchase_receipt_main",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Recalculate",
|
||||
"trigger": "Client",
|
||||
"fieldname": "recalculate",
|
||||
"label": "Get Items",
|
||||
"options": "pull_details",
|
||||
"fieldname": "get_items",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Currency & Price List",
|
||||
"fieldname": "currency_price_list",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Currency",
|
||||
"oldfieldname": "currency",
|
||||
"options": "link:Currency",
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Select",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "The rate at which Bill Currency is converted into company's base currency",
|
||||
"default": "1",
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Exchange Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break2",
|
||||
@ -233,70 +279,36 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "The rate at which Bill Currency is converted into company's base currency",
|
||||
"default": "1",
|
||||
"oldfieldtype": "Currency",
|
||||
"colour": "White:FFF",
|
||||
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
|
||||
"doctype": "DocField",
|
||||
"label": "Bill Conversion Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"fieldname": "conversion_rate",
|
||||
"label": "Price List",
|
||||
"options": "Price List",
|
||||
"fieldname": "price_list_name",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"depends_on": "price_list_name",
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Currency",
|
||||
"options": "Currency",
|
||||
"fieldname": "price_list_currency",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"depends_on": "price_list_name",
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Exchange Rate",
|
||||
"fieldname": "plc_conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Bill Currency",
|
||||
"oldfieldname": "currency",
|
||||
"options": "link:Currency",
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Select",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Select Items from Purchase Order",
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Order",
|
||||
"oldfieldname": "purchase_order_main",
|
||||
"permlevel": 0,
|
||||
"trigger": "Client",
|
||||
"fieldname": "purchase_order_main",
|
||||
"fieldtype": "Link",
|
||||
"options": "Purchase Order"
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Select Items from Purchase Receipt",
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Receipt",
|
||||
"oldfieldname": "purchase_receipt_main",
|
||||
"permlevel": 0,
|
||||
"trigger": "Client",
|
||||
"fieldname": "purchase_receipt_main",
|
||||
"fieldtype": "Link",
|
||||
"options": "Purchase Receipt"
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Button",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Get Items",
|
||||
"options": "pull_details",
|
||||
"fieldname": "get_items",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Add / Edit Taxes and Charges",
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes",
|
||||
"fieldname": "taxes",
|
||||
@ -339,7 +351,6 @@
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Calculate Tax",
|
||||
"trigger": "Client",
|
||||
"fieldname": "calculate_tax",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
@ -373,20 +384,17 @@
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Supplier",
|
||||
"oldfieldname": "supplier",
|
||||
"permlevel": 0,
|
||||
"trigger": "Client",
|
||||
"options": "Supplier",
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"options": "Supplier"
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.supplier",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Supplier Address",
|
||||
"options": "Address",
|
||||
@ -404,7 +412,6 @@
|
||||
{
|
||||
"print_hide": 1,
|
||||
"depends_on": "eval:doc.supplier",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Contact Person",
|
||||
"options": "Contact",
|
||||
@ -412,206 +419,6 @@
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
"label": "More Info",
|
||||
"fieldname": "more_info",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"default": "No",
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Is Opening",
|
||||
"oldfieldname": "is_opening",
|
||||
"permlevel": 0,
|
||||
"trigger": "Client",
|
||||
"fieldname": "is_opening",
|
||||
"fieldtype": "Select",
|
||||
"search_index": 1,
|
||||
"options": "No\nYes",
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Date",
|
||||
"doctype": "DocField",
|
||||
"label": "Aging Date",
|
||||
"oldfieldname": "aging_date",
|
||||
"fieldname": "aging_date",
|
||||
"fieldtype": "Date",
|
||||
"search_index": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"doctype": "DocField",
|
||||
"label": "Amended From",
|
||||
"oldfieldname": "amended_from",
|
||||
"options": "Purchase Invoice",
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "The date at which current entry is corrected in the system.",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Date",
|
||||
"doctype": "DocField",
|
||||
"label": "Amendment Date",
|
||||
"oldfieldname": "amendment_date",
|
||||
"fieldname": "amendment_date",
|
||||
"fieldtype": "Date",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"allow_on_submit": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Select Print Heading",
|
||||
"oldfieldname": "select_print_heading",
|
||||
"permlevel": 0,
|
||||
"trigger": "Client",
|
||||
"fieldname": "select_print_heading",
|
||||
"fieldtype": "Link",
|
||||
"options": "Print Heading",
|
||||
"report_hide": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Date",
|
||||
"doctype": "DocField",
|
||||
"label": "Due Date",
|
||||
"oldfieldname": "due_date",
|
||||
"fieldname": "due_date",
|
||||
"fieldtype": "Date",
|
||||
"search_index": 1,
|
||||
"permlevel": 0,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Mode of Payment",
|
||||
"oldfieldname": "mode_of_payment",
|
||||
"options": "link:Mode of Payment",
|
||||
"fieldname": "mode_of_payment",
|
||||
"fieldtype": "Select",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break4",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"doctype": "DocField",
|
||||
"label": "Company",
|
||||
"oldfieldname": "company",
|
||||
"options": "Company",
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"search_index": 1,
|
||||
"permlevel": 0,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Fiscal Year",
|
||||
"oldfieldname": "fiscal_year",
|
||||
"options": "link:Fiscal Year",
|
||||
"fieldname": "fiscal_year",
|
||||
"fieldtype": "Select",
|
||||
"search_index": 1,
|
||||
"permlevel": 0,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Cancel Reason",
|
||||
"oldfieldname": "cancel_reason",
|
||||
"fieldname": "cancel_reason",
|
||||
"fieldtype": "Data",
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Text",
|
||||
"doctype": "DocField",
|
||||
"label": "Remarks",
|
||||
"oldfieldname": "remarks",
|
||||
"fieldname": "remarks",
|
||||
"fieldtype": "Small Text",
|
||||
"reqd": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
"label": "Advances",
|
||||
"fieldname": "advances",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Get Advances Paid",
|
||||
"options": "get_advances",
|
||||
"fieldname": "get_advances_paid",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Table",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Invoice Advances",
|
||||
"oldfieldname": "advance_allocation_details",
|
||||
"options": "Purchase Invoice Advance",
|
||||
"fieldname": "advance_allocation_details",
|
||||
"fieldtype": "Table",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
@ -620,22 +427,13 @@
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break7",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added",
|
||||
"oldfieldname": "other_charges_added",
|
||||
"fieldname": "other_charges_added",
|
||||
"label": "Net Total (Import)",
|
||||
"oldfieldname": "net_total_import",
|
||||
"fieldname": "net_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
@ -643,9 +441,9 @@
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted",
|
||||
"oldfieldname": "other_charges_deducted",
|
||||
"fieldname": "other_charges_deducted",
|
||||
"label": "Taxes and Charges Added (Import)",
|
||||
"oldfieldname": "other_charges_added_import",
|
||||
"fieldname": "other_charges_added_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
@ -653,33 +451,32 @@
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total",
|
||||
"oldfieldname": "grand_total",
|
||||
"fieldname": "grand_total",
|
||||
"label": "Taxes and Charges Deducted (Import)",
|
||||
"oldfieldname": "other_charges_deducted_import",
|
||||
"fieldname": "other_charges_deducted_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total (Import)",
|
||||
"oldfieldname": "grand_total_import",
|
||||
"fieldname": "grand_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "In Words will be visible once you save the Purchase Invoice.",
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words",
|
||||
"oldfieldname": "in_words",
|
||||
"fieldname": "in_words",
|
||||
"label": "In Words (Import)",
|
||||
"oldfieldname": "in_words_import",
|
||||
"fieldname": "in_words_import",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break8",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
@ -716,6 +513,67 @@
|
||||
"permlevel": 1,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break8",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Will be calculated automatically when you enter the details",
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total",
|
||||
"oldfieldname": "net_total",
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added",
|
||||
"oldfieldname": "other_charges_added",
|
||||
"fieldname": "other_charges_added",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted",
|
||||
"oldfieldname": "other_charges_deducted",
|
||||
"fieldname": "other_charges_deducted",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total",
|
||||
"oldfieldname": "grand_total",
|
||||
"fieldname": "grand_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "In Words will be visible once you save the Purchase Invoice.",
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words",
|
||||
"oldfieldname": "in_words",
|
||||
"fieldname": "in_words",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
@ -729,7 +587,6 @@
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"depends_on": "eval:flt(doc.write_off_amount)!=0",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Write Off Account",
|
||||
"options": "Account",
|
||||
@ -741,7 +598,6 @@
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"depends_on": "eval:flt(doc.write_off_amount)!=0",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Write Off Cost Center",
|
||||
"options": "Account",
|
||||
@ -749,47 +605,6 @@
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added (Import)",
|
||||
"oldfieldname": "other_charges_added_import",
|
||||
"fieldname": "other_charges_added_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted (Import)",
|
||||
"oldfieldname": "other_charges_deducted_import",
|
||||
"fieldname": "other_charges_deducted_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total (Import)",
|
||||
"oldfieldname": "grand_total_import",
|
||||
"fieldname": "grand_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words (Import)",
|
||||
"oldfieldname": "in_words_import",
|
||||
"fieldname": "in_words_import",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
@ -803,6 +618,176 @@
|
||||
"permlevel": 0,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
"label": "Advances",
|
||||
"fieldname": "advances",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Get Advances Paid",
|
||||
"options": "get_advances",
|
||||
"fieldname": "get_advances_paid",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Table",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Invoice Advances",
|
||||
"oldfieldname": "advance_allocation_details",
|
||||
"options": "Purchase Invoice Advance",
|
||||
"fieldname": "advance_allocation_details",
|
||||
"fieldtype": "Table",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
"label": "More Info",
|
||||
"fieldname": "more_info",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"default": "No",
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Is Opening",
|
||||
"oldfieldname": "is_opening",
|
||||
"permlevel": 0,
|
||||
"fieldname": "is_opening",
|
||||
"fieldtype": "Select",
|
||||
"search_index": 1,
|
||||
"options": "No\nYes",
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Date",
|
||||
"doctype": "DocField",
|
||||
"label": "Aging Date",
|
||||
"oldfieldname": "aging_date",
|
||||
"fieldname": "aging_date",
|
||||
"fieldtype": "Date",
|
||||
"search_index": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"doctype": "DocField",
|
||||
"label": "Amended From",
|
||||
"oldfieldname": "amended_from",
|
||||
"options": "Purchase Invoice",
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"allow_on_submit": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Select Print Heading",
|
||||
"oldfieldname": "select_print_heading",
|
||||
"permlevel": 0,
|
||||
"fieldname": "select_print_heading",
|
||||
"fieldtype": "Link",
|
||||
"options": "Print Heading",
|
||||
"report_hide": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Date",
|
||||
"doctype": "DocField",
|
||||
"label": "Due Date",
|
||||
"oldfieldname": "due_date",
|
||||
"fieldname": "due_date",
|
||||
"fieldtype": "Date",
|
||||
"search_index": 1,
|
||||
"permlevel": 0,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Mode of Payment",
|
||||
"oldfieldname": "mode_of_payment",
|
||||
"options": "link:Mode of Payment",
|
||||
"fieldname": "mode_of_payment",
|
||||
"fieldtype": "Select",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_63",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"doctype": "DocField",
|
||||
"label": "Company",
|
||||
"oldfieldname": "company",
|
||||
"options": "Company",
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"search_index": 1,
|
||||
"permlevel": 0,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Fiscal Year",
|
||||
"oldfieldname": "fiscal_year",
|
||||
"options": "link:Fiscal Year",
|
||||
"fieldname": "fiscal_year",
|
||||
"fieldtype": "Select",
|
||||
"search_index": 1,
|
||||
"permlevel": 0,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
"label": "Cancel Reason",
|
||||
"oldfieldname": "cancel_reason",
|
||||
"fieldname": "cancel_reason",
|
||||
"fieldtype": "Data",
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Text",
|
||||
"doctype": "DocField",
|
||||
"label": "Remarks",
|
||||
"oldfieldname": "remarks",
|
||||
"fieldname": "remarks",
|
||||
"fieldtype": "Small Text",
|
||||
"reqd": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
@ -819,8 +804,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 1,
|
||||
"write": 1,
|
||||
"cancel": 1,
|
||||
"role": "Accounts User",
|
||||
"cancel": 1,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
@ -829,8 +814,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 0,
|
||||
"cancel": 0,
|
||||
"role": "Purchase User",
|
||||
"cancel": 0,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
@ -839,8 +824,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 1,
|
||||
"cancel": 0,
|
||||
"role": "Purchase User",
|
||||
"cancel": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
@ -849,8 +834,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 0,
|
||||
"cancel": 0,
|
||||
"role": "Supplier",
|
||||
"cancel": 0,
|
||||
"permlevel": 0,
|
||||
"match": "supplier"
|
||||
},
|
||||
@ -860,8 +845,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 0,
|
||||
"cancel": 0,
|
||||
"role": "Accounts Manager",
|
||||
"cancel": 0,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
@ -870,8 +855,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 1,
|
||||
"write": 1,
|
||||
"cancel": 1,
|
||||
"role": "Accounts Manager",
|
||||
"cancel": 1,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
@ -880,8 +865,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 0,
|
||||
"cancel": 0,
|
||||
"role": "Accounts User",
|
||||
"cancel": 0,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
@ -890,8 +875,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 0,
|
||||
"cancel": 0,
|
||||
"role": "Auditor",
|
||||
"cancel": 0,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
@ -900,8 +885,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 0,
|
||||
"cancel": 0,
|
||||
"role": "Auditor",
|
||||
"cancel": 0,
|
||||
"permlevel": 0
|
||||
}
|
||||
]
|
@ -26,6 +26,7 @@ from webnotes.model.doc import make_autoname
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, form, msgprint
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
session = webnotes.session
|
||||
|
||||
@ -412,7 +413,7 @@ class DocType(TransactionBase):
|
||||
|
||||
|
||||
def set_in_words(self):
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
dcc = get_company_currency(self.doc.company)
|
||||
self.doc.in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.rounded_total)
|
||||
self.doc.in_words_export = get_obj('Sales Common').get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
|
||||
|
||||
@ -503,7 +504,7 @@ class DocType(TransactionBase):
|
||||
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
||||
|
||||
for d in getlist(self.doclist, 'packing_details'):
|
||||
bin = sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
bin = webnotes.conn.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
||||
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
|
||||
|
||||
|
@ -18,6 +18,245 @@
|
||||
// ------
|
||||
// cur_frm.cscript.tname - Details table name
|
||||
// cur_frm.cscript.fname - Details fieldname
|
||||
|
||||
wn.provide("erpnext.buying");
|
||||
|
||||
erpnext.buying.BuyingController = erpnext.utils.Controller.extend({
|
||||
setup: function() {
|
||||
var me = this;
|
||||
|
||||
if(this.frm.fields_dict.price_list_name) {
|
||||
this.frm.fields_dict.price_list_name.get_query = function() {
|
||||
return repl("select distinct price_list_name from `tabItem Price` \
|
||||
where buying = 1 and price_list_name like \"%s%%\"");
|
||||
};
|
||||
}
|
||||
|
||||
if(this.frm.fields_dict.price_list_currency) {
|
||||
this.frm.fields_dict.price_list_currency.get_query = function() {
|
||||
return repl("select distinct ref_currency from `tabItem Price` \
|
||||
where price_list_name=\"%(price_list_name)s\" and buying = 1 \
|
||||
and ref_currency like \"%s%%\"",
|
||||
{price_list_name: me.frm.doc.price_list_name});
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
this.frm.clear_custom_buttons();
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
if(this.frm.fields_dict.supplier)
|
||||
this.frm.toggle_display("contact_section", this.frm.doc.supplier);
|
||||
|
||||
if(this.frm.fields_dict.currency)
|
||||
this.set_dynamic_labels();
|
||||
|
||||
// TODO: improve this
|
||||
if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name
|
||||
&& this.frm.doc.price_list_name && this.frm.doc.price_list_currency) {
|
||||
this.price_list_name();
|
||||
}
|
||||
},
|
||||
|
||||
price_list_name: function() {
|
||||
this.frm.toggle_reqd(["price_list_currency", "plc_conversion_rate"],
|
||||
!!(this.frm.doc.price_list_name));
|
||||
|
||||
var me = this;
|
||||
|
||||
if(this.frm.doc.price_list_name) {
|
||||
// set price list currency
|
||||
this.frm.call({
|
||||
method: "setup.utils.get_price_list_currency",
|
||||
args: {args: {
|
||||
price_list_name: this.frm.doc.price_list_name,
|
||||
use_for: "buying"
|
||||
}},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
// for now, setting it as 1.0
|
||||
if(me.frm.doc.price_list_currency === me.get_company_currency())
|
||||
me.frm.set_value("plc_conversion_rate", 1.0);
|
||||
else if(me.frm.doc.price_list_currency === me.frm.doc.currency)
|
||||
me.frm.set_value("plc_conversion_rate", me.frm.doc.conversion_rate);
|
||||
|
||||
if(r.message.price_list_currency)
|
||||
me.price_list_currency();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
item_code: function(doc, cdt, cdn) {
|
||||
var me = this;
|
||||
var item = locals[cdt][cdn];
|
||||
if(item.item_code) {
|
||||
this.frm.call({
|
||||
method: "buying.utils.get_item_details",
|
||||
child: item,
|
||||
args: {
|
||||
args: {
|
||||
doctype: me.frm.doc.doctype,
|
||||
docname: me.frm.doc.name,
|
||||
item_code: item.item_code,
|
||||
warehouse: item.warehouse,
|
||||
supplier: me.frm.doc.supplier,
|
||||
conversion_rate: me.frm.doc.conversion_rate,
|
||||
price_list_name: me.frm.doc.price_list_name,
|
||||
price_list_currency: me.frm.doc.price_list_currency,
|
||||
plc_conversion_rate: me.frm.doc.plc_conversion_rate
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
update_item_details: function(doc, dt, dn, callback) {
|
||||
if(!this.frm.doc.__islocal) return;
|
||||
|
||||
var me = this;
|
||||
var children = getchildren(this.tname, this.frm.doc.name, this.fname);
|
||||
if(children && children.length) {
|
||||
this.frm.call({
|
||||
doc: me.frm.doc,
|
||||
method: "update_item_details",
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
refresh_field(me.fname);
|
||||
me.load_defaults(me.frm.doc, dt, dn, callback);
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.load_taxes(doc, dt, dn, callback);
|
||||
}
|
||||
},
|
||||
|
||||
currency: function() {
|
||||
this.set_dynamic_labels();
|
||||
},
|
||||
|
||||
company: function() {
|
||||
this.set_dynamic_labels();
|
||||
},
|
||||
|
||||
price_list_currency: function() {
|
||||
this.set_dynamic_labels();
|
||||
|
||||
if(this.frm.doc.price_list_currency === this.get_company_currency()) {
|
||||
this.frm.set_value("plc_conversion_rate", 1.0);
|
||||
}
|
||||
},
|
||||
|
||||
set_dynamic_labels: function(doc, dt, dn) {
|
||||
var company_currency = this.get_company_currency();
|
||||
|
||||
this.change_form_labels(company_currency);
|
||||
this.change_grid_labels(company_currency);
|
||||
},
|
||||
|
||||
change_form_labels: function(company_currency) {
|
||||
var me = this;
|
||||
var field_label_map = {};
|
||||
|
||||
var setup_field_label_map = function(fields_list, currency) {
|
||||
$.each(fields_list, function(i, fname) {
|
||||
var docfield = wn.meta.get_docfield(me.frm.doc.doctype, fname);
|
||||
if(docfield) {
|
||||
var label = wn._((docfield.label || "")).replace(/\([^\)]*\)/g, "");
|
||||
field_label_map[fname] = label.trim() + " (" + currency + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setup_field_label_map(["net_total", "total_tax", "grand_total", "in_words",
|
||||
"other_charges_added", "other_charges_deducted",
|
||||
"outstanding_amount", "total_advance", "total_amount_to_pay", "rounded_total"],
|
||||
company_currency);
|
||||
|
||||
setup_field_label_map(["net_total_import", "grand_total_import", "in_words_import",
|
||||
"other_charges_added_import", "other_charges_deducted_import"], this.frm.doc.currency);
|
||||
|
||||
setup_field_label_map(["conversion_rate"], "1 " + this.frm.doc.currency
|
||||
+ " = [?] " + company_currency);
|
||||
|
||||
if(this.frm.doc.price_list_currency && this.frm.doc.price_list_currency!=company_currency) {
|
||||
setup_field_label_map(["plc_conversion_rate"], "1 " + this.frm.doc.price_list_currency
|
||||
+ " = [?] " + company_currency);
|
||||
}
|
||||
|
||||
// toggle fields
|
||||
this.frm.toggle_display(["conversion_rate", "net_total", "grand_total",
|
||||
"in_words", "other_charges_added", "other_charges_deducted"],
|
||||
this.frm.doc.currency != company_currency);
|
||||
|
||||
// set labels
|
||||
$.each(field_label_map, function(fname, label) {
|
||||
me.frm.fields_dict[fname].set_label(label);
|
||||
});
|
||||
},
|
||||
|
||||
change_grid_labels: function(company_currency) {
|
||||
var me = this;
|
||||
var field_label_map = {};
|
||||
|
||||
var setup_field_label_map = function(fields_list, currency, parentfield) {
|
||||
var grid_doctype = me.frm.fields_dict[parentfield].grid.doctype;
|
||||
$.each(fields_list, function(i, fname) {
|
||||
var docfield = wn.meta.get_docfield(grid_doctype, fname);
|
||||
if(docfield) {
|
||||
field_label_map[grid_doctype + "-" + fname] =
|
||||
docfield.label + " (" + currency + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setup_field_label_map(["purchase_rate", "purchase_ref_rate", "amount", "rate"],
|
||||
company_currency, this.fname);
|
||||
|
||||
setup_field_label_map(["import_rate", "import_ref_rate", "import_amount"],
|
||||
this.frm.doc.currency, this.fname);
|
||||
|
||||
setup_field_label_map(["tax_amount", "total"], company_currency, this.other_fname);
|
||||
|
||||
if(this.frm.fields_dict["advance_allocation_details"]) {
|
||||
setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
|
||||
"advance_allocation_details");
|
||||
}
|
||||
|
||||
// toggle columns
|
||||
var item_grid = this.frm.fields_dict[this.fname].grid;
|
||||
var hide = this.frm.doc.currency == company_currency;
|
||||
$.each(["purchase_rate", "purchase_ref_rate", "amount", "rate"], function(i, fname) {
|
||||
if(wn.meta.get_docfield(item_grid.doctype, fname))
|
||||
item_grid.set_column_disp(fname, hide);
|
||||
});
|
||||
|
||||
// set labels
|
||||
var $wrapper = $(this.frm.wrapper);
|
||||
$.each(field_label_map, function(fname, label) {
|
||||
$wrapper.find('[data-grid-fieldname="'+fname+'"]').text(label);
|
||||
});
|
||||
},
|
||||
|
||||
get_company_currency: function() {
|
||||
return (wn.boot.company[this.frm.doc.company].default_currency ||
|
||||
sys_defaults['currency']);
|
||||
}
|
||||
});
|
||||
|
||||
// to save previous state of cur_frm.cscript
|
||||
var prev_cscript = {};
|
||||
$.extend(prev_cscript, cur_frm.cscript);
|
||||
|
||||
cur_frm.cscript = new erpnext.buying.BuyingController({frm: cur_frm});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
$.extend(cur_frm.cscript, prev_cscript);
|
||||
|
||||
|
||||
var tname = cur_frm.cscript.tname;
|
||||
var fname = cur_frm.cscript.fname;
|
||||
|
||||
@ -64,100 +303,6 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
|
||||
cur_frm.cscript.load_taxes(doc, dt, dn, callback);
|
||||
}
|
||||
|
||||
// Update existing item details
|
||||
cur_frm.cscript.update_item_details = function(doc, dt, dn, callback) {
|
||||
if(!cur_frm.doc.__islocal) { return; }
|
||||
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
|
||||
if(children) {
|
||||
$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_details', '',
|
||||
function(r, rt) {
|
||||
if(!r.exc) {
|
||||
refresh_field(cur_frm.cscript.fname);
|
||||
doc = locals[doc.doctype][doc.name];
|
||||
cur_frm.cscript.load_defaults(doc, dt, dn, callback);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
cur_frm.cscript.load_taxes(doc, dt, dn, callback);
|
||||
}
|
||||
}
|
||||
|
||||
var set_dynamic_label_par = function(doc, cdt, cdn, base_curr) {
|
||||
//parent flds
|
||||
par_cols_base = {'net_total': 'Net Total', 'total_tax': 'Total Tax', 'grand_total': 'Grand Total', /*'rounded_total': 'Rounded Total',*/
|
||||
'in_words': 'In Words', 'other_charges_added': 'Taxes and Charges Added', 'other_charges_deducted': 'Taxes and Charges Deducted'}
|
||||
par_cols_import = {'net_total_import': 'Net Total', 'grand_total_import': 'Grand Total', 'in_words_import': 'In Words',
|
||||
'other_charges_added_import': 'Taxes and Charges Added', 'other_charges_deducted_import': 'Taxes and Charges Deducted'};
|
||||
|
||||
for (d in par_cols_base) cur_frm.fields_dict[d].label_area.innerHTML = par_cols_base[d]+' (' + base_curr + ')';
|
||||
for (d in par_cols_import) cur_frm.fields_dict[d].label_area.innerHTML = par_cols_import[d]+' (' + doc.currency + ')';
|
||||
cur_frm.fields_dict['conversion_rate'].label_area.innerHTML = "Conversion Rate (" + doc.currency +' -> '+ base_curr + ')';
|
||||
|
||||
if (doc.doctype == 'Purchase Invoice') {
|
||||
cur_frm.fields_dict['outstanding_amount'].label_area.innerHTML = 'Outstanding Amount (' + base_curr + ')';
|
||||
cur_frm.fields_dict['total_advance'].label_area.innerHTML = 'Total Advance (Incl. TDS) (' + base_curr + ')';
|
||||
cur_frm.fields_dict['total_amount_to_pay'].label_area.innerHTML = 'Total Amount To Pay (' + base_curr + ')';
|
||||
} else cur_frm.fields_dict['rounded_total'].label_area.innerHTML = 'Rounded Total (' + base_curr + ')';
|
||||
|
||||
}
|
||||
|
||||
|
||||
var set_dynamic_label_child = function(doc, cdt, cdn, base_curr) {
|
||||
// item table flds
|
||||
item_cols_base = {'purchase_ref_rate': 'Ref Rate', 'amount': 'Amount'};
|
||||
item_cols_import = {'import_rate': 'Rate', 'import_ref_rate': 'Ref Rate', 'import_amount': 'Amount'};
|
||||
|
||||
for (d in item_cols_base) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_base[d]+' ('+base_curr+')');
|
||||
for (d in item_cols_import) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_import[d]+' ('+doc.currency+')');
|
||||
|
||||
var hide = (doc.currency == sys_defaults['currency']) ? false : true;
|
||||
for (f in item_cols_base) {
|
||||
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(f, hide);
|
||||
}
|
||||
if (doc.doctype == 'Purchase Invoice') {
|
||||
$('[data-grid-fieldname="'+cur_frm.cscript.tname+'-rate"]').html('Rate ('+base_curr+')');
|
||||
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp('rate', hide);
|
||||
// advance table flds
|
||||
adv_cols = {'advance_amount': 'Advance Amount', 'allocated_amount': 'Allocated Amount'}
|
||||
for (d in adv_cols) $('[data-grid-fieldname="Purchase Invoice Advance-'+d+'"]').html(adv_cols[d]+' ('+base_curr+')');
|
||||
}
|
||||
else {
|
||||
$('[data-grid-fieldname="'+cur_frm.cscript.tname+'-purchase_rate"]').html('Rate ('+base_curr+')');
|
||||
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp('purchase_rate', hide);
|
||||
}
|
||||
|
||||
//tax table flds
|
||||
tax_cols = {'tax_amount': 'Amount', 'total': 'Aggregate Total'};
|
||||
for (d in tax_cols) $('[data-grid-fieldname="Purchase Taxes and Charges-'+d+'"]').html(tax_cols[d]+' ('+base_curr+')');
|
||||
}
|
||||
|
||||
// Change label dynamically based on currency
|
||||
//------------------------------------------------------------------
|
||||
|
||||
cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, callback1) {
|
||||
var base_currency = wn.boot.company[doc.company].default_currency || sys_defaults['currency'];
|
||||
if (doc.currency === base_currency) {
|
||||
set_multiple(cdt, cdn, {conversion_rate:1});
|
||||
hide_field(['conversion_rate', 'net_total_import','grand_total_import',
|
||||
'in_words_import', 'other_charges_added_import', 'other_charges_deducted_import']);
|
||||
} else {
|
||||
unhide_field(['conversion_rate', 'net_total_import','grand_total_import',
|
||||
'in_words_import', 'other_charges_added_import', 'other_charges_deducted_import']);
|
||||
}
|
||||
|
||||
set_dynamic_label_par(doc, cdt, cdn, base_currency);
|
||||
set_dynamic_label_child(doc, cdt, cdn, base_currency);
|
||||
|
||||
if (callback1) callback1(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.currency = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.dynamic_label(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.company = cur_frm.cscript.currency;
|
||||
|
||||
|
||||
// ======================== Conversion Rate ==========================================
|
||||
cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) {
|
||||
cur_frm.cscript.calc_amount( doc, 1);
|
||||
@ -177,18 +322,6 @@ cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc,
|
||||
}
|
||||
}
|
||||
|
||||
//==================== Get Item Code Details =====================================================
|
||||
cur_frm.cscript.item_code = function(doc,cdt,cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.item_code) {
|
||||
temp = {
|
||||
item_code: d.item_code || '',
|
||||
warehouse: d.warehouse || ''
|
||||
}
|
||||
get_server_fields('get_item_details', JSON.stringify(temp), fname, doc, cdt, cdn, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//==================== Update Stock Qty ==========================================================
|
||||
cur_frm.cscript.update_stock_qty = function(doc,cdt,cdn){
|
||||
d = locals[cdt][cdn]
|
||||
@ -651,10 +784,6 @@ var calculate_outstanding = function(doc) {
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.toggle_contact_section = function(doc) {
|
||||
cur_frm.toggle_display("contact_section", doc.supplier);
|
||||
}
|
||||
|
||||
cur_frm.cscript.project_name = function(doc, cdt, cdn) {
|
||||
var item_doc = locals[cdt][cdn];
|
||||
if (item_doc.project_name) {
|
||||
|
@ -17,18 +17,17 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, cint, cstr, flt, getdate, now
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.utils import add_days, cint, cstr, flt
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import form, msgprint, _
|
||||
from webnotes import msgprint, _
|
||||
from buying.utils import get_last_purchase_details
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType(TransactionBase):
|
||||
from controllers.buying_controller import BuyingController
|
||||
class DocType(BuyingController):
|
||||
def __init__(self, doc, doclist=None):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
@ -105,80 +104,6 @@ class DocType(TransactionBase):
|
||||
r = sql("select terms from `tabTerms and Conditions` where name = %s", obj.doc.tc_name)
|
||||
if r: obj.doc.terms = r[0][0]
|
||||
|
||||
# Get Item Details
|
||||
def get_item_details(self, obj, arg =''):
|
||||
import json
|
||||
arg = json.loads(arg)
|
||||
item = sql("select item_name,item_group, brand, description, min_order_qty, stock_uom, default_warehouse,lead_time_days from `tabItem` where name = %s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())", (arg['item_code']), as_dict = 1)
|
||||
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , arg['item_code'])
|
||||
t = {}
|
||||
for x in tax: t[x[0]] = flt(x[1])
|
||||
# get warehouse
|
||||
if arg['warehouse']:
|
||||
wh = arg['warehouse']
|
||||
else:
|
||||
wh = item and item[0]['default_warehouse'] or ''
|
||||
|
||||
ret = {
|
||||
'item_name': item and item[0]['item_name'] or '',
|
||||
'item_group': item and item[0]['item_group'] or '',
|
||||
'brand': item and item[0]['brand'] or '',
|
||||
'description': item and item[0]['description'] or '',
|
||||
'qty': 0,
|
||||
'uom': item and item[0]['stock_uom'] or '',
|
||||
'stock_uom': item and item[0]['stock_uom'] or '',
|
||||
'conversion_factor': '1',
|
||||
'warehouse': wh,
|
||||
'item_tax_rate': json.dumps(t),
|
||||
'batch_no': '',
|
||||
'discount_rate': 0
|
||||
}
|
||||
|
||||
# get min_order_qty from item
|
||||
if obj.doc.doctype == 'Purchase Request':
|
||||
ret['min_order_qty'] = item and flt(item[0]['min_order_qty']) or 0
|
||||
|
||||
# get projected qty from bin
|
||||
if ret['warehouse']:
|
||||
bin = sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (arg['item_code'], ret['warehouse']), as_dict=1)
|
||||
ret['projected_qty'] = bin and flt(bin[0]['projected_qty']) or 0
|
||||
|
||||
# get schedule date, lead time date
|
||||
if obj.doc.transaction_date and item and item[0]['lead_time_days']:
|
||||
ret['schedule_date'] = cstr(add_days(obj.doc.transaction_date, cint(item[0]['lead_time_days'])))
|
||||
ret['lead_time_date'] = cstr(add_days(obj.doc.transaction_date, cint(item[0]['lead_time_days'])))
|
||||
|
||||
# get last purchase rate as per stock uom and default currency for following list of doctypes
|
||||
if obj.doc.doctype in ['Purchase Order', 'Purchase Receipt']:
|
||||
last_purchase_details, last_purchase_date = self.get_last_purchase_details(arg['item_code'], obj.doc.name)
|
||||
|
||||
if last_purchase_details:
|
||||
# updates ret with purchase_ref_rate, discount_rate, purchase_rate
|
||||
conversion_rate = flt(obj.doc.fields.get('conversion_rate'))
|
||||
ret.update(last_purchase_details)
|
||||
ret.update({
|
||||
'import_ref_rate': flt(last_purchase_details['purchase_ref_rate']) / conversion_rate,
|
||||
'import_rate': flt(last_purchase_details['purchase_rate']) / conversion_rate,
|
||||
})
|
||||
else:
|
||||
# set these values as blank in the form
|
||||
ret.update({
|
||||
'purchase_ref_rate': 0,
|
||||
'discount_rate': 0,
|
||||
'purchase_rate': 0,
|
||||
'import_ref_rate': 0,
|
||||
'import_rate': 0,
|
||||
})
|
||||
|
||||
if obj.doc.doctype == 'Purchase Order':
|
||||
supplier_part_no = webnotes.conn.sql("""\
|
||||
select supplier_part_no from `tabItem Supplier`
|
||||
where parent = %s and parenttype = 'Item' and
|
||||
supplier = %s""", (arg['item_code'], obj.doc.supplier))
|
||||
if supplier_part_no and supplier_part_no[0][0]:
|
||||
ret['supplier_part_no'] = supplier_part_no[0][0]
|
||||
|
||||
return ret
|
||||
|
||||
# Get Available Qty at Warehouse
|
||||
def get_bin_details( self, arg = ''):
|
||||
@ -194,14 +119,15 @@ class DocType(TransactionBase):
|
||||
|
||||
import webnotes.utils
|
||||
this_purchase_date = webnotes.utils.getdate(obj.doc.fields.get('posting_date') or obj.doc.fields.get('transaction_date'))
|
||||
|
||||
|
||||
for d in getlist(obj.doclist,obj.fname):
|
||||
# get last purchase details
|
||||
last_purchase_details, last_purchase_date = self.get_last_purchase_details(d.item_code, obj.doc.name)
|
||||
last_purchase_details = get_last_purchase_details(d.item_code, obj.doc.name)
|
||||
|
||||
# compare last purchase date and this transaction's date
|
||||
last_purchase_rate = None
|
||||
if last_purchase_date > this_purchase_date:
|
||||
if last_purchase_details and \
|
||||
(last_purchase_details.purchase_date > this_purchase_date):
|
||||
last_purchase_rate = last_purchase_details['purchase_rate']
|
||||
elif is_submit == 1:
|
||||
# even if this transaction is the latest one, it should be submitted
|
||||
@ -220,7 +146,7 @@ class DocType(TransactionBase):
|
||||
|
||||
for d in getlist(obj.doclist, obj.fname):
|
||||
if d.item_code:
|
||||
last_purchase_details, last_purchase_date = self.get_last_purchase_details(d.item_code, doc_name)
|
||||
last_purchase_details = get_last_purchase_details(d.item_code, doc_name)
|
||||
|
||||
if last_purchase_details:
|
||||
d.purchase_ref_rate = last_purchase_details['purchase_ref_rate'] * (flt(d.conversion_factor) or 1.0)
|
||||
@ -238,58 +164,6 @@ class DocType(TransactionBase):
|
||||
d.purchase_ref_rate = d.purchase_rate = d.import_ref_rate \
|
||||
= d.import_rate = item_last_purchase_rate
|
||||
|
||||
def get_last_purchase_details(self, item_code, doc_name):
|
||||
import webnotes
|
||||
import webnotes.utils
|
||||
|
||||
# get last purchase order item details
|
||||
last_po_item = webnotes.conn.sql("""\
|
||||
select po.name, po.transaction_date, po_item.conversion_factor, po_item.purchase_ref_rate,
|
||||
po_item.discount_rate, po_item.purchase_rate
|
||||
from `tabPurchase Order` po, `tabPurchase Order Item` po_item
|
||||
where po.docstatus = 1 and po_item.item_code = %s and po.name != %s and
|
||||
po.name = po_item.parent
|
||||
order by po.transaction_date desc, po.name desc
|
||||
limit 1""", (item_code, doc_name), as_dict=1)
|
||||
|
||||
# get last purchase receipt item details
|
||||
last_pr_item = webnotes.conn.sql("""\
|
||||
select pr.name, pr.posting_date, pr.posting_time, pr_item.conversion_factor,
|
||||
pr_item.purchase_ref_rate, pr_item.discount_rate, pr_item.purchase_rate
|
||||
from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
|
||||
where pr.docstatus = 1 and pr_item.item_code = %s and pr.name != %s and
|
||||
pr.name = pr_item.parent
|
||||
order by pr.posting_date desc, pr.posting_time desc, pr.name desc
|
||||
limit 1""", (item_code, doc_name), as_dict=1)
|
||||
|
||||
# get the latest of the two
|
||||
po_date_obj = webnotes.utils.getdate(last_po_item and last_po_item[0]['transaction_date'] or '2000-01-01')
|
||||
pr_date_obj = webnotes.utils.getdate(last_pr_item and last_pr_item[0]['posting_date'] or '2000-01-01')
|
||||
|
||||
# if both exists, return true
|
||||
both_exists = last_po_item and last_pr_item
|
||||
|
||||
# get the last purchased item, by comparing dates
|
||||
if (both_exists and po_date_obj > pr_date_obj) or (not both_exists and last_po_item):
|
||||
last_purchase_item = last_po_item[0]
|
||||
last_purchase_date = po_date_obj
|
||||
elif both_exists or (not both_exists and last_pr_item):
|
||||
last_purchase_item = last_pr_item[0]
|
||||
last_purchase_date = pr_date_obj
|
||||
else:
|
||||
# if none exists
|
||||
return None, webnotes.utils.getdate('2000-01-01')
|
||||
|
||||
# prepare last purchase details, dividing by conversion factor
|
||||
conversion_factor = flt(last_purchase_item['conversion_factor'])
|
||||
last_purchase_details = {
|
||||
'purchase_ref_rate': flt(last_purchase_item['purchase_ref_rate']) / conversion_factor,
|
||||
'purchase_rate': flt(last_purchase_item['purchase_rate']) / conversion_factor,
|
||||
'discount_rate': flt(last_purchase_item['discount_rate']),
|
||||
}
|
||||
|
||||
return last_purchase_details, last_purchase_date
|
||||
|
||||
# validation
|
||||
# -------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -381,67 +255,6 @@ class DocType(TransactionBase):
|
||||
else:
|
||||
chk_dupl_itm.append(f)
|
||||
|
||||
# validate conversion rate
|
||||
def validate_conversion_rate(self, obj):
|
||||
default_currency = TransactionBase().get_company_currency(obj.doc.company)
|
||||
if not default_currency:
|
||||
msgprint('Message: Please enter default currency in Company Master')
|
||||
raise Exception
|
||||
|
||||
if obj.doc.conversion_rate == 0:
|
||||
msgprint('Conversion Rate cannot be 0', raise_exception=1)
|
||||
elif not obj.doc.conversion_rate:
|
||||
msgprint('Please specify Conversion Rate', raise_exception=1)
|
||||
elif obj.doc.currency == default_currency and \
|
||||
flt(obj.doc.conversion_rate) != 1.00:
|
||||
msgprint("""Conversion Rate should be equal to 1.00, \
|
||||
since the specified Currency and the company's currency \
|
||||
are same""", raise_exception=1)
|
||||
elif obj.doc.currency != default_currency and \
|
||||
flt(obj.doc.conversion_rate) == 1.00:
|
||||
msgprint("""Conversion Rate should not be equal to 1.00, \
|
||||
since the specified Currency and the company's currency \
|
||||
are different""", raise_exception=1)
|
||||
|
||||
def validate_doc(self, obj, prevdoc_doctype, prevdoc_docname):
|
||||
if prevdoc_docname :
|
||||
get_name = sql("select name from `tab%s` where name = '%s'" % (prevdoc_doctype, prevdoc_docname))
|
||||
name = get_name and get_name[0][0] or ''
|
||||
if name: #check for incorrect docname
|
||||
dt = sql("select company, docstatus from `tab%s` where name = '%s'" % (prevdoc_doctype, name))
|
||||
company_name = dt and cstr(dt[0][0]) or ''
|
||||
docstatus = dt and dt[0][1] or 0
|
||||
|
||||
# check for docstatus
|
||||
if (docstatus != 1):
|
||||
msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) + " is not Submitted Document.")
|
||||
raise Exception
|
||||
|
||||
# check for company
|
||||
if (company_name != obj.doc.company):
|
||||
msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) + " does not belong to the Company: " + cstr(obj.doc.company))
|
||||
raise Exception
|
||||
|
||||
if prevdoc_doctype in ['Purchase Order', 'Purchase Receipt']:
|
||||
dt = sql("select supplier, currency from `tab%s` where name = '%s'" % (prevdoc_doctype, name))
|
||||
supplier = dt and dt[0][0] or ''
|
||||
currency = dt and dt[0][1] or ''
|
||||
|
||||
# check for supplier
|
||||
if (supplier != obj.doc.supplier):
|
||||
msgprint("Purchase Order: " + cstr(d.prevdoc_docname) + " supplier :" + cstr(supplier) + " does not match with supplier of current document.")
|
||||
raise Exception
|
||||
|
||||
# check for curency
|
||||
if (currency != obj.doc.currency):
|
||||
msgprint("Purchase Order: " + cstr(d.prevdoc_docname) + " currency :" + cstr(currency) + " does not match with currency of current document.")
|
||||
raise Exception
|
||||
|
||||
else: # if not name than
|
||||
msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) + " is not a valid " + cstr(prevdoc_doctype))
|
||||
raise Exception
|
||||
|
||||
|
||||
# Validate values with reference document
|
||||
#---------------------------------------
|
||||
def validate_reference_value(self, obj):
|
||||
@ -655,7 +468,6 @@ class DocType(TransactionBase):
|
||||
# get against document date
|
||||
#-----------------------------
|
||||
def get_prevdoc_date(self, obj):
|
||||
import datetime
|
||||
for d in getlist(obj.doclist, obj.fname):
|
||||
if d.prevdoc_doctype and d.prevdoc_docname:
|
||||
dt = sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
|
||||
|
@ -14,6 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.provide("erpnext.buying");
|
||||
|
||||
cur_frm.cscript.tname = "Purchase Order Item";
|
||||
cur_frm.cscript.fname = "po_details";
|
||||
cur_frm.cscript.other_fname = "purchase_tax_details";
|
||||
@ -22,6 +24,35 @@ wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxe
|
||||
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||
wn.require('app/utilities/doctype/sms_control/sms_control.js');
|
||||
|
||||
erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function(doc, cdt, cdn) {
|
||||
this._super();
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||
if(flt(doc.per_received, 2) < 100) cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']);
|
||||
if(flt(doc.per_billed, 2) < 100) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']);
|
||||
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']);
|
||||
|
||||
},
|
||||
|
||||
onload_post_render: function(doc, dt, dn) {
|
||||
var callback = function(doc, dt, dn) {
|
||||
if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
|
||||
}
|
||||
this.update_item_details(doc, dt, dn, callback);
|
||||
}
|
||||
});
|
||||
|
||||
var new_cscript = new erpnext.buying.PurchaseOrderController({frm: cur_frm});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
$.extend(cur_frm.cscript, new_cscript);
|
||||
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
// set missing values in parent doc
|
||||
set_missing_values(doc, {
|
||||
@ -34,32 +65,6 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
var callback = function(doc, dt, dn) {
|
||||
if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
|
||||
}
|
||||
cur_frm.cscript.update_item_details(doc, dt, dn, callback);
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.clear_custom_buttons();
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
cur_frm.cscript.dynamic_label(doc, cdt, cdn);
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||
if(flt(doc.per_received, 2) < 100) cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']);
|
||||
if(flt(doc.per_billed, 2) < 100) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']);
|
||||
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']);
|
||||
|
||||
cur_frm.cscript.toggle_contact_section(doc);
|
||||
}
|
||||
|
||||
cur_frm.cscript.supplier = function(doc,dt,dn) {
|
||||
if (doc.supplier) {
|
||||
get_server_fields('get_default_supplier_address',
|
||||
|
@ -17,30 +17,60 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr, date_diff, flt, get_defaults, now
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import addchild, make_autoname
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.utils import cstr, flt, get_defaults
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
from buying.utils import get_last_purchase_details
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType(TransactionBase):
|
||||
from controllers.buying_controller import BuyingController
|
||||
class DocType(BuyingController):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
self.defaults = get_defaults()
|
||||
self.tname = 'Purchase Order Item'
|
||||
self.fname = 'po_details'
|
||||
|
||||
# Validate
|
||||
def validate(self):
|
||||
super(DocType, self).validate()
|
||||
|
||||
self.validate_fiscal_year()
|
||||
|
||||
# Autoname
|
||||
# ---------
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
|
||||
if not self.doc.status:
|
||||
self.doc.status = "Draft"
|
||||
|
||||
import utilities
|
||||
utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Stopped",
|
||||
"Cancelled"])
|
||||
|
||||
# Step 2:=> get Purchase Common Obj
|
||||
pc_obj = get_obj(dt='Purchase Common')
|
||||
|
||||
# Step 3:=> validate mandatory
|
||||
pc_obj.validate_mandatory(self)
|
||||
|
||||
# Step 4:=> validate for items
|
||||
pc_obj.validate_for_items(self)
|
||||
|
||||
# Get po date
|
||||
pc_obj.get_prevdoc_date(self)
|
||||
|
||||
# validate_doc
|
||||
self.validate_doc(pc_obj)
|
||||
|
||||
# Check for stopped status
|
||||
self.check_for_stopped_status(pc_obj)
|
||||
|
||||
# get total in words
|
||||
dcc = get_company_currency(self.doc.company)
|
||||
self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
|
||||
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
|
||||
|
||||
def get_default_schedule_date(self):
|
||||
get_obj(dt = 'Purchase Common').get_default_schedule_date(self)
|
||||
@ -48,27 +78,6 @@ class DocType(TransactionBase):
|
||||
def validate_fiscal_year(self):
|
||||
get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'PO Date')
|
||||
|
||||
|
||||
# Get Item Details
|
||||
def get_item_details(self, arg =''):
|
||||
import json
|
||||
if arg:
|
||||
return get_obj(dt='Purchase Common').get_item_details(self,arg)
|
||||
else:
|
||||
obj = get_obj('Purchase Common')
|
||||
for doc in self.doclist:
|
||||
if doc.fields.get('item_code'):
|
||||
temp = {
|
||||
'item_code': doc.fields.get('item_code'),
|
||||
'warehouse': doc.fields.get('warehouse')
|
||||
}
|
||||
ret = obj.get_item_details(self, json.dumps(temp))
|
||||
for r in ret:
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = ret[r]
|
||||
|
||||
|
||||
|
||||
# get available qty at warehouse
|
||||
def get_bin_details(self, arg = ''):
|
||||
return get_obj(dt='Purchase Common').get_bin_details(arg)
|
||||
@ -80,7 +89,7 @@ class DocType(TransactionBase):
|
||||
pcomm = get_obj('Purchase Common')
|
||||
for d in getlist(self.doclist, 'po_details'):
|
||||
if d.item_code and not d.purchase_rate:
|
||||
last_purchase_details, last_purchase_date = pcomm.get_last_purchase_details(d.item_code, self.doc.name)
|
||||
last_purchase_details = get_last_purchase_details(d.item_code, self.doc.name)
|
||||
if last_purchase_details:
|
||||
conversion_factor = d.conversion_factor or 1.0
|
||||
conversion_rate = self.doc.fields.get('conversion_rate') or 1.0
|
||||
@ -125,44 +134,6 @@ class DocType(TransactionBase):
|
||||
pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
|
||||
|
||||
|
||||
# Validate
|
||||
def validate(self):
|
||||
self.validate_fiscal_year()
|
||||
|
||||
if not self.doc.status:
|
||||
self.doc.status = "Draft"
|
||||
|
||||
import utilities
|
||||
utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Stopped",
|
||||
"Cancelled"])
|
||||
|
||||
# Step 2:=> get Purchase Common Obj
|
||||
pc_obj = get_obj(dt='Purchase Common')
|
||||
|
||||
# Step 3:=> validate mandatory
|
||||
pc_obj.validate_mandatory(self)
|
||||
|
||||
# Step 4:=> validate for items
|
||||
pc_obj.validate_for_items(self)
|
||||
|
||||
# Step 5:=> validate conversion rate
|
||||
pc_obj.validate_conversion_rate(self)
|
||||
|
||||
# Get po date
|
||||
pc_obj.get_prevdoc_date(self)
|
||||
|
||||
# validate_doc
|
||||
self.validate_doc(pc_obj)
|
||||
|
||||
# Check for stopped status
|
||||
self.check_for_stopped_status(pc_obj)
|
||||
|
||||
# get total in words
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
|
||||
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
|
||||
|
||||
|
||||
def update_bin(self, is_submit, is_stopped = 0):
|
||||
pc_obj = get_obj('Purchase Common')
|
||||
for d in getlist(self.doclist, 'po_details'):
|
||||
@ -237,10 +208,6 @@ class DocType(TransactionBase):
|
||||
# Step 3 :=> Check For Approval Authority
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total)
|
||||
|
||||
# Step 4 :=> Update Current PO No. in Supplier as last_purchase_order.
|
||||
update_supplier = webnotes.conn.set_value("Supplier", self.doc.supplier,
|
||||
"last_purchase_order", self.doc.name)
|
||||
|
||||
# Step 5 :=> Update last purchase rate
|
||||
purchase_controller.update_last_purchase_rate(self, is_submit = 1)
|
||||
|
||||
|
@ -2,13 +2,14 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-08-06 20:00:37",
|
||||
"creation": "2013-01-18 12:46:59",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-03 17:10:41"
|
||||
"modified": "2013-01-18 13:24:20"
|
||||
},
|
||||
{
|
||||
"is_submittable": 1,
|
||||
"autoname": "naming_series:",
|
||||
"allow_attach": 1,
|
||||
"is_submittable": 1,
|
||||
"search_fields": "status, transaction_date, supplier,grand_total",
|
||||
"module": "Buying",
|
||||
"doctype": "DocType",
|
||||
@ -35,20 +36,11 @@
|
||||
"name": "Purchase Order",
|
||||
"doctype": "DocType"
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Series",
|
||||
"oldfieldname": "naming_series",
|
||||
@ -62,12 +54,10 @@
|
||||
"print_hide": 1,
|
||||
"description": "Supplier (vendor) name as entered in supplier master",
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Supplier",
|
||||
"oldfieldname": "supplier",
|
||||
"permlevel": 0,
|
||||
"trigger": "Client",
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Link",
|
||||
"search_index": 1,
|
||||
@ -118,6 +108,7 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
@ -128,21 +119,18 @@
|
||||
{
|
||||
"description": "The date at which current entry is made in system.",
|
||||
"oldfieldtype": "Date",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Order Date",
|
||||
"oldfieldname": "transaction_date",
|
||||
"trigger": "Client",
|
||||
"fieldname": "transaction_date",
|
||||
"fieldtype": "Date",
|
||||
"search_index": 1,
|
||||
"reqd": 1,
|
||||
"in_filter": 1,
|
||||
"permlevel": 0
|
||||
"permlevel": 0,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Items",
|
||||
"fieldname": "items",
|
||||
@ -164,97 +152,39 @@
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"options": "Simple",
|
||||
"fieldname": "section_break0",
|
||||
"fieldname": "sb_last_purchase",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Get Last Purchase Rate",
|
||||
"fieldname": "get_last_purchase_rate",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break2",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total*",
|
||||
"oldfieldname": "net_total",
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 0,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total (Import)",
|
||||
"oldfieldname": "net_total_import",
|
||||
"fieldname": "net_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"oldfieldtype": "Button",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Get Last Purchase Rate",
|
||||
"trigger": "Client",
|
||||
"fieldname": "get_last_purchase_rate",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Re-Calculate Values",
|
||||
"trigger": "Client",
|
||||
"fieldname": "recalculate_values",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Supplier's currency",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Currency",
|
||||
"oldfieldname": "currency",
|
||||
"permlevel": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Select",
|
||||
"reqd": 1,
|
||||
"options": "link:Currency"
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Rate at which supplier's currency is converted to company's base currency",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Conversion Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"default": "1",
|
||||
"trigger": "Client",
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"reqd": 1,
|
||||
"hidden": 0,
|
||||
"fieldname": "section_break0",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
@ -262,7 +192,6 @@
|
||||
"description": "You can make a purchase order from multiple Purchase Requests. Select Purchase Requests one by one and click on the button below.",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Select Purchase Request",
|
||||
"oldfieldname": "indent_no",
|
||||
@ -284,6 +213,14 @@
|
||||
"hidden": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "You can make a purchase order from multiple Supplier Quotations. Select Supplier Quotations one by one and click on the button below.",
|
||||
@ -304,10 +241,86 @@
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Currency & Price List",
|
||||
"fieldname": "price_list_and_currency",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cb_currency",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Supplier's currency",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Currency",
|
||||
"oldfieldname": "currency",
|
||||
"permlevel": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Select",
|
||||
"reqd": 1,
|
||||
"options": "link:Currency"
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Rate at which supplier's currency is converted to company's base currency",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Exchange Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"default": "1",
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"reqd": 1,
|
||||
"hidden": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cb_price_list",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
|
||||
"doctype": "DocField",
|
||||
"label": "Price List",
|
||||
"options": "Price List",
|
||||
"fieldname": "price_list_name",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"depends_on": "price_list_name",
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Currency",
|
||||
"options": "Currency",
|
||||
"fieldname": "price_list_currency",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"depends_on": "price_list_name",
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Exchange Rate",
|
||||
"fieldname": "plc_conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes",
|
||||
"fieldname": "taxes",
|
||||
@ -319,14 +332,13 @@
|
||||
"description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Taxes and Charges",
|
||||
"oldfieldname": "purchase_other_charges",
|
||||
"permlevel": 0,
|
||||
"options": "Purchase Taxes and Charges Master",
|
||||
"fieldname": "purchase_other_charges",
|
||||
"fieldtype": "Link",
|
||||
"options": "Purchase Taxes and Charges Master"
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
@ -354,7 +366,6 @@
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Calculate Tax",
|
||||
"trigger": "Client",
|
||||
"fieldname": "calculate_tax",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
@ -369,112 +380,25 @@
|
||||
"fieldtype": "HTML",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Total Tax*",
|
||||
"oldfieldname": "total_tax",
|
||||
"fieldname": "total_tax",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Totals",
|
||||
"fieldname": "totals",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total",
|
||||
"oldfieldname": "grand_total",
|
||||
"fieldname": "grand_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Rounded Total",
|
||||
"oldfieldname": "rounded_total",
|
||||
"fieldname": "rounded_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "In Words will be visible once you save the Purchase Order.",
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words",
|
||||
"oldfieldname": "in_words",
|
||||
"fieldname": "in_words",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added",
|
||||
"oldfieldname": "other_charges_added",
|
||||
"fieldname": "other_charges_added",
|
||||
"label": "Net Total (Import)",
|
||||
"oldfieldname": "net_total_import",
|
||||
"fieldname": "net_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted",
|
||||
"oldfieldname": "other_charges_deducted",
|
||||
"fieldname": "other_charges_deducted",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break4",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total (Import)",
|
||||
"oldfieldname": "grand_total_import",
|
||||
"fieldname": "grand_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words(Import)",
|
||||
"oldfieldname": "in_words_import",
|
||||
"fieldname": "in_words_import",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
@ -499,6 +423,113 @@
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total (Import)",
|
||||
"oldfieldname": "grand_total_import",
|
||||
"fieldname": "grand_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words(Import)",
|
||||
"oldfieldname": "in_words_import",
|
||||
"fieldname": "in_words_import",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break4",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total*",
|
||||
"oldfieldname": "net_total",
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 0,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added",
|
||||
"oldfieldname": "other_charges_added",
|
||||
"fieldname": "other_charges_added",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted",
|
||||
"oldfieldname": "other_charges_deducted",
|
||||
"fieldname": "other_charges_deducted",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Total Tax*",
|
||||
"oldfieldname": "total_tax",
|
||||
"fieldname": "total_tax",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total",
|
||||
"oldfieldname": "grand_total",
|
||||
"fieldname": "grand_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Rounded Total",
|
||||
"oldfieldname": "rounded_total",
|
||||
"fieldname": "rounded_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "In Words will be visible once you save the Purchase Order.",
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words",
|
||||
"oldfieldname": "in_words",
|
||||
"fieldname": "in_words",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
@ -507,18 +538,6 @@
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"allow_on_submit": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Letter Head",
|
||||
"oldfieldname": "letter_head",
|
||||
"options": "link:Letter Head",
|
||||
"fieldname": "letter_head",
|
||||
"fieldtype": "Select",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Link",
|
||||
@ -575,6 +594,12 @@
|
||||
"permlevel": 0,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cb_contact",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"doctype": "DocField",
|
||||
@ -597,7 +622,6 @@
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Status",
|
||||
"oldfieldname": "status",
|
||||
@ -631,6 +655,18 @@
|
||||
"hidden": 1,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"allow_on_submit": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Letter Head",
|
||||
"oldfieldname": "letter_head",
|
||||
"options": "link:Letter Head",
|
||||
"fieldname": "letter_head",
|
||||
"fieldtype": "Select",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
@ -662,7 +698,6 @@
|
||||
"description": "Select the relevant company name if you have multiple companies",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Company",
|
||||
"oldfieldname": "company",
|
||||
@ -693,7 +728,6 @@
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"allow_on_submit": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Select Print Heading",
|
||||
@ -715,6 +749,7 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
@ -727,7 +762,6 @@
|
||||
"description": "% of materials received against this Purchase Order",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "% Received",
|
||||
"oldfieldname": "per_received",
|
||||
@ -741,7 +775,6 @@
|
||||
"description": "% of materials billed against this Purchase Order.",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "% Billed",
|
||||
"oldfieldname": "per_billed",
|
||||
@ -754,7 +787,6 @@
|
||||
"print_hide": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Text",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Payment Terms",
|
||||
"oldfieldname": "payment_terms",
|
||||
@ -777,7 +809,6 @@
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Cancel Reason",
|
||||
"oldfieldname": "cancel_reason",
|
||||
@ -791,7 +822,6 @@
|
||||
"print_hide": 1,
|
||||
"description": "Required raw materials issued to the supplier for producing a sub - contracted item.",
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Raw Material Details",
|
||||
"fieldname": "raw_material_details",
|
||||
@ -800,9 +830,9 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"allow_on_submit": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Table",
|
||||
"allow_on_submit": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Order Items Supplied",
|
||||
"oldfieldname": "po_raw_material_details",
|
||||
|
@ -19,6 +19,31 @@ cur_frm.cscript.fname = "indent_details";
|
||||
|
||||
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||
wn.require('app/utilities/doctype/sms_control/sms_control.js');
|
||||
|
||||
erpnext.buying.PurchaseRequestController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function(doc) {
|
||||
this._super();
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation);
|
||||
if(flt(doc.per_ordered, 2) < 100) {
|
||||
cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order']);
|
||||
cur_frm.add_custom_button('Stop Purchase Request', cur_frm.cscript['Stop Purchase Request']);
|
||||
}
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
||||
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button('Unstop Purchase Request', cur_frm.cscript['Unstop Purchase Request'])
|
||||
}
|
||||
});
|
||||
|
||||
var new_cscript = new erpnext.buying.PurchaseRequestController({frm: cur_frm});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
$.extend(cur_frm.cscript, new_cscript);
|
||||
|
||||
|
||||
//========================== On Load =================================================
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
@ -43,26 +68,6 @@ cur_frm.cscript.get_item_defaults = function(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//======================= Refresh =====================================
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.clear_custom_buttons();
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation);
|
||||
if(flt(doc.per_ordered, 2) < 100) {
|
||||
cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order']);
|
||||
cur_frm.add_custom_button('Stop Purchase Request', cur_frm.cscript['Stop Purchase Request']);
|
||||
}
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
||||
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button('Unstop Purchase Request', cur_frm.cscript['Unstop Purchase Request'])
|
||||
}
|
||||
|
||||
//======================= transaction date =============================
|
||||
cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
|
||||
if(doc.__islocal){
|
||||
|
@ -17,18 +17,16 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr, date_diff, flt, get_defaults, now
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import make_autoname
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.utils import cstr, flt, get_defaults
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
|
||||
class DocType:
|
||||
from controllers.buying_controller import BuyingController
|
||||
class DocType(BuyingController):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
@ -36,12 +34,6 @@ class DocType:
|
||||
self.tname = 'Purchase Request Item'
|
||||
self.fname = 'indent_details'
|
||||
|
||||
# Autoname
|
||||
# ---------
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
|
||||
|
||||
|
||||
def get_default_schedule_date(self):
|
||||
get_obj(dt = 'Purchase Common').get_default_schedule_date(self)
|
||||
|
||||
@ -102,25 +94,6 @@ class DocType:
|
||||
def validate_fiscal_year(self):
|
||||
get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Purchase Request Date')
|
||||
|
||||
# get item details
|
||||
# ---------------------------------
|
||||
def get_item_details(self, arg =''):
|
||||
if arg:
|
||||
return get_obj(dt='Purchase Common').get_item_details(self,arg)
|
||||
else:
|
||||
obj = get_obj('Purchase Common')
|
||||
for doc in self.doclist:
|
||||
if doc.fields.get('item_code'):
|
||||
temp = {
|
||||
'item_code': doc.fields.get('item_code'),
|
||||
'warehouse': doc.fields.get('warehouse')
|
||||
}
|
||||
ret = obj.get_item_details(self, json.dumps(temp))
|
||||
for r in ret:
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = ret[r]
|
||||
|
||||
|
||||
# GET TERMS & CONDITIONS
|
||||
#-----------------------------
|
||||
def get_tc_details(self):
|
||||
@ -138,6 +111,8 @@ class DocType:
|
||||
# Validate
|
||||
# ---------------------
|
||||
def validate(self):
|
||||
super(DocType, self).validate()
|
||||
|
||||
self.validate_schedule_date()
|
||||
self.validate_fiscal_year()
|
||||
|
||||
|
@ -2,13 +2,14 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-07-03 13:29:58",
|
||||
"creation": "2012-12-03 17:56:31",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-03 17:10:41"
|
||||
"modified": "2013-01-15 15:34:47"
|
||||
},
|
||||
{
|
||||
"is_submittable": 1,
|
||||
"autoname": "naming_series:",
|
||||
"allow_attach": 1,
|
||||
"is_submittable": 1,
|
||||
"allow_print": 0,
|
||||
"search_fields": "status,transaction_date,sales_order_no",
|
||||
"module": "Buying",
|
||||
@ -28,6 +29,7 @@
|
||||
"parent": "Purchase Request",
|
||||
"read": 1,
|
||||
"doctype": "DocPerm",
|
||||
"report": 1,
|
||||
"parenttype": "DocType",
|
||||
"parentfield": "permissions"
|
||||
},
|
||||
@ -40,7 +42,6 @@
|
||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Series",
|
||||
"oldfieldname": "naming_series",
|
||||
@ -52,14 +53,13 @@
|
||||
},
|
||||
{
|
||||
"description": "The date at which current entry is made in system.",
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Date",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Transaction Date",
|
||||
"oldfieldname": "transaction_date",
|
||||
"width": "100px",
|
||||
"trigger": "Client",
|
||||
"fieldname": "transaction_date",
|
||||
"fieldtype": "Date",
|
||||
"search_index": 1,
|
||||
@ -69,7 +69,6 @@
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Items",
|
||||
"fieldname": "items",
|
||||
@ -79,7 +78,6 @@
|
||||
{
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Table",
|
||||
"colour": "White:FFF",
|
||||
"allow_on_submit": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Requisition Details",
|
||||
@ -97,6 +95,7 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break4",
|
||||
@ -106,9 +105,9 @@
|
||||
{
|
||||
"permlevel": 0,
|
||||
"description": "One or multiple Sales Order no which generated this Purchase Requisition",
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Sales Order No",
|
||||
"oldfieldname": "sales_order_no",
|
||||
@ -118,6 +117,7 @@
|
||||
"options": "Sales Order"
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break5",
|
||||
@ -136,7 +136,6 @@
|
||||
"description": "Filing in Additional Information about the Purchase Requisition will help you analyze your data better.",
|
||||
"default": "Give additional details about the indent.",
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "More Info",
|
||||
"fieldname": "more_info",
|
||||
@ -144,6 +143,7 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
@ -154,9 +154,9 @@
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Select the relevant company name if you have multiple companies",
|
||||
"print_width": "150px",
|
||||
"permlevel": 0,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Company",
|
||||
"oldfieldname": "company",
|
||||
@ -170,9 +170,9 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"print_width": "150px",
|
||||
"permlevel": 0,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Fiscal Year",
|
||||
"oldfieldname": "fiscal_year",
|
||||
@ -186,9 +186,9 @@
|
||||
},
|
||||
{
|
||||
"description": "Name of the entity who has requested for the Purchase Requisition",
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Requested By",
|
||||
"oldfieldname": "requested_by",
|
||||
@ -202,7 +202,6 @@
|
||||
"description": "After cancelling the Purchase Requisition, a dialog box will ask you reason for cancellation which will be reflected in this field",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Cancel Reason",
|
||||
"oldfieldname": "cancel_reason",
|
||||
@ -211,6 +210,7 @@
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
@ -220,8 +220,8 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"allow_on_submit": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Letter Head",
|
||||
"oldfieldname": "letter_head",
|
||||
@ -233,9 +233,9 @@
|
||||
{
|
||||
"print_hide": 1,
|
||||
"permlevel": 1,
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Status",
|
||||
"oldfieldname": "status",
|
||||
@ -252,7 +252,6 @@
|
||||
"description": "% of materials ordered against this Purchase Requisition",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "% Ordered",
|
||||
"oldfieldname": "per_ordered",
|
||||
@ -262,6 +261,7 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"print_width": "150px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
@ -275,6 +275,7 @@
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "The date at which current entry is corrected in the system.",
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Date",
|
||||
"doctype": "DocField",
|
||||
@ -287,6 +288,7 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"print_width": "150px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Small Text",
|
||||
"doctype": "DocField",
|
||||
@ -346,22 +348,6 @@
|
||||
"hidden": 1,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"submit": 1,
|
||||
"write": 1,
|
||||
"role": "Purchase User",
|
||||
"cancel": 1,
|
||||
"permlevel": 0,
|
||||
"match": ""
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Purchase User",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"create": 0,
|
||||
@ -421,5 +407,24 @@
|
||||
"role": "Material User",
|
||||
"cancel": 1,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"submit": 1,
|
||||
"write": 1,
|
||||
"role": "Purchase User",
|
||||
"cancel": 1,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"role": "Purchase User",
|
||||
"cancel": 0,
|
||||
"permlevel": 1
|
||||
}
|
||||
]
|
@ -62,11 +62,6 @@ class DocType(TransactionBase):
|
||||
if not self.doc.naming_series:
|
||||
self.doc.naming_series = ''
|
||||
|
||||
# create address
|
||||
addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode]
|
||||
address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds))
|
||||
webnotes.conn.set(self.doc,'address', address_line)
|
||||
|
||||
# create account head
|
||||
self.create_account_head()
|
||||
|
||||
@ -124,7 +119,16 @@ class DocType(TransactionBase):
|
||||
if not sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)):
|
||||
parent_account = self.get_parent_account(abbr)
|
||||
|
||||
arg = {'account_name':self.doc.name,'parent_account': parent_account, 'group_or_ledger':'Ledger', 'company':self.doc.company,'account_type':'','tax_rate':'0','master_type':'Supplier','master_name':self.doc.name,'address':self.doc.address}
|
||||
arg = {
|
||||
'account_name': self.doc.name,
|
||||
'parent_account': parent_account,
|
||||
'group_or_ledger':'Ledger',
|
||||
'company': self.doc.company,
|
||||
'account_type': '',
|
||||
'tax_rate': '0',
|
||||
'master_type': 'Supplier',
|
||||
'master_name': self.doc.name,
|
||||
}
|
||||
# create
|
||||
ac = get_obj('GL Control').add_ac(cstr(arg))
|
||||
msgprint("Created Account Head: "+ac)
|
||||
|
@ -23,6 +23,24 @@ cur_frm.cscript.other_fname = "purchase_tax_details";
|
||||
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
|
||||
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||
|
||||
erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function() {
|
||||
this._super();
|
||||
|
||||
cur_frm.cscript.load_taxes(this.frm.doc);
|
||||
|
||||
if (this.frm.doc.docstatus === 1) {
|
||||
cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var new_cscript = new erpnext.buying.SupplierQuotationController({frm: cur_frm});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
$.extend(cur_frm.cscript, new_cscript);
|
||||
|
||||
|
||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
// set missing values in parent doc
|
||||
set_missing_values(doc, {
|
||||
@ -35,19 +53,6 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
erpnext.hide_naming_series();
|
||||
cur_frm.cscript.dynamic_label(doc, dt, dn);
|
||||
cur_frm.cscript.load_taxes(doc, dt, dn);
|
||||
|
||||
cur_frm.cscript.toggle_contact_section(doc);
|
||||
|
||||
cur_frm.clear_custom_buttons();
|
||||
if (doc.docstatus === 1) {
|
||||
cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.make_purchase_order = function() {
|
||||
var new_po_name = wn.model.make_new_doc_and_get_name("Purchase Order");
|
||||
$c("dt_map", {
|
||||
|
@ -17,19 +17,17 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.model.code import get_obj
|
||||
from utilities.transaction_base import TransactionBase
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
class DocType(TransactionBase):
|
||||
from controllers.buying_controller import BuyingController
|
||||
class DocType(BuyingController):
|
||||
def __init__(self, doc, doclist=None):
|
||||
self.doc, self.doclist = doc, doclist or []
|
||||
self.tname, self.fname = "Supplier Quotation Item", "quotation_items"
|
||||
|
||||
def autoname(self):
|
||||
"""autoname based on naming series value"""
|
||||
from webnotes.model.doc import make_autoname
|
||||
self.doc.name = make_autoname(self.doc.naming_series + ".#####")
|
||||
|
||||
def validate(self):
|
||||
super(DocType, self).validate()
|
||||
|
||||
if not self.doc.status:
|
||||
self.doc.status = "Draft"
|
||||
|
||||
@ -53,22 +51,6 @@ class DocType(TransactionBase):
|
||||
def on_trash(self):
|
||||
pass
|
||||
|
||||
def get_item_details(self, args=None):
|
||||
if args:
|
||||
return get_obj(dt='Purchase Common').get_item_details(self, args)
|
||||
else:
|
||||
obj = get_obj('Purchase Common')
|
||||
for doc in self.doclist:
|
||||
if doc.fields.get('item_code'):
|
||||
temp = {
|
||||
'item_code': doc.fields.get('item_code'),
|
||||
'warehouse': doc.fields.get('warehouse')
|
||||
}
|
||||
ret = obj.get_item_details(self, json.dumps(temp))
|
||||
for r in ret:
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = ret[r]
|
||||
|
||||
def get_indent_details(self):
|
||||
if self.doc.indent_no:
|
||||
mapper = get_obj("DocType Mapper", "Purchase Request-Supplier Quotation")
|
||||
@ -96,12 +78,11 @@ class DocType(TransactionBase):
|
||||
pc = get_obj('Purchase Common')
|
||||
pc.validate_mandatory(self)
|
||||
pc.validate_for_items(self)
|
||||
pc.validate_conversion_rate(self)
|
||||
pc.get_prevdoc_date(self)
|
||||
pc.validate_reference_value(self)
|
||||
|
||||
def set_in_words(self):
|
||||
pc = get_obj('Purchase Common')
|
||||
company_currency = TransactionBase().get_company_currency(self.doc.company)
|
||||
company_currency = get_company_currency(self.doc.company)
|
||||
self.doc.in_words = pc.get_total_in_words(company_currency, self.doc.grand_total)
|
||||
self.doc.in_words_import = pc.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
|
||||
|
@ -2,13 +2,14 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-08-06 11:15:46",
|
||||
"creation": "2013-01-18 12:47:01",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-10 18:30:00"
|
||||
"modified": "2013-01-18 13:25:50"
|
||||
},
|
||||
{
|
||||
"is_submittable": 1,
|
||||
"autoname": "naming_series:",
|
||||
"allow_attach": 1,
|
||||
"is_submittable": 1,
|
||||
"search_fields": "status, transaction_date, supplier,grand_total",
|
||||
"module": "Buying",
|
||||
"doctype": "DocType",
|
||||
@ -35,20 +36,11 @@
|
||||
"name": "Supplier Quotation",
|
||||
"doctype": "DocType"
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Series",
|
||||
"oldfieldname": "naming_series",
|
||||
@ -62,12 +54,10 @@
|
||||
"print_hide": 1,
|
||||
"description": "Supplier (vendor) name as entered in supplier master",
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Supplier",
|
||||
"oldfieldname": "supplier",
|
||||
"permlevel": 0,
|
||||
"trigger": "Client",
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Link",
|
||||
"search_index": 1,
|
||||
@ -118,6 +108,7 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
@ -128,21 +119,18 @@
|
||||
{
|
||||
"description": "The date at which current entry is made in system.",
|
||||
"oldfieldtype": "Date",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Quotation Date",
|
||||
"oldfieldname": "transaction_date",
|
||||
"trigger": "Client",
|
||||
"fieldname": "transaction_date",
|
||||
"fieldtype": "Date",
|
||||
"search_index": 1,
|
||||
"reqd": 1,
|
||||
"in_filter": 1,
|
||||
"permlevel": 0
|
||||
"permlevel": 0,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Items",
|
||||
"fieldname": "items",
|
||||
@ -168,82 +156,19 @@
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break2",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total*",
|
||||
"oldfieldname": "net_total",
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 0,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total (Import)",
|
||||
"oldfieldname": "net_total_import",
|
||||
"fieldname": "net_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Re-Calculate Values",
|
||||
"trigger": "Client",
|
||||
"fieldname": "recalculate_values",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Supplier's currency",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Currency",
|
||||
"oldfieldname": "currency",
|
||||
"permlevel": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Select",
|
||||
"reqd": 1,
|
||||
"options": "link:Currency"
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Rate at which supplier's currency is converted to company's base currency",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Conversion Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"default": "1",
|
||||
"trigger": "Client",
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 1,
|
||||
"hidden": 0,
|
||||
"options": "Simple",
|
||||
"fieldname": "section_break_14",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
@ -251,7 +176,6 @@
|
||||
"description": "You can make a purchase order from multiple Purchase Requests. Select Purchase Requests one by one and click on the button below.",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Select Purchase Request",
|
||||
"oldfieldname": "indent_no",
|
||||
@ -271,9 +195,81 @@
|
||||
"hidden": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Currency & Price List",
|
||||
"fieldname": "currency_price_list",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Supplier's currency",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Currency",
|
||||
"oldfieldname": "currency",
|
||||
"permlevel": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Select",
|
||||
"reqd": 1,
|
||||
"options": "link:Currency"
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Rate at which supplier's currency is converted to company's base currency",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Exchange Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"default": "1",
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 1,
|
||||
"hidden": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "cb_price_list",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
|
||||
"doctype": "DocField",
|
||||
"label": "Price List",
|
||||
"options": "Price List",
|
||||
"fieldname": "price_list_name",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"depends_on": "price_list_name",
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Currency",
|
||||
"options": "Currency",
|
||||
"fieldname": "price_list_currency",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"depends_on": "price_list_name",
|
||||
"doctype": "DocField",
|
||||
"label": "Price List Exchange Rate",
|
||||
"fieldname": "plc_conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes",
|
||||
"fieldname": "taxes",
|
||||
@ -285,14 +281,13 @@
|
||||
"description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Taxes and Charges",
|
||||
"oldfieldname": "purchase_other_charges",
|
||||
"permlevel": 0,
|
||||
"options": "Purchase Taxes and Charges Master",
|
||||
"fieldname": "purchase_other_charges",
|
||||
"fieldtype": "Link",
|
||||
"options": "Purchase Taxes and Charges Master"
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
@ -320,7 +315,6 @@
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Calculate Tax",
|
||||
"trigger": "Client",
|
||||
"fieldname": "calculate_tax",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
@ -335,112 +329,25 @@
|
||||
"fieldtype": "HTML",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Total Tax*",
|
||||
"oldfieldname": "total_tax",
|
||||
"fieldname": "total_tax",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Totals",
|
||||
"fieldname": "totals",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total",
|
||||
"oldfieldname": "grand_total",
|
||||
"fieldname": "grand_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Rounded Total",
|
||||
"oldfieldname": "rounded_total",
|
||||
"fieldname": "rounded_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "In Words will be visible once you save the Purchase Order.",
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words",
|
||||
"oldfieldname": "in_words",
|
||||
"fieldname": "in_words",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added",
|
||||
"oldfieldname": "other_charges_added",
|
||||
"fieldname": "other_charges_added",
|
||||
"label": "Net Total (Import)",
|
||||
"oldfieldname": "net_total_import",
|
||||
"fieldname": "net_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted",
|
||||
"oldfieldname": "other_charges_deducted",
|
||||
"fieldname": "other_charges_deducted",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break4",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total (Import)",
|
||||
"oldfieldname": "grand_total_import",
|
||||
"fieldname": "grand_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words(Import)",
|
||||
"oldfieldname": "in_words_import",
|
||||
"fieldname": "in_words_import",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
@ -465,6 +372,113 @@
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total (Import)",
|
||||
"oldfieldname": "grand_total_import",
|
||||
"fieldname": "grand_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1,
|
||||
"report_hide": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words(Import)",
|
||||
"oldfieldname": "in_words_import",
|
||||
"fieldname": "in_words_import",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break4",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total*",
|
||||
"oldfieldname": "net_total",
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 0,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added",
|
||||
"oldfieldname": "other_charges_added",
|
||||
"fieldname": "other_charges_added",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted",
|
||||
"oldfieldname": "other_charges_deducted",
|
||||
"fieldname": "other_charges_deducted",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Total Tax*",
|
||||
"oldfieldname": "total_tax",
|
||||
"fieldname": "total_tax",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total",
|
||||
"oldfieldname": "grand_total",
|
||||
"fieldname": "grand_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Rounded Total",
|
||||
"oldfieldname": "rounded_total",
|
||||
"fieldname": "rounded_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "In Words will be visible once you save the Purchase Order.",
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words",
|
||||
"oldfieldname": "in_words",
|
||||
"fieldname": "in_words",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
@ -475,8 +489,8 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"allow_on_submit": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"allow_on_submit": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Letter Head",
|
||||
"oldfieldname": "letter_head",
|
||||
@ -563,7 +577,6 @@
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Status",
|
||||
"oldfieldname": "status",
|
||||
@ -616,7 +629,6 @@
|
||||
"description": "Select the relevant company name if you have multiple companies",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Company",
|
||||
"oldfieldname": "company",
|
||||
@ -647,7 +659,6 @@
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"allow_on_submit": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Select Print Heading",
|
||||
@ -660,6 +671,7 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
@ -671,7 +683,6 @@
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Cancel Reason",
|
||||
"oldfieldname": "cancel_reason",
|
||||
|
180
buying/utils.py
Normal file
180
buying/utils.py
Normal file
@ -0,0 +1,180 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import getdate, flt, add_days
|
||||
import json
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_item_details(args):
|
||||
"""
|
||||
args = {
|
||||
"doctype": "",
|
||||
"docname": "",
|
||||
"item_code": "",
|
||||
"warehouse": None,
|
||||
"supplier": None,
|
||||
"transaction_date": None,
|
||||
"conversion_rate": 1.0
|
||||
}
|
||||
"""
|
||||
if isinstance(args, basestring):
|
||||
args = json.loads(args)
|
||||
|
||||
args = webnotes._dict(args)
|
||||
|
||||
item_wrapper = webnotes.model_wrapper("Item", args.item_code)
|
||||
item = item_wrapper.doc
|
||||
|
||||
from stock.utils import validate_end_of_life
|
||||
validate_end_of_life(item.name, item.end_of_life)
|
||||
|
||||
# fetch basic values
|
||||
out = webnotes._dict()
|
||||
out.update({
|
||||
"item_name": item.item_name,
|
||||
"item_group": item.item_group,
|
||||
"brand": item.brand,
|
||||
"description": item.description,
|
||||
"qty": 0,
|
||||
"stock_uom": item.stock_uom,
|
||||
"uom": item.stock_uom,
|
||||
"conversion_factor": 1,
|
||||
"warehouse": args.warehouse or item.default_warehouse,
|
||||
"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in
|
||||
item_wrapper.doclist.get({"parentfield": "ref_rate_details"})))),
|
||||
"batch_no": None,
|
||||
"expense_head": item.purchase_account,
|
||||
"cost_center": item.cost_center
|
||||
})
|
||||
|
||||
if args.supplier:
|
||||
item_supplier = item_wrapper.doclist.get({"parentfield": "item_supplier_details",
|
||||
"supplier": args.supplier})
|
||||
if item_supplier:
|
||||
out["supplier_part_no"] = item_supplier[0].supplier_part_no
|
||||
|
||||
if out.warehouse:
|
||||
out.projected_qty = webnotes.conn.get_value("Bin", {"item_code": item.name,
|
||||
"warehouse": out.warehouse}, "projected_qty")
|
||||
|
||||
if args.transaction_date and item.lead_time_days:
|
||||
out.schedule_date = out.lead_time_date = add_days(args.transaction_date,
|
||||
item.lead_time_days)
|
||||
|
||||
# set zero
|
||||
out.purchase_ref_rate = out.discount_rate = out.purchase_rate = \
|
||||
out.import_ref_rate = out.import_rate = 0.0
|
||||
|
||||
if args.doctype in ["Purchase Order", "Purchase Invoice", "Purchase Receipt",
|
||||
"Supplier Quotation"]:
|
||||
# try fetching from price list
|
||||
if args.price_list_name and args.price_list_currency:
|
||||
rates_as_per_price_list = get_rates_as_per_price_list(args, item_wrapper.doclist)
|
||||
if rates_as_per_price_list:
|
||||
out.update(rates_as_per_price_list)
|
||||
|
||||
# if not found, fetch from last purchase transaction
|
||||
if not out.purchase_rate:
|
||||
last_purchase = get_last_purchase_details(item.name, args.docname, args.conversion_rate)
|
||||
if last_purchase:
|
||||
out.update(last_purchase)
|
||||
|
||||
return out
|
||||
|
||||
def get_rates_as_per_price_list(args, item_doclist=None):
|
||||
if not item_doclist:
|
||||
item_doclist = webnotes.model_wrapper("Item", args.item_code).doclist
|
||||
|
||||
result = item_doclist.get({"parentfield": "ref_rate_details",
|
||||
"price_list_name": args.price_list_name, "ref_currency": args.price_list_currency,
|
||||
"buying": 1})
|
||||
|
||||
if result:
|
||||
purchase_ref_rate = flt(result[0].ref_rate) * flt(args.plc_conversion_rate)
|
||||
conversion_rate = flt(args.conversion_rate) or 1.0
|
||||
return webnotes._dict({
|
||||
"purchase_ref_rate": purchase_ref_rate,
|
||||
"purchase_rate": purchase_ref_rate,
|
||||
"rate": purchase_ref_rate,
|
||||
"discount_rate": 0,
|
||||
"import_ref_rate": purchase_ref_rate / conversion_rate,
|
||||
"import_rate": purchase_ref_rate / conversion_rate
|
||||
})
|
||||
else:
|
||||
return webnotes._dict()
|
||||
|
||||
def get_last_purchase_details(item_code, doc_name, conversion_rate=1.0):
|
||||
"""returns last purchase details in stock uom"""
|
||||
# get last purchase order item details
|
||||
last_purchase_order = webnotes.conn.sql("""\
|
||||
select po.name, po.transaction_date, po.conversion_rate,
|
||||
po_item.conversion_factor, po_item.purchase_ref_rate,
|
||||
po_item.discount_rate, po_item.purchase_rate
|
||||
from `tabPurchase Order` po, `tabPurchase Order Item` po_item
|
||||
where po.docstatus = 1 and po_item.item_code = %s and po.name != %s and
|
||||
po.name = po_item.parent
|
||||
order by po.transaction_date desc, po.name desc
|
||||
limit 1""", (item_code, doc_name), as_dict=1)
|
||||
|
||||
# get last purchase receipt item details
|
||||
last_purchase_receipt = webnotes.conn.sql("""\
|
||||
select pr.name, pr.posting_date, pr.posting_time, pr.conversion_rate,
|
||||
pr_item.conversion_factor, pr_item.purchase_ref_rate, pr_item.discount_rate,
|
||||
pr_item.purchase_rate
|
||||
from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
|
||||
where pr.docstatus = 1 and pr_item.item_code = %s and pr.name != %s and
|
||||
pr.name = pr_item.parent
|
||||
order by pr.posting_date desc, pr.posting_time desc, pr.name desc
|
||||
limit 1""", (item_code, doc_name), as_dict=1)
|
||||
|
||||
purchase_order_date = getdate(last_purchase_order and last_purchase_order[0].transaction_date \
|
||||
or "1900-01-01")
|
||||
purchase_receipt_date = getdate(last_purchase_receipt and \
|
||||
last_purchase_receipt[0].posting_date or "1900-01-01")
|
||||
|
||||
if (purchase_order_date > purchase_receipt_date) or \
|
||||
(last_purchase_order and not last_purchase_receipt):
|
||||
# use purchase order
|
||||
last_purchase = last_purchase_order[0]
|
||||
purchase_date = purchase_order_date
|
||||
|
||||
elif (purchase_receipt_date > purchase_order_date) or \
|
||||
(last_purchase_receipt and not last_purchase_order):
|
||||
# use purchase receipt
|
||||
last_purchase = last_purchase_receipt[0]
|
||||
purchase_date = purchase_receipt_date
|
||||
|
||||
else:
|
||||
return webnotes._dict()
|
||||
|
||||
conversion_factor = flt(last_purchase.conversion_factor)
|
||||
out = webnotes._dict({
|
||||
"purchase_ref_rate": flt(last_purchase.purchase_ref_rate) / conversion_factor,
|
||||
"purchase_rate": flt(last_purchase.purchase_rate) / conversion_factor,
|
||||
"discount_rate": flt(last_purchase.discount_rate),
|
||||
"purchase_date": purchase_date
|
||||
})
|
||||
|
||||
conversion_rate = flt(conversion_rate) or 1.0
|
||||
out.update({
|
||||
"import_ref_rate": out.purchase_ref_rate / conversion_rate,
|
||||
"import_rate": out.purchase_rate / conversion_rate,
|
||||
"rate": out.purchase_rate
|
||||
})
|
||||
|
||||
return out
|
70
controllers/buying_controller.py
Normal file
70
controllers/buying_controller.py
Normal file
@ -0,0 +1,70 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _, msgprint
|
||||
from webnotes.utils import flt
|
||||
|
||||
from buying.utils import get_item_details
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
class BuyingController(TransactionBase):
|
||||
def validate(self):
|
||||
if self.meta.get_field("currency"):
|
||||
self.company_currency = get_company_currency(self.doc.company)
|
||||
self.validate_conversion_rate("currency", "conversion_rate")
|
||||
|
||||
if self.doc.price_list_name and self.doc.price_list_currency:
|
||||
self.validate_conversion_rate("price_list_currency", "plc_conversion_rate")
|
||||
|
||||
def update_item_details(self):
|
||||
for item in self.doclist.get({"parentfield": self.fname}):
|
||||
ret = get_item_details({
|
||||
"doctype": self.doc.doctype,
|
||||
"docname": self.doc.name,
|
||||
"item_code": item.item_code,
|
||||
"warehouse": item.warehouse,
|
||||
"supplier": self.doc.supplier,
|
||||
"transaction_date": self.doc.posting_date,
|
||||
"conversion_rate": self.doc.conversion_rate
|
||||
})
|
||||
for r in ret:
|
||||
if not item.fields.get(r):
|
||||
item.fields[r] = ret[r]
|
||||
|
||||
def validate_conversion_rate(self, currency_field, conversion_rate_field):
|
||||
"""common validation for currency and price list currency"""
|
||||
|
||||
currency = self.doc.fields.get(currency_field)
|
||||
conversion_rate = flt(self.doc.fields.get(conversion_rate_field))
|
||||
conversion_rate_label = self.meta.get_label(conversion_rate_field)
|
||||
|
||||
if conversion_rate == 0:
|
||||
msgprint(conversion_rate_label + _(' cannot be 0'), raise_exception=True)
|
||||
|
||||
# parenthesis for 'OR' are necessary as we want it to evaluate as
|
||||
# mandatory valid condition and (1st optional valid condition
|
||||
# or 2nd optional valid condition)
|
||||
valid_conversion_rate = (conversion_rate and
|
||||
((currency == self.company_currency and conversion_rate == 1.00)
|
||||
or (currency != self.company_currency and conversion_rate != 1.00)))
|
||||
|
||||
if not valid_conversion_rate:
|
||||
msgprint(_('Please enter valid ') + conversion_rate_label + (': ')
|
||||
+ ("1 %s = [?] %s" % (currency, self.company_currency)),
|
||||
raise_exception=True)
|
@ -1,4 +1,7 @@
|
||||
erpnext.updates = [
|
||||
["18th January, 2013", [
|
||||
"Buying: Added Price List to purchase cycle",
|
||||
]],
|
||||
["16th January, 2013", [
|
||||
"Job Applicant: Track Job Applicants and extract them from a mailbox like 'jobs@example.com'. See <a href='#Form/Jobs Email Settings'>Jobs Email Settings</a>.",
|
||||
"Extract leads: Extract Leads from a mailbox like 'sales@example.com'. See <a href='#Form/Sales Email Settings'>Sales Email Settings</a>.",
|
||||
|
@ -18,11 +18,11 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, cint, cstr, flt, getdate
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import make_autoname
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
@ -137,7 +137,7 @@ class DocType(TransactionBase):
|
||||
|
||||
def validate(self):
|
||||
self.check_existing()
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
dcc = get_company_currency(self.doc.company)
|
||||
self.doc.total_in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.rounded_total)
|
||||
|
||||
|
||||
|
9
patches/january_2013/purchase_price_list.py
Normal file
9
patches/january_2013/purchase_price_list.py
Normal file
@ -0,0 +1,9 @@
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
webnotes.reload_doc("stock", "doctype", "item_price")
|
||||
|
||||
# check for selling
|
||||
webnotes.conn.sql("""update `tabItem Price` set selling=1
|
||||
where ifnull(selling, 0)=0 and ifnull(buying, 0)=0""")
|
||||
|
@ -152,4 +152,5 @@ patch_list = [
|
||||
"patches.january_2013.update_country_info",
|
||||
"patches.january_2013.remove_tds_entry_from_gl_mapper",
|
||||
"patches.january_2013.update_number_format",
|
||||
"patches.january_2013.purchase_price_list",
|
||||
]
|
@ -17,12 +17,11 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr, load_json
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.utils import cstr, getdate
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
@ -194,7 +193,7 @@ class DocType(TransactionBase):
|
||||
sales_com_obj.check_conversion_rate(self)
|
||||
|
||||
# Get total in words
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
dcc = get_company_currency(self.doc.company)
|
||||
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
|
||||
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
|
||||
|
||||
|
@ -23,6 +23,7 @@ from webnotes.model.doc import addchild
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import form, msgprint, _
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
get_value = webnotes.conn.get_value
|
||||
|
||||
@ -351,7 +352,7 @@ class DocType(TransactionBase):
|
||||
# Check Conversion Rate (i.e. it will not allow conversion rate to be 1 for Currency other than default currency set in Global Defaults)
|
||||
# ===========================================================================
|
||||
def check_conversion_rate(self, obj):
|
||||
default_currency = TransactionBase().get_company_currency(obj.doc.company)
|
||||
default_currency = get_company_currency(obj.doc.company)
|
||||
if not default_currency:
|
||||
msgprint('Message: Please enter default currency in Company Master')
|
||||
raise Exception
|
||||
|
@ -17,11 +17,11 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr, date_diff, flt, getdate
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.utils import cstr, flt, getdate
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
@ -222,7 +222,7 @@ class DocType(TransactionBase):
|
||||
self.doclist = sales_com_obj.make_packing_list(self,'sales_order_details')
|
||||
|
||||
# get total in words
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
dcc = get_company_currency(self.doc.company)
|
||||
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
|
||||
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
|
||||
|
||||
|
@ -18,9 +18,9 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr, flt, has_common, make_esc
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes import session, msgprint
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
@ -52,7 +52,7 @@ class DocType(TransactionBase):
|
||||
if not has_common(appr_roles, webnotes.user.get_roles()) and not has_common(appr_users, [session['user']]):
|
||||
msg, add_msg = '',''
|
||||
if max_amount:
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
dcc = get_company_currency(self.doc.company)
|
||||
if based_on == 'Grand Total': msg = "since Grand Total exceeds %s. %s" % (dcc, flt(max_amount))
|
||||
elif based_on == 'Itemwise Discount': msg = "since Discount exceeds %s for Item Code : %s" % (cstr(max_amount)+'%', item)
|
||||
elif based_on == 'Average Discount' or based_on == 'Customerwise Discount': msg = "since Discount exceeds %s" % (cstr(max_amount)+'%')
|
||||
|
49
setup/utils.py
Normal file
49
setup/utils.py
Normal file
@ -0,0 +1,49 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _, msgprint
|
||||
import json
|
||||
|
||||
def get_company_currency(company):
|
||||
currency = webnotes.conn.get_value("Company", company, "default_currency")
|
||||
if not currency:
|
||||
currency = webnotes.conn.get_default("currency")
|
||||
if not currency:
|
||||
msgprint(_('Please specify Default Currency in Company Master \
|
||||
and Global Defaults'), raise_exception=True)
|
||||
|
||||
return currency
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_price_list_currency(args):
|
||||
"""
|
||||
args = {
|
||||
"price_list_name": "Something",
|
||||
"use_for": "buying" or "selling"
|
||||
}
|
||||
"""
|
||||
if isinstance(args, basestring):
|
||||
args = json.loads(args)
|
||||
|
||||
result = webnotes.conn.sql("""select ref_currency from `tabItem Price`
|
||||
where price_list_name=%s and `%s`=1""" % ("%s", args.get("use_for")),
|
||||
(args.get("price_list_name"),))
|
||||
if result and len(result)==1:
|
||||
return {"price_list_currency": result[0][0]}
|
||||
else:
|
||||
return {}
|
@ -18,10 +18,10 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr, flt, getdate
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
@ -149,7 +149,7 @@ class DocType(TransactionBase):
|
||||
sales_com_obj.check_conversion_rate(self)
|
||||
|
||||
# Get total in Words
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
dcc = get_company_currency(self.doc.company)
|
||||
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
|
||||
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2013-01-16 11:35:56",
|
||||
"creation": "2013-01-17 10:57:15",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2013-01-19 12:09:54"
|
||||
"modified": "2013-01-17 11:22:07"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
@ -35,6 +35,7 @@
|
||||
"parenttype": "DocType",
|
||||
"report": 1,
|
||||
"permlevel": 0,
|
||||
"amend": 0,
|
||||
"parentfield": "permissions"
|
||||
},
|
||||
{
|
||||
@ -50,15 +51,6 @@
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Small Text",
|
||||
"doctype": "DocField",
|
||||
"label": "Trash Reason",
|
||||
"oldfieldname": "trash_reason",
|
||||
"fieldname": "trash_reason",
|
||||
"fieldtype": "Small Text",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"description": "Item will be saved by this name in the data base.",
|
||||
"oldfieldtype": "Data",
|
||||
@ -598,18 +590,6 @@
|
||||
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Create a price list from Price List master and enter standard ref rates against each of them. On selection of a price list in Quotation, Sales Order or Delivery Note, corresponding ref rate will be fetched for this item.",
|
||||
"oldfieldtype": "Table",
|
||||
"doctype": "DocField",
|
||||
"label": "Item Prices",
|
||||
"oldfieldname": "ref_rate_details",
|
||||
"options": "Item Price",
|
||||
"fieldname": "ref_rate_details",
|
||||
"fieldtype": "Table",
|
||||
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "For the convenience of customers, these codes can be used in print formats like Invoices and Delivery Notes",
|
||||
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
|
||||
@ -638,6 +618,25 @@
|
||||
"fieldtype": "Table",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Price Lists and Rates",
|
||||
"fieldname": "price_list_section",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Create a price list from Price List master and enter standard ref rates against each of them. On selection of a price list in Quotation, Sales Order or Delivery Note, corresponding ref rate will be fetched for this item.",
|
||||
"oldfieldtype": "Table",
|
||||
"doctype": "DocField",
|
||||
"label": "Item Prices",
|
||||
"oldfieldname": "ref_rate_details",
|
||||
"options": "Item Price",
|
||||
"fieldname": "ref_rate_details",
|
||||
"fieldtype": "Table",
|
||||
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"doctype": "DocField",
|
||||
|
@ -2,31 +2,24 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-03-27 14:36:36",
|
||||
"creation": "2013-01-15 18:43:18",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-03-27 14:36:36"
|
||||
"modified": "2013-01-17 17:53:42"
|
||||
},
|
||||
{
|
||||
"section_style": "Tray",
|
||||
"istable": 1,
|
||||
"in_create": 1,
|
||||
"module": "Stock",
|
||||
"server_code_error": " ",
|
||||
"read_only": 0,
|
||||
"istable": 1,
|
||||
"autoname": "RFD/.#####",
|
||||
"name": "__common__",
|
||||
"colour": "White:FFF",
|
||||
"in_create": 1,
|
||||
"doctype": "DocType",
|
||||
"show_in_menu": 0,
|
||||
"version": 3
|
||||
"module": "Stock",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"name": "__common__",
|
||||
"parent": "Item Price",
|
||||
"search_index": 1,
|
||||
"doctype": "DocField",
|
||||
"parenttype": "DocType",
|
||||
"in_filter": 1,
|
||||
"permlevel": 0,
|
||||
"parentfield": "fields"
|
||||
},
|
||||
@ -40,9 +33,11 @@
|
||||
"label": "Price List Name",
|
||||
"oldfieldname": "price_list_name",
|
||||
"fieldname": "price_list_name",
|
||||
"fieldtype": "Select",
|
||||
"fieldtype": "Link",
|
||||
"search_index": 1,
|
||||
"reqd": 1,
|
||||
"options": "link:Price List"
|
||||
"options": "Price List",
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Currency",
|
||||
@ -51,7 +46,9 @@
|
||||
"oldfieldname": "ref_rate",
|
||||
"fieldname": "ref_rate",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 0
|
||||
"search_index": 0,
|
||||
"reqd": 0,
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Select",
|
||||
@ -60,7 +57,23 @@
|
||||
"oldfieldname": "ref_currency",
|
||||
"fieldname": "ref_currency",
|
||||
"fieldtype": "Select",
|
||||
"search_index": 1,
|
||||
"reqd": 1,
|
||||
"options": "link:Currency"
|
||||
"options": "link:Currency",
|
||||
"in_filter": 1
|
||||
},
|
||||
{
|
||||
"description": "Allow this price in sales related forms",
|
||||
"doctype": "DocField",
|
||||
"label": "For Selling",
|
||||
"fieldname": "selling",
|
||||
"fieldtype": "Check"
|
||||
},
|
||||
{
|
||||
"description": "Allow this price in purchase related forms",
|
||||
"doctype": "DocField",
|
||||
"label": "For Buying",
|
||||
"fieldname": "buying",
|
||||
"fieldtype": "Check"
|
||||
}
|
||||
]
|
@ -22,6 +22,29 @@ wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxe
|
||||
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||
wn.require('app/utilities/doctype/sms_control/sms_control.js');
|
||||
|
||||
erpnext.buying.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function() {
|
||||
this._super();
|
||||
|
||||
if(this.frm.doc.docstatus == 1) {
|
||||
if(flt(this.frm.doc.per_billed, 2) < 100) {
|
||||
cur_frm.add_custom_button('Make Purchase Invoice',
|
||||
cur_frm.cscript['Make Purchase Invoice']);
|
||||
}
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||
}
|
||||
|
||||
if(wn.boot.control_panel.country == 'India') {
|
||||
unhide_field(['challan_no', 'challan_date']);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var new_cscript = new erpnext.buying.PurchaseReceiptController({frm: cur_frm});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
$.extend(cur_frm.cscript, new_cscript);
|
||||
|
||||
//========================== On Load ================================================================
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
if(!doc.fiscal_year && doc.__islocal){ wn.model.set_default_values(doc);}
|
||||
@ -38,26 +61,6 @@ cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
cur_frm.cscript.dynamic_label(doc, dt, dn, callback);
|
||||
}
|
||||
|
||||
//========================== Refresh ===============================================================
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.clear_custom_buttons();
|
||||
|
||||
erpnext.hide_naming_series();
|
||||
if(doc.supplier) $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
|
||||
else $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(false);
|
||||
|
||||
if (!cur_frm.cscript.is_onload) cur_frm.cscript.dynamic_label(doc, cdt, cdn);
|
||||
|
||||
if(doc.docstatus == 1){
|
||||
if (flt(doc.per_billed, 2) < 100) cur_frm.add_custom_button('Make Purchase Invoice', cur_frm.cscript['Make Purchase Invoice']);
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||
}
|
||||
|
||||
if(wn.boot.control_panel.country == 'India') {
|
||||
unhide_field(['challan_no', 'challan_date']);
|
||||
}
|
||||
}
|
||||
|
||||
//Supplier
|
||||
cur_frm.cscript.supplier = function(doc,dt,dn) {
|
||||
if (doc.supplier) {
|
||||
@ -65,7 +68,6 @@ cur_frm.cscript.supplier = function(doc,dt,dn) {
|
||||
JSON.stringify({ supplier: doc.supplier }),'', doc, dt, dn, 1, function() {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,18 +18,16 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cstr, flt, get_defaults, getdate
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import addchild, make_autoname
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.wrapper import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
from setup.utils import get_company_currency
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType(TransactionBase):
|
||||
from controllers.buying_controller import BuyingController
|
||||
class DocType(BuyingController):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
@ -38,32 +36,9 @@ class DocType(TransactionBase):
|
||||
self.fname = 'purchase_receipt_details'
|
||||
self.count = 0
|
||||
|
||||
# Autoname
|
||||
# ---------
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Transaction Date')
|
||||
|
||||
def get_item_details(self, arg = ''):
|
||||
if arg:
|
||||
return get_obj(dt='Purchase Common').get_item_details(self,arg)
|
||||
else:
|
||||
import json
|
||||
obj = get_obj('Purchase Common')
|
||||
for doc in self.doclist:
|
||||
if doc.fields.get('item_code'):
|
||||
temp = {
|
||||
'item_code': doc.fields.get('item_code'),
|
||||
'warehouse': doc.fields.get('warehouse')
|
||||
}
|
||||
ret = obj.get_item_details(self, json.dumps(temp))
|
||||
for r in ret:
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = ret[r]
|
||||
|
||||
|
||||
# GET TERMS & CONDITIONS
|
||||
# =====================================================================================
|
||||
def get_tc_details(self):
|
||||
@ -125,14 +100,6 @@ class DocType(TransactionBase):
|
||||
#d.valuation_rate = (flt(d.purchase_rate) + ((flt(d.amount) * (total_b_cost)) / (self.doc.net_total * flt(d.qty))) + (flt(d.rm_supp_cost) / flt(d.qty))) / flt(d.conversion_factor)
|
||||
d.valuation_rate = (flt(d.purchase_rate) + ((flt(d.amount) * (total_b_cost)) / (self.doc.net_total * flt(d.qty))) + (flt(d.rm_supp_cost) / flt(d.qty)) + (flt(d.item_tax_amount)/flt(d.qty))) / flt(d.conversion_factor)
|
||||
|
||||
# Check for Stopped status
|
||||
def check_for_stopped_status(self, pc_obj):
|
||||
check_list =[]
|
||||
for d in getlist(self.doclist, 'purchase_receipt_details'):
|
||||
if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
|
||||
check_list.append(d.prevdoc_docname)
|
||||
pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
|
||||
|
||||
#check in manage account if purchase order required or not.
|
||||
# ====================================================================================
|
||||
def po_required(self):
|
||||
@ -146,6 +113,8 @@ class DocType(TransactionBase):
|
||||
|
||||
# validate
|
||||
def validate(self):
|
||||
super(DocType, self).validate()
|
||||
|
||||
self.po_required()
|
||||
self.validate_fiscal_year()
|
||||
|
||||
@ -163,13 +132,12 @@ class DocType(TransactionBase):
|
||||
pc_obj = get_obj(dt='Purchase Common')
|
||||
pc_obj.validate_for_items(self)
|
||||
pc_obj.validate_mandatory(self)
|
||||
pc_obj.validate_conversion_rate(self)
|
||||
pc_obj.get_prevdoc_date(self)
|
||||
pc_obj.validate_reference_value(self)
|
||||
self.check_for_stopped_status(pc_obj)
|
||||
|
||||
# get total in words
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
dcc = get_company_currency(self.doc.company)
|
||||
self.doc.in_words = pc_obj.get_total_in_words(dcc, self.doc.grand_total)
|
||||
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
|
||||
# update valuation rate
|
||||
@ -255,7 +223,6 @@ class DocType(TransactionBase):
|
||||
self.values.append({
|
||||
'item_code' : d.fields.has_key('item_code') and d.item_code or d.rm_item_code,
|
||||
'warehouse' : wh,
|
||||
'transaction_date' : getdate(self.doc.modified).strftime('%Y-%m-%d'),
|
||||
'posting_date' : self.doc.posting_date,
|
||||
'posting_time' : self.doc.posting_time,
|
||||
'voucher_type' : 'Purchase Receipt',
|
||||
@ -287,7 +254,6 @@ class DocType(TransactionBase):
|
||||
check_list.append(d.prevdoc_docname)
|
||||
pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
|
||||
|
||||
|
||||
# on submit
|
||||
def on_submit(self):
|
||||
purchase_controller = webnotes.get_obj("Purchase Common")
|
||||
|
@ -2,13 +2,14 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-07-17 13:24:57",
|
||||
"creation": "2013-01-18 12:47:03",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-03 17:10:41"
|
||||
"modified": "2013-01-18 13:25:36"
|
||||
},
|
||||
{
|
||||
"is_submittable": 1,
|
||||
"autoname": "naming_series:",
|
||||
"allow_attach": 1,
|
||||
"is_submittable": 1,
|
||||
"search_fields": "status, posting_date, supplier",
|
||||
"module": "Stock",
|
||||
"doctype": "DocType",
|
||||
@ -36,6 +37,7 @@
|
||||
"doctype": "DocType"
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
@ -48,7 +50,6 @@
|
||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Series",
|
||||
"oldfieldname": "naming_series",
|
||||
@ -60,15 +61,14 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"print_width": "150px",
|
||||
"permlevel": 0,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"allow_on_submit": 0,
|
||||
"doctype": "DocField",
|
||||
"label": "Supplier",
|
||||
"oldfieldname": "supplier",
|
||||
"width": "150px",
|
||||
"trigger": "Client",
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Link",
|
||||
"search_index": 1,
|
||||
@ -118,6 +118,7 @@
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
@ -128,9 +129,9 @@
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "The date at which current entry will get or has actually executed.",
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Date",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Posting Date",
|
||||
"oldfieldname": "posting_date",
|
||||
@ -145,9 +146,9 @@
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Time at which materials were received",
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Time",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Posting Time",
|
||||
"oldfieldname": "posting_time",
|
||||
@ -161,9 +162,9 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Challan No",
|
||||
"oldfieldname": "challan_no",
|
||||
@ -176,9 +177,9 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Date",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Challan Date",
|
||||
"oldfieldname": "challan_date",
|
||||
@ -191,7 +192,6 @@
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Items",
|
||||
"fieldname": "items",
|
||||
@ -200,8 +200,8 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"allow_on_submit": 1,
|
||||
"oldfieldtype": "Table",
|
||||
"allow_on_submit": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Receipt Items",
|
||||
"oldfieldname": "purchase_receipt_details",
|
||||
@ -213,44 +213,12 @@
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"options": "Simple",
|
||||
"fieldname": "section_break0",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total",
|
||||
"oldfieldname": "net_total",
|
||||
"width": "150px",
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 1,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total (Import)",
|
||||
"oldfieldname": "net_total_import",
|
||||
"fieldname": "net_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Re-Calculate Values",
|
||||
"trigger": "Client",
|
||||
"fieldname": "recalculate_values",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Button",
|
||||
@ -262,6 +230,83 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_18",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Re-Calculate Values",
|
||||
"fieldname": "recalculate_values",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_20",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"description": "You can make a purchase receipt from multiple purchase orders. Select purchase orders one by one and click on the button below.",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Order",
|
||||
"oldfieldname": "purchase_order_no",
|
||||
"options": "Purchase Order",
|
||||
"fieldname": "purchase_order_no",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Pull Purchase Order Details",
|
||||
"options": "get_po_details",
|
||||
"fieldname": "pull_purchase_order_details",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Currency & Price List",
|
||||
"fieldname": "currency_price_list",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Supplier's currency",
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
"label": "Currency",
|
||||
"oldfieldname": "currency",
|
||||
"options": "link:Currency",
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Select",
|
||||
"reqd": 1,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Rate at which supplier's currency is converted to company's base currency",
|
||||
"default": "1.00",
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Exchange Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"reqd": 1,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
@ -271,62 +316,37 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Supplier's currency",
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
|
||||
"doctype": "DocField",
|
||||
"label": "Currency",
|
||||
"oldfieldname": "currency",
|
||||
"permlevel": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Select",
|
||||
"reqd": 1,
|
||||
"options": "link:Currency"
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "Rate at which supplier's currency is converted to company's base currency",
|
||||
"default": "1.00",
|
||||
"oldfieldtype": "Currency",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Conversion Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"trigger": "Client",
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"reqd": 1,
|
||||
"label": "Price List",
|
||||
"options": "Price List",
|
||||
"fieldname": "price_list_name",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 0,
|
||||
"description": "You can make a purchase receipt from multiple purchase orders. Select purchase orders one by one and click on the button below.",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"print_hide": 1,
|
||||
"depends_on": "price_list_name",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Order",
|
||||
"oldfieldname": "purchase_order_no",
|
||||
"permlevel": 0,
|
||||
"fieldname": "purchase_order_no",
|
||||
"label": "Price List Currency",
|
||||
"options": "Currency",
|
||||
"fieldname": "price_list_currency",
|
||||
"fieldtype": "Link",
|
||||
"options": "Purchase Order"
|
||||
"hidden": 0,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Button",
|
||||
"colour": "White:FFF",
|
||||
"depends_on": "price_list_name",
|
||||
"doctype": "DocField",
|
||||
"label": "Pull Purchase Order Details",
|
||||
"options": "get_po_details",
|
||||
"fieldname": "pull_purchase_order_details",
|
||||
"fieldtype": "Button",
|
||||
"label": "Price List Exchange Rate",
|
||||
"fieldname": "plc_conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Add / Edit Taxes and Charges",
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes",
|
||||
"fieldname": "taxes",
|
||||
@ -337,7 +357,6 @@
|
||||
"print_hide": 1,
|
||||
"description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.",
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Purchase Taxes and Charges",
|
||||
"oldfieldname": "purchase_other_charges",
|
||||
@ -371,21 +390,10 @@
|
||||
"oldfieldtype": "Button",
|
||||
"doctype": "DocField",
|
||||
"label": "Calculate Tax",
|
||||
"trigger": "Client",
|
||||
"fieldname": "calculate_tax",
|
||||
"fieldtype": "Button",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Total Tax",
|
||||
"oldfieldname": "total_tax",
|
||||
"fieldname": "total_tax",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "HTML",
|
||||
@ -398,7 +406,6 @@
|
||||
{
|
||||
"description": "Detailed Breakup of the totals",
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Totals",
|
||||
"fieldname": "totals",
|
||||
@ -409,83 +416,12 @@
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total",
|
||||
"oldfieldname": "grand_total",
|
||||
"fieldname": "grand_total",
|
||||
"label": "Net Total (Import)",
|
||||
"oldfieldname": "net_total_import",
|
||||
"fieldname": "net_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Rounded Total",
|
||||
"oldfieldname": "rounded_total",
|
||||
"fieldname": "rounded_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "In Words will be visible once you save the Purchase Receipt.",
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words",
|
||||
"oldfieldname": "in_words",
|
||||
"fieldname": "in_words",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added",
|
||||
"oldfieldname": "other_charges_added",
|
||||
"fieldname": "other_charges_added",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted",
|
||||
"oldfieldname": "other_charges_deducted",
|
||||
"fieldname": "other_charges_deducted",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total (Import)",
|
||||
"oldfieldname": "grand_total_import",
|
||||
"fieldname": "grand_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words (Import)",
|
||||
"oldfieldname": "in_words_import",
|
||||
"fieldname": "in_words_import",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
@ -506,10 +442,111 @@
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total (Import)",
|
||||
"oldfieldname": "grand_total_import",
|
||||
"fieldname": "grand_total_import",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words (Import)",
|
||||
"oldfieldname": "in_words_import",
|
||||
"fieldname": "in_words_import",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"print_width": "150px",
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Net Total",
|
||||
"oldfieldname": "net_total",
|
||||
"width": "150px",
|
||||
"fieldname": "net_total",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 1,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Added",
|
||||
"oldfieldname": "other_charges_added",
|
||||
"fieldname": "other_charges_added",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Taxes and Charges Deducted",
|
||||
"oldfieldname": "other_charges_deducted",
|
||||
"fieldname": "other_charges_deducted",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Total Tax",
|
||||
"oldfieldname": "total_tax",
|
||||
"fieldname": "total_tax",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Grand Total",
|
||||
"oldfieldname": "grand_total",
|
||||
"fieldname": "grand_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"doctype": "DocField",
|
||||
"label": "Rounded Total",
|
||||
"oldfieldname": "rounded_total",
|
||||
"fieldname": "rounded_total",
|
||||
"fieldtype": "Currency",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "In Words will be visible once you save the Purchase Receipt.",
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
"label": "In Words",
|
||||
"oldfieldname": "in_words",
|
||||
"fieldname": "in_words",
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"description": "Add Terms and Conditions for the Purchase Receipt. You can also prepare a Terms and Conditions Master and use the Template.",
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Terms and Conditions",
|
||||
"fieldname": "terms_section_break",
|
||||
@ -571,6 +608,12 @@
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_57",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"doctype": "DocField",
|
||||
@ -583,7 +626,6 @@
|
||||
{
|
||||
"description": "Filing in Additional Information about the Purchase Receipt will help you analyze your data better.",
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "More Info",
|
||||
"fieldname": "more_info",
|
||||
@ -593,9 +635,9 @@
|
||||
{
|
||||
"print_hide": 1,
|
||||
"permlevel": 1,
|
||||
"print_width": "150px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Status",
|
||||
"oldfieldname": "status",
|
||||
@ -612,7 +654,6 @@
|
||||
"description": "% of materials billed against this Purchase Receipt",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Currency",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "% Billed",
|
||||
"oldfieldname": "per_billed",
|
||||
@ -626,17 +667,18 @@
|
||||
"description": "Select \"Yes\" for sub - contracting items",
|
||||
"default": "No",
|
||||
"oldfieldtype": "Select",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Is Subcontracted",
|
||||
"oldfieldname": "is_subcontracted",
|
||||
"permlevel": 0,
|
||||
"options": "\nYes\nNo",
|
||||
"fieldname": "is_subcontracted",
|
||||
"fieldtype": "Select",
|
||||
"options": "\nYes\nNo"
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"permlevel": 1,
|
||||
"print_width": "150px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"doctype": "DocField",
|
||||
@ -646,26 +688,11 @@
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"description": "The date at which current entry is corrected in the system.",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Date",
|
||||
"doctype": "DocField",
|
||||
"label": "Amendment Date",
|
||||
"oldfieldname": "amendment_date",
|
||||
"width": "100px",
|
||||
"fieldname": "amendment_date",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 1,
|
||||
"permlevel": 0
|
||||
"options": "Purchase Receipt"
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Range",
|
||||
"oldfieldname": "range",
|
||||
@ -700,13 +727,11 @@
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"allow_on_submit": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Select Print Heading",
|
||||
"oldfieldname": "select_print_heading",
|
||||
"permlevel": 0,
|
||||
"trigger": "Client",
|
||||
"fieldname": "select_print_heading",
|
||||
"fieldtype": "Link",
|
||||
"options": "Print Heading",
|
||||
@ -716,9 +741,9 @@
|
||||
"print_hide": 1,
|
||||
"permlevel": 0,
|
||||
"description": "Select the relevant company name if you have multiple companies",
|
||||
"print_width": "150px",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Company",
|
||||
"oldfieldname": "company",
|
||||
@ -733,6 +758,7 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"print_width": "150px",
|
||||
"permlevel": 0,
|
||||
"oldfieldtype": "Select",
|
||||
"doctype": "DocField",
|
||||
@ -748,6 +774,7 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"print_width": "50%",
|
||||
"oldfieldtype": "Column Break",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
@ -757,9 +784,9 @@
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"print_width": "30%",
|
||||
"permlevel": 0,
|
||||
"oldfieldtype": "HTML",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Other Details",
|
||||
"width": "30%",
|
||||
@ -774,7 +801,6 @@
|
||||
"description": "Warehouse where you are maintaining stock of rejected items",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Rejected Warehouse",
|
||||
"oldfieldname": "rejected_warehouse",
|
||||
@ -788,9 +814,9 @@
|
||||
"print_hide": 1,
|
||||
"permlevel": 0,
|
||||
"description": "Supplier warehouse where you have issued raw materials for sub - contracting",
|
||||
"print_width": "50px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Link",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Supplier Warehouse",
|
||||
"oldfieldname": "supplier_warehouse",
|
||||
@ -803,7 +829,6 @@
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Cancel Reason",
|
||||
"oldfieldname": "cancel_reason",
|
||||
@ -849,9 +874,9 @@
|
||||
{
|
||||
"print_hide": 0,
|
||||
"description": "Transporter lorry number",
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Data",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "LR No",
|
||||
"oldfieldname": "lr_no",
|
||||
@ -863,9 +888,9 @@
|
||||
{
|
||||
"print_hide": 0,
|
||||
"description": "Date on which lorry started from supplier warehouse",
|
||||
"print_width": "100px",
|
||||
"no_copy": 1,
|
||||
"oldfieldtype": "Date",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "LR Date",
|
||||
"oldfieldname": "lr_date",
|
||||
@ -875,6 +900,7 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"print_width": "50%",
|
||||
"doctype": "DocField",
|
||||
"width": "50%",
|
||||
"fieldname": "column_break5",
|
||||
@ -885,7 +911,6 @@
|
||||
"print_hide": 1,
|
||||
"description": "Following table will show values if items are sub - contracted. These values will be fetched from the master of \"Bill of Materials\" of sub - contracted items.",
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Raw Material Details",
|
||||
"fieldname": "raw_material_details",
|
||||
@ -922,8 +947,7 @@
|
||||
"write": 1,
|
||||
"role": "Purchase User",
|
||||
"cancel": 1,
|
||||
"permlevel": 0,
|
||||
"match": ""
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
@ -933,12 +957,12 @@
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Supplier",
|
||||
"match": "supplier",
|
||||
"permlevel": 0
|
||||
"permlevel": 0,
|
||||
"match": "supplier"
|
||||
},
|
||||
{
|
||||
"write": 1,
|
||||
"doctype": "DocPerm",
|
||||
"write": 1,
|
||||
"role": "All",
|
||||
"permlevel": 2
|
||||
},
|
||||
|
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.require("public/app/js/stock_controller.js");
|
||||
wn.require("public/app/js/controllers/stock_controller.js");
|
||||
wn.provide("erpnext.stock");
|
||||
|
||||
erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
|
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.require("public/app/js/stock_controller.js");
|
||||
wn.require("public/app/js/controllers/stock_controller.js");
|
||||
wn.provide("erpnext.stock");
|
||||
|
||||
erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
|
@ -20,7 +20,9 @@ from webnotes.utils import load_json, cstr, flt, get_defaults
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.wrapper import copy_doclist
|
||||
|
||||
class TransactionBase:
|
||||
from webnotes.model.controller import DocListController
|
||||
|
||||
class TransactionBase(DocListController):
|
||||
|
||||
# Get Customer Default Primary Address - first load
|
||||
# -----------------------
|
||||
@ -227,14 +229,6 @@ class TransactionBase:
|
||||
ch.incentives = d and flt(d[3]) or 0
|
||||
ch.idx = idx
|
||||
idx += 1
|
||||
|
||||
# Get Company Specific Default Currency
|
||||
# -------------------------------------
|
||||
def get_company_currency(self, name):
|
||||
ret = webnotes.conn.sql("select default_currency from tabCompany where name = '%s'" %(name))
|
||||
dcc = ret and ret[0][0] or get_defaults()['currency']
|
||||
return dcc
|
||||
|
||||
|
||||
def load_notification_message(self):
|
||||
dt = self.doc.doctype.lower().replace(" ", "_")
|
||||
|
Loading…
Reference in New Issue
Block a user