コード例 #1
0
        public HostDeposit CreateHostDeposit(HostPaymentEntity hostPaymentEntity, Address address)
        {
            var hostPaymentFactory  = new HostPaymentFactory();
            var domainObjectToMapTo = new HostDeposit();

            hostPaymentFactory.CreateHostDeposit(hostPaymentEntity, domainObjectToMapTo, address);
            domainObjectToMapTo.DepositApplicablityMode  = (DepositType)hostPaymentEntity.DepositType;
            domainObjectToMapTo.DepositFullRefundDueDays = hostPaymentEntity.DepositFullRefundDays;
            return(domainObjectToMapTo);
        }
コード例 #2
0
        public HostPaymentEntity CreateHostPayment(HostDeposit hostDeposit)
        {
            var hostPaymentFactory = new HostPaymentFactory();
            var entityToMapTo      = hostPaymentFactory.CreateHostPaymentEntity(hostDeposit);

            entityToMapTo.IsDeposit             = true;
            entityToMapTo.DepositType           = (long)hostDeposit.DepositApplicablityMode;
            entityToMapTo.DepositFullRefundDays = hostDeposit.DepositFullRefundDueDays;
            entityToMapTo.IsNew = hostDeposit.Id == 0;
            return(entityToMapTo);
        }
コード例 #3
0
        public HostDeposit Save(HostDeposit hostDeposit)
        {
            NullArgumentChecker.CheckIfNull(hostDeposit, "hostDeposit");

            var hostPaymentEntity = _hostDepositFactory.CreateHostPayment(hostDeposit);

            using (IDataAccessAdapter myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                if (!myAdapter.SaveEntity(hostPaymentEntity, true))
                {
                    throw new PersistenceFailureException();
                }
                var address = _addressRepository.GetAddress(hostPaymentEntity.MailingAddressId.Value);
                return(_hostDepositFactory.CreateHostDeposit(hostPaymentEntity, address));
            }
        }
コード例 #4
0
        public bool UpdateHostPaymentStatusAndNotes(long hostPaymentId, decimal amount, int hostPaymentStatus, int hostPaymentType, string notes, string paymentDate, long organizationRoleUserId, long hostId, string taxIdNumber, bool isDeposit)
        {
            DateTime transactionDate      = DateTime.Now;
            int      hostPaymentStatusOld = hostPaymentStatus;

            if (!string.IsNullOrEmpty(paymentDate))
            {
                transactionDate = Convert.ToDateTime(paymentDate);
            }

            try
            {
                HostDeposit       hostDepositInfo = null;
                HostPayment       hostPaymentInfo = null;
                HostPaymentStatus currentPaymentStatus;

                if (isDeposit)
                {
                    hostDepositInfo = _hostDepositRepository.GetByHostDepositById(hostPaymentId);
                    if (hostDepositInfo != null && hostDepositInfo.DepositApplicablityMode == DepositType.Refunded && hostPaymentStatus == (int)HostPaymentStatus.Paid)
                    {
                        hostPaymentStatus = (int)HostPaymentStatus.Receivable;
                    }
                    currentPaymentStatus = hostDepositInfo != null ? hostDepositInfo.Status : HostPaymentStatus.Pending;
                }
                else
                {
                    hostPaymentInfo      = _hostPaymentRepository.GetHostPaymentById(hostPaymentId);
                    currentPaymentStatus = hostPaymentInfo != null ? hostPaymentInfo.Status : HostPaymentStatus.Pending;
                }

                //using (var transaction = new TransactionScope())
                //{
                // Update Host Payment
                _hostPaymentRepository.UpdateHostPaymentStatusAndNotes(hostPaymentId, amount, hostPaymentStatus);

                if (hostPaymentStatusOld == (int)HostPaymentStatus.Paid || hostPaymentStatusOld == (int)HostPaymentStatus.Refunded)
                {
                    var hostPaymentTransaction = new HostPaymentTransaction()
                    {
                        HostPaymentId         = hostPaymentId,
                        TransactionType       = (HostPaymentStatus)hostPaymentStatusOld,
                        TransactionMethod     = (HostPaymentType)hostPaymentType,
                        Amount                = amount,
                        Notes                 = notes,
                        TransactionDate       = transactionDate,
                        TransactionRecordedBy = organizationRoleUserId > 0
                                                    ? new OrganizationRoleUser(
                            organizationRoleUserId)
                                                    : null
                    };

                    var hostPaymentTransactionExisting =
                        _hostPaymentTransactionRepository.GetByIdAndStatus(hostPaymentId, hostPaymentStatusOld);
                    if (hostPaymentTransactionExisting == null)
                    {
                        if ((hostPaymentStatusOld == (int)HostPaymentStatus.Paid &&
                             currentPaymentStatus != HostPaymentStatus.Paid) ||
                            (hostPaymentStatusOld == (int)HostPaymentStatus.Refunded &&
                             currentPaymentStatus != HostPaymentStatus.Refunded)
                            )
                        {
                            _hostPaymentTransactionRepository.Save(hostPaymentTransaction);
                        }
                    }
                    else
                    {
                        if ((hostPaymentStatusOld == (int)HostPaymentStatus.Paid &&
                             currentPaymentStatus != HostPaymentStatus.Paid) ||
                            (hostPaymentStatusOld == (int)HostPaymentStatus.Refunded &&
                             currentPaymentStatus != HostPaymentStatus.Refunded)
                            )
                        {
                            _hostPaymentTransactionRepository.UpdateHostPaymentTransactionByIdAndStatus(
                                hostPaymentTransaction);
                        }
                    }
                }
                // delete (Paid to Pending(Delete Paid))
                if ((currentPaymentStatus == HostPaymentStatus.Paid) && (hostPaymentStatusOld == (int)HostPaymentStatus.Pending))
                {
                    _hostPaymentTransactionRepository.DeleteByIdAndStatus(hostPaymentId, currentPaymentStatus);
                }
                // delete (Refunded to Paid (Delete Refunded))
                else if ((currentPaymentStatus == HostPaymentStatus.Refunded) && (hostPaymentStatusOld == (int)HostPaymentStatus.Paid))
                {
                    _hostPaymentTransactionRepository.DeleteByIdAndStatus(hostPaymentId, currentPaymentStatus);
                }

                // delete (Refunded to Pending (Both records))
                //else if ((currentPaymentStatus == HostPaymentStatus.Refunded) && (hostPaymentStatus == (int)HostPaymentStatus.Pending))
                //    {
                //        _hostPaymentTransactionRepository.DeleteByIdAndStatus(hostPaymentId, currentPaymentStatus);
                //        _hostPaymentTransactionRepository.DeleteByIdAndStatus(hostPaymentId, HostPaymentStatus.Paid);
                //    }

                if (!string.IsNullOrEmpty(taxIdNumber))
                {
                    _hostRepository.UpdateHostTaxIdNumber(hostId, taxIdNumber);
                }
                //transaction.Complete();
                //}
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #5
0
        public static List <EventHostDepositViewData> HostDepositViewData(this IEnumerable <HostDeposit> hostDeposits, IEnumerable <Event> events, IEnumerable <Host> hosts)
        {
            var eventHostDepositViewDatas = new List <EventHostDepositViewData>();

            foreach (var hostDeposit in hostDeposits)
            {
                if (hostDeposit != null)
                {
                    HostDeposit deposit = hostDeposit;

                    var currentEvent = events.SingleOrDefault(e => e.Id == deposit.EventId);
                    var host         = hosts.SingleOrDefault(h => h.Id == deposit.HostId);

                    if (host != null && currentEvent != null)
                    {
                        var eventHostDepositViewData = new EventHostDepositViewData
                        {
                            IsDeposit   = true,
                            EventId     = hostDeposit.EventId,
                            EventDate   = currentEvent.EventDate,
                            EventStatus = currentEvent.Status,
                            TaxIdNumber =
                                !string.IsNullOrEmpty(host.TaxIdNumber)
                                    ? host.TaxIdNumber
                                    : string.Empty,
                            Name = events.Single(e => e.Id == deposit.EventId).Name,
                            EventStreetAddressLine1 = host.Address.StreetAddressLine1,
                            EventStreetAddressLine2 = host.Address.StreetAddressLine2,
                            EventCity               = host.Address.City,
                            EventState              = host.Address.State,
                            EventZip                = host.Address.ZipCode != null ? host.Address.ZipCode.Zip:string.Empty,
                            EventCountry            = host.Address.Country,
                            HostId                  = hostDeposit.HostId,
                            Amount                  = hostDeposit.Amount,
                            PaymentMode             = hostDeposit.PaymentMode,
                            DueDate                 = hostDeposit.DueDate,
                            PayableTo               = hostDeposit.PayableTo,
                            MailingAttentionOf      = hostDeposit.MailingAttentionOf,
                            MailingOrganizationName =
                                hostDeposit.MailingOrganizationName,
                            AddressId          = hostDeposit.PaymentMailingAddress.Id,
                            StreetAddressLine1 =
                                hostDeposit.PaymentMailingAddress.StreetAddressLine1,
                            StreetAddressLine2 =
                                hostDeposit.PaymentMailingAddress.StreetAddressLine2,
                            City     = hostDeposit.PaymentMailingAddress.City,
                            State    = hostDeposit.PaymentMailingAddress.State,
                            Zip      = hostDeposit.PaymentMailingAddress.ZipCode != null ?hostDeposit.PaymentMailingAddress.ZipCode.Zip:string.Empty,
                            Country  = hostDeposit.PaymentMailingAddress.Country,
                            Status   = hostDeposit.Status,
                            IsActive = hostDeposit.IsActive,
                            Id       = hostDeposit.Id,
                            DepositFullRefundDueDays =
                                hostDeposit.DepositFullRefundDueDays > 0
                                    ? (int)hostDeposit.DepositFullRefundDueDays
                                    : 0,
                            DepositFullRefundDueDate =
                                hostDeposit.DepositFullRefundDueDays > 0
                                    ? events.Single(e => e.Id == deposit.EventId).
                                EventDate.AddDays(
                                    (long)
                                    -hostDeposit.DepositFullRefundDueDays)
                                    : (DateTime?)null,
                            DepositApplicablityMode =
                                hostDeposit.DepositApplicablityMode,
                            HostPaymentTransactions =
                                hostDeposit.HostPaymentTransactions
                        };
                        eventHostDepositViewDatas.Add(eventHostDepositViewData);
                    }
                }
            }
            return(eventHostDepositViewDatas);
        }