{
	"info": {
		"_postman_id": "customer-po-matching-collection",
		"name": "Customer Purchase Orders - Supply Domain",
		"description": "API collection for Customer Purchase Order matching functionality in Supply Quotations",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "1. Create Customer Purchase Order",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"temporary_folder\": \"{{temporary_folder}}\",\n    \"po_number\": \"PO-2026-001\",\n    \"po_date\": \"2026-02-15\",\n    \"payment_method\": \"Bank Transfer\",\n    \"required_delivery_time\": \"30 days\",\n    \"items\": [\n        {\n            \"item_name\": \"Item 1\",\n            \"quantity\": 10,\n            \"unit_price\": 100.50,\n            \"total\": 1005.00\n        },\n        {\n            \"item_name\": \"Item 2\",\n            \"quantity\": 5,\n            \"unit_price\": 250.75,\n            \"total\": 1253.75\n        }\n    ]\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{BASE_URL}}/supply/quotations/:quotation_id/customer-purchase-orders",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [

						"supply",
						"quotations",
						":quotation_id",
						"customer-purchase-orders"
					],
					"variable": [
						{
							"key": "quotation_id",
							"value": "1",
							"description": "Supply Quotation ID"
						}
					]
				},
				"description": "Create a new Customer Purchase Order for an approved Supply Quotation. The PO file must be uploaded first via the temporary file upload endpoint, and the temporary_folder ID should be provided here."
			},
			"response": []
		},
		{
			"name": "2. Get Customer Purchase Order Details",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [

						"supply",
						"customer-purchase-orders",
						":po_id"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Retrieve detailed information about a Customer Purchase Order including items, matches, and file information."
			},
			"response": []
		},
		{
			"name": "3. Get Comparison Data",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/comparison",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [

						"supply",
						"customer-purchase-orders",
						":po_id",
						"comparison"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Get side-by-side comparison data between the Supply Quotation and Customer Purchase Order for matching interface."
			},
			"response": []
		},
		{
			"name": "4. Detect Discrepancies",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/detect-discrepancies",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [

						"supply",
						"customer-purchase-orders",
						":po_id",
						"detect-discrepancies"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Automatically detect discrepancies between the quotation and PO (validity dates, payment methods, item quantities/prices)."
			},
			"response": []
		},
		{
			"name": "5. Submit Matching Results",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"matches\": [\n        {\n            \"match_type\": \"validity\",\n            \"quotation_value\": \"2026-03-15\",\n            \"po_value\": \"2026-02-15\",\n            \"match_status\": \"match\",\n            \"remarks\": null\n        },\n        {\n            \"match_type\": \"delivery_time\",\n            \"quotation_value\": \"30 days\",\n            \"po_value\": \"30 days\",\n            \"match_status\": \"match\",\n            \"remarks\": null\n        },\n        {\n            \"match_type\": \"payment_method\",\n            \"quotation_value\": \"Bank Transfer\",\n            \"po_value\": \"Bank Transfer\",\n            \"match_status\": \"match\",\n            \"remarks\": null\n        },\n        {\n            \"match_type\": \"item\",\n            \"quotation_item_id\": 1,\n            \"po_item_id\": 1,\n            \"quotation_value\": \"Item 1\",\n            \"po_value\": \"Item 1\",\n            \"match_status\": \"match\",\n            \"remarks\": null\n        },\n        {\n            \"match_type\": \"item\",\n            \"quotation_item_id\": 2,\n            \"po_item_id\": 2,\n            \"quotation_value\": \"Item 2\",\n            \"po_value\": \"Item 2\",\n            \"match_status\": \"mismatch\",\n            \"remarks\": \"Quantity differs: Quote has 5, PO has 6\"\n        }\n    ],\n    \"match_notes\": \"All items matched except Item 2 quantity discrepancy\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/match",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [

						"supply",
						"customer-purchase-orders",
						":po_id",
						"match"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Submit matching results for validity, delivery time, payment method, and items. Remarks are mandatory for mismatches."
			},
			"response": []
		},
		{
			"name": "6. Approve Customer Purchase Order",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"notes\": \"All items matched successfully. Proceeding with order.\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/approve",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [

						"supply",
						"customer-purchase-orders",
						":po_id",
						"approve"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Approve a Customer Purchase Order after matching. Requires: PO file uploaded, all items matched, and remarks for any mismatches."
			},
			"response": []
		},
		{
			"name": "7. Reject Customer Purchase Order",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"reason\": \"Multiple discrepancies found that cannot be resolved. Customer needs to revise PO.\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/reject",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [

						"supply",
						"customer-purchase-orders",
						":po_id",
						"reject"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Reject a Customer Purchase Order. Requires a reason (minimum 10 characters)."
			},
			"response": []
		},
		{
			"name": "8. Suspend Customer Purchase Order",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"reason\": \"Waiting for customer clarification on payment terms before proceeding.\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/suspend",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [

						"supply",
						"customer-purchase-orders",
						":po_id",
						"suspend"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Suspend a Customer Purchase Order temporarily. Requires a reason (minimum 10 characters)."
			},
			"response": []
		},
		{
			"name": "9. Revert to Requote",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/requote",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [

						"supply",
						"customer-purchase-orders",
						":po_id",
						"requote"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Revert Customer Purchase Order to requote status, resetting the quotation workflow."
			},
			"response": []
		},
		{
			"name": "10. Initiate Requote",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"item_ids\": [1, 2],\n    \"reason\": \"Customer requested price revision for specific items due to market changes.\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/initiate-requote",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [
						"supply",
						"customer-purchase-orders",
						":po_id",
						"initiate-requote"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Initiate a requote process for specific items or the entire PO. Creates a new supply order for repricing."
			},
			"response": []
		},
		{
			"name": "11. Get Requote Status",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/requote-status",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [
						"supply",
						"customer-purchase-orders",
						":po_id",
						"requote-status"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Get the current status of the requote process, including the new supply order and quotation details."
			},
			"response": []
		},
		{
			"name": "12. Check Repricing Completion",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/check-repricing",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [
						"supply",
						"customer-purchase-orders",
						":po_id",
						"check-repricing"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Check if repricing has been completed for all items in the requote supply order."
			},
			"response": []
		},
		{
			"name": "13. Get Margin Comparison",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/margin-comparison",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [
						"supply",
						"customer-purchase-orders",
						":po_id",
						"margin-comparison"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Get profit margin comparison between original quotation and new quotation after requote."
			},
			"response": []
		},
		{
			"name": "14. Approve Requote Decision",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"approve_new_quote\": true,\n    \"notes\": \"New quotation approved. Margin is acceptable.\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{BASE_URL}}/supply/customer-purchase-orders/:po_id/approve-requote",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [
						"supply",
						"customer-purchase-orders",
						":po_id",
						"approve-requote"
					],
					"variable": [
						{
							"key": "po_id",
							"value": "1",
							"description": "Customer Purchase Order ID"
						}
					]
				},
				"description": "Approve or reject the new quotation after requote. Set approve_new_quote to true to approve the new quote, false to reject and keep original."
			},
			"response": []
		},
		{
			"name": "Helper: Upload PO File (Temporary)",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "formdata",
					"formdata": [
						{
							"key": "type",
							"value": "customer_purchase_orders",
							"type": "text"
						},
						{
							"key": "file",
							"type": "file",
							"src": [],
							"description": "Upload PDF or Image file (max 50MB)"
						}
					]
				},
				"url": {
					"raw": "{{BASE_URL}}/upload-file",
					"host": [
						"{{BASE_URL}}"
					],
					"path": [
						"upload-file"
					]
				},
				"description": "Upload PO file to temporary storage first. Use the returned 'folder' value as 'temporary_folder' in the Create PO request."
			},
			"response": []
		}
	],
	"variable": [
		{
			"key": "BASE_URL",
			"value": "http://localhost:8000",
			"type": "string"
		},
		{
			"key": "access_token",
			"value": "",
			"type": "string"
		},
		{
			"key": "temporary_folder",
			"value": "",
			"type": "string"
		}
	]
}
