Hi, I am using yii2 basic application template. I am desiging a web portal for SHG. Here the modules are groupdetails where the user creates new group profile and member details.
The second module is Groupsaving details where each month group transaction details are recorded and maintained.
The process is when a new group is created with 10 members then they do total saving of that month. Here Opening balance of first month is set to 0, Total saving for example is 1000, Loan recovery is set to 0, Loan Interest is 0, fine is 0 Bank Interest is 0. Now Expense is 50, Loan Given is 0 and Bank Loan is 0.
So the formula is
Closing balance=(Opening Balance+TotalSaving+LoanRecovery+LoanInterest+Fine+BankInterest-Expense-LoanGiven-BankLoan.)
Total Value of Loan Given = Current month Loan given+all previous month loan given
Total Value of Loan Outstanding= Total Value of Loan Given - Loan Repaid uptil now
So I have groupdetails CRUD and groupsaving ddetails CRUD.
Now In Group saving details Controller actionCreate() I have to check whether there exists a record less than or equal to entered year, entered month and selected group. If record does not exists, the entry is first time.
$count = Yii::$app->db->createCommand('SELECT count(*)
FROM `groupsavingdetails`, groupdetails
where groupdetails.GroupId=groupsavingdetails.GroupId
and groupsavingdetails.Year<='.$model->Year.'
and groupsavingdetails.Month<='.$model->Month.'
and groupsavingdetails.GroupId='.$model->GroupId
)
->queryScalar();
if($count==0)
{
$model->OpeningBalance=0;
$model->TotalValueofLoanGiven=0;
$model->LoanRepaidUptilNow= 0;
$model->TotalValueOfLoanOutstanding = 0;
$model->ClosingBalance=($model->OpeningBalance+$model->TotalSaving+$model->LoanRecovery+$model->LoanInterest+$model->Fine+$model->BankInterest-$model->Epense-$model->LoanGiven-$model->BankLoan);
}
So Opening balance, Totalvalue of Loan Given, Loan repaid uptil now , Total value of loan outstanding and closing balance fields are disabled.
So how should I set the values as 0 to the fields using controller or jquery in form. How these values will get updated as soon as I change the values in other textInputs. This calculation is a cumulative calculation where first month closing balance will be next month opening balance and as such. How should I assign values as Opening Balance to 0 on the form field from controller or any different way.