Пример #1
0
        /// <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();
                }
            }
        }