//need not load this directly. always load through PaymentAdvice ///// <summary> ///// constructor to load from database ///// </summary> ///// <param name="key">primary key value of ClassFee</param> //public ClassFee(long key) //{ // Load(key, false); //} /// <summary> /// constructor to create "new" ClassFee /// </summary> /// <param name="parentPaymentAdvice"></param> /// <param name="pIdRegular"></param> public ClassFee(PaymentAdvice parentPaymentAdvice, int pIdRegular) { if (parentPaymentAdvice == null) throw new ApasInvaidOperationException( "Invalid Operation: Unable to create a classfee without " + "a vailid parent PaymentAdvice."); if (pIdRegular < 0) throw new ApasInvaidOperationException( "Invalid Operation: Unable to create a classfee without " + "a vailid regular class."); IdRegular = pIdRegular; Id = 0; Absence = 0; Prorate = 0; Makeup = 0; Forfeit = 0; Credit = 0; CreditAdjustment = 0; NextMonthCredit = 0; PayableCredit = 0; PerLessonFee = 0; PayableFee = 0; PrivateRemark = null; PublicRemark = null; PaymentAdviceText = null; IsExcluded = 0; ApasConfigurationManager cfg=new ApasConfigurationManager(); ColorCode = cfg.getConfigValue("DefaultNewColor"); Status = ClassFeeStatus.ClassFeeStatusDictionary["New: Unapproved"]; FeeDeviations = new Dictionary<int, FeeDeviationPayableFee>(); parentPaymentAdvice.AddClassFee(this); }
/// <summary> /// Create "new" ClassFee from a template previoius ClassFee /// </summary> /// <param name="parentPaymentAdvice">Parent PaymentAdvice: must assign to create ClassFee</param> /// <param name="prevClassFee">Template previous ClassFee to copy necessary fields from</param> public ClassFee(PaymentAdvice parentPaymentAdvice, ClassFee prevClassFee) { ApasConfigurationManager cfg = new ApasConfigurationManager(); if (parentPaymentAdvice == null) throw new ApasInvaidOperationException( "Invalid Operation: Unable to create a ClassFee without " + "a vailid parent PaymentAdvice."); if (prevClassFee == null || prevClassFee.Validate().Count>0) throw new ApasInvaidOperationException( "Invalid Operation: Unable to create a ClassFee. Given " + "ClassFee template is not valid."); IdRegular = prevClassFee.IdRegular; Id = 0; PrivateRemark = prevClassFee.PrivateRemark; PublicRemark = prevClassFee.PublicRemark; ColorCode = prevClassFee.ColorCode ; Absence = 0; Prorate = 0; Makeup = 0; Forfeit = 0; Credit = 0; CreditAdjustment = 0; NextMonthCredit = 0; PayableCredit = 0; PerLessonFee = 0; PayableFee = 0; PaymentAdviceText = null; IsExcluded = 0; FeeDeviations = new Dictionary<int, FeeDeviationPayableFee>(); if (prevClassFee.Status.Name == "Withdrawn: Unapproved" || prevClassFee.Status.Name == "Withdrawn: Approved") { Status = ClassFeeStatus.ClassFeeStatusDictionary["New: Unapproved"]; ColorCode = cfg.getConfigValue("DefaultNewColor"); } else Status = ClassFeeStatus.ClassFeeStatusDictionary["Normal"]; parentPaymentAdvice.AddClassFee(this); Save(); foreach (FeeDeviationPayableFee fd in prevClassFee.FeeDeviations.Values) { if (fd.IsRecurring == 1) { FeeDeviationPayableFee newFD = new FeeDeviationPayableFee(this, fd); newFD.Save(); } } }