public SubscriptionCharge(ClientAddress deliveryAddress = null, UnitofWork uow = null) { _subscriptionHelper = uow == null ? new SubscriptionHelper() : new SubscriptionHelper(uow); _orderCharge= new OrderChargeModel(); if (deliveryAddress != null) { _deliveryAddress = deliveryAddress; } }
//Plan //PlanId = 1, //ExternalId = "1", //Description = "3 Meals per week", //Title="Mike Weekly Plan" // Cooker Subscription // CookerSubscriptionId = 1, // CookerId = 1, // PlanId = 1, // ServingPriceId = 1 //SubscriptionServingPrice // ServingPrice // { // ServicePriceId = 1, // ServingMeasurementId = 1, // PLanId = 1, // Price = (decimal)19.99, // Quantity = 1 // } public OrderSubscription FirstSubscriptionOrder() { var cookerServingPriceModel = new SubscriptionHelper().GetCookerServingPriceModel(ClientSubscriptionId); var firstSubscriptionOrder = new OrderSubscription { OrderSubscriptionId = 1, ClientId = 1, OrderDate = DateTime.Today.Date, DeliveryDate = null, OrderTypeId = (int)OrderType.Values.PickUp, PaymentMethodId = (int)PaymentMethodType.Values.CardOnLine, CouponId = null, PromotionId = null, PlanId = cookerServingPriceModel.PLanId, SubTotal = cookerServingPriceModel.Price, CurrencyId = (int)CurrencyType.Values.Usd, OrderStatusId = (int)OrderStatus.Values.InProgress, ServingMeasurementId = cookerServingPriceModel.ServingMeasurementId, NumberofServingTotal = 4 * cookerServingPriceModel.Quantity, ClientSubscriptionId = ClientSubscriptionId, }; #region Week1 firstSubscriptionOrder.OrderSubscriptionItems.Add(GetFirstOrderSubscriptionItem((int)WeekType.Values.Week1)); firstSubscriptionOrder.OrderSubscriptionItems.Add(GetSecondOrderSubscriptionItem((int)WeekType.Values.Week1)); firstSubscriptionOrder.OrderSubscriptionItems.Add(GetThirdOrderSubscriptionItem((int)WeekType.Values.Week1)); #endregion #region Week2 firstSubscriptionOrder.OrderSubscriptionItems.Add(GetFirstOrderSubscriptionItem((int)WeekType.Values.Week2)); firstSubscriptionOrder.OrderSubscriptionItems.Add(GetSecondOrderSubscriptionItem((int)WeekType.Values.Week2)); firstSubscriptionOrder.OrderSubscriptionItems.Add(GetFourthOrderSubscriptionItem((int)WeekType.Values.Week2)); #endregion #region Week3 firstSubscriptionOrder.OrderSubscriptionItems.Add(GetFirstOrderSubscriptionItem((int)WeekType.Values.Week3)); firstSubscriptionOrder.OrderSubscriptionItems.Add(GetSecondOrderSubscriptionItem((int)WeekType.Values.Week3)); firstSubscriptionOrder.OrderSubscriptionItems.Add(GetThirdOrderSubscriptionItem((int)WeekType.Values.Week3)); #endregion #region Week4 firstSubscriptionOrder.OrderSubscriptionItems.Add(GetFirstOrderSubscriptionItem((int)WeekType.Values.Week4)); firstSubscriptionOrder.OrderSubscriptionItems.Add(GetFourthOrderSubscriptionItem((int)WeekType.Values.Week4)); firstSubscriptionOrder.OrderSubscriptionItems.Add(GetFirstOrderSubscriptionItem((int)WeekType.Values.Week4)); #endregion return firstSubscriptionOrder; }
private OrderSubscription CreateSubscriptionOrder(ClientSubscription newClientSubscription) { var cookerServingPriceModel = new SubscriptionHelper(_uow).GetCookerServingPriceModel(newClientSubscription.ClientSubscriptionId); var subscriptionOrder = new OrderSubscription { OrderSubscriptionId = _uow.OrderSubscriptionItemRepository.All.ToList().Max(x => x.OrderSubscriptionId) + 1, ClientId = newClientSubscription.ClientId, OrderDate = DateTime.Today.Date, DeliveryDate = null, OrderTypeId = (int)OrderType.Values.NotSet, PaymentMethodId = (int)PaymentMethodType.Values.NotSet, CouponId = null, PromotionId = null, PlanId = cookerServingPriceModel.PLanId, SubTotal = cookerServingPriceModel.Price, CurrencyId = (int)CurrencyType.Values.Usd, OrderStatusId = (int)OrderStatus.Values.InProgress, ServingMeasurementId = cookerServingPriceModel.ServingMeasurementId, NumberofServingTotal = 4 * cookerServingPriceModel.Quantity, ClientSubscriptionId = newClientSubscription.ClientSubscriptionId }; #region WeeksSubscriptionItems #region Week1 subscriptionOrder.OrderSubscriptionItems.Add(MostPopularDishFromCooker1MenuSubscriptionItem((int)WeekType.Values.Week1)); #endregion #region Week2 subscriptionOrder.OrderSubscriptionItems.Add(MostPopularDishFromCooker1MenuSubscriptionItem((int)WeekType.Values.Week2)); #endregion #region Week3 subscriptionOrder.OrderSubscriptionItems.Add(MostPopularDishFromCooker1MenuSubscriptionItem((int)WeekType.Values.Week3)); #endregion #region Week4 subscriptionOrder.OrderSubscriptionItems.Add(MostPopularDishFromCooker1MenuSubscriptionItem((int)WeekType.Values.Week4)); #endregion #endregion _uow.OrderSubscriptionRepository.Add(subscriptionOrder); _uow.Save(); return subscriptionOrder; }
private Invoice CreateSubscriptionInvoice(OrderSubscription orderSubscription) { if (orderSubscription == null) return null; var subscriptionHelper = new SubscriptionHelper(_uow); var subscriptionOrderCharge = new SubscriptionCharge(uow: _uow).Calculate(orderSubscription.ClientId, orderSubscription); var subscriptionOrderInvoice = new Invoice { InvoiceId = _uow.InvoiceRepository.All.ToList().Max(x => x == null ? 0 : x.InvoiceId) + 1, #region Orders Fields //OrderId = null, OrderDate = null, DeliveryDate = null, #endregion #region Subscription Fields OrderId = orderSubscription.OrderSubscriptionId, SubscriptionStartDate = DateTime.Now.Date, SubscriptionEndDate = DateTime.Now.Date.AddMonths(1), SubscriptionInvoiceDate = DateTime.Now.Date, ClientSubscriptionId = orderSubscription.ClientSubscriptionId, CookerSubscriptionId = subscriptionHelper.GetCookerSubscription(orderSubscription.ClientSubscriptionId).CookerSubscriptionId, ServingPriceId = subscriptionHelper.GetCookerServingPriceModel(orderSubscription.ClientSubscriptionId).ServicePriceId, PlanId = orderSubscription.PlanId, PlanTitle = subscriptionHelper.GetPlanTitle(orderSubscription.PlanId), #endregion #region Common Fields ClientId = orderSubscription.ClientId, CookerId = subscriptionOrderCharge.CookerId, OrderModelTypeId = orderSubscription.OrderTypeId, OrderTypeValue = subscriptionOrderCharge.OrderTypeValue, PaymentMethodValue = subscriptionOrderCharge.PaymentMethodValue, CurrencyId = orderSubscription.CurrencyId, PromotionTitle = subscriptionOrderCharge.PromotionTitle, PromotionPrice = subscriptionOrderCharge.PromotionPrice, PromotionCurrencyId = subscriptionOrderCharge.PromotionCurrencyId, CouponTitle = subscriptionOrderCharge.CouponTitle, CouponPrice = subscriptionOrderCharge.CouponPrice, CouponCurrencyId = subscriptionOrderCharge.CouponCurrencyId, SalesTax = subscriptionOrderCharge.SalesTaxes, DeliveryFees = subscriptionOrderCharge.DeliveryFee, SubTotal = subscriptionOrderCharge.Subtotal, Total = subscriptionOrderCharge.TotalCharges #endregion }; return subscriptionOrderInvoice; }
public Invoice FirstSubscriptionInvoice() { MySubscriptionsOrders = new List<OrderSubscription>(); var client1SubscriptionsOrders = new FakeClient1SubscriptionsOrder().MyOrders; foreach (var order in client1SubscriptionsOrders) { MySubscriptionsOrders.Add(order); } var firstSubscriptionOrder = MySubscriptionsOrders.FirstOrDefault(); if (firstSubscriptionOrder == null) return null; var subscriptionHelper = new SubscriptionHelper(); var firstSubscriptionOrderCharge = new SubscriptionCharge().Calculate(firstSubscriptionOrder.ClientId, firstSubscriptionOrder); var firstSubscriptionOrderInvoice = new Invoice { InvoiceId = 20, #region Orders Fields //OrderId = null, OrderDate = null, DeliveryDate = null, #endregion #region Subscription Fields OrderId = firstSubscriptionOrder.OrderSubscriptionId, SubscriptionStartDate = DateTime.Now.Date, SubscriptionEndDate = DateTime.Now.Date.AddMonths(1), SubscriptionInvoiceDate = DateTime.Now.Date, ClientSubscriptionId = firstSubscriptionOrder.ClientSubscriptionId, CookerSubscriptionId = subscriptionHelper.GetCookerSubscription(firstSubscriptionOrder.ClientSubscriptionId).CookerSubscriptionId, ServingPriceId = subscriptionHelper.GetCookerServingPriceModel(firstSubscriptionOrder.ClientSubscriptionId).ServicePriceId, PlanId = firstSubscriptionOrder.PlanId, PlanTitle = subscriptionHelper.GetPlanTitle(firstSubscriptionOrder.PlanId), #endregion #region Common Fields ClientId = firstSubscriptionOrder.ClientId, CookerId = firstSubscriptionOrderCharge.CookerId, OrderModelTypeId = firstSubscriptionOrder.OrderTypeId, OrderTypeValue = firstSubscriptionOrderCharge.OrderTypeValue, PaymentMethodValue = firstSubscriptionOrderCharge.PaymentMethodValue, CurrencyId = firstSubscriptionOrder.CurrencyId, PromotionTitle = firstSubscriptionOrderCharge.PromotionTitle, PromotionPrice = firstSubscriptionOrderCharge.PromotionPrice, PromotionCurrencyId = firstSubscriptionOrderCharge.PromotionCurrencyId, CouponTitle = firstSubscriptionOrderCharge.CouponTitle, CouponPrice = firstSubscriptionOrderCharge.CouponPrice, CouponCurrencyId = firstSubscriptionOrderCharge.CouponCurrencyId, SalesTax = firstSubscriptionOrderCharge.SalesTaxes, DeliveryFees = firstSubscriptionOrderCharge.DeliveryFee, SubTotal = firstSubscriptionOrderCharge.Subtotal, Total = firstSubscriptionOrderCharge.TotalCharges #endregion }; return firstSubscriptionOrderInvoice; }