function mod($num, $div) { // (let [m (rem num div)] // (if (or (zero? m) (= (pos? num) (pos? div))) // m // (+ m div)))) $m = rem($num, $div); if (is_zero($m) || is_pos($num) === is_pos($div)) { return $m; } return $m + $div; }
function pick($n, $lat) { return is_zero(sub($n, 1)) ? car($lat) : pick(sub($n, 1), cdr($lat)); }
function process_leave_card() { $this->sl_vsl = FALSE; // Initialize to FALSE to prevent from always TRUE $this->period = is_zero($this->period); $this->v_earned = is_zero($this->v_earned); // If MC#06 if ($this->v_abs == 0 || $this->leave_type_id == 3) { $this->v_abs = ''; } $this->v_abs_wop = is_zero($this->v_abs_wop); $this->s_earned = is_zero($this->s_earned); // If maternity, paternity or solo parent leave, mc2 s. 2012 $leave_ids = array(4, 5, 6, 24); if ($this->s_abs == 0 || in_array($this->leave_type_id, $leave_ids)) { $this->s_abs = ''; } $this->s_abs_wop = is_zero($this->s_abs_wop); // balance here if ($this->v_balance != 0) { $this->vacation_leave_balance += $this->v_balance; } if ($this->s_balance != 0) { $this->sick_leave_balance += $this->s_balance; } // If the there is a file for vacation leave // Vacation leave balance minus the number of // vacation leave days filed. if ($this->v_abs != 0) { $this->vacation_leave_balance -= $this->v_abs; } // Same as VL above if ($this->s_abs != 0) { $this->sick_leave_balance -= $this->s_abs; } // Earned if ($this->v_earned != 0) { $this->vacation_leave_balance += $this->v_earned; } if ($this->s_earned != 0) { $this->sick_leave_balance += $this->s_earned; } // Tell if the entry is leave forwarded $cut_particulars = substr($this->particulars, 0, 3); // If negative if (substr($this->sick_leave_balance, 0, 1) == '-') { // If balance forwarded if ($cut_particulars == 'Bal') { } else { // Do only if the entry is not earnings of leave and the entry is for sick leave // Do this if the application is sick leave if ($this->particulars != '' && $this->s_abs != 0) { $abs_sick_leave_balance = abs($this->sick_leave_balance); // If the leave application is greater than // negative balance if ($abs_sick_leave_balance > $this->s_abs) { $this->sick_leave_balance = $abs_sick_leave_balance - $this->s_abs; $this->sick_leave_balance = '-' . $this->sick_leave_balance; // If vacation leave balance is greater than // number of sick leave applied if ($this->vacation_leave_balance > $this->s_abs) { $this->vacation_leave_balance = $this->vacation_leave_balance - $this->s_abs; $this->v_abs = $this->s_abs; $this->particulars = $this->v_abs . ' VSL'; // SL and VSL $this->sl_vsl = TRUE; $this->s_abs = ''; } // If vacation leave balance is less than // sick leave applied // make the w/out pay to sick leave if ($this->vacation_leave_balance < $this->s_abs) { $this->s_abs_wop = abs($this->s_abs); $this->s_abs = ''; } } else { $this->s_abs_wop = abs($this->sick_leave_balance); $this->sick_leave_balance = 0; //echo $this->s_abs_wop; // vacation leave balance less sick leave wop $this->vacation_leave_balance -= $this->s_abs_wop; $s = $this->s_abs - $this->s_abs_wop; $this->particulars = $s . ' SL, ' . $this->s_abs_wop . ' VSL'; // SL and VSL $this->sl_vsl = TRUE; if ($s == 0) { $this->particulars = $this->s_abs_wop . ' VSL'; // SL and VSL $this->sl_vsl = TRUE; } $this->s_abs = $s; $this->v_abs = $this->s_abs_wop; $this->s_abs_wop = ''; } } } } $this->is_vacation_negative(); $this->is_terminal_leave(); }