---
# System prepended metadata

title: Revisit RFQ

---

# Revisit RFQ
---
# Tables (cuanki)
## spec_key_values
### columns
- spec_key_id
- spec_value_id

---
# Tables (phoenix)

## inquiries
### columns

## inquiriy_cancellations
- canceled_at
- canceled_by
- inquiry_cancelation_reason_id

## inquiry_cancellation_reasons
### columns
- code
- name
- additional : {"next_step": 2}

## inquiry_suppliers
### columns
- partner_id
+ organization_supplier_id

## organization_items
- industry_id

## industries
- id
- code
- name

---
# Endpoint

## Spec Keys List
### URL: `GET /spec-values`
### Params
```json=
{
  "spec_key_id":1,
	"query":""
}
```
### Response:
```json=
[{
  "id": ID,
	"spec_key_id": 1,
  "code": "Code",
  "name": "Spec Value Name"
},
{
  "id": ID,
	"spec_key_id": 1,
  "code": "Code",
  "name": "Spec Value Name"
},
{
  "id": ID,
	"spec_key_id": 1,
  "code": "Code",
  "name": "Spec Value Name"
}]
```
---
## RFQ Draft
### URL: `GET /phoenix/inquiries/draft`
### Params
```json=
{
	"query": "",
    "sort_by": "",
    "sort_direction": "",
    "page": "",
    "per": "",
    "organization_item_id": 1
}
```
### Response:
```json=
[{ "See inquiries detail" }]
```

---
## RFQ Delete
### URL: `DELETE /phoenix/inquiries/:id`
### Response:
```json=
{ "Success" }
```

### Logic:
- return 422 jika status bukan draft
- jika draft hapus RFQ

---
## RFQ Cancel
### URL: `PUT /phoenix/inquiries/:id/cancel`
### Params:
```json=
{
  "reason_id": "reason_id",
  "action_type": "cancel" || "cancel_and_create_similar"
}
```

### Response:
```json=
{ "Inquiry Detail" }
```

### Logic:
- bidding cancelled
- reasons
  - No Longer need the item > full cancel
  - Incorrect data entry > ?
  - Need to change the specifications > step 2
  - Need to change the quantity > step 3
  - Need to change the shipping address > step 3
  - Need to change the terms of payment > step 4
  - Need to add / remove proof > step 4
  - There are no suppliers who offer quotes > ?
- Change status to cancel
- store cancel reason
- call Module Create similar RFQ if
  - reason to step 2..4
  - Apabila butuh ganti spec, redirect ke step 2 spec (Create RFQ 5 step)
  - Apabila tidak butuh ganti spec, redirect ke step 1 shipment (Create RFQ 3 step)
- add canceled_at, cancelled_by, cancelled_reason

## Module create similar
### Logic:
- clone rfq to new number
- jika org item id ada, rfq step = 3, store org item id & duplicate inquiry
- jika tidak ada org item id, rfq step = 2, buat org item kosong 

---
## RFQ Create Similar
### URL: `POST /phoenix/inquiries/:id/duplicate`
### Params:
```json=
{
    "rfq_step": 2,
    "organization_item_id": 1 //optional
}
```

### Response:
```json=
{
    "See RFQ detail"
}
```


---
## Revisit /phoenix/rfq/:id/suppliers
## RFQ Invite Supplier
//### URL: `POST /phoenix/inquiries/:id/suppliers/invite`
### Params:
```json=
{
    "partner_id": 1,
    "name": "",
    "email": ""
}
```
### Response:
```json=
{
    "See Inquiry Supplier detail"
}
```

### logic:
- call officer organizationsupplierofficer
- then add organization_suppliers.id to inquiry_suppliers.organization_supplier_id

---
## Revisit Inquiry Supplier
### Logic:
- change inquiry_suppliers.partner_id to inqury_suppliers.organization_supplier_id
- if partner_id dont exists in organization_suppliers, then add new organization suppliers with this partner_id
- if partner dont exist in partners then create org suppliers (invited)

---
## Revisit New Round
### Params:
```json=
{
    "bidding_id": 1,
    "bidding_end_time": "",
    "bidding_submission_ids": [1, 2, 3, 4, 5, 6],
    "quotation_id": 1, // smart sourcing
    "round_reason_id": [1, 2],
    "description": "description"
}
```

### Logic:
- create new bidding round + 1, bidding end time = params[:bidding_end_time]
- comment clone quotation & clone submissions
- clone bidding invitation filtered by submissions/quotation partner and status = nil

---
### Rfq Custom Form (Pending)
### URL: `POST /phoenix/items`
### Params: 
```json=
{
  // add_key
  "industry": ""
}
```

### Response:
```json=
{
  // add_key 
  "industry": ""
}
```
## List of Industries (tobe deleted)
### URL: `GET /api/industries`
### Params:
```json=
{
	"query": "",
    "sort_by": "",
    "sort_direction": "",
    "page": "",
    "per": ""
}
```

### Response:
```json=
[{
    "id": 1,
    "code": "",
    "name": ""
}]
```
---
## Revisit RFQ Forms - Step 2 - Item
### params:
- tambahkan industry


---
## Revisit Partner Assignment
### Logic:
- Cek ke organization_item utk dapat industry
- filter partner based on industry (partner_industries)

---
## Tasks:
- migrasi
- revisit spec key list
- inquiries draft
- inquiries delete
- inquiries cancel
- inquiries similar & module
- inquiries supplier invite & revisit supplier
- revisit new round
- revisit partner assigment


