function getCollegeTuition($idno, $school_year, $period, $level, $program_code, $tuitionrate, $discounttf, $discountof, $discount_code, $discounttype, $type_of_account) { $grades = \App\GradeCollege::where('idno', $idno)->where('school_year', $school_year)->where('period', $period)->get(); $chartofaccount = \App\ChartOfAccount::where('accounting_name', "Tuition Fee")->first(); $lab = 0; $receipt_type = "OR"; if (count($grades) > 0) { foreach ($grades as $grade) { $lab = $lab + $this->getLabCount($lab, $grade->lab, $grade->course_code); if ($grade->is_petitioned == 0) { if ($grade->is_overload == 0) { if ($discounttype == 0) { $tobediscount = (($grade->lec * $tuitionrate * $grade->percent_tuition / 100) + (($grade->lab * $tuitionrate * $grade->percent_tuition / 100) * 3)) * ($discounttf / 100); } else if ($discounttype == 1) { $tobediscount = $discounttf / count($grades); } if ($type_of_account != "regular") { $discounttf = $this->getSpecialDiscount($idno, $school_year, $period, $level, $program_code, $tuitionrate, $discounttf, $discountof, $discount_code, $discounttype, $type_of_account); $tobediscount = (($grade->lec * $tuitionrate * $grade->percent_tuition / 100) + (($grade->lab * $tuitionrate * $grade->percent_tuition / 100) * 3)) * ($discounttf / 100); $discount_code = $type_of_account; } } else { $tobediscount = 0; $discount_code = ""; } //negative $c_amount = (($grade->lec * $tuitionrate * $grade->percent_tuition / 100) + (($grade->lab * $tuitionrate * $grade->percent_tuition / 100) * 3)); if ($tobediscount > $c_amount) { $tobediscount = $c_amount; } $check = $this->getSpecialFee($grade->course_code, $level, $program_code, $school_year, $period, $idno, $tobediscount, $discount_code, $discounttype, $discounttf, $grades); if ($check == 0) { $addledger = new \App\ledger; $addledger->idno = $idno; $addledger->program_code = $program_code; $addledger->level = $level; $addledger->school_year = $school_year; $addledger->period = $period; $addledger->category = "Tuition Fee"; $addledger->description = $grade->course_code; $addledger->receipt_details = "Tuition Fee"; $addledger->receipt_type = $receipt_type; $addledger->accounting_code = env("TF_CODE");//$chartofaccount->accounting_code; $addledger->category_switch = "3"; $addledger->amount = (($grade->lec * $tuitionrate * $grade->percent_tuition / 100) + (($grade->lab * $tuitionrate * $grade->percent_tuition / 100) * 3)); $addledger->discount = $tobediscount; $addledger->discount_code = $discount_code; $addledger->save(); } } } if ($lab > 0) { $this->getLabFee($idno, $school_year, $period, $level, $program_code, $tuitionrate, $discounttf, $discountof, $discount_code, $discounttype, $type_of_account); } } if ($type_of_account != "regular") { $this->getFeesValidate($idno, $school_year, $period, $level, $program_code, $tuitionrate, $discounttf, $discountof, $discount_code, $discounttype, $type_of_account); } if ($discounttype == 1) { $this->fixDiscount($idno, $school_year, $period, $level, $program_code, $tuitionrate, $discounttf, $discountof, $discount_code, $discounttype, $type_of_account); } }