[fix] related to mapping

This commit is contained in:
Nabin Hait
2013-07-10 16:48:29 +05:30
parent 3093e6fd39
commit 10b112807c
5 changed files with 55 additions and 50 deletions

View File

@@ -94,14 +94,15 @@ def make_purchase_order(source_name, target_doclist=None):
}, },
"Supplier Quotation Item": { "Supplier Quotation Item": {
"doctype": "Purchase Order Item", "doctype": "Purchase Order Item",
"field_map": { "field_map": [
"name": "supplier_quotation_item", ["name", "supplier_quotation_item"],
"parent": "supplier_quotation", ["parent", "supplier_quotation"],
"uom": "stock_uom", ["uom", "stock_uom"],
"prevdoc_detail_docname": "prevdoc_detail_docname", ["uom", "uom"],
"prevdoc_doctype": "prevdoc_doctype", ["prevdoc_detail_docname", "prevdoc_detail_docname"],
"prevdoc_docname": "prevdoc_docname", ["prevdoc_doctype", "prevdoc_doctype"],
}, ["prevdoc_docname", "prevdoc_docname"]
],
"postprocess": update_item "postprocess": update_item
}, },
"Purchase Taxes and Charges": { "Purchase Taxes and Charges": {

View File

@@ -20,13 +20,14 @@ cur_frm.add_fetch('employee', 'company', 'company');
// ------------------------------------------------------------------- // -------------------------------------------------------------------
cur_frm.cscript.onload = function(doc,dt,dn){ cur_frm.cscript.onload = function(doc,dt,dn){
if((cint(doc.__islocal) == 1) && !doc.amended_from){ if((cint(doc.__islocal) == 1) && !doc.amended_from){
var today=new Date(); if(!doc.month) {
month = (today.getMonth()+01).toString(); var today=new Date();
if(month.length>1) doc.month = month; month = (today.getMonth()+01).toString();
else doc.month = '0'+month; if(month.length>1) doc.month = month;
doc.fiscal_year = sys_defaults['fiscal_year']; else doc.month = '0'+month;
}
if(!doc.fiscal_year) doc.fiscal_year = sys_defaults['fiscal_year'];
refresh_many(['month', 'fiscal_year']); refresh_many(['month', 'fiscal_year']);
cur_frm.cscript.fiscal_year(doc, dt, dn);
} }
} }
@@ -42,8 +43,6 @@ cur_frm.cscript.fiscal_year = function(doc,dt,dn){
cur_frm.cscript.month = cur_frm.cscript.employee = cur_frm.cscript.fiscal_year; cur_frm.cscript.month = cur_frm.cscript.employee = cur_frm.cscript.fiscal_year;
// Calculate total if lwp exists
// ------------------------------------------------------------------------
cur_frm.cscript.leave_without_pay = function(doc,dt,dn){ cur_frm.cscript.leave_without_pay = function(doc,dt,dn){
if (doc.employee && doc.fiscal_year && doc.month) { if (doc.employee && doc.fiscal_year && doc.month) {
$c_obj(make_doclist(doc.doctype,doc.name), 'get_leave_details',doc.leave_without_pay,function(r, rt) { $c_obj(make_doclist(doc.doctype,doc.name), 'get_leave_details',doc.leave_without_pay,function(r, rt) {
@@ -54,16 +53,12 @@ cur_frm.cscript.leave_without_pay = function(doc,dt,dn){
} }
} }
// Calculate all
// ------------------------------------------------------------------------
var calculate_all = function(doc, dt, dn) { var calculate_all = function(doc, dt, dn) {
calculate_earning_total(doc, dt, dn); calculate_earning_total(doc, dt, dn);
calculate_ded_total(doc, dt, dn); calculate_ded_total(doc, dt, dn);
calculate_net_pay(doc, dt, dn); calculate_net_pay(doc, dt, dn);
} }
// Trigger on earning modified amount and depends on lwp
// ------------------------------------------------------------------------
cur_frm.cscript.e_modified_amount = function(doc,dt,dn){ cur_frm.cscript.e_modified_amount = function(doc,dt,dn){
calculate_earning_total(doc, dt, dn); calculate_earning_total(doc, dt, dn);
calculate_net_pay(doc, dt, dn); calculate_net_pay(doc, dt, dn);

View File

@@ -17,7 +17,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import add_days, cint, cstr, flt, getdate from webnotes.utils import add_days, cint, cstr, flt, getdate, nowdate
from webnotes.model.doc import make_autoname from webnotes.model.doc import make_autoname
from webnotes.model.bean import getlist from webnotes.model.bean import getlist
from webnotes.model.code import get_obj from webnotes.model.code import get_obj
@@ -40,9 +40,7 @@ class DocType(TransactionBase):
def get_emp_and_leave_details(self): def get_emp_and_leave_details(self):
if self.doc.employee: if self.doc.employee:
# Get payment days self.get_leave_details()
if self.doc.fiscal_year and self.doc.month:
self.get_leave_details()
# check sal structure # check sal structure
struct = self.check_sal_struct() struct = self.check_sal_struct()
@@ -59,14 +57,24 @@ class DocType(TransactionBase):
def pull_sal_struct(self, struct): def pull_sal_struct(self, struct):
self.doclist = self.doc.clear_table(self.doclist, 'earning_details')
self.doclist = self.doc.clear_table(self.doclist, 'deduction_details')
from hr.doctype.salary_structure.salary_structure import make_salary_slip from hr.doctype.salary_structure.salary_structure import make_salary_slip
make_salary_slip(struct, self.doclist) self.doclist = make_salary_slip(struct, self.doclist)
def pull_emp_details(self):
emp = webnotes.conn.get_value("Employee", self.doc.employee,
["bank_name", "bank_ac_no", "esic_card_no", "pf_number"], as_dict=1)
if emp:
self.doc.bank_name = emp.bank_name
self.doc.bank_ac_no = emp.bank_ac_no
self.doc.esic_no = emp.esic_card_no
self.doc.pf_no = emp.pf_number
def get_leave_details(self, lwp=None): def get_leave_details(self, lwp=None):
if not self.doc.fiscal_year:
self.doc.fiscal_year = webnotes.get_default("fiscal_year")
if not self.doc.month:
self.doc.month = "%02d" % getdate(nowdate()).month
m = get_obj('Salary Manager').get_month_details(self.doc.fiscal_year, self.doc.month) m = get_obj('Salary Manager').get_month_details(self.doc.fiscal_year, self.doc.month)
if not lwp: if not lwp:

View File

@@ -99,13 +99,10 @@ def make_salary_slip(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist from webnotes.model.mapper import get_mapped_doclist
def postprocess(source, target): def postprocess(source, target):
emp = webnotes.conn.get_value("Employee", source.doc.employee, sal_slip = webnotes.bean(target)
["bank_name", "bank_ac_no", "esic_card_no", "pf_number"], as_dict=1) sal_slip.run_method("pull_emp_details")
if emp: sal_slip.run_method("get_leave_details")
target[0].bank_name = emp.bank_name sal_slip.run_method("calculate_net_pay")
target[0].bank_ac_no = emp.bank_ac_no
target[0].esic_no = emp.esic_card_no
target[0].pf_no = emp.pf_number
doclist = get_mapped_doclist("Salary Structure", source_name, { doclist = get_mapped_doclist("Salary Structure", source_name, {
"Salary Structure": { "Salary Structure": {
@@ -116,16 +113,19 @@ def make_salary_slip(source_name, target_doclist=None):
}, },
"Salary Structure Deduction": { "Salary Structure Deduction": {
"doctype": "Salary Slip Deduction", "doctype": "Salary Slip Deduction",
"field_map": { "field_map": [
"depend_on_lwp": "d_depends_on_lwp" ["depend_on_lwp", "d_depends_on_lwp"],
} ["d_modified_amt", "d_amount"],
["d_modified_amt", "d_modified_amount"]
]
}, },
"Salary Structure Earning": { "Salary Structure Earning": {
"doctype": "Salary Slip Earning", "doctype": "Salary Slip Earning",
"field_map": { "field_map": [
"depend_on_lwp": "e_depends_on_lwp", ["depend_on_lwp", "e_depends_on_lwp"],
"modified_value": "e_modified_amount" ["modified_value", "e_modified_amount"],
} ["modified_value", "e_amount"]
]
} }
}, target_doclist, postprocess) }, target_doclist, postprocess)

View File

@@ -254,12 +254,13 @@ def make_purchase_order(source_name, target_doclist=None):
}, },
"Material Request Item": { "Material Request Item": {
"doctype": "Purchase Order Item", "doctype": "Purchase Order Item",
"field_map": { "field_map": [
"name": "prevdoc_detail_docname", ["name", "prevdoc_detail_docname"],
"parent": "prevdoc_docname", ["parent", "prevdoc_docname"],
"parenttype": "prevdoc_doctype", ["parenttype", "prevdoc_doctype"],
"uom": "stock_uom" ["uom", "stock_uom"],
}, ["uom", "uom"]
],
"postprocess": update_item "postprocess": update_item
} }
}, target_doclist, set_missing_values) }, target_doclist, set_missing_values)