Exemplo n.º 1
0
        protected override void MapDomainFields(ShippingDetailEntity entity,
                                                ShippingDetail domainObjectToMapTo)
        {
            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(entity.OrganizationRoleUserCreatorId, entity.DateCreated, entity.ModifiedBy, entity.DateModified);

            domainObjectToMapTo.Id = entity.ShippingDetailId;

            domainObjectToMapTo.DataRecorderMetaData = dataRecorderMetaData;

            domainObjectToMapTo.ShipmentDate = entity.ShipmentDate;


            domainObjectToMapTo.ShippingOption = entity.ShippingOption != null
                                                     ? _shippingOptionMapper.Map(entity.ShippingOption)
                                                     : new ShippingOption(entity.ShippingOptionId);

            domainObjectToMapTo.ShippingAddress = entity.Address != null
                ? _addressFactory.CreateAddressDomain(entity.Address) : new Address(entity.ShippingAddressId);

            domainObjectToMapTo.Status = (ShipmentStatus)entity.Status;

            domainObjectToMapTo.ActualPrice            = entity.ActualPrice;
            domainObjectToMapTo.IsExclusivelyRequested = entity.IsExclusivelyRequested;
            domainObjectToMapTo.ShippedByOrgRoleUserId = entity.ShippedByOrgRoleUserId;
        }
Exemplo n.º 2
0
        public void MapSetsDataRecorderMetaDataToReturnedObjectOfMetaDataFactoryCall()
        {
            const int organizationRoleUserCreatorId = 3;
            var       dateCreated  = new DateTime(2003, 1, 1);
            var       refundEntity = new RefundEntity {
                OrganizationRoleUserCreatorId =
                    organizationRoleUserCreatorId, DateCreated = dateCreated
            };
            var expectedDataRecorderMetaData = new DataRecorderMetaData
            {
                DataRecorderCreator = new OrganizationRoleUser(organizationRoleUserCreatorId),
                DateCreated         = dateCreated
            };

            Expect.Call(_dataRecorderMetaDataFactory.CreateDataRecorderMetaData
                            (organizationRoleUserCreatorId, dateCreated)).Return(expectedDataRecorderMetaData);

            _mocks.ReplayAll();
            Refund refund = _refundFactory.Map(refundEntity);

            _mocks.VerifyAll();

            Assert.AreEqual(expectedDataRecorderMetaData, refund.DataRecorderMetaData,
                            "Refund DataRecorderMetaData mapped incorrectly.");
        }
Exemplo n.º 3
0
        public void MapSetsDataRecorderMetaDataToResultOfMetaDataFactoryCall()
        {
            const int organizationRoleUserCreatorId = 23;
            var       dateCreated = new DateTime(2001, 1, 1);
            var       expectedDataRecorderMetaData = new DataRecorderMetaData();
            var       orderDetailEntity            = GetValidOrderDetailEntity();

            orderDetailEntity.DateCreated = dateCreated;
            orderDetailEntity.OrganizationRoleUserCreatorId = organizationRoleUserCreatorId;

            Expect.Call(_mockedDataRecorderMetaDataFactory.CreateDataRecorderMetaData
                            (organizationRoleUserCreatorId, dateCreated)).
            Return(expectedDataRecorderMetaData);
            Expect.Call(_mockedOrderItemStatusFactory.CreateOrderItemStatus
                            ((OrderItemType)orderDetailEntity.OrderItem.Type, orderDetailEntity.Status)).
            Return(FakeOrderItemStatus.StatusZero);

            _mocks.ReplayAll();
            OrderDetail orderDetail = _mapper.Map(orderDetailEntity);

            _mocks.VerifyAll();

            Assert.AreEqual(expectedDataRecorderMetaData, orderDetail.DataRecorderMetaData,
                            "The OrderDetail's DataRecorderMetaData was not set correctly.");
        }
Exemplo n.º 4
0
        public void MakePaymentPersistsPaymentToStorageWhenEverythingIsValid()
        {
            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(VALID_ORGANIZATION_ROLE_USER);

            var check = new Check
            {
                DataRecorderMetaData = dataRecorderMetaData,
                Amount    = 5.01m,
                PayableTo = "PayableTo"
            };

            var medicalVendorPayment = new MedicalVendorPayment
            {
                DataRecorderMetaData = dataRecorderMetaData,
                PaymentStatus        = PaymentStatus.Unpaid,
            };

            medicalVendorPayment.PaymentInstruments.Add(check);
            var medicalVendorInvoiceIdsToApplyPaymentTo = new List <long> {
                VALID_MEDICAL_VENDOR_INVOICE_ID
            };

            _medicalVendorPaymentRepository.MakePayment(medicalVendorPayment, medicalVendorInvoiceIdsToApplyPaymentTo);
        }
Exemplo n.º 5
0
        public OrderDetail CreateNewOrderDetailforCanellationItem(decimal cancellationFee, long orderId, long forOrganizationRoleUserId,
                                                                  long dataRecorderCreatorId)
        {
            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(dataRecorderCreatorId);

            OrderItemStatus orderItemStatus =
                _orderItemStatusFactory.CreateOrderItemStatus(OrderItemType.CancellationFee,
                                                              (int)OrderStatusState.FinalSuccess); // orFinalFailure

            return(new OrderDetail
            {
                Description = "Cancellation fee charged",
                Price = cancellationFee,
                Quantity = 1,
                DataRecorderMetaData = dataRecorderMetaData,
                ForOrganizationRoleUserId = forOrganizationRoleUserId,
                OrderItemStatus = orderItemStatus,
                OrderId = orderId,
                OrderItemId = 0, // Need a new Order Item
                SourceCodeOrderDetail = null,
                EventCustomerOrderDetail = null,
                ShippingDetailOrderDetails = null,
                DetailType = OrderItemType.CancellationFee
            });
        }
Exemplo n.º 6
0
        public void MakePaymentDoesNotBombWhenAllParametersAreCorrectAndPersistenceSucceeds()
        {
            var dataRecorderMetaData = new DataRecorderMetaData
            {
                DataRecorderCreator  = new OrganizationRoleUser(),
                DataRecorderModifier = new OrganizationRoleUser()
            };
            var check = new Check {
                DataRecorderMetaData = dataRecorderMetaData
            };
            var medicalVendorPayment = new MedicalVendorPayment
            {
                PaymentInstruments = new List <PaymentInstrument> {
                    check
                }
            };
            var medicalVendorPaymentEntity = new PhysicianPaymentEntity();

            ExpectGetDataAccessAdapterAndDispose();
            ExpectSaveEntity(true, true, medicalVendorPaymentEntity);
            ExpectSaveEntityTransaction(medicalVendorPayment, medicalVendorPaymentEntity, false);
            ExpectSaveEntityCollection(_validInvoiceIds.Count);
            ExpectSaveEntity(true, true);
            ExpectSaveEntity(true);
            Expect.Call(_validator.IsValid(medicalVendorPayment)).Return(true);

            _mocks.ReplayAll();
            _medicalVendorPaymentRepository.MakePayment(medicalVendorPayment, _validInvoiceIds);
            _mocks.VerifyAll();
        }
Exemplo n.º 7
0
        private OrderDetail GetRefunTypeOrderLineItem(decimal amount, string reasonForRefund, long orderId, long customerId, long processedbyOrgRoleUserId)
        {
            var dataRecorder = new DataRecorderMetaData(processedbyOrgRoleUserId, DateTime.Now, null);
            var refund       = new Refund()
            {
                DataRecorderMetaData = dataRecorder,
                Notes        = reasonForRefund,
                RefundReason = RefundReason.ProcessedRefundRequest,
                Price        = amount
            };

            refund = _refundRepository.Save(refund);
            OrderItem orderItem = _orderItemRepository.SaveOrderItem(refund.Id, OrderItemType.RefundItem);

            var orderDetail = new OrderDetail()
            {
                DataRecorderMetaData      = dataRecorder,
                Description               = reasonForRefund,
                DetailType                = OrderItemType.RefundItem,
                ForOrganizationRoleUserId = customerId,
                OrderId         = orderId,
                OrderItemId     = orderItem.Id,
                OrderItemStatus =
                    (new OrderItemStatusFactory()).CreateOrderItemStatus(
                        OrderItemType.RefundItem, RefundItemStatus.Applied.StatusCode),
                Price    = amount,
                Quantity = 1
            };

            return(orderDetail);
        }
Exemplo n.º 8
0
        public void CanSaveCheckPayment()
        {
            IDataRecorderMetaDataFactory metaDataFactory = new DataRecorderMetaDataFactory();
            DataRecorderMetaData         metaData        = metaDataFactory.CreateDataRecorderMetaData(2);

            var check = new Check {
                Amount               = 200,
                Memo                 = "Happy Birthday!",
                CheckDate            = new DateTime(1903, 6, 6),
                AccountNumber        = "testtest",
                BankName             = "Bank of Sans Serif",
                CheckNumber          = "blue",
                DataRecorderMetaData = metaData,
                PayableTo            = "Falcon",
                PaymentId            = PAYMENT_ID_WITH_ONLY_CHECKS,
                RoutingNumber        = "twelve"
            };

            var checkPayment = new CheckPayment {
                PaymentId            = PAYMENT_ID_WITH_ONLY_CHECKS,
                Amount               = check.Amount,
                DataRecorderMetaData = metaData,
                Check = check
            };

            checkPayment = (CheckPayment)_checkPaymentRepository.SavePaymentInstrument(checkPayment);

            Assert.IsNotNull(checkPayment, "Check Payment is null but should not be.");
            Assert.IsNotNull(checkPayment.Check, "Check is null but should not be.");
            Assert.AreNotEqual(0, checkPayment.Check.Id);
        }
Exemplo n.º 9
0
        protected override void MapDomainFields(PaymentEntity entity, Payment domainObjectToMapTo)
        {
            DataRecorderMetaData dataRecorderMetaData = _factory.CreateDataRecorderMetaData
                                                            (entity.OrganizationRoleUserCreatorId, entity.DateCreated);

            domainObjectToMapTo.Id    = entity.PaymentId;
            domainObjectToMapTo.Notes = entity.Notes;
            domainObjectToMapTo.DataRecorderMetaData = dataRecorderMetaData;
        }
Exemplo n.º 10
0
        protected override void MapDomainFields(OrderEntity entity, Order domainObjectToMapTo)
        {
            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(entity.OrganizationRoleUserCreatorId,
                                                                                   entity.DateCreated);

            domainObjectToMapTo.Id = entity.OrderId;
            domainObjectToMapTo.DataRecorderMetaData = dataRecorderMetaData;
            domainObjectToMapTo.OrderType            = (OrderType)entity.Type;
        }
Exemplo n.º 11
0
        public Finance.Domain.Order CreateNewOrder(OrderType orderType, long dataRecorderCreatorId)
        {
            DataRecorderMetaData metaData = _dataRecorderMetaDataFactory.
                                            CreateDataRecorderMetaData(dataRecorderCreatorId);

            return(new Finance.Domain.Order
            {
                OrderType = orderType,
                DataRecorderMetaData = metaData
            });
        }
Exemplo n.º 12
0
        public bool UpdatePriorityinQueue(PriorityInQueueEditModel model, long createdByOrgRoleUserId)
        {
            var piq = _priorityInQueueRepository.GetByEventCustomerResultId(model.EventCustomerResultId);

            if (model.IsPriorityInQueue)
            {
                if (piq != null)
                {
                    if (piq.NoteId == null)
                    {
                        return(true);
                    }
                    var noteObj = _notesRepository.Get(piq.NoteId.Value);
                    if (noteObj.Text != model.Note)
                    {
                        noteObj.Text = model.Note;
                        _notesRepository.Save(noteObj);
                    }
                    return(true);
                }
                var metaData = new DataRecorderMetaData(createdByOrgRoleUserId, DateTime.Now, DateTime.Now);
                var newNote  = new Notes()
                {
                    Text = model.Note, DataRecorderMetaData = metaData
                };
                newNote = _notesRepository.Save(newNote);

                piq = new PriorityInQueue
                {
                    EventCustomerResultId = model.EventCustomerResultId,
                    NoteId = newNote.Id,
                    CreatedByOrgRoleUserId  = createdByOrgRoleUserId,
                    ModifiedByOrgRoleUserId = createdByOrgRoleUserId,
                    InQueuePriority         = _priorityInQueueRepository.GetMaxPriorityInQueue(),
                    IsActive = true
                };

                piq.DateCreated = piq.DateModified = DateTime.Now;
                _priorityInQueueRepository.Save(piq);
            }
            else
            {
                //var piq = _priorityInQueueRepository.GetByEventCustomerResultId(model.EventCustomerResultId);
                if (piq != null)
                {
                    piq.InQueuePriority         = 0;
                    piq.IsActive                = false;
                    piq.DateModified            = DateTime.Now;
                    piq.ModifiedByOrgRoleUserId = createdByOrgRoleUserId;
                    _priorityInQueueRepository.Save(piq);
                }
            }
            return(true);
        }
        private void ExpectCreateDataRecorderMetaData(PhysicianPaymentEntity medicalVendorPaymentEntity)
        {
            long     dataRecoderCreatorId = medicalVendorPaymentEntity.DataRecoderCreatorId;
            DateTime dateCreated          = medicalVendorPaymentEntity.DateCreated;
            var      dataRecorderMetaData = new DataRecorderMetaData
            {
                DataRecorderCreator = new OrganizationRoleUser(), DateCreated = dateCreated
            };

            Expect.Call(_mockedFactory.CreateDataRecorderMetaData(dataRecoderCreatorId, dateCreated)).
            Return(dataRecorderMetaData);
        }
Exemplo n.º 14
0
        protected override void MapDomainFields(RefundEntity entity, Refund domainObjectToMapTo)
        {
            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(entity.OrganizationRoleUserCreatorId,
                                                                                   entity.DateCreated);

            domainObjectToMapTo.Id                   = entity.RefundId;
            domainObjectToMapTo.RefundReason         = (RefundReason)entity.ReasonId;
            domainObjectToMapTo.Notes                = entity.Notes;
            domainObjectToMapTo.DataRecorderMetaData = dataRecorderMetaData;
            domainObjectToMapTo.Price                = entity.Amount;
        }
Exemplo n.º 15
0
        public void CreateDataRecorderMetaDataDefaultsDateCreatedToCalendarNow()
        {
            DateTime expectedDateCreated = DateTime.Now;

            Expect.Call(_calendar.Now).Return(expectedDateCreated);

            _mocks.ReplayAll();
            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.CreateDataRecorderMetaData(0);

            _mocks.VerifyAll();

            Assert.AreEqual(expectedDateCreated, dataRecorderMetaData.DateCreated, "DateCreated did not default to Calendar's Now DateTime.");
        }
Exemplo n.º 16
0
        public bool IsValid(T objectToValidate)
        {
            if (objectToValidate == null || _metaDataToCheck(objectToValidate) == null)
            {
                return(false);
            }
            DataRecorderMetaData metaDataToCheck = _metaDataToCheck(objectToValidate);

            _isDateCreatedInRange        = metaDataToCheck.DateCreated < DateTime.Today.GetEndOfDay();
            _isModificationMetaDataValid = !((metaDataToCheck.DateModified == null) ^ (metaDataToCheck.DataRecorderModifier == null));
            _isCreatorSet = metaDataToCheck.DataRecorderCreator != null;

            return(_isDateCreatedInRange && _isModificationMetaDataValid && _isCreatorSet);
        }
Exemplo n.º 17
0
        private DataRecorderMetaData SetDataRecorderMetaData(DataRecorderMetaData dataRecorder, long uploadedby)
        {
            if (dataRecorder == null)
            {
                dataRecorder = new DataRecorderMetaData(new OrganizationRoleUser(uploadedby), DateTime.Now, null);
            }
            else
            {
                dataRecorder.DataRecorderModifier = new OrganizationRoleUser(uploadedby);
                dataRecorder.DateModified         = DateTime.Now;
            }

            return(dataRecorder);
        }
Exemplo n.º 18
0
        protected override void MapDomainFields(ChargeCardPaymentEntity entity,
                                                ChargeCardPayment domainObjectToMapTo)
        {
            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(entity.OrganizationRoleUserCreatorId,
                                                                                   entity.DateCreated);

            domainObjectToMapTo.Id                      = entity.ChargeCardPaymentId;
            domainObjectToMapTo.Amount                  = entity.Amount;
            domainObjectToMapTo.ChargeCardId            = entity.ChargeCardId;
            domainObjectToMapTo.ChargeCardPaymentStatus = (ChargeCardPaymentStatus)entity.Status;
            domainObjectToMapTo.ProcessorResponse       = entity.ProcessorResponse;
            domainObjectToMapTo.PaymentId               = entity.PaymentId;
            domainObjectToMapTo.DataRecorderMetaData    = dataRecorderMetaData;
        }
Exemplo n.º 19
0
        public void ManageOrderforRefundRequestwithFreeDiscountandProduct(RefundRequestResultEditModel model, long orderId, long customerId, long processedbyOrgRoleUserId)
        {
            var order = _orderRepository.GetOrder(orderId);

            if (order == null)
            {
                return;
            }
            var dataRecorder = new DataRecorderMetaData(processedbyOrgRoleUserId, DateTime.Now, null);

            var productsAvailed = model.OfferFreeProduct.Where(fp => fp.ProductAvailed);

            foreach (var product in productsAvailed)
            {
                long orderItemId = product.OrderItemId;
                if (orderItemId < 1)
                {
                    orderItemId = _orderItemRepository.SaveOrderItem(product.ProductId, OrderItemType.ProductItem).Id;
                    var orderDetail = new OrderDetail()
                    {
                        DataRecorderMetaData      = dataRecorder,
                        Description               = "Offered free product while Resolving Request",
                        DetailType                = OrderItemType.ProductItem,
                        ForOrganizationRoleUserId = customerId,
                        OrderId         = orderId,
                        OrderItemId     = orderItemId,
                        OrderItemStatus =
                            (new OrderItemStatusFactory()).CreateOrderItemStatus(
                                OrderItemType.ProductItem, ProductItemStatus.Availed.StatusCode),
                        Price    = 0.00m,
                        Quantity = 1
                    };
                    order.OrderDetails.Add(orderDetail);
                }
                else
                {
                    var eproduct = _electronicProductRepository.GetById(product.ProductId);
                    order.OrderDetails.Add(GetRefunTypeOrderLineItem(product.ProductPriceinOrder.Value, "Issuing Refund for Product " + eproduct.Name + " in Order [Id:" + orderId + "]", orderId, customerId, processedbyOrgRoleUserId));
                }
            }

            if (model.OfferDiscount)
            {
                order.OrderDetails.Add(GetRefunTypeOrderLineItem(model.DiscountAmount, "Offered Discount while Resolving Request", orderId, customerId, processedbyOrgRoleUserId));
            }

            order = _orderRepository.SaveOrder(order);
        }
Exemplo n.º 20
0
        protected override void MapDomainFields(ChargeCardEntity entity, ChargeCard domainObjectToMapTo)
        {
            // TODO: persist encrypted fields.
            DataRecorderMetaData metaData = _metaDataFactory.CreateDataRecorderMetaData(
                entity.OrganizationRoleUserCreatorId,
                entity.DateCreated);

            domainObjectToMapTo.Id                   = entity.ChargeCardId;
            domainObjectToMapTo.CVV                  = _encrypter.Decrypt(entity.Cvv);
            domainObjectToMapTo.CardIssuer           = entity.CardIssuer;
            domainObjectToMapTo.ExpirationDate       = entity.ExpirationDate;
            domainObjectToMapTo.IsDebit              = entity.IsDebitCard;
            domainObjectToMapTo.NameOnCard           = entity.NameOnCard;
            domainObjectToMapTo.Number               = _encrypter.Decrypt(entity.Number);
            domainObjectToMapTo.TypeId               = (ChargeCardType)entity.TypeId;
            domainObjectToMapTo.DataRecorderMetaData = metaData;
        }
Exemplo n.º 21
0
        protected override void MapDomainFields(CheckEntity entity, Check domainObjectToMapTo)
        {
            DataRecorderMetaData metaData = _metaDataFactory.CreateDataRecorderMetaData
                                                (entity.DataRecoderCreatorId, entity.DateCreated);

            domainObjectToMapTo.Id                   = entity.CheckId;
            domainObjectToMapTo.AccountNumber        = entity.AccountNumber;
            domainObjectToMapTo.Amount               = entity.Amount;
            domainObjectToMapTo.BankName             = entity.BankName;
            domainObjectToMapTo.CheckDate            = entity.CheckDate;
            domainObjectToMapTo.CheckNumber          = entity.CheckNumber;
            domainObjectToMapTo.Memo                 = entity.Memo;
            domainObjectToMapTo.PayableTo            = entity.PayableTo;
            domainObjectToMapTo.RoutingNumber        = entity.RoutingNumber;
            domainObjectToMapTo.DataRecorderMetaData = metaData;
            domainObjectToMapTo.AcountHolderName     = entity.AccountHolderName;
            domainObjectToMapTo.IsElectronicCheck    = entity.IsElectronic;
        }
Exemplo n.º 22
0
        public void MapSetsDataRecorderMetaDataToMetaDataFactoryCallReturnValue()
        {
            var orderEntity = new OrderEntity {
                OrganizationRoleUserCreatorId = 1,
                DateCreated = new DateTime(2003, 2, 2)
            };
            var expectedMetaData = new DataRecorderMetaData();

            Expect.Call(_dataRecorderMetaDataFactory.CreateDataRecorderMetaData(orderEntity.
                                                                                OrganizationRoleUserCreatorId, orderEntity.DateCreated)).Return(expectedMetaData);

            _mocks.ReplayAll();
            Order order = _mapper.Map(orderEntity);

            _mocks.VerifyAll();

            Assert.AreEqual(expectedMetaData, order.DataRecorderMetaData,
                            "Order returned with incorrect DataRecorderMetaData.");
        }
Exemplo n.º 23
0
        public OrderDetail CreateNewOrderDetail(OrderDetail existingOrderDetail, long forOrganizationRoleUserId,
                                                long dataRecorderCreatorId)
        {
            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(dataRecorderCreatorId);
            OrderItemStatus orderItemStatus;
            // Negate the entry for the existing order detail.
            decimal price = existingOrderDetail.Price * (-1);

            if (existingOrderDetail.DetailType != OrderItemType.RefundItem)
            {
                existingOrderDetail.OrderItemStatus =
                    _orderItemStatusFactory.CreateOrderItemStatus(existingOrderDetail.DetailType,
                                                                  (int)OrderStatusState.Initial);
                orderItemStatus =
                    _orderItemStatusFactory.CreateOrderItemStatus(existingOrderDetail.DetailType,
                                                                  (int)OrderStatusState.FinalFailure);
            }
            else
            {
                orderItemStatus =
                    _orderItemStatusFactory.CreateOrderItemStatus(existingOrderDetail.DetailType,
                                                                  (int)OrderStatusState.Initial);
            }
            return(new OrderDetail
            {
                Description = existingOrderDetail.Description,
                Price = price,
                Quantity = existingOrderDetail.Quantity,
                DataRecorderMetaData = dataRecorderMetaData,
                ForOrganizationRoleUserId = forOrganizationRoleUserId,
                OrderItemStatus = orderItemStatus,
                OrderId = existingOrderDetail.OrderId,
                OrderItemId = existingOrderDetail.OrderItemId,
                SourceCodeOrderDetail = null,
                EventCustomerOrderDetail = null,
                ShippingDetailOrderDetails = null,
                DetailType = existingOrderDetail.DetailType,
                SourceId = existingOrderDetail.SourceId
            });
        }
Exemplo n.º 24
0
        protected override void MapDomainFields(OrderDetailEntity entity, OrderDetail domainObjectToMapTo)
        {
            NullArgumentChecker.CheckIfNull(entity.OrderItem, "entity.OrderItem",
                                            "The OrderItem associated with the given OrderDetail must be provided.");

            OrderItemStatus orderItemStatus = _orderItemStatusFactory.CreateOrderItemStatus
                                                  ((OrderItemType)entity.OrderItem.Type, entity.Status);
            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(entity.OrganizationRoleUserCreatorId, entity.DateCreated);

            domainObjectToMapTo.Id          = entity.OrderDetailId;
            domainObjectToMapTo.OrderId     = entity.OrderId;
            domainObjectToMapTo.OrderItemId = entity.OrderItemId;
            domainObjectToMapTo.ForOrganizationRoleUserId = entity.ForOrganizationRoleUserId;
            domainObjectToMapTo.Description          = entity.Description;
            domainObjectToMapTo.Quantity             = entity.Quantity;
            domainObjectToMapTo.Price                = entity.Price;
            domainObjectToMapTo.DataRecorderMetaData = dataRecorderMetaData;
            domainObjectToMapTo.OrderItemStatus      = orderItemStatus;
            domainObjectToMapTo.DetailType           = (OrderItemType)entity.OrderItem.Type;
            domainObjectToMapTo.SourceId             = entity.SourceId;
        }
Exemplo n.º 25
0
        protected override void MapDomainFields(GiftCertificateEntity entity,
                                                GiftCertificate domainObjectToMapTo)
        {
            DataRecorderMetaData dataRecorderMetaData = entity.OrgazizationRoleUserCreatorId.HasValue
                                                            ? _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(
                entity.OrgazizationRoleUserCreatorId.Value,
                entity.DateCreated)
                                                            : null;

            domainObjectToMapTo.Id                    = entity.GiftCertificateId;
            domainObjectToMapTo.Price                 = entity.Amount;
            domainObjectToMapTo.ClaimCode             = entity.ClaimCode;
            domainObjectToMapTo.DataRecorderMetaData  = dataRecorderMetaData;
            domainObjectToMapTo.ExpirationDate        = entity.ExpirationDate;
            domainObjectToMapTo.FromName              = entity.FromName;
            domainObjectToMapTo.GiftCertificateTypeId = entity.TypeId;
            domainObjectToMapTo.Message               = entity.Message;
            domainObjectToMapTo.ToName                = entity.ToName;
            domainObjectToMapTo.ApplicablePackageId   = entity.ApplicablePackageId;
            domainObjectToMapTo.ToEmail               = entity.ToEmail;
        }
        public void CreatePaymentInstrumentSetsMetaDataToCreatedMetaData()
        {
            var checkEntity = new CheckEntity
            {
                DateCreated           = new DateTime(2001, 1, 1),
                DateModified          = new DateTime(2002, 2, 2),
                DataRecoderCreatorId  = 234,
                DataRecoderModifierId = 456
            };
            var expectedDataRecorderMetaData = new DataRecorderMetaData();

            Expect.Call(_dataRecorderMetaDataFactory.CreateDataRecorderMetaData(checkEntity.DataRecoderCreatorId,
                                                                                checkEntity.DateCreated, checkEntity.DataRecoderModifierId, checkEntity.DateModified))
            .Return(expectedDataRecorderMetaData);

            _mocks.ReplayAll();
            PaymentInstrument paymentInstrument = _paymentInstrumentFactory.
                                                  CreatePaymentInstrument(checkEntity);

            _mocks.VerifyAll();

            Assert.AreEqual(expectedDataRecorderMetaData, paymentInstrument.DataRecorderMetaData);
        }
Exemplo n.º 27
0
        public PaymentInstrument CreatePaymentInstrument(CheckEntity checkEntity)
        {
            if (checkEntity == null)
            {
                throw new ArgumentNullException("checkEntity", "Given CheckEntity cannot be null.");
            }

            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(checkEntity.DataRecoderCreatorId, checkEntity.DateCreated,
                                                                                   checkEntity.DataRecoderModifierId, checkEntity.DateModified);

            return(new Check(checkEntity.CheckId)
            {
                DataRecorderMetaData = dataRecorderMetaData,
                AccountNumber = checkEntity.AccountNumber,
                Amount = checkEntity.Amount,
                BankName = checkEntity.BankName,
                CheckDate = checkEntity.CheckDate,
                CheckNumber = checkEntity.CheckNumber,
                PayableTo = checkEntity.PayableTo,
                RoutingNumber = checkEntity.RoutingNumber,
                Memo = checkEntity.Memo
            });
        }
Exemplo n.º 28
0
        public long SavePayment(PaymentEditModel paymentEditModel, long dataRecorderOrgRoleUserId)
        {
            if (paymentEditModel.Payments == null || paymentEditModel.Payments.Count() < 1)
            {
                return(0);
            }

            var payments           = paymentEditModel.Payments.Where(p => p.Amount != 0);
            var paymentInstruments = new List <PaymentInstrument>();

            var dataRecordermetaData = new DataRecorderMetaData()
            {
                DateCreated         = DateTime.Now,
                DataRecorderCreator = new OrganizationRoleUser(dataRecorderOrgRoleUserId)
            };

            foreach (var payment in payments)
            {
                if ((payment.PaymentType == PaymentType.CreditCard.PersistenceLayerId || payment.PaymentType == PaymentType.CreditCardOnFile_Value) && payment.ChargeCard != null)
                {
                    payment.ChargeCard.ChargeCardPayment.DataRecorderMetaData = dataRecordermetaData;
                    payment.ChargeCard.ChargeCardPayment.Id = 0;

                    if (payment.ChargeCard.ChargeCard.Id < 1)
                    {
                        payment.ChargeCard.ChargeCard.DataRecorderMetaData = dataRecordermetaData;
                    }

                    if (payment.PaymentType != PaymentType.CreditCardOnFile_Value)
                    {
                        payment.ChargeCard.ChargeCard = _chargeCardRepository.Save(payment.ChargeCard.ChargeCard);
                    }

                    payment.ChargeCard.ChargeCardPayment.ChargeCardId            = payment.ChargeCard.ChargeCard.Id;
                    payment.ChargeCard.ChargeCardPayment.ChargeCardPaymentStatus = ChargeCardPaymentStatus.Approve;
                    if (paymentEditModel.PaymentFlow == PaymentFlow.Out)
                    {
                        payment.ChargeCard.ChargeCardPayment.Amount = -1 * payment.ChargeCard.ChargeCardPayment.Amount;
                    }

                    paymentInstruments.Add(payment.ChargeCard.ChargeCardPayment);
                }
                else if (payment.PaymentType == PaymentType.Cash.PersistenceLayerId)
                {
                    var cashPayment = new CashPayment
                    {
                        Amount = paymentEditModel.PaymentFlow == PaymentFlow.Out ? -1 * payment.Amount : payment.Amount,
                        DataRecorderMetaData = dataRecordermetaData
                    };
                    paymentInstruments.Add(cashPayment);
                }
                else if (payment.PaymentType == PaymentType.Check.PersistenceLayerId && payment.Check != null)
                {
                    var check        = payment.Check.Check;
                    var checkPayment = payment.Check.CheckPayment;

                    if (check.Id < 1)
                    {
                        check.DataRecorderMetaData = dataRecordermetaData;
                    }

                    if (checkPayment.Id < 1)
                    {
                        checkPayment.DataRecorderMetaData = dataRecordermetaData;
                    }

                    checkPayment.Check = check;
                    if (paymentEditModel.PaymentFlow == PaymentFlow.Out)
                    {
                        checkPayment.Amount = -1 * checkPayment.Amount;
                        check.Amount        = -1 * check.Amount;
                    }

                    paymentInstruments.Add(checkPayment);
                }
                else if (payment.PaymentType == PaymentType.ElectronicCheck.PersistenceLayerId && payment.ECheck != null)
                {
                    var check        = payment.ECheck.ECheck;
                    var checkPayment = payment.ECheck.ECheckPayment;

                    if (check.Id < 1)
                    {
                        check.DataRecorderMetaData = dataRecordermetaData;
                    }

                    if (checkPayment.Id < 1)
                    {
                        checkPayment.DataRecorderMetaData = dataRecordermetaData;
                    }

                    checkPayment.ECheck = check;

                    paymentInstruments.Add(checkPayment);
                }
                else if (payment.PaymentType == PaymentType.GiftCertificate.PersistenceLayerId && payment.GiftCertificate != null)
                {
                    var giftCertificate        = payment.GiftCertificate.GiftCertificate;
                    var giftCertificatePayment = payment.GiftCertificate.GiftCertificatePayment;

                    if (giftCertificate.Id < 1)
                    {
                        giftCertificate.DataRecorderMetaData = dataRecordermetaData;
                    }

                    if (giftCertificatePayment.Id < 1)
                    {
                        giftCertificatePayment.DataRecorderMetaData = dataRecordermetaData;
                    }

                    paymentInstruments.Add(giftCertificatePayment);
                }
                else if (payment.PaymentType == PaymentType.Insurance.PersistenceLayerId && payment.Insurance != null && payment.Insurance.EligibilityId > 0 && payment.Insurance.InsurancePayment.AmountToBePaid > 0)
                {
                    var insurancePayment = payment.Insurance.InsurancePayment;
                    insurancePayment.Amount = 0;
                    insurancePayment.DataRecorderMetaData = dataRecordermetaData;

                    paymentInstruments.Add(insurancePayment);
                }
            }

            long paymentId = SavePayment(paymentInstruments, "Payment", dataRecorderOrgRoleUserId);

            return(paymentId);
        }
Exemplo n.º 29
0
        public OrderDetail CreateNewOrderDetail(IOrderable orderable, int quantity,
                                                long forOrganizationRoleUserId, long dataRecorderCreatorId, SourceCode sourceCode,
                                                EventCustomer eventCustomer, ShippingDetail shippingDetail, long?sourceId = null)
        {
            if (orderable == null)
            {
                throw new ArgumentNullException("orderable");
            }
            if (orderable.Id == 0)
            {
                throw new InvalidOperationException("itemToOrder must already exist in the database.");
            }
            if (quantity < 1)
            {
                throw new ArgumentOutOfRangeException("quantity", "The quantity must be at least 1.");
            }
            DataRecorderMetaData dataRecorderMetaData = _dataRecorderMetaDataFactory.
                                                        CreateDataRecorderMetaData(dataRecorderCreatorId);
            OrderItemStatus orderItemStatus = _orderItemStatusFactory.CreateOrderItemStatus(orderable.
                                                                                            OrderItemType, (int)OrderStatusState.Initial);

            decimal price = orderable.Price;

            // TODO: Test source code logic.
            SourceCodeOrderDetail sourceCodeOrderDetail = null;

            if (sourceCode != null)
            {
                sourceCodeOrderDetail = new SourceCodeOrderDetail
                {
                    Amount       = sourceCode.CouponValue,
                    SourceCodeId = sourceCode.Id,
                    IsActive     = true,
                    OrganizationRoleUserCreatorId =
                        dataRecorderMetaData.DataRecorderCreator.Id
                };
            }

            EventCustomerOrderDetail eventCustomerOrderDetail = null;

            if (eventCustomer != null)
            {
                eventCustomerOrderDetail = new EventCustomerOrderDetail
                {
                    EventCustomerId = eventCustomer.Id,
                    IsActive        = true
                };
            }

            ShippingDetailOrderDetail shippingDetailOrderDetail = null;

            if (shippingDetail != null)
            {
                shippingDetailOrderDetail = new ShippingDetailOrderDetail
                {
                    ShippingDetailId = shippingDetail.Id,
                    IsActive         = true
                };
            }

            return(new OrderDetail
            {
                Description = orderable.Description,
                Price = price,
                Quantity = quantity,
                DetailType = orderable.OrderItemType,
                DataRecorderMetaData = dataRecorderMetaData,
                ForOrganizationRoleUserId = forOrganizationRoleUserId,
                OrderItemStatus = orderItemStatus,
                SourceCodeOrderDetail = sourceCodeOrderDetail,
                EventCustomerOrderDetail = eventCustomerOrderDetail,
                ShippingDetailOrderDetails = new List <ShippingDetailOrderDetail> {
                    shippingDetailOrderDetail
                },
                SourceId = sourceId
            });
        }
Exemplo n.º 30
0
        protected ResultReading <T> SynchronizeResultReading <T>(ResultReading <T> currentReading, ResultReading <T> newReading, DataRecorderMetaData dataRecorderMetaData)
        {
            if (currentReading == null && newReading == null)
            {
                return(null);
            }

            if (currentReading == null)
            {
                if (newReading.Reading == null)
                {
                    newReading = null;
                }
                else
                {
                    newReading.RecorderMetaData = new DataRecorderMetaData
                    {
                        DataRecorderCreator = dataRecorderMetaData.DataRecorderCreator,
                        DateCreated         = dataRecorderMetaData.DateCreated
                    };
                }
                return(newReading);
            }

            if (newReading != null)
            {
                newReading.Id = currentReading.Id;

                if (currentReading.Reading.Equals(newReading.Reading))
                {
                    return(currentReading);
                }

                if (currentReading.ReadingSource == ReadingSource.Manual && newReading.ReadingSource == ReadingSource.Automatic)
                {
                    return(currentReading);
                }

                if (newReading.ReadingSource == ReadingSource.Manual)
                {
                    if (newReading.Reading == null)
                    {
                        return(null);
                    }
                }
                else if (currentReading.ReadingSource == ReadingSource.Automatic && newReading.ReadingSource == ReadingSource.Automatic)
                {
                    if (newReading.Reading == null && currentReading.Reading != null)
                    {
                        return(currentReading);
                    }
                }

                newReading.RecorderMetaData = new DataRecorderMetaData
                {
                    DataRecorderCreator  = currentReading.RecorderMetaData.DataRecorderCreator,
                    DateCreated          = currentReading.RecorderMetaData.DateCreated,
                    DataRecorderModifier = dataRecorderMetaData.DataRecorderCreator,
                    DateModified         = dataRecorderMetaData.DateCreated
                };
            }
            else
            {
                if (currentReading.ReadingSource == ReadingSource.Manual && NewReadingSource == ReadingSource.Automatic)
                {
                    return(currentReading);
                }
            }

            return(newReading);
        }