From a186f4bf9e2b6b5f99c1be1fffb1dce3c5d6c5b3 Mon Sep 17 00:00:00 2001 From: Duc Le Date: Thu, 11 Jan 2024 16:24:19 +0700 Subject: [PATCH] NEXT-30083 - Documentation for Quotes --- .../quotes-management/entities-and-schema.md | 145 ++++++++++++++++++ .../b2b-components/quotes-management/index.md | 12 ++ .../quotes-management/quotes-conversion.md | 59 +++++++ 3 files changed, 216 insertions(+) create mode 100644 products/extensions/b2b-components/quotes-management/entities-and-schema.md create mode 100644 products/extensions/b2b-components/quotes-management/index.md create mode 100644 products/extensions/b2b-components/quotes-management/quotes-conversion.md diff --git a/products/extensions/b2b-components/quotes-management/entities-and-schema.md b/products/extensions/b2b-components/quotes-management/entities-and-schema.md new file mode 100644 index 000000000..5fbd148bd --- /dev/null +++ b/products/extensions/b2b-components/quotes-management/entities-and-schema.md @@ -0,0 +1,145 @@ +--- +nav: + title: Entities & Schema + position: 20 + +--- + +# Entities and schema + +## Entities + +### Quote + +The quote entity stores fundamental information about each quote such as state, pricing, discount, associated users, customer and customers. + +### Quote Delivery + +The quote delivery represents the delivery information of a quote. It includes details such as the shipping method, earliest and latest shipping date. + +### Quote Delivery Position + +The quote delivery position represents the line items of a quote delivery. It has a quote line item, price, total price, unit price, quantity, and custom fields. + +### Quote Line item + +The quote line item represents the line items of a quote. Only product type is supported currently. + +### Quote Transaction + +The quote transaction entity captures payment amount and also allows saving an external reference. + +### Quote Comment + +The quote comment entity stores comments related to a quote. + +### Quote Employee + +The quote employee entity represents employees associated with a quote. + +### Quote Document + +The quote document entity represents documents associated with a quote. + +## Schema + + +```mermaid +erDiagram + Quote { + id uuid PK + version_id uuid PK + auto_increment bigint + state_id uuid + customer_id uuid + order_id uuid + order_version_id uuid + quote_number varchar(64) + price json + shipping_costs json + discount json + amount_total double + amount_net double + custom_fields json + } + QuoteComment { + id uuid PK + version_id uuid PK + comment longtext + seen_at datetime(3) + quote_id uuid + quote_version_id uuid + state_id uuid + customer_id uuid + } + QuoteDelivery { + id uuid PK + version_id uuid PK + quote_id uuid + quote_version_id uuid + shipping_method_id uuid + shipping_costs json + custom_fields json + } + QuoteDeliveryPosition { + id uuid PK + version_id uuid PK + quote_line_item_id uuid + quote_line_item_version_id uuid + price json + total_price int + unit_price int + quantity int + custom_fields json + } + QuoteDocument { + id uuid PK + version_id uuid PK + document_number varchar(255) + document_type_id uuid + file_type varchar(255) + quote_id uuid + quote_version_id uuid + config json + custom_fields json + } + QuoteEmployee { + id uuid PK + version_id uuid PK + quote_id uuid + quote_version_id uuid + employee_id uuid + first_name varchar(255) + last_name varchar(255) + } + QuoteLineItem { + id uuid PK + version_id uuid PK + product_id uuid + product_version_id uuid + label varchar(255) + quantity int + type varchar(255) + payload json + price json + discount json + position int + } + QuoteTransaction { + id uuid PK + version_id uuid PK + quote_id uuid + quote_version_id uuid + payment_method_id uuid + amount json + custom_fields json + } + QuoteDelivery o{--|| Quote : "has deliveries" + QuoteDeliveryPosition o{--|| QuoteDelivery : "has positions" + QuoteLineItem o{--|| Quote : "has line items" + QuoteComment o{--|| Quote : "has comments" + QuoteTransaction o{--|| Quote : "has transactions" + QuoteDocument o{--|| Quote : "has documents" + QuoteEmployee o{--|| Quote : "belongs to employee" + QuoteDeliveryPosition o{--|| QuoteLineItem : "has positions" +``` diff --git a/products/extensions/b2b-components/quotes-management/index.md b/products/extensions/b2b-components/quotes-management/index.md new file mode 100644 index 000000000..7761d4379 --- /dev/null +++ b/products/extensions/b2b-components/quotes-management/index.md @@ -0,0 +1,12 @@ +--- +nav: + title: Quotes Management + position: 10 + +--- + +# Quotes Management + +The Quote Management feature streamlines the B2B partnership process by enabling partners to seamlessly request and accept quotes without the need for time-consuming manual negotiations. The process begins with B2B partners populating their cart with desired products, after which they can initiate a quote request based on the contents of their cart. Once the request is submitted, B2B merchants have the ability to review the quote within the administration system. They can also apply discounts to individual product items within the quote to tailor the offer to the partner's needs. Subsequently, the modified quote is sent to the B2B partners for their consideration. + +Partners are free to accept or decline the offer, and upon acceptance, they are guided through the seamless checkout process. The system then automatically generates an order based on the accepted quote, optimizing efficiency and ensuring a smooth transition from negotiation to transaction. This feature revolutionizes B2B interactions by reducing the need for extensive manual discussions and fostering a more efficient and collaborative environment for both partners and merchants. \ No newline at end of file diff --git a/products/extensions/b2b-components/quotes-management/quotes-conversion.md b/products/extensions/b2b-components/quotes-management/quotes-conversion.md new file mode 100644 index 000000000..f3fe57e36 --- /dev/null +++ b/products/extensions/b2b-components/quotes-management/quotes-conversion.md @@ -0,0 +1,59 @@ +--- +nav: + title: Quotes conversion + position: 30 + +--- + +# Quotes conversion + +Customers can convert their shopping carts into quotes to facilitate seamless processing. There are two new services to handle the conversion process : + +## Cart to quote converter + +When a customer wants to request a quote for their shopping cart, the process involves converting a cart to an order and then proceeding to enrich the data for the quote. The method `convertToQuote` of class `Shopware\Commercial\B2B\QuoteManagement\Domain\CartToQuote\CartToQuoteConverter` is responsible for this process. + +```PHP +use Shopware\Core\Checkout\Cart\Order\OrderConversionContext; +use Shopware\Core\Checkout\Cart\Cart; +use Shopware\Core\Checkout\Cart\Order\OrderConverter; + +public function convertToQuote(Cart $cart, SalesChannelContext $context, OrderConversionContext $orderContext = null): Quote + { + $order = $this->orderConverter->convertToOrder($cart, $context, $orderContext); + + $quote = $order; + + //enrich quote data + + //enrich quote line-items + + return $quote; + } +``` + +## Quote to cart converter + +When a customer wants to place an order based on a quote, a new cart is created based on the quote data. The method `convertToCart` of class `Shopware\Commercial\B2B\QuoteManagement\Domain\QuoteToCart\QuoteToCartConverter` is responsible for this process. + +```PHP +use Shopware\Core\Checkout\Cart\Cart; +use Shopware\Core\Framework\Uuid\Uuid; +use Shopware\Core\System\SalesChannel\SalesChannelContext; +use Shopware\Commercial\B2B\QuoteManagement\Entity\Quote\QuoteEntity; +use Shopware\Commercial\B2B\QuoteManagement\Domain\Transformer\QuoteLineItemTransformer; + +public function convertToCart(QuoteEntity $quote, SalesChannelContext $context): Cart + { + + $cart = new Cart(Uuid::randomHex()); + $cart->setPrice($quote->getPrice()); + + $lineItems = QuoteLineItemTransformer::transformToLineItems($quote->getLineItems()); + $cart->setLineItems($lineItems); + + //enrich the cart + + return $cart; + } +```