Quotations are purchase offers that occur after a basket submission. The user wants to create a quotation from the products in their basket and can create a new quotation by giving a name.
If the division of the user is main-division then the initial status of quotation will be set to pending status. If the division of the user is sub-division the initial status of quotation depends on IS_SUB_DIVISION_QUOTATION_APPROVAL_REQUIRED dynamic setting. If it is true the status will be set to request approval, if it is false the status will be set to pending status. The default value of this setting is true.
There is a hierarchy regarding updating the quotation. You can understand this structure better in the attached image.
How to Manage Quotations?
There are 2 API services to manage quotations:
Via omnishop platform /api/v1/my-quotations/ endpoint to manage operations for users to their own quotations. Via omnitron admin users can use /api/v1/quotations/ endpoint to manage operations on all quotations.
Both parts perform similar operations. Let's consider both separately. First, let's look at the requests that are sent via commerce. Requests to the B2B project via Commerce are sent to /api/v1/my-quotations/.
There are eight different statuses for quotations. These are cancelled, request_approval, pending, draft, sending_approval_request, approved, rejected and expired.
Cancelled: The quotation has been canceled by the owner.
Request Approval: Created by a sub-division, awaiting approval from the main division.
Pending: Approved by the main division or created by a division, awaiting approval from the superuser.
Draft: Used by the superuser to edit the quotation.
Sending Approval Request: Utilized by the superuser to send the quotation to the owner for approval.
Approved: Successfully approved by the superuser and is ready for ordering.
Rejected: Rejected either by the superuser or the main division.
After the create quotation users can cancel & reject their quotation from the my-quotations endpoint but can not approve. Because firstly, the quotation should be sent to the divisions for approval. Once the quotation is approved, it is sent back to the quotation owners for their approval. Following their approval, the quotation can then be converted into orders.
Example Request
curl --location '{B2B_Backend_URL}/api/v1/my-quotations/<quotation.id>/cancel/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token {token}' \
--data '{
"reason": "I dont want to do it"
}'
Reject Quotation
In order to reject a quotation, you must be the owner of the quotation or be affiliated with the main-division.
Example Request
curl --location '{B2B_Backend_URL}/api/v1/my-quotations/<quotation.id>/reject/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token {token}' \
--data '{
"reason": "I dont want to do it"
}'
To see the comments of a quotation use the following API:
Approve for Pending Quotation use the following API: Requests created by sub-division users wait as request_approval before becoming requests as status. In this section, request_approval is used to approve the pending requests and put them on pending. If the quotation's status is set to request_approval and the creator user is affiliated with the main division, one can approve the quotation. If the quotation status is different or the user's division type is not main, the request will not be successful.
Example Request
curl --location --request POST '{B2B_Backend_URL}/api/v1/my-quotations/<quotation.id>/approve_pending/' \
--header 'Authorization: Token {token}'
Approve Quotation
Requests created by the sub-division users pass to the "sending_request_approval" status after they are approved by the parent dealer. Here it waits for the bidder's approval.
There are eight different statuses for quotations. These are cancelled, request_approval, pending, draft, sending_approval_request, approved, rejected and expired.
Cancelled: The quotation has been canceled by the owner.
Request Approval: Created by a sub-division, awaiting approval from the main division.
Pending: Approved by the main division or created by a division, awaiting approval from the superuser.
Draft: Used by the superuser to edit the quotation.
Sending Approval Request: Utilized by the superuser to send the quotation to the owner for approval.
Approved: Successfully approved by the superuser and is ready for ordering.
Rejected: Rejected either by the superuser or the main division.
There are two different discount types, percentage and fixed. percentage is used to define a 'percentage' discount on the price. Used 'fixed' when you want to apply a fixed price discount.
curl --location --request POST '{B2B_Backend_URL}/api/v1/quotations/<quotation.id>/draft/' \
--header 'Authorization: Token {token}'
Approve Quotation
After the quotation is approved, orders are created on the b2b according to the division count in quotation and B2B_BULK_PROCESSES_BATCH_SIZE environment variable. Let's say that the quotation below is approved and B2B_BULK_PROCESSES_BATCH_SIZE value is 500.
Product
Division
Quantity
Product X
Division A
600
Product Y
Division A
300
Product X
Division B
300
Since the environment value of B2B_BULK_PROCESSES_BATCH_SIZE is 500, orders are divided into pieces of 500.
Following orders will be created.
Order 1:
Division A − Product X * 500
Order 2:
Division A − Product X * 100 − Product Y * 300
There are three status for orders. These are pending, created and failed. Once orders are created, they enter the "pending" status. This means that the Order is waiting to be created as an order on commerce. When the order is created on commerce, the status is updated to “created”. If an error occurs during this process, the "failed" status is used.
Checks the status of an export file using the cache key obtained from the export request. Provides information on whether the file is ready for download.