Customers

Quản lý các báo cáo về khách hàng

GET /reports/customers/:type

Loại báo cáo (type):
- selling: Báo cáo bán hàng theo khách hàng.
+ Params: start_date, end_date, customer_name, taxid, category_id, order, dir. (Phải có ít nhất 1 param để lọc)
+ Order by: customer_name, reference, product_name, datenew, ticketid, tickettype, units, total_price.

- debt: Báo cáo công nợ khách hàng.
+ Params: start_date, end_date, customer_name, taxid, category_id, order, dir.
+ Order by: customer_name, taxid, address, curdate, maxdebt, curdebt.

- diary: Nhật ký thanh toán của khách hàng.
+ Params: start_date, end_date, customer_name, taxid, category_id, order, dir. (Phải có ít nhất 1 param để lọc)
+ Order by: customer_name, taxid, datenew, ticketid, payment, total.

- price-list: Bảng giá theo khách hàng hoặc nhóm khách hàng.
+ Params: customer_name, taxid, category_id, order, dir.
+ Order by: customer_name, reference, product_name, units, price, total_price.

- price-history: Lịch sử thay đổi giá theo khách hàng / nhóm khách hàng.
+ Params: start_date, end_date, customer_name, taxid, category_id, product_name, reference, order, dir. (Phải có ít nhất 1 param để lọc)
+ Order by: customer_name, reference, product_name, units, date, price_old, price_new.

- stock-price: Báo cáo tồn kho kèm giá bán theo khách hàng / nhóm khách hàng.
+ Params: get_location (Y để lấy danh sách kho), customer_id (id khách hàng), category_id (id nhóm KH), code, product_name, reference, order, dir. (Phải có customer_id hoặc category_id)
+ Order by: product_name, reference, total_price, is_price_customer, unit_[location_id].

- state-trans: Báo cáo tình trạng giao dịch của khách hàng.
+ Params: start_date, end_date, state (Y: có giao dịch, N: không có giao dịch), customer_name, taxid, category_id, order, dir.
+ Order by: taxid, customer_name, category_name, region, city, address, debt, score.

Request

Headers

Header Value
Accept
application/vnd.reports.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.reports.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

- selling:
{
    "_embedded": {
        "customers": [
            {
                "id",
                "datenew",
                "tickettype",
                "ticketid",
                "customer_id",
                "customer_name",
                "product_id",
                "reference",
                "product_name",
                "units",
                "total_price"
            },
            ...
        ]
    }
}

- debt:
{
    "_embedded": {
        "customers": [
            {
                "id",
                "taxid",
                "customer_name",
                "address",
                "address2",
                "curdate",
                "curdebt",
                "maxdebt"
            },
            ...
        ]
    }
}

- diary:
{
    "_embedded": {
        "customers": [
            {
                "id",
                "customer_name",
                "taxid",
                "ticketid",
                "datenew",
                "payment",
                "total"
            },
            ...
        ]
    }
}

- price-list:
{
    "_embedded": {
        "customers": [
            {
                "id",
                "customer_name",
                "customer_cat_name",
                "reference",
                "product_name",
                "price",
                "units",
                "total_price"
            },
            ...
        ]
    }
}

- price-history:
{
    "_embedded": {
        "customers": [
            {
                "id",
                "customer_name",
                "reference",
                "product_name",
                "price_old",
                "price_new",
                "date",
                "units"
            },
            ...
        ]
    }
}

- stock-price:
{
    "_embedded": {
        "customers": [
            {
                "id",
                "product_name",
                "reference",
                "units_package",
                "units_label",
                "total_price",
                "is_price_customer",
                "units_[location_id]",
                "deviation_[location_id]",
                "reality_[location_id]",
                "flag_type_[location_id]",
                "update_at_[location_id]",
                ...
            },
            ...
        ]
    }
}

- state-trans:
{
    "_embedded": {
        "customers": [
            {
                "id",
                "taxid",
                "customer_name",
                "region",
                "city",
                "address",
                "address2",
                "curdate",
                "curdebt",
                "score",
                "category_name"
            },
            ...
        ]
    }
}

Products

GET /reports/products/:type

  • Report sản phẩm: /reports/products/product
  • Param: code, name, reference, category (id), pricesell, pricebuy, supplier (id), units
  • Order: name, reference, pricebuy, pricesell, supplier, units, category

  • Report sản phẩm mới: /reports/products/new-product

  • Param: code, name, reference, category (id), supplier (id), start_date, end_date (cần có ít nhất 1 param)
  • Order: name, reference, pricebuy, pricesell, created_at, supplier, uom, category

  • Report lịch sử giá bán lẻ: /reports/products/history-pricesell

  • Param: code, name, reference, category (id), start_date, end_date (cần có ít nhất 1 param)
  • Order: name, reference, units, date, price_old, price_new

  • Report lịch sử giá mua: /reports/products/history-pricebuy

  • Param: code, name, reference, category (id), start_date, end_date (cần có ít nhất 1 param)
  • Order: name, reference, category, date, price_old, price_new

  • Report chi tiết giá bán lẻ: /reports/products/pricesell-detail

  • Param: code, name, reference, category (id)
  • Order: name, reference, units, price, total_price

  • Report chi tiết tồn giá bán lẻ: /reports/products/retail-detail

  • Truyền param get_location=Y để lấy danh sách location
  • Param: code, reference, name (cần có chức năng bật tắt tìm kiếm tương đối (tự động thêm % trước và sau name khi submit))
  • Order: name, reference, total_price, unit_[location_id]

  • Report thông tin sản phẩm bán: /reports/products/unit-sell

  • Param: start_date (ngày bán), end_date, name (tên sản phẩm), reference, location, category (cần có ít nhất 1 param). Ngoài ra còn có param cust_cat_view_price (Xem giá nhóm KH) là id nhóm KH dùng để hiển thị giá theo nhóm KH này.
  • Order: name, reference, pricebuy, pricesell, price_cust_cat, total_qty

Request

Headers

Header Value
Accept
application/vnd.reports.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.reports.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

- Report sản phẩm:
{
    "_embedded": {
        "products": [
            {
                "id", //product id
                "reference",
                "name",
                "pricesell",
                "pricebuy", //Có phân quyền
                "supplier", //Tên NCC
                "units", //Tổng tồn các kho
                "category", //Tên danh mục
            },
            ...
        ]
    }
}

- Report sản phẩm mới
{
    "_embedded": {
        "products": [
            {
                "id", //id product
                "reference",
                "code",
                "name":,
                "pricesell",
                "pricebuy",
                "created_at", //Ngày tạo
                "supplier",
                "uom", //Tên DVT
                "category"
            },
            ...
        ]
    }
}

- Report lịch sử giá bán lẻ
{
    "_embedded": {
        "products": [
            {
                "id", //id product
                "price_old",
                "price_new",
                "date", //Ngày chỉnh giá
                "units", //Số lượng SP / gói                
                "reference",
                "name",
            },
            ...
        ]
    }
}

- Report lịch sử giá mua
{
    "_embedded": {
        "products": [
            {
                "id", //id product
                "price_old",
                "price_new",
                "date", //Ngày chỉnh giá
                "units", //Số lượng SP / gói                
                "reference",
                "name",
                "category"
            },
            ...
        ]
    }
}

- Report chi tiết giá bán lẻ
{
    "_embedded": {
        "products": [
            {
                "id", //id product
                "units", // Số lượng SP / gói
                "price", // Giá sản phẩm
                "total_price", //Giá gói
                "name",
                "reference",
            },
            ...
        ]
    }
}

- Report chi tiết tồn giá bán lẻ
{
    "_embedded": {
        "products": [
            {
                "id", //id product
                "name", //Tên SP
                "reference",
                "units_package", // SL/gói
                "total_price", //Giá gói
                "units_[location_id]", //Tồn máy kho ....
                "deviation_[location_id]", //Tồn lệch kho ....
                "reality_[location_id]", //Tồn thực kho ...
                "flag_type_[location_id]", //Cờ kiểm lệch kho ...
                "update_at_[location_id]", //Ngày kiểm lệch kho ...
                ...
            },
            ...
        ]
    }
}

- Report thông tin sản phẩm bán:
{
    "_embedded": {
        "products": [            
            {
                "id", //product id
                "reference",
                "name", //product name
                "pricesell",
                "pricebuy",
                "price_cust_cat", //Giá nhóm KH
                "total_qty", //Tổng số lượng bán
            }
        ]
    },
}

Sales

Quản lý các báo cáo bán hàng

GET /reports/sales/:type

Type: - product-detail: Doanh số sản phẩm chi tiết + Param: start_date, end_date, product_ref, product_name, person (//id), customer (//id), order (//sắp xếp: product_ref, product_name, pricesell, ticketid, date, person, customer, qty, actual_price, total_price), dir (//thứ tự sắp xếp: asc, desc). Điều kiện phải có 1 trong các param: start_date (<=32 ngày), product_ref, product_name, person, customer. - profit: Lợi nhuân + Param: start_date (required, <=32 ngày, >2022-04-01), end_date, person (//id), location (//id), order (//sắp xếp: product_ref, product_name, pricebuy, pricesell, qty, cost_value, expected_sales_value, actual_sales_value, expected_profit, actual_profit), dir (//thứ tự sắp xếp: asc, desc). + Truyền thêm param "get_total=Y" để chỉ lấy tổng số. - top-sale: Top doanh số + Param: start_date (required, <=32 ngày, >2022-04-01), end_date, product_ref, product_name, location (//id), category (//id), order (//sắp xếp: product_ref, product_name, total_qty, total_price), dir (//thứ tự sắp xếp: asc, desc). + Truyền thêm param "get_total=Y" để chỉ lấy tổng số.

Request

Headers

Header Value
Accept
application/vnd.reports.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.reports.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

- product-detail:
{
    "_embedded": {
        "sales": [
            {
                "id", //uuid ticket
                "units",//số lượng bán/trả
                "price", //giá bán thực tế
                "product_name_sale": //tên sản phẩm khi bán,
                "datenew", //ngày bán
                "ticketid",
                "total_price", //Tổng giá
                "product_ref", //Mã SP
                "product_name", //Tên SP hiện tại
                "pricesell", //Giá bán hiện tại
                "person",
                "customer",
            },
            ...
      ]
   }
}

- profit:
{
    "_embedded": {
        "sales": [
            {
                "id", //id sản phẩm
                "product_ref",
                "product_name",
                "pricebuy",
                "pricesell",
                "qty",
                "cost_value",//Tổng mua
                "expected_sales_value", //Kỳ vọng bán
                "actual_sales_value" ,//Thực tế bán
                "expected_profit", //Lọi nhuận kỳ vọng
                "actual_profit", //Lợi nhuận thực tế
            },
            ...
       ]
   }
}
-Tổng profit:
{
    "result": "SUCCESS",
    "total": {
        "cost_value",
        "expected_sales_value",
        "actual_sales_value",
        "expected_profit",
        "actual_profit"
    },
}

- top-sale:
{
    "_embedded": {
        "sales": [
            {
                "id", //id product
                "product_ref":,
                "product_name",
                "total_qty",
                "total_price"
            },
            ...
        ]
   }
}
-Tổng top-sale:
{
    "result": "SUCCESS",
    "total": {
        "total_qty",
        "total_price"
    }
}

Stock

Quản lý các báo cáo kho hàng

GET /reports/stock/:type

Type:
value: Giá trị tồn kho
+ Params: product_name, product_ref, category (//id), uom (//id), location (//id), supplier (//id), pricesell, totalpricesell, pricebuy, totalpricebuy, units, position
+ Order: product_ref, product_name, uom, pricesell, totalpricesell, pricebuy, totalpricebuy, units, position
+ Truyền thêm param "get_total=Y" để chỉ lấy tổng số.

inventory: Tồn kho
+ Params: product_ref, product_name, min, max, position, category (//id), uom (//id), location (//id), supplier (//id), units
+ Order: product_name, product_ref, min, max, position, location, uom, category, supplier, units

reorder: Hàng cần nhập kho
+ Params: product_name, product_ref, category (//id), location (//id), supplier (//id), position, units
+ Order: product_name, product_ref, min, max, location, supplier, position, units, units_order

reorder-by-date: Hàng cần nhập theo ngày
+ Params: start_date (required, số ngày < 32), end_date, product_name, product_ref, category, location_from (required), location_to (required), units (tồn kho nhập)
+ Order: product_name, product_ref, units_location_from, min, max, position, units_location_to, units_received

ledger: Sổ kho
+ Params: start_date (required, số ngày < 32), end_date, supplier (//id), reason (//id), location (//id)
+ Order: product_name, product_ref, location, supplier, reason, datenew, units, price, total_price.
+ Truyền thêm param "get_total=Y" để chỉ lấy tổng số.

diary: Nhật ký kho
+ Params: start_date (required, số ngày < 32), end_date, category (//id), reason (//id), location (//id)
+ Order: product_name, product_ref, location, category, units_in, total_in, units_out, total_out, units_diff, total_diff.
+ Truyền thêm param "get_total=Y" để chỉ lấy tổng số.

diary-detail: Chi tiết nhật ký kho
+ Params: start_date, end_date, product_name, product_ref, location (//id), category (//id), reason (//id), units. Điều kiện phải có 1 trong các param: start_date (<=32 ngày), product_ref, product_name.
+ Order: product_name, product_ref, location, category, datenew, reason, appuser, note, units_in, total_in, units_out, total_out
+ Truyền thêm param "get_total=Y" để chỉ lấy tổng số.

movement-detail: Chi tiết nhập xuất di chuyển
+ Params: start_date (required), end_date, product_name, product_ref, location_from (//id, required), location_to (//id, required), category (//id), units
+ Order: product_name, product_ref, datenew, appuser, note, units

diary-group: Nhật ký kho - nhóm giao dịch
+ Params: group (//group_id), start_date, end_date, reason, location (//id, lấy tất cả kho), supplier (//id), ticket (//ticketid), confirm (Y|N|NULL)
+ Order: group_id, location_name, person_name, datenew, reason_label, note, ticketid, supplier_name, is_confirm

Request

Headers

Header Value
Accept
application/vnd.reports.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.reports.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

- value:
{
    "_embedded": {
            "stock": [
                {
                    "units",
                    "product_id",
                    "product_name",
                    "product_ref",
                    "pricebuy",
                    "pricesell",
                    "uom_name",
                    "category_name",
                    "supplier_name",
                    "total_pricebuy",
                    "total_pricesell",
                },
                ...
        ]
    }
}
-Tổng value:
{
    "result": "SUCCESS",
    "total": {
        "total_pricebuy",
        "total_pricesell"
    },
}

- inventory:
{
    "_embedded": {
            "stock": [
                {
                    "units",
                    "product_id",
                    "product_name",
                    "product_ref",
                    "min",
                    "max",
                    "position",
                    "location_name",
                    "uom_name",
                    "category_name",
                    "supplier_name",
                },
                ...
        ]
    }
}

- reorder:
{
    "_embedded": {
        "stock": [
            {
                "units",
                "product_id",
                "product_name",
                "product_ref",
                "min",
                "max",
                "position",
                "units_order",
                "location_name",
                "category_name",
                "supplier_name" 
            },
            ...
        ]
    }
}
- reorder:
{
    "_embedded": {
        "stock": [
            {
                "product_id",
                "product_name",
                "product_ref",
                "units_location_to",
                "units_received",
                "units_location_from",
                "min",
                "max",
                "position",
            },
            ...
        ]
    }
}
- ledger:
{
    "_embedded": {
        "stock": [
            {
                "datenew",
                "price",
                "units",
                "total_price",
                "reason_label",
                "product_id",
                "product_name",
                "product_ref",
                "product_code",
                "location_name",
                "supplier_name",
            },
            ...
        ]
    }
}
-Tổng ledger:
{
    "result": "SUCCESS",
    "total": {
        "total_price",
    }
}

- diary:
{
    "_embedded": {
        "stock": [
            {
                "units_out",
                "units_in",
                "units_diff",
                "product_id",
                "product_name",
                "product_ref",
                "location_name",
                "category_name",
                "total_out",
                "total_in",
                "total_diff",
            },
            ...
        ]
    }
}
-Tổng diary:
{
    "result": "SUCCESS",
    "total": {
        "total_out",
        "total_in",
        "total_diff""
    }
}

- diary-detail:
{
    "_embedded": {
        "stock": [
            {
                "datenew",
                "appuser",
                "note",
                "reason_label",
                "units_out",
                "units_in",
                "product_id",
                "product_name",
                "product_ref",
                "location_name",
                "category_name",
                "total_out",
                "total_in",
            },
            ...
        ]
    }
}
-Tổng diary-detail:
{
    "result": "SUCCESS",
    "total": {
        "total_out",
        "total_in" 
    }
}

- movement-detail:
{
    "_embedded": {
        "stock": [
            {
                "units",
                "datenew",
                "appuser",
                "note",
                "product_id",
                "product_ref",
                "product_name",
            },
            ...
        ]
    }
}

- diary-group
{
    "_embedded": {
        "stock": [            
            {
                "id", //group uuid
                "group_id",
                "location_name",
                "person_name",
                "datenew", //Ngày giao dịch
                "reason_label",
                "note",
                "receipt", //ticket uuid, để tạo link qua hóa đơn
                "ticketid", // Hiển thị khi có dữ liệu (cột chung ticketid, supplier_name, is_confirm)
                "supplier_name", // Hiển thị khi có dữ liệu (cột chung ticketid, supplier_name, is_confirm)
                "is_confirm":"Y|N|NULL", // Xác nhận giao nhau. Hiển thị khi có dữ liệu (cột chung ticketid, supplier_name, is_confirm)
            }
        ]
    },
}

GET /reports/stock/:type[/:id]

  • Lấy danh sách lý do theo người dùng: /reports/stock/[type]/reason
  • Lấy thông tin chi tiết nhóm giao dịch: /reports/stock/diary-group/[group_uuid]

Request

Headers

Header Value
Accept
application/vnd.reports.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.reports.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

//Thông tin chi tiết nhóm giao dịch
{
    "result": "OK",
    "group_diary": {
        "group_id",
        "datenew", //Ngày giao dịch
        "person_name", //NV giao dịch
        "location_name", //Kho
        "reason_label", //Lý do
        "note_diary", //Ghi chú giao dịch
        "supplier_name", //Chỉ có khi là giao dịch nhập mua hàng (1) hoặc xuất trả NCC (-2)
        "receipt", //ticket uuid. Chỉ có khi là giao dịch xuất bán (-1) hoặc nhập khách trả (2)
        "ticketid", //Chỉ có khi là giao dịch xuất bán (-1) hoặc nhập khách trả (2)
        "group_uuid_crossing", //uuid của group diary khác giao nhau. Chỉ có khi là giao dịch nhập di chuyển
        "group_id_crossing", //id của group diary khác giao nhau. Chỉ có khi là giao dịch giao nhau
        "location_crossing", //Kho giao nhau. Chỉ có khi là giao dịch giao nhau
        "is_correct", // Xác nhận giao nhau đúng hay sai. Chỉ có khi là giao dịch giao nhau
        "person_confirm", //Người xác nhận. Chỉ có khi là giao dịch giao nhau
        "date_confirm", //Ngày xác nhận. Chỉ có khi là giao dịch giao nhau
        "note_confirm", //Ghi chú xác nhận. Chỉ có khi là giao dịch giao nhau
        "diary_error", //String JSON diary uuid sai. Chỉ có khi là giao dịch giao nhau
        "is_processed", //Đã xử lý giao dịch sai. Chỉ có khi là giao dịch giao nhau
        "person_process", //Người xử lý. Chỉ có khi là giao dịch giao nhau
        "date_process", //Ngày xử lý. Chỉ có khi là giao dịch giao nhau
        "note_process", //Gi chú xử lý. Chỉ có khi là giao dịch giao nhau
        "diary": [ //Danh sách doariary thuộc group.
            {
                "id", //id diary
                "reference",
                "product_name",
                "units"
            },
            ...
        ]
    }
}

Suppliers

GET /reports/suppliers/:type

  • Report nhật ký NCC: /reports/suppliers/diary
  • Param: start_date, end_date, supplier_name
  • Order: supplier_name, datenew, stockdiary_group_id, payment_method, total

  • Report chi tiết mua hàng: /reports/suppliers/purchase-detail

  • Param: start_date, end_date, supplier_id, reference, product_name
  • Order: supplier_name, reference, product_name, datenew, stockdiary_group_id, reason, units, price, total

Request

Headers

Header Value
Accept
application/vnd.reports.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.reports.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

- Report nhật ký NCC:
{
    "_embedded": {
        "suppliers": [
            {
                "id", //stockdiary_group_uuid
                "supplier_name",
                "datenew",
                "stockdiary_group_id",
                "payment_method": "Tiền mặt | Ghi nợ | Trả tiền mặt | Trả nợ | Thanh toán nợ",
                "total",
                "note"
            },
            ...
        ]
    }
}

- Report chi tiết mua hàng:
{
    "_embedded": {
        "suppliers": [
            {
                "id", //id stockdiary
                "supplier_name",
                "reference",
                "product_name",
                "datenew",
                "stockdiary_group_id",
                "reason": "Nhập mua | Xuất trả NCC",
                "units",
                "price",
                "total",
            },
            ...
        ]
    }
}