SupplierPurchaseTemp
GET /supplier-purchase-temp
Lấy danh sách phiếu tạm
Fields
| Field | Type | Description | Required |
|---|---|---|---|
| action | YES | ||
| trans_id | YES | ||
| product_id | NO | ||
| product_code | NO | ||
| line_id | NO | ||
| units | NO | ||
| pricebuy | NO | ||
| update_supplier | NO | ||
| update_pricebuy | NO | ||
| reason | NO | ||
| person_id | NO | ||
| location_id | NO | ||
| supplier_id | NO | ||
| business_id | NO | ||
| note | NO | ||
| products | NO |
Request
Headers
| Header | Value |
|---|---|
| Accept | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Authorization | HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details) |
Response
Status Codes
- 406: Not Acceptable
- 415: Unsupported Media Type
- 200: OK
- 401: Unauthorized
- 403: Forbidden
Headers
| Header | Value |
|---|---|
| Content-Type | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Allow | Comma-separated list of all HTTP methods allowed |
Body
{
"_embedded": {
"supplier_purchase_temp": [
{
"id", //uuid purchase
"reason":"purchase|return", //Loại giao dịch: Mua hàng | Trả hàng
"person_name",
"supplier_name",
"person_share",
"first_product_name",
"num_other_line",
"created_at",
"updated_at"
},
...
]
}
}
GET /supplier-purchase-temp[/:temp_id]
- Lấy danh sách kho theo người dùng: /location-person
- Lấy thông tin phiếu hiện tại: /current. Thêm param set_current_access_token=Y để set quyền truy cập phiếu hiện tại.
Fields
| Field | Type | Description | Required |
|---|---|---|---|
| action | YES | ||
| trans_id | YES | ||
| product_id | NO | ||
| product_code | NO | ||
| line_id | NO | ||
| units | NO | ||
| pricebuy | NO | ||
| update_supplier | NO | ||
| update_pricebuy | NO | ||
| reason | NO | ||
| person_id | NO | ||
| location_id | NO | ||
| supplier_id | NO | ||
| business_id | NO | ||
| note | NO | ||
| products | NO |
Request
Headers
| Header | Value |
|---|---|
| Accept | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Authorization | HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details) |
Response
Status Codes
- 406: Not Acceptable
- 415: Unsupported Media Type
- 200: OK
- 404: Not Found
- 401: Unauthorized
- 403: Forbidden
Headers
| Header | Value |
|---|---|
| Content-Type | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Allow | Comma-separated list of all HTTP methods allowed |
Body
//LOCATION-PERSON
{
"location_person": {
[location_id]: [location_name],
...
},
}
//CURRENT
{
"result": "SUCCESS",
"current_trans": {
"trans_info": {
"id",
"reason", //Loại giao dịch
"person_name",
"location_id",
"location_name",
"supplier_id",
"supplier_name",
"business_id",
"business_name",
"note"
},
"trans_lines": [
{
"line_id",
"product_id",
"product_name",
"reference",
"units",
"pricebuy",
"update_supplier": "Y|N", //Cập nhật NCC vào sản phẩm
"update_pricebuy": "Y|N" //Cập nhật giá mua vào sản phẩm
},
...
]
},
}
//Lỗi CURRENT có thể xảy ra:
- NOT_CURRENT_ACCESS_TOKEN
- ERROR
PUT /supplier-purchase-temp[/:temp_id]
Xử lý các Action:
- addLine: Thêm SP
- editTrans: Sửa các thông tin chung của phiếu: Kho, NCC, ghi chú,...
- editUnit: Chỉnh sửa số lượng SP
- editPricebuy: Chỉnh sửa giá mua SP
- editUpdateProduct: Sửa trạng thái cập nhật giá mua, NCC sản phẩm
- deleteLine: Xóa dòng
- activeTrans: Kích hoạt phiếu chờ
- forwardTrans: Chuyển tiếp phiếu
- createNewTrans: Tạo phiếu mới
- importProduct: import từ danh sách sản phẩm
Fields
| Field | Type | Description | Required |
|---|---|---|---|
| action | YES | ||
| trans_id | YES | ||
| product_id | NO | ||
| product_code | NO | ||
| line_id | NO | ||
| units | NO | ||
| pricebuy | NO | ||
| update_supplier | NO | ||
| update_pricebuy | NO | ||
| reason | NO | ||
| person_id | NO | ||
| location_id | NO | ||
| supplier_id | NO | ||
| business_id | NO | ||
| note | NO | ||
| products | NO |
Request
Headers
| Header | Value |
|---|---|
| Accept | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Content-Type | application/vnd.suppliers.v1+json
application/json |
| Authorization | HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details) |
Body
{
"action": "addLine | editTrans | editUnits | editPricebuy | editUpdateProduct | deleteLine | activeTrans | forwardTrans | createNewTrans | importProduct",
"trans_id": "Phiếu đang xử lý hoặc phiếu đang chờ cho action activeTrans",
"product_id|product_code": "Áp dụng với action addLine",
"line_id": "Áp dụng với các action: editUnit, editPricebuy, editUpdateProduct, deleteLine",
"units": "Áp dụng với action addLine, editUnits",
"pricebuy": "Áp dụng với action editPricebuy",
"update_supplier": "Áp dụng với action editUpdateProduct",
"update_pricebuy": "Áp dụng với action editUpdateProduct",
"person_id" : "Áp dụng với action forwardTrans",
"reason": "Áp dụng với action editTrans",
"location_id": "Áp dụng với action editTrans",
"supplier_id": "Áp dụng với action editTrans",
"business_id": "Áp dụng với action editTrans",
"note": "Áp dụng với action editTrans",
"products": "Áp dụng với action importProduct. Là 1 mảng string JSON theo cấu trúc [{"reference":"[reference]","units":"[units]","pricebuy":"[pricebuy]"},...], phần tử pricebuy có thể có hoặc không"
}
Response
Status Codes
- 406: Not Acceptable
- 415: Unsupported Media Type
- 200: OK
- 404: Not Found
- 400: Client Error
- 422: Unprocessable Entity
- 401: Unauthorized
- 403: Forbidden
Headers
| Header | Value |
|---|---|
| Content-Type | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Allow | Comma-separated list of all HTTP methods allowed |
Body
//SUCCESS
Đa số các action trả về dạng {"result":"SUCCESS"}
Riêng:
- Action addLine:
{
"result": "SUCCESS",
"line": {
"line_id",
"product_id",
"product_name",
"units",
"update_supplier": "Y|N", //Cập nhật NCC vào sản phẩm
"update_pricebuy": "Y|N" //Cập nhật giá mua vào sản phẩm
},
"is_update": "Y|N" // Cập nhật SL line sản phẩm đã tồn tại hay tạo line mới
}
- Action editTrans:
{
"result": "SUCCESS",
"trans_info": {
"location_id",
"location_name",
"supplier_id",
"supplier_name",
"business_id",
"business_name",
"note",
},
}
- Action activeTrans, forwardTrans, createNewTrans: Trả về cấu trúc giống GET /current
Các lỗi có thể xảy ra:
Lỗi chung:
+ TRANS_NOT_CURRENT: Giá trị trans_id không phải trans hiện tại. (Trừ action activeTrans)
+ NOT_CURRENT_ACCESS_TOKEN: Chưa set truy cập phiếu tạm cho access_token hiện tại.
+ ERROR: Lỗi khác.
Lỗi riêng:
- addLine:
+ PRODUCT_NOT_FOUND: Không tìm thấy SP
- editTrans:
+ NOT_PERMISSION_SELECT_THIS_LOCATION: Không có quyền chọn kho
+ NOT_PERMISSION_SELECT_THIS_REASON: Không có quyền chọn loại giao dịch
+ NOT_FOUND_SUPPLIER: Không tìm thấy NCC
+ NOT_FOUND_BUSINESS: Không tìm thấy doanh nghiệp
- editUnits, editPricebuy, editUpdateProduct, deleteLine:
+ LINE_NOT_FOUND: Không tìm thấy line để chỉnh sửa
- activeTrans:
+ TRANS_NOT_FOUND: Không tìm thấy phiếu
- forwardTrans:
+ PERSON_NOT_FOUND: Nhân viên không tìm thấy
+ NOT_FORWARD_YOURSELF: Không được chuyển tiếp cho chính mình
+ TRANS_NOT_ITEM: Phiếu không có item nào
- createNewTrans: không có
- importProduct:
+ DUPLICATE_REFERENCE: Trùng mã trên dữ liệu import
+ INCORRECT_UNITS: Số lượng không đúng
+ INCORRECT_PRICEBUY: GIá mua không đúng
+ NOT_FOUND_PRODUCT: Không tìm thấy từ mã SP
DELETE /supplier-purchase-temp[/:temp_id]
Xóa phiếu hiện tại: /[trans_id]; Và tự động tạo phiếu mới. Trả về thông tin phiếu mới theo cấu trúc trả về GET /current. Các lỗi có thể xảy ra: - TRANS_NOT_CURRENT: Không tìm thấy phiếu; - NOT_CURRENT_ACCESS_TOKEN: Chưa set truy cập phiếu tạm cho access_token hiện tại; - ERROR: Lỗi khác
Fields
| Field | Type | Description | Required |
|---|---|---|---|
| action | YES | ||
| trans_id | YES | ||
| product_id | NO | ||
| product_code | NO | ||
| line_id | NO | ||
| units | NO | ||
| pricebuy | NO | ||
| update_supplier | NO | ||
| update_pricebuy | NO | ||
| reason | NO | ||
| person_id | NO | ||
| location_id | NO | ||
| supplier_id | NO | ||
| business_id | NO | ||
| note | NO | ||
| products | NO |
Request
Headers
| Header | Value |
|---|---|
| Accept | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Authorization | HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details) |
Response
Status Codes
- 406: Not Acceptable
- 415: Unsupported Media Type
- 204: No Content
- 404: Not Found
- 401: Unauthorized
- 403: Forbidden
Headers
| Header | Value |
|---|---|
| Content-Type | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Allow | Comma-separated list of all HTTP methods allowed |
SupplierPurchase
POST /supplier-purchase[/:purchase_id]
Thực hiện đặt hàng từ phiếu tạm
Fields
| Field | Type | Description | Required |
|---|---|---|---|
| trans_temp_id | NO | ||
| payment_method | NO | ||
| payment_note | NO |
Request
Headers
| Header | Value |
|---|---|
| Accept | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Content-Type | application/vnd.suppliers.v1+json
application/json |
| Authorization | HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details) |
Body
{
"purchase_temp_id", //id phiếu tạm
"payment_method": "cash|debt", // Phương thức thanh toán
"payment_note" //Ghi chú thanh toán
}
Response
Status Codes
- 406: Not Acceptable
- 415: Unsupported Media Type
- 201: Created
- 400: Client Error
- 422: Unprocessable Entity
- 401: Unauthorized
- 403: Forbidden
Headers
| Header | Value |
|---|---|
| Content-Type | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Allow | Comma-separated list of all HTTP methods allowed |
Body
//SUCCESS
{"result": "SUCCESS"}
//ERROR
+ PURCHASE_TEMP_INVALID: Giá trị purchase_temp_id không hợp lệ.
+ NOT_CURRENT_ACCESS_TOKEN: Chưa set truy cập phiếu tạm cho access_token hiện tại.
+ REQUIRED_LOCATION_ID: Chưa chọn kho.
+ NOT_PERMISSION_SELECT_THIS_LOCATION: Không có quyền với kho này.
+ REQUIRED_SUPPLIER_ID: Chưa chọn NCC.
+ NOT_FOUND_SUPPLIER: Không tìm thấy NCC.
+ NOT_FOUND_BUSINESS: Không tìm thấy doanh nghiệp.
+ PURCHASE_TEMP_NOT_ITEM: Phiếu tạm chưa có SP nào.
+ REQUEST_UNITS_GREATER_0: Số lượng phải lớn hơn 0.
+ DEBT_NOT_GREATER_MAXDEBT: Tổng nợ không được vượt quá max nợ.
+ ERROR: Lỗi khác
Suppliers
GET /suppliers
Lấy danh sách nhà cung cấp - Filter: visible=N|Y , name
Fields
| Field | Type | Description | Required |
|---|---|---|---|
| name | NO | ||
| visible | NO | ||
| phone | NO | ||
| region | NO | ||
| city | NO | ||
| address | NO | ||
| action | NO | ||
| searchkey | NO | ||
| taxid | NO | ||
| payment_method | Phương thức cập nhật |
NO | |
| debt | Số nợ giao dịch |
NO | |
| note | NO | ||
| maxdebt | NO |
Request
Headers
| Header | Value |
|---|---|
| Accept | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Authorization | HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details) |
Response
Status Codes
- 406: Not Acceptable
- 415: Unsupported Media Type
- 200: OK
- 401: Unauthorized
- 403: Forbidden
Headers
| Header | Value |
|---|---|
| Content-Type | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Allow | Comma-separated list of all HTTP methods allowed |
Body
{
"_embedded": {
"suppliers": [
{
"id",
"taxid",
"name",
"curdebt",
"curdate",
"phone",
"visible",
},
...
]
}
}
POST /suppliers
Tạo tài khoản NCC
Fields
| Field | Type | Description | Required |
|---|---|---|---|
| name | NO | ||
| visible | NO | ||
| phone | NO | ||
| region | NO | ||
| city | NO | ||
| address | NO | ||
| action | NO | ||
| searchkey | NO | ||
| taxid | NO | ||
| payment_method | Phương thức cập nhật |
NO | |
| debt | Số nợ giao dịch |
NO | |
| note | NO | ||
| maxdebt | NO |
Request
Headers
| Header | Value |
|---|---|
| Accept | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Content-Type | application/vnd.suppliers.v1+json
application/json |
| Authorization | HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details) |
Body
{
"name", //required
"phone",
"region", //Tỉnh / TP
"city", //Quận / Huyện
"address", //Địa chỉ
}
Response
Status Codes
- 406: Not Acceptable
- 415: Unsupported Media Type
- 201: Created
- 400: Client Error
- 422: Unprocessable Entity
- 401: Unauthorized
- 403: Forbidden
Headers
| Header | Value |
|---|---|
| Content-Type | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Allow | Comma-separated list of all HTTP methods allowed |
Body
//SUCCESS
{
"result": "SUCCESS",
"supplier": {
"id",
"searchkey",
"taxid",
"name",
"address",
"city",
"region",
"phone"
}
}
//ERROR
- ERROR: Lỗi lưu trữ
GET /suppliers[/:supplier_id]
Lấy thông tin chi tiết của NCC
Fields
| Field | Type | Description | Required |
|---|---|---|---|
| name | NO | ||
| visible | NO | ||
| phone | NO | ||
| region | NO | ||
| city | NO | ||
| address | NO | ||
| action | NO | ||
| searchkey | NO | ||
| taxid | NO | ||
| payment_method | Phương thức cập nhật |
NO | |
| debt | Số nợ giao dịch |
NO | |
| note | NO | ||
| maxdebt | NO |
Request
Headers
| Header | Value |
|---|---|
| Accept | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Authorization | HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details) |
Response
Status Codes
- 406: Not Acceptable
- 415: Unsupported Media Type
- 200: OK
- 404: Not Found
- 401: Unauthorized
- 403: Forbidden
Headers
| Header | Value |
|---|---|
| Content-Type | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Allow | Comma-separated list of all HTTP methods allowed |
Body
{
"result": "SUCCESS",
"supplier": {
"id",
"searchkey",
"taxid",
"name",
"maxdebt",
"curdebt",
"curdate",
"phone",
"address",
"city",
"region",
"visible": "N|Y"
},
}
Lỗi có thể xảy ra: NOT_FOUND_SUPPLIER
DELETE /suppliers[/:supplier_id]
Xóa tài khoản NCC. Lỗi có thể xảy ra: NOT_FOUND_SUPPLER
Fields
| Field | Type | Description | Required |
|---|---|---|---|
| name | NO | ||
| visible | NO | ||
| phone | NO | ||
| region | NO | ||
| city | NO | ||
| address | NO | ||
| action | NO | ||
| searchkey | NO | ||
| taxid | NO | ||
| payment_method | Phương thức cập nhật |
NO | |
| debt | Số nợ giao dịch |
NO | |
| note | NO | ||
| maxdebt | NO |
Request
Headers
| Header | Value |
|---|---|
| Accept | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Authorization | HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details) |
Response
Status Codes
- 406: Not Acceptable
- 415: Unsupported Media Type
- 204: No Content
- 404: Not Found
- 401: Unauthorized
- 403: Forbidden
Headers
| Header | Value |
|---|---|
| Content-Type | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Allow | Comma-separated list of all HTTP methods allowed |
PUT /suppliers[/:supplier_id]
Chỉnh sửa các thông tin NCC
Fields
| Field | Type | Description | Required |
|---|---|---|---|
| name | NO | ||
| visible | NO | ||
| phone | NO | ||
| region | NO | ||
| city | NO | ||
| address | NO | ||
| action | NO | ||
| searchkey | NO | ||
| taxid | NO | ||
| payment_method | Phương thức cập nhật |
NO | |
| debt | Số nợ giao dịch |
NO | |
| note | NO | ||
| maxdebt | NO |
Request
Headers
| Header | Value |
|---|---|
| Accept | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Content-Type | application/vnd.suppliers.v1+json
application/json |
| Authorization | HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details) |
Body
{
"action": "editName | editCode | editVisible | editMaxDebt | updateCurdebt | editContactInfo",
"name", //Với action editName. Required
"searchkey", //Với action editCode. Required
"taxid", //Với action editCode. Required
"visible", //Với action editVisible. Required
"maxdebt", //Với action editMaxDebt. Required
"payment_method": "debt (thêm nợ)|debtpaid (thanh toán nợ)", //Phương thức cập nhật. Với action updateCurdebt. Required
"debt", //Số nợ giao dịch. Với action updateCurdebt. Required
"note", //Với action updateCurdebt
"phone", //Với action editContacinfo
"region", //Với action editContacinfo
"city":, //Với action editContacinfo
"address", //Với action editContacinfo
}
Response
Status Codes
- 406: Not Acceptable
- 415: Unsupported Media Type
- 200: OK
- 404: Not Found
- 400: Client Error
- 422: Unprocessable Entity
- 401: Unauthorized
- 403: Forbidden
Headers
| Header | Value |
|---|---|
| Content-Type | application/vnd.suppliers.v1+json
application/hal+json
application/json |
| Allow | Comma-separated list of all HTTP methods allowed |
Body
//SUCCESS
{"result":"SUCCESS"}
//ERROR
Lỗi chung
- NOT_FOUND_SUPPLIER: Không tìm thấy NCC
- ERROR: Lỗi khác
Lỗi riêng action updateCurdebt:
- DEBT_NOT_GREATER_MAXDEBT: tổng nợ không được vượt quá max nợ.
- DEBT_NOT_GREATER_CURDEBT: Số nợ giao dịch không được lớn hơn số nợ hiện tại.