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; }