/// <summary> /// Generates an <see cref="IInvoice"/> representing the bill for the current "checkout order" /// </summary> /// <param name="invoiceBuilder">The invoice builder class</param> /// <returns>An <see cref="IInvoice"/> that is not persisted to the database.</returns> public IInvoice PrepareInvoice(IBuilderChain <IInvoice> invoiceBuilder) { if (!IsReadyToInvoice()) { return(null); } var attempt = invoiceBuilder.Build(); if (attempt.Success) { InvoicePrepared.RaiseEvent(new SalesPreparationEventArgs <IInvoice>(attempt.Result), this); return(attempt.Result); } LogHelper.Error <SalePreparationBase>("The invoice builder failed to generate an invoice.", attempt.Exception); throw attempt.Exception; }
/// <summary> /// Generates an <see cref="IInvoice"/> representing the bill for the current "checkout order" /// </summary> /// <param name="invoiceBuilder">The invoice builder class</param> /// <returns>An <see cref="IInvoice"/> that is not persisted to the database.</returns> public virtual IInvoice PrepareInvoice(IBuilderChain <IInvoice> invoiceBuilder) { if (!IsReadyToInvoice()) { return(null); } ////var requestCache = _merchelloContext.Cache.RequestCache; ////var cacheKey = string.Format("merchello.salespreparationbase.prepareinvoice.{0}", ItemCache.VersionKey); var attempt = invoiceBuilder.Build(); if (attempt.Success) { InvoicePrepared.RaiseEvent(new CheckoutEventArgs <IInvoice>(Context.Customer, attempt.Result), this); return(attempt.Result); } LogHelper.Error <SalePreparationBase>("The invoice builder failed to generate an invoice.", attempt.Exception); throw attempt.Exception; }