[fix] related to mapping
This commit is contained in:
parent
3093e6fd39
commit
10b112807c
@ -94,14 +94,15 @@ def make_purchase_order(source_name, target_doclist=None):
|
||||
},
|
||||
"Supplier Quotation Item": {
|
||||
"doctype": "Purchase Order Item",
|
||||
"field_map": {
|
||||
"name": "supplier_quotation_item",
|
||||
"parent": "supplier_quotation",
|
||||
"uom": "stock_uom",
|
||||
"prevdoc_detail_docname": "prevdoc_detail_docname",
|
||||
"prevdoc_doctype": "prevdoc_doctype",
|
||||
"prevdoc_docname": "prevdoc_docname",
|
||||
},
|
||||
"field_map": [
|
||||
["name", "supplier_quotation_item"],
|
||||
["parent", "supplier_quotation"],
|
||||
["uom", "stock_uom"],
|
||||
["uom", "uom"],
|
||||
["prevdoc_detail_docname", "prevdoc_detail_docname"],
|
||||
["prevdoc_doctype", "prevdoc_doctype"],
|
||||
["prevdoc_docname", "prevdoc_docname"]
|
||||
],
|
||||
"postprocess": update_item
|
||||
},
|
||||
"Purchase Taxes and Charges": {
|
||||
|
@ -20,13 +20,14 @@ cur_frm.add_fetch('employee', 'company', 'company');
|
||||
// -------------------------------------------------------------------
|
||||
cur_frm.cscript.onload = function(doc,dt,dn){
|
||||
if((cint(doc.__islocal) == 1) && !doc.amended_from){
|
||||
var today=new Date();
|
||||
month = (today.getMonth()+01).toString();
|
||||
if(month.length>1) doc.month = month;
|
||||
else doc.month = '0'+month;
|
||||
doc.fiscal_year = sys_defaults['fiscal_year'];
|
||||
if(!doc.month) {
|
||||
var today=new Date();
|
||||
month = (today.getMonth()+01).toString();
|
||||
if(month.length>1) doc.month = month;
|
||||
else doc.month = '0'+month;
|
||||
}
|
||||
if(!doc.fiscal_year) doc.fiscal_year = sys_defaults['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;
|
||||
|
||||
// Calculate total if lwp exists
|
||||
// ------------------------------------------------------------------------
|
||||
cur_frm.cscript.leave_without_pay = function(doc,dt,dn){
|
||||
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) {
|
||||
@ -54,16 +53,12 @@ cur_frm.cscript.leave_without_pay = function(doc,dt,dn){
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate all
|
||||
// ------------------------------------------------------------------------
|
||||
var calculate_all = function(doc, dt, dn) {
|
||||
calculate_earning_total(doc, dt, dn);
|
||||
calculate_ded_total(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){
|
||||
calculate_earning_total(doc, dt, dn);
|
||||
calculate_net_pay(doc, dt, dn);
|
||||
|
@ -17,7 +17,7 @@
|
||||
from __future__ import unicode_literals
|
||||
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.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
@ -40,9 +40,7 @@ class DocType(TransactionBase):
|
||||
|
||||
def get_emp_and_leave_details(self):
|
||||
if self.doc.employee:
|
||||
# Get payment days
|
||||
if self.doc.fiscal_year and self.doc.month:
|
||||
self.get_leave_details()
|
||||
self.get_leave_details()
|
||||
|
||||
# check sal structure
|
||||
struct = self.check_sal_struct()
|
||||
@ -59,14 +57,24 @@ class DocType(TransactionBase):
|
||||
|
||||
|
||||
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
|
||||
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):
|
||||
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)
|
||||
|
||||
if not lwp:
|
||||
|
@ -99,14 +99,11 @@ def make_salary_slip(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
|
||||
def postprocess(source, target):
|
||||
emp = webnotes.conn.get_value("Employee", source.doc.employee,
|
||||
["bank_name", "bank_ac_no", "esic_card_no", "pf_number"], as_dict=1)
|
||||
if emp:
|
||||
target[0].bank_name = emp.bank_name
|
||||
target[0].bank_ac_no = emp.bank_ac_no
|
||||
target[0].esic_no = emp.esic_card_no
|
||||
target[0].pf_no = emp.pf_number
|
||||
|
||||
sal_slip = webnotes.bean(target)
|
||||
sal_slip.run_method("pull_emp_details")
|
||||
sal_slip.run_method("get_leave_details")
|
||||
sal_slip.run_method("calculate_net_pay")
|
||||
|
||||
doclist = get_mapped_doclist("Salary Structure", source_name, {
|
||||
"Salary Structure": {
|
||||
"doctype": "Salary Slip",
|
||||
@ -116,16 +113,19 @@ def make_salary_slip(source_name, target_doclist=None):
|
||||
},
|
||||
"Salary Structure Deduction": {
|
||||
"doctype": "Salary Slip Deduction",
|
||||
"field_map": {
|
||||
"depend_on_lwp": "d_depends_on_lwp"
|
||||
}
|
||||
"field_map": [
|
||||
["depend_on_lwp", "d_depends_on_lwp"],
|
||||
["d_modified_amt", "d_amount"],
|
||||
["d_modified_amt", "d_modified_amount"]
|
||||
]
|
||||
},
|
||||
"Salary Structure Earning": {
|
||||
"doctype": "Salary Slip Earning",
|
||||
"field_map": {
|
||||
"depend_on_lwp": "e_depends_on_lwp",
|
||||
"modified_value": "e_modified_amount"
|
||||
}
|
||||
"field_map": [
|
||||
["depend_on_lwp", "e_depends_on_lwp"],
|
||||
["modified_value", "e_modified_amount"],
|
||||
["modified_value", "e_amount"]
|
||||
]
|
||||
}
|
||||
}, target_doclist, postprocess)
|
||||
|
||||
|
@ -254,12 +254,13 @@ def make_purchase_order(source_name, target_doclist=None):
|
||||
},
|
||||
"Material Request Item": {
|
||||
"doctype": "Purchase Order Item",
|
||||
"field_map": {
|
||||
"name": "prevdoc_detail_docname",
|
||||
"parent": "prevdoc_docname",
|
||||
"parenttype": "prevdoc_doctype",
|
||||
"uom": "stock_uom"
|
||||
},
|
||||
"field_map": [
|
||||
["name", "prevdoc_detail_docname"],
|
||||
["parent", "prevdoc_docname"],
|
||||
["parenttype", "prevdoc_doctype"],
|
||||
["uom", "stock_uom"],
|
||||
["uom", "uom"]
|
||||
],
|
||||
"postprocess": update_item
|
||||
}
|
||||
}, target_doclist, set_missing_values)
|
||||
|
Loading…
x
Reference in New Issue
Block a user