Example #1
0
        //This method tightly couples with CORE classes. maybe, reconsider later
        //Nhibernate does not suppport bidirectional association with
        //list collections. No choice but have to ask the parent for studId
        public virtual void SyncDerivedFields(PaymentAdvice parent)
        {
            wsvAttendanceLn.AttendanceLn DBAttln =
                new wsvAttendanceLn.AttendanceLn();

            wsvAttendanceLn.CAttendanceLn[] aryAttln =
                DBAttln.GetAttendanceByStudentClass(parent.IdStudent, IdRegular);

            Absence = 0;
            Prorate = 0;
            if (aryAttln != null)
            {
                foreach (wsvAttendanceLn.CAttendanceLn attln in aryAttln)
                {
                    if (attln.isPresent == 0)
                        Absence++;
                    else if (attln.isPresent == 2)
                        Prorate++;
                }
            }

            //check log for number of forfeits. Very unnatural....
            AdoNetManager db = new AdoNetManager("ForfeitLog");

            String strSQL =
            " SELECT ISNULL(SUM(intCreditForfeitLog),0) FROM ForfeitLog " +
            " WHERE intIdUserForfeitLog=@idStud " +
            " AND intIdClassScheduleForfeitLog=@idClass ";

            db.ClearParameters();
            db.Parameters.Add("@idClass", SqlDbType.Int).Value = IdRegular;
            db.Parameters.Add("@idStud", SqlDbType.Int).Value = parent.IdStudent;

            Forfeit =Convert.ToInt32(db.executeScalar(strSQL));

            wsvMakeupAttendance.MakeupAttendance dbMakeup
                = new wsvMakeupAttendance.MakeupAttendance();
            wsvMakeupAttendance.CMakeupAttendance[] aryMakeup
                = dbMakeup.getMakeupAttendanceByStudent(parent.IdStudent);

            if (aryMakeup == null)
                Makeup = 0;
            else
            {
                foreach (wsvMakeupAttendance.CMakeupAttendance objMakeup in aryMakeup)
                {
                    if (objMakeup.IdAttendanceRegular == IdRegular)
                        Makeup++;
                }
            }

            ApasRegular regClass = GetAssociatedClass();
            PerLessonFee = Convert.ToDecimal(regClass.Fee);

            //get credit from student classshedule
            wsvStudentClassSchedule.StudentClassSchedule dbSC =
                new wsvStudentClassSchedule.StudentClassSchedule();

            wsvStudentClassSchedule.CStudentClassSchedule objSC =
                dbSC.getStudentClassSchedule(parent.IdStudent, IdRegular);

            //offset credit with number of attendances unmarked in this month
            DateTime month = parent.GetParentPAList().Month.AddMonths(-1);

            wsvAttendance.Attendance dbAtt = new wsvAttendance.Attendance();
            wsvAttendance.CAttendance[] aryAtt =
                dbAtt.getAttendancesBetween(regClass.Id,
                new DateTime(month.Year, month.Month, 1),
                new DateTime(month.Year, month.Month, DateTime.DaysInMonth(month.Year, month.Month))
            );
            int dayCount = GetDayCountOf(regClass.Day, regClass.ClassStartDate, month);
            int attCount = (aryAtt == null) ? 0 : aryAtt.Length;
            int unmarkedCount = (dayCount-attCount) < 0 ? 0 : dayCount-attCount;

            Credit = objSC.Credit-unmarkedCount;
        }
Example #2
0
        public virtual void ComputeDynamicFields(PaymentAdvice parent)
        {
            ApasConfigurationManager cfg = new ApasConfigurationManager();

            decimal deviationTotal = 0;

            PayableFee=Amount;

            foreach (FeeDeviationPayableFee objFD in FeeDeviations.Values)
            {
                //objFD returns exact amount. round it before adding to total
                deviationTotal += MyUtils.FormatCurrencyWithRounding(objFD.ComputeNetDeviation(0));//dummy zero, type is "fixed"
            }

            PayableFee += deviationTotal;

            BCStudent student = new BCStudent();
            student.Id = parent.IdStudent ;
            student.loadData();

            PaymentAdviceText = cfg.getConfigValue("PaymentAdviceTemplateOFee");

            //get Config paymentadvice Text template and fill PaymentAdviceText
            PaymentAdviceText =
                PaymentAdviceText
                    .Replace("[Name]", student.FullName)
                    .Replace("[Amount]", String.Format("{0:C}", Amount))
                    .Replace("[Payable Fee]", String.Format("{0:C}", PayableFee))
                    .Replace("[Fee Deviation Total]", String.Format("{0:C}", deviationTotal))
                    .Replace("[Private Remarks]", PrivateRemark)
                    .Replace("[Public Remarks]", PublicRemark)
                    .Replace("[Month]", parent.GetParentPAList().Month.ToString("MMMM"))
                    .Replace("[Year]", parent.GetParentPAList().Month.ToString("yyyy"))
                    .Replace("[Type]", OtherFeeType.Name);
        }
Example #3
0
        public virtual void ComputeDynamicFields(PaymentAdvice parent)
        {
            ApasConfigurationManager cfg=new ApasConfigurationManager();

            decimal deviationTotal=0;

            PayableCredit=NextMonthCredit -Credit +CreditAdjustment;

            PayableFee=PerLessonFee*PayableCredit;

            foreach(FeeDeviationPayableFee objFD in FeeDeviations.Values)
            {
                //objFD returns exact amount. round it before adding to total
                deviationTotal += MyUtils.FormatCurrencyWithRounding(objFD.ComputeNetDeviation(PayableFee));
            }

            PayableFee += deviationTotal;

            PayableFee = MyUtils.FormatCurrencyWithRounding(PayableFee);

            //get Config paymentadvice Text template and fill PaymentAdviceText
            PaymentAdviceText = cfg.getConfigValue("PaymentAdviceTemplateCFee");

            BCStudent student = new BCStudent();
            student.Id = parent.IdStudent;
            student.loadData();

            ApasRegular regClass = GetAssociatedClass();

            PaymentAdviceText =
                PaymentAdviceText
                .Replace("[Name]", student.FullName)
                .Replace("[Subject]", regClass.GetSubject().name)
                .Replace("[Level]", regClass.getLevel().Name)
                .Replace("[Time Start]", regClass.TimeStart.ToString("hh:mm tt"))
                .Replace("[Time End]", regClass.TimeEnd.ToString("hh:mm tt"))
                .Replace("[Day]", regClass.Day)
                .Replace("[Absence]", Convert.ToString(Absence))
                .Replace("[Prorate]", Convert.ToString(Prorate))
                .Replace("[Makeup]", Convert.ToString(Makeup))
                .Replace("[Forfeit]", Convert.ToString(Forfeit))
                .Replace("[Credit]", Convert.ToString(Credit))
                .Replace("[Payable Credit]", Convert.ToString(PayableCredit))
                .Replace("[Next Mth Lessons]", Convert.ToString(NextMonthCredit))
                .Replace("[Credit Adjustment]", Convert.ToString(CreditAdjustment))
                .Replace("[Per Lesson Fee]", String.Format("{0:C}", PerLessonFee))
                .Replace("[Fee Deviation Total]", String.Format("{0:C}", deviationTotal))
                .Replace("[Payable Fee]", String.Format("{0:C}", PayableFee))
                .Replace("[Private Remarks]", PrivateRemark)
                .Replace("[Public Remarks]", PublicRemark)
                .Replace("[Month]", parent.GetParentPAList().Month.ToString("MMMM"))
                .Replace("[Year]", parent.GetParentPAList().Month.ToString("yyyy"));
        }