Esempio n. 1
0
        public bool ApplyWaiver(PermitImpactFee permit, string IpAddress, UserAccess ua)
        {
            if (permit.ImpactFee_Amount != Amount)
            {
                // Partial Waiver Process:
                // This process needs to do the following:
                // 1. Reduce the amount of the current impact fee (captured in permit) by the amount in permit.
                // 2. Insert a new charge that has the following properties:
                //    a. Same Catcode as the original impact fee
                //    b. Same amount in permit object
                //    c. Can probably do this easily with a Select Insert.
                // 3. Capture the freshly inserted row's ItemId.
                // 4. Use the waiver/exemption process on the new ItemId
                // So largely, this process will just pre-empt the ApplyWaiver process.
                // We should just be able to update the permit object with the new item id and
                // proceed as normal.
                var NewItemId = PartialImpactFeeHandling(permit, Amount);
                if (NewItemId == -1)
                {
                    Constants.Log("Error Applying Partial Waiver", permit.ItemId.Value.ToString(), permit.Permit_Number, permit.ImpactFee_Amount_Formatted, "");
                }
                permit.ItemId = NewItemId; // Set it to the newly created row
            }
            var nt = new Claypay.NewTransaction();

            nt.ItemIds.Add(permit.ItemId.Value);

            var ifPayment = new Claypay.Payment(Payment_Type)
            {
                Amount         = permit.ImpactFee_Amount.Value,
                AmountTendered = 0,
                AmountApplied  = permit.ImpactFee_Amount.Value,
                Validated      = true
            };

            nt.TransactionCashierData.PayerCompanyName = permit.Contractor_Name;
            nt.Payments.Add(ifPayment);
            nt.TransactionCashierData.ipAddress   = IpAddress;
            nt.TransactionCashierData.CurrentUser = ua;
            return(nt.SaveTransaction());
        }
Esempio n. 2
0
        public string Validate(PermitImpactFee permit)
        {
            Payment_Type = Get_Payment_Type();
            if (Payment_Type == Claypay.Payment.payment_type.impact_fee_credit)
            {
                return("Cannot apply Impact Fee Credits using this process.");
            }
            if (Amount > permit.ImpactFee_Amount)
            {
                return($"You cannot waive an amount greater than the amount of the impact fee.  Amount waived: {Amount.ToString("C2")}, Impact fee Amount: {permit.ImpactFee_Amount_Formatted}");
            }
            //if(permit.ImpactFee_Amount != Amount)
            //{
            //  return "The Impact Fee amount provided does not match. Please check your permit number and try again.  If this issue persists, please contact the helpdesk.";
            //}
            if (permit.ImpactFee_Amount <= 0)
            {
                return("The Impact Fee Amount cannot be less than or equal to zero.");
            }

            return("");
        }
Esempio n. 3
0
        public List <string> ValidateImpactFeeCredits()
        {
            List <string> errors = new List <string>();

            Permit_Number = Permit_Number.Trim();
            var current = PermitAllocation.Get(Permit_Number);
            var pif     = PermitImpactFee.Get(Permit_Number, "IFCR");

            if (pif.Error_Text.Length > 0)
            {
                errors.Add(pif.Error_Text);
            }
            if (current.Permit_Number.Length == 0)
            {
                // the checks we perform in this block are for
                // new credits only
                if (pif.Cashier_Id.Length > 0)
                {
                    errors.Add("This fee has already been paid, so it is not eligible for the impact fee credit process.");
                }
            }
            if (Builder_Id < 0)
            {
                errors.Add("The Builder Id provided was invalid.");
            }
            if (Permit_Number.Length == 0)
            {
                errors.Add("No Permit Number was specified.");
            }
            if (Permit_Number.Length != 8)
            {
                errors.Add("Permit Number was not 8 digits.");
            }
            if (Amount_Allocated < 0)
            {
                errors.Add("The Amount Allocated cannot be a negative number.");
            }
            return(errors);
        }
Esempio n. 4
0
        public static PermitImpactFee Get(
            string Permit_Number,
            string Search_Type,
            string Agreement_Number = "")
        {
            var dp = new DynamicParameters();

            dp.Add("@Permit_Number", Permit_Number);
            List <string> catCodes = new List <string>();

            if (Search_Type == "IFWS")
            {
                catCodes.Add("IFSCH"); // School Impact Fee
            }
            else
            {
                catCodes.Add("IFRD2");
                catCodes.Add("IFRD3");
                catCodes.Add("MFD1");
                catCodes.Add("MFD2");
                catCodes.Add("MFD4");
                catCodes.Add("MFD7");
                catCodes.Add("MFD10");
            }
            dp.Add("@CatCodes", catCodes);
            string query = @"
        WITH void_charges AS (

          SELECT
            CashierId
          FROM ccCashier
          WHERE IsVoided = 1
        )

        SELECT
          M.PermitNo Permit_Number,
          M.IssueDate Issue_Date,
          M.VoidDate Void_Date,
          B.ContractorId Contractor_Id,
          ISNULL(LTRIM(RTRIM(C.CompanyName)), '') Contractor_Name,
          B.X,
          B.Y,
          CI.ItemId ItemId,
          CI.Total ImpactFee_Amount,
          LTRIM(RTRIM(CI.CashierId)) Cashier_Id,
          ISNULL(CP.PmtType, '') Payment_Type,
          PA.Amount_Allocated
        FROM bpMASTER_PERMIT M
        INNER JOIN bpBASE_PERMIT B ON M.BaseID = B.BaseID
        LEFT OUTER JOIN clContractor C ON B.ContractorId = C.ContractorCd
        LEFT OUTER JOIN ccCashierItem CI ON M.PermitNo = CI.AssocKey AND CI.CatCode IN @CatCodes
        LEFT OUTER JOIN ccCashier CC ON CI.CashierId = CC.CashierId
        LEFT OUTER JOIN void_charges VC ON VC.CashierId = CI.CashierId
        LEFT OUTER JOIN ImpactFees_Permit_Allocations PA ON M.PermitNo = PA.Permit_Number
        LEFT OUTER JOIN ccCashierPayment CP ON CP.OTid = CC.OTId
        WHERE M.PermitNo=@Permit_Number
          AND VC.CashierId IS NULL;";

            var permits = Constants.Get_Data <PermitImpactFee>(query, dp);

            // if we get multiple permits back for one permit number, we've most likely got multiple impact fees on the permit.
            if (permits.Count() >= 1)
            {
                if (Search_Type == "IFEX")
                {
                    permits.RemoveAll(prmt => prmt.Payment_Type == "IFCR");
                }
                var permit = permits.First();
                if (permits.Count > 1)
                {
                    permit.Error_Text = "This permit has multiple Impact fees.  If this is not the case, please contact MIS with this permit number and error message.";
                    return(permit);
                }
                permit.Validate(Agreement_Number);
                return(permit);
            }
            var p = new PermitImpactFee
            {
                Error_Text = $"Permit Number {Permit_Number} was not found."
            };

            return(p);
        }
Esempio n. 5
0
        public static int PartialImpactFeeHandling(PermitImpactFee permit, decimal Amount)
        {
            var dp = new DynamicParameters();

            dp.Add("@NewItemId", dbType: DbType.Int32, direction: ParameterDirection.Output);
            dp.Add("@ItemId", permit.ItemId.Value);
            dp.Add("@WaivedAmount", Amount);
            string sql = @"
        SET @WaivedAmount = CAST(@WaivedAmount AS DECIMAL(10, 2));
        UPDATE ccCashierItem
        SET 
          BaseFee = BaseFee - @WaivedAmount,
          Total = Total - @WaivedAmount
        WHERE 
          ItemId=@ItemId;

        INSERT INTO [dbo].[ccCashierItem]
          ([OTId]
          ,[OperId]
          ,[CatCdID]
          ,[CatCode]
          ,[Narrative]
          ,[Assoc]
          ,[AssocKey]
          ,[Variable]
          ,[BaseFee]
          ,[Total]
          ,[TimeStamp]
          ,[Audit]
          ,[Flag]
          ,[Recon]
          ,[ReconInit]
          ,[NTUser]
          ,[UnCollectable])

        SELECT
          0,
          OperId,
          CatCdID,
          CatCode,
          Narrative,
          Assoc,
          AssocKey,
          Variable,
          @WaivedAmount,
          @WaivedAmount,
          GETDATE(),
          Audit,
          Flag,
          Recon,
          ReconInit,
          'claypay',
          UnCollectable
        FROM ccCashierItem
        WHERE ItemId=@ItemId;

        SET @NewItemId = @@IDENTITY;";

            try
            {
                int i = Constants.Exec_Query(sql, dp);
                if (i != -1)
                {
                    int newItemId = dp.Get <int>("@NewItemId");
                    return(newItemId);
                }
                return(-1);
            }
            catch (Exception ex)
            {
                Constants.Log(ex, sql);
                return(-1);
                //TODO: add rollback in StartTransaction function
            }
        }
Esempio n. 6
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));
        }