22// For license information, please see license.txt
33
44frappe . ui . form . on ( 'Employee Benefit Application' , {
5- setup : function ( frm ) {
6- if ( ! frm . doc . employee || ! frm . doc . date ) {
7- frappe . throw ( __ ( "Please select Employee and Date first" ) ) ;
8- } else {
9- frm . set_query ( "earning_component" , "employee_benefits" , function ( ) {
10- return {
11- query : "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_earning_components" ,
12- filters : { date : frm . doc . date , employee : frm . doc . employee }
13- } ;
14- } ) ;
15- }
16- } ,
17-
185 employee : function ( frm ) {
6+ frm . trigger ( 'set_earning_component' ) ;
197 var method , args ;
208 if ( frm . doc . employee && frm . doc . date && frm . doc . payroll_period ) {
219 method = "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits_remaining" ;
@@ -35,6 +23,21 @@ frappe.ui.form.on('Employee Benefit Application', {
3523 get_max_benefits ( frm , method , args ) ;
3624 }
3725 } ,
26+
27+ date : function ( frm ) {
28+ frm . trigger ( 'set_earning_component' ) ;
29+ } ,
30+
31+ set_earning_component : function ( frm ) {
32+ if ( ! frm . doc . employee && ! frm . doc . date ) return ;
33+ frm . set_query ( "earning_component" , "employee_benefits" , function ( ) {
34+ return {
35+ query : "erpnext.hr.doctype.employee_benefit_application.employee_benefit_application.get_earning_components" ,
36+ filters : { date : frm . doc . date , employee : frm . doc . employee }
37+ }
38+ } ) ;
39+ } ,
40+
3841 payroll_period : function ( frm ) {
3942 var method , args ;
4043 if ( frm . doc . employee && frm . doc . date && frm . doc . payroll_period ) {
0 commit comments