Пример #1
0
        public List <string> Validate()
        {
            Agreement_Number = Agreement_Number.Trim();
            Builder_Name     = Builder_Name.Trim().ToUpper();
            List <string> errors = new List <string>();

            if (Allocation_Amount > 0)
            {
                var currentAgreement = CombinedAllocation.Get(Agreement_Number).First();
                if (Id.HasValue)
                {
                    var     currentAllocation = Get(Agreement_Number, Id.Value);
                    decimal p = currentAgreement.Developer_Amount_Currently_Allocated - currentAllocation.Allocation_Amount + Allocation_Amount;
                    if (currentAgreement.Agreement_Amount < p)
                    {
                        errors.Add("This allocation is for an amount greater than the amount remaining for this Developer.  Please check your numbers and try again.");
                    }
                }
                else
                {
                    // this allocation has not yet been saved
                    decimal p = currentAgreement.Developer_Amount_Currently_Allocated + Allocation_Amount;
                    if (currentAgreement.Agreement_Amount < p)
                    {
                        errors.Add("This allocation is for an amount greater than the amount remaining for this Developer.  Please check your numbers and try again.");
                    }
                }
            }
            if (Agreement_Number.Length == 0)
            {
                errors.Add("No Agreement Number was specified.");
            }
            if (Builder_Name.Length == 0)
            {
                errors.Add("No Builder Name was specified.");
            }
            if (Allocation_Amount < 0)
            {
                errors.Add("The Amount Allocated cannot be a negative number.");
            }
            if (Allocation_Amount < Amount_Currently_Allocated)
            {
                errors.Add("The Amount Allocated cannot be set to less than the amount currently allocated to Permits.");
            }
            return(errors);
        }
Пример #2
0
        public bool Update(Models.UserAccess ua, string IpAddress)
        {
            var current = PermitAllocation.Get(Permit_Number);

            if (current == null)
            {
                return(false);                // some kind of error occurred while getting the current permit data.
            }
            if (current.Audit_Log.Length > 0) // this record already exists
            {
                if (!Data_Changed(current))
                {
                    return(true);                // if the data doesn't change, we don't need to do anything.
                }
                string s = "";
                if (Amount_Allocated_Formatted != current.Amount_Allocated_Formatted)
                {
                    // If the amount changes, we will also need to reapply the credit
                    // to the ccCashierItem table.
                    s         = Constants.Create_Audit_Log(ua.user_name, "Amount Allocated", current.Amount_Allocated_Formatted, Amount_Allocated_Formatted);
                    Audit_Log = s + '\n' + current.Audit_Log;
                }

                if (Builder_Id != current.Builder_Id)
                {
                    // we're going to get all of the combined allocation data now
                    // in order to create a proper audit log
                    var data           = CombinedAllocation.Get();
                    var currentBuilder = (from d in data
                                          where d.Builder_Id == current.Builder_Id
                                          select d).First();

                    var newBuilder = (from d in data
                                      where d.Builder_Id == Builder_Id
                                      select d).First();
                    // check to see if the builder name changed here
                    var currentBuilderName = currentBuilder.Builder_Name + " (" + currentBuilder.Builder_Id + ")";
                    var newBuilderName     = newBuilder.Builder_Name + " (" + newBuilder.Builder_Id + ")";
                    s         = Constants.Create_Audit_Log(ua.user_name, "Builder", currentBuilderName, newBuilderName);
                    Audit_Log = s + '\n' + current.Audit_Log;

                    // check to see if the agreement changed
                    if (currentBuilder.Agreement_Number != newBuilder.Agreement_Number)
                    {
                        s         = Constants.Create_Audit_Log(ua.user_name, "Agreement Number", currentBuilder.Agreement_Number, newBuilder.Agreement_Number);
                        Audit_Log = s + '\n' + current.Audit_Log;
                    }
                }
            }
            else // this is a new permit number
            {
                Audit_Log = Constants.Create_Audit_Log(ua.user_name, "Record Created");
                // will also need to apply the credit.
            }
            if (!SaveAllocation())
            {
                return(false);
            }
            var permit = PermitImpactFee.Get(Permit_Number, "IFCR");

            if (!permit.ItemId.HasValue)
            {
                return(false);
            }
            if (permit.ImpactFee_Amount < this.Amount_Allocated)
            {
                // This is a partial impact fee credit.
                // Those credits are applied when the remainder is paid.
                return(true);
            }
            return(ApplyCreditPayment(permit, IpAddress, ua));
        }