---
# System prepended metadata

title: Order & Invoice

---

# Order

## Tables

**orders**
| Name                               | Type          | Desc                                                                                                          |     |
|:---------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------- |:--- |
| source_type                        | varchar(255)  | 'Cart', 'Quotation'                                                                                           |     |
| source_id                          | int           |                                                                                                               |     |
| number                             | varchar(255)  |                                                                                                               |     |
| order_date                         | date          |                                                                                                               |     |
| status                             | varchar(255)  | 'waiting_payment', 'paid', 'prepress', 'processing', 'waiting_delivery', 'on_delivery', 'arrived', 'complete' |     |
| price                              | decimal(15,2) |                                                                                                               |     |
| tax                                | decimal(15,2) |                                                                                                               |     |
| total_price                        | decimal(15,2) |                                                                                                               |     |
| service_time_id                    | int           |                                                                                                               |     |
| service_time_delivery_option_name  | varchar(255)  |                                                                                                               |     |
| service_time_additional_percentage | decimal(5,2)  |                                                                                                               |     |
| service_time_min_charge            | decimal(15,2) |                                                                                                               |     |
| service_time_max_charge            | decimal(15,2) |                                                                                                               |     |
| service_time_duration              | int           |                                                                                                               |     |
| service_time_charge                | decimal(15,2) |                                                                                                               |     |

**order_items**
| Name            | Type          | Desc                          |
| --------------- |:------------- |:----------------------------- |
| order_id        | int           |                               |
| source_type     | varchar(255)  | 'cart_item', 'quotation_item' |
| source_id       | int           |                               |
| title_id        | varchar(255)  |                               |
| title_en        | varchar(255)  |                               |
| product_sku_id  | varchar(255)  |                               |
| variant_page_id | varchar(255)  |                               |
| spec_set        | jsonb         |                               |
| qty             | int           |                               |
| price_each      | decimal(15,2) |                               |
| final_price     | decilam(15,2) |                               |
| notes           | text          |                               |
| artwork_url     | varchar(255)  |                               |
| thumbnail_url   | varchar(255)  |                               |

**order_timelines**
| Name          | Type     | Desc                                                                                                                         |
| ------------- |:-------- |:---------------------------------------------------------------------------------------------------------------------------- |
| order_id      | int      |                                                                                                                              |
| status        | jsonb    | {'id': 'Pesanan Dibuat', 'Pesanan Dibayar', 'Menunggu Produksi', 'Proses Produksi', 'Pesanan Dikirimkan', 'Pesanan Selesai', 'en': } |
| start_date    | datetime |                                                                                                                              |
| end_date      | datetime |                                                                                                                              |
| timeline_date | datetime |                                                                                                                              |

**order_shippings**
| Name                          | Type           | Desc            |
|:----------------------------- |:-------------- |:--------------- |
| order_id                      | int            |                 |
| shipping_service_id           | int            |                 |
| shipping_service_name         | varchar(255)   |                 |
| shipping_sevice_duration      | int            |                 |
| shipping_sevice_duration_type | varchar(255)   | 'hours', 'days' |
| shipping_service_price        | decimal(15,2)  |                 |
| waybill_number                | varchar(255)   |                 |
| name                          | varchar(255)   |                 |
| address                       | varchar(255)   |                 |
| phone                         | varchar(255)   |                 |
| latitude                      | decimal(16,13) |                 |
| longitude                     | decimal(16,13) |                 |
| notes                         | text           |                 |
| is_dropshipping               | boolean        |                 |
| dropshipper_name              | varchar(255)   |                 |
| dropshipper_phone             | varchar(255)   |                 |
| user_shipping_address_id      | int            |                 |

**order_shipping_timelines**
| Name              | Type         | Desc |
| ----------------- | ------------ |:---- |
| order_shipping_id | int          |      |
| timeline_date     | datetime     |      |
| status            | varchar(255) |      |
| description       | varchar(255) |      |

**invoices**
| Name                   | Type          | Desc                              |
|:---------------------- |:------------- |:--------------------------------- |
| order_id               | int           |                                   |
| number                 | varchar(255)  |                                   |
| invoice_date           | date          |                                   |
| status                 | varchar(255)  | 'waiting_payment', 'paid', 'void' |
| amount                 | decimal(15,2) |                                   |
| service_time_charge    | decimal(15,2) |                                   |
| shipping_service_price | decimal(15,2) |                                   |
| tax                    | decimal(15,2) |                                   |
| total_amount           | decimal(15,2) |                                   |

**invoice_payments**
| Name              | Type          | Desc                                                  |
| ----------------- |:------------- |:----------------------------------------------------- |
| invoice_id        | int           |                                                       |
| payment_method_id | int           |                                                       |
| amount            | decimal(15,2) |                                                       |
| payment_date      | datetime      |                                                       |
| external_id       | varchar(255)  |                                                       |
| status            | varchar(255)  | 'succeeded','pending', 'failed', 'voided', 'refunded' |
| settled_at        | datetime      |                                                       |
| ref_number        | varchar(255)  |                                                       |

**payment_api_logs**
| Name       | Type         | Desc                |
| ---------- |:------------ |:------------------- |
| resource   | varchar(255) | 'invoice-payment/1' |
| uri        | varchar(255) |                     |
| payload    | jsonb        |                     |
| response   | jsonb        |                     |
| is_success | boolean      |                     |


| Status          | Description                                                                       |
| --------------- | --------------------------------------------------------------------------------- |
| confirmed       | Order has been confirmed. Locating nearest driver to pick up.                     |
| allocated       | Courier has been allocated. Waiting to pick up.                                   |
| pickingUp       | Courier is on the way to pick up item.                                            |
| picked          | Item has been picked and ready to be shipped.                                     |
| droppingOff     | Item is on the way to customer.                                                   |
| returnInTransit | Order is on the way back to the origin.                                           |
| onHold          | Your shipment is on hold at the moment. We'll ship your item after it's resolved. |
| delivered       | Item has been delivered.                                                          |
| rejected        | Your shipment has been rejected. Please contact Biteship for more information.    |
| courierNotFound | Your shipment is canceled because there's no courier available at the moment.     |
| returned        | Order successfully returned.                                                      |
| cancelled       | Order is cancelled.                                                               |
| disposed        | Order successfully disposed.                                                      |



| Key       | Value                                                       |
| --------- | ----------------------------------------------------------- |
| SUCCEEDED | Payment transaction for specified charge_id is successfully |
| PENDING          |   Payment transaction for specified charge_id is awaiting payment attempt by end user                                                          |
FAILED
Payment transaction for specified charge_id has failed, check failure codes for reasons

VOIDED
Payment transaction for specified charge_id has been voided

REFUNDED
Payment transaction for specified charge_id has been either partially or fully refunded
	
	
## To DO
- Create Order
    - Order, Order Item, Order Shipping, 
- Create Invoice
    - Invoice, invoice payment, payment api logs
- Get List Order
    - filter status, search, sorting, pagination
- Get Detail Order
    - Order item, Shipping, Summary
- Get Order timeline
    - Order Timeline, Order shipping timeline
- webhook shipping
- webhook payment
- scheduled job auto complete (if 3 days no confirm by user 3 after arrived ) explore dulu
