Skip to content

Commit

Permalink
NEXT-30083 - Documentation for Quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
leduc92 committed Feb 20, 2024
1 parent 3781770 commit 6eb6937
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 0 deletions.
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
nav:
title: Entities & Schema
position: 20

---

# Entities and schema

## Entities

### Quote

The quote entity stores fundamental information about each quote such as unique identifiers, state, pricing, discount, associated users, customer.

### 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 payment capture, it has an amount, 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
}
quote_comment {
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
}
quote_delivery {
id uuid PK
version_id uuid PK
quote_id uuid
quote_version_id uuid
shipping_method_id uuid
shipping_costs json
custom_fields json
}
quote_delivery_position {
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
}
quote_document {
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
}
quote_employee {
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)
}
quote_line_item {
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
}
quote_transaction {
id uuid PK
version_id uuid PK
quote_id uuid
quote_version_id uuid
payment_method_id uuid
amount json
custom_fields json
}
quote_delivery ||--o{ quote : "has deliveries"
quote_delivery_position ||--o{ quote_delivery : "has positions"
quote_line_item ||--o{ quote : "has line items"
quote_comment ||--o{ quote : "has comments"
quote_transaction ||--o{ quote : "has transactions"
quote_document ||--o{ quote : "has documents"
quote_employee||--o{ quote : "belongs to employee"
```
12 changes: 12 additions & 0 deletions products/extensions/b2b-components/quotes-management/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
nav:
title: Quotes Management
position: 10

---

# Quote Management

The Quotes Management feature streamlines the B2B partnership process by enabling partners to seamlessly request and accept quotes without the need for time-consuming manual negotiations. This 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 thoroughly review the quote within the administration system. They are also empowered to apply discounts to individual product items within the quote to tailor the offer to the partner's needs. Subsequently, the modified quote is transmitted to the B2B partners for their consideration.

Partners have the freedom 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
nav:
title: Quote conversion
position: 30

---

# Quotes conversion

We allow customers to convert their shopping carts into quotes to facilitate seamless processing. We introduce 2 new services to handle the conversion process

**CartToQuoteConverter:**

When a customer wants to request a quote from their shopping cart, we basically convert a cart to an order, then process to enrich the data for quote.
```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;
}
```

**QuoteToCartConverter:**

When a customer wants to place an order based on a quote, we will create a new cart based on quote data. The customer can process the check-out normally afterward.

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

0 comments on commit 6eb6937

Please sign in to comment.