Example #1
0
        public JsonResult Update(ThirdPartyPaymentModel model)
        {
            var thirdpayment = PaymentService.FindThirdPartyPaymentById(model.ThirdPartyScheduleId);

            Dictionary <string, object> dicThirdPartySchedule = new Dictionary <string, object>();

            ActivityLogService.CreateDictionaryForThirdParty(ref dicThirdPartySchedule, thirdpayment);

            ActivityLogService.CreateActivityLog(new ActivityLog {
                Comment      = XmlHelper.SerializeKeyValuePairs("ThirdPartySchedule", dicThirdPartySchedule),
                ObjectTypeId = (int)AuditObjectType.PaymentThirdPartySchedule,
                ObjectId     = thirdpayment.ThirdPartyScheduleId.ToString()
            }, "ThirdPartySchedule.Update");

            thirdpayment.FirstInstallmentAmount  = 0;
            thirdpayment.SecondInstallmentAmount = 0;
            thirdpayment.SinglePaymentAmount     = 0;

            if (model.IsSinglePayment)
            {
                thirdpayment.SinglePaymentAmount = model.SinglePaymentAmount;
                thirdpayment.OrderAmount         = model.SinglePaymentAmount;
            }
            else
            {
                thirdpayment.FirstInstallmentAmount  = model.FirstInstallmentAmount;
                thirdpayment.SecondInstallmentAmount = model.SecondInstallmentAmount;
                thirdpayment.OrderAmount             = model.FirstInstallmentAmount + model.SecondInstallmentAmount;
            }
            thirdpayment.Comment          = model.Comment;
            thirdpayment.ModifiedDateTime = System.DateTime.UtcNow;
            thirdpayment.ModifiedBy       = WebHelper.GetUserName();

            PaymentService.ModifyThirdPayment(thirdpayment);

            return(Json(new BasicDataTablesResult(new { Status = "OK" })));
        }
Example #2
0
        public JsonResult Insert(ThirdPartyPaymentModel model)
        {
            int?newEntityId = null;
            var entity      = new Entity();
            var address     = new Address();

            if (model.EntityTypeId == 1)
            {
                entity = new Entity
                {
                    SourceId       = 8,
                    FirstName      = model.CustodyFirstName,
                    MiddleName     = model.CustodySecondName,
                    LastName       = model.CustodyFirstLastName,
                    SecondLastName = model.CustodySecondLastName,
                    FullName       = string.Format("{0} {1} {2} {3}", model.CustodyFirstName, model.CustodySecondName, model.CustodyFirstLastName, model.CustodySecondLastName)
                };

                address = new Address
                {
                    EntityId    = entity.EntityId,
                    SourceId    = 8,
                    FullAddress = string.Format("{0} {1}", model.CustodyAddressLine1, model.CustodyAddressLine2),
                    Line1       = model.CustodyAddressLine1,
                    Line2       = model.CustodyAddressLine2,
                    CityId      = model.CustodyCityId,
                    ZipCode     = model.CustodyPostalCode == null ? string.Empty : model.CustodyPostalCode.Trim().Replace('-', '\0').PadRight(9, '0').Substring(0, 5),
                    ZipCodeExt  = model.CustodyPostalCode == null ? string.Empty : model.CustodyPostalCode.Trim().Replace('-', '\0').PadRight(9, '0').Substring(5, 4)
                };
                entity.Addresses.Add(address);

                EntityService.CreateEntity(entity);

                newEntityId = entity.EntityId;
            }
            else if (model.EntityTypeId == 2)
            {
                entity = new Entity
                {
                    SourceId = 9,
                    FullName = model.EntityName
                };

                address = new Address
                {
                    SourceId    = 9,
                    EntityId    = entity.EntityId,
                    FullAddress = string.Format("{0} {1}", model.EntityAddressLine1, model.EntityAddressLine2),
                    Line1       = model.EntityAddressLine1,
                    Line2       = model.EntityAddressLine2,
                    CityId      = model.EntityCityId,
                    ZipCode     = model.EntityPostalCode == null ? string.Empty : model.EntityPostalCode.Trim().Replace('-', '\0').PadRight(9, '0').Substring(0, 5),
                    ZipCodeExt  = model.EntityPostalCode == null ? string.Empty : model.EntityPostalCode.Trim().Replace('-', '\0').PadRight(9, '0').Substring(5, 4)
                };
                entity.Addresses.Add(address);

                EntityService.CreateEntity(entity);

                newEntityId = entity.EntityId;
            }
            else if (model.EntityTypeId == 3)
            {
                newEntityId = model.CourtId;
            }

            decimal amount = decimal.Zero;

            if (model.SinglePaymentAmount.HasValue)
            {
                amount = model.SinglePaymentAmount.Value;
            }
            else
            {
                amount = model.FirstInstallmentAmount.GetValueOrDefault(decimal.Zero) + model.SecondInstallmentAmount.GetValueOrDefault(decimal.Zero);
            }

            var thirdPartySchedule = new ThirdPartySchedule
            {
                CaseId                  = model.CaseId,
                CaseDetailId            = model.CaseDetailId,
                EntityId_RemitTo        = model.EntityTypeId == 2 || model.EntityTypeId == 3 ? newEntityId : null,
                ClaimNumber             = model.ClaimNumber,
                OrderIdentifier         = model.OrderIdentifier,
                TerminationFlag         = model.TerminationFlag,
                EffectiveDate           = model.EffectiveDate,
                TerminationOrderNumber  = model.TerminationOrderNumber,
                SinglePaymentAmount     = model.SinglePaymentAmount,
                FirstInstallmentAmount  = model.FirstInstallmentAmount,
                SecondInstallmentAmount = model.SecondInstallmentAmount,
                Comment                 = model.Comment,
                OrderAmount             = model.OrderAmount,
                TerminationDate         = model.TerminationDate,
                CreatedDateTime         = System.DateTime.UtcNow,
                CreatedBy               = WebHelper.GetUserName(),
            };

            PaymentService.CreateThirdPayment(thirdPartySchedule);

            return(Json(new BasicDataTablesResult(new { Status = "OK" })));
        }