Модель StoreDocument (заголовок документа)
Модель StoreDocument — представляет заголовок документа склада, содержит основную информацию о нем.
* @property integer $id // ID документа * @property $document_type // тип документа значения document_type: prihod - приходная накладная rashod - расходная накладная inventar - инвентаризация transfer - передача товара между складами transfer_receiver - дополнительный документ при передаче между складами invoice - счет return_good - возврат товаров * @property $status // статус документа значения: save, exec, deleted, disabled * @property integer $store_id // ID склада * @property integer $receiver_store_id // ID склада получателя, при передаче товара между складами. тип документа - 'transfer' * @property integer $supplier_id // ID поставщика в приходной накладной. тип документа - 'prihod' * @property integer $receiver_id // ID контрагент в расходной накладной. тип документа - 'rashod' * @property timestamp $add_dt // дата добавления * @property timestamp $edit_dt // дата редактирования * @property timestamp $exec_dt // дата выполнения @property double $total // сумма (по приходной накладной общая сумма приходной)
Модель StoreDocumentOperation(товары в документе, история действий)
Модель StoreDocumentOperation — Представляет товары вошедшие в документ склада, хранит в себе историю действий с документом
* @property integer $id // ID строки * @property integer $document_id // ID заголовка (ID из модели StoreDocument) * @property string $status // действие с документом значения: add, edit, exec, rollback, deleted, disabled * @property integer $good_id // ID товара * @property integer $characteristic_id // ID характеристики товара * @property float $quantity // количество * @property float $price // цена * @property float $quantity_fakt // количество по факту, используется в инвентаре * @property integer $history_num // номер действия по порядку в пределах одного документа * @property timestamp $add_dt // дата добавления строки * @property integer $party_account_id // ID заголовка партии в которую добавляется или с которой списывается товар, в зависимости от типа документа * @property integer $party_account_id_by_transfer // ID созданной партии при передаче товара между складами. тип документа - 'transfer' * @property integer $invoice_document_id // ID строки счета, связь со строкой товара, если товар списывался со склада при выполнении счета. * @property float $price_no_nds // Цена без НДС * @property float $cost_no_nds // Стоимость без НДС * @property float $stavka_nds_percent // Ставка НДС(%). Значение "-1" означает, что в документе указано "Без НДС". * @property float $sum_nds //Сумма НДС * @property float $cost // Стоимость с НДС
В этой модели есть уникальный ключ по полям (document_id, invoice_document_id, good_id, characteristic_id, history_num, party_account_id, status)
Пример StoreDocument
curl --location --request GET 'https://{DOMAIN NAME}/rest/api/StoreDocument/226' \
--header 'X-REST-API-KEY: {REST API KEY}' \
--header 'Content-Type: application/json'Ответ сервера
{
"success": true,
"message": "Record Retrieved Successfully",
"data": {
"totalCount": 1,
"storeDocument": {
"id": "226",
"document_type": "inventar",
"status": "save",
"store_id": "3",
"receiver_store_id": "0",
"supplier_id": "1",
"add_dt": "2021-09-22 14:47:17",
"edit_dt": "2021-09-22 14:52:41",
"exec_dt": "0000-00-00 00:00:00",
"receiver_id": "0",
"prihod_number": "",
"prihod_date": "0000-00-00",
"creator_id": "1",
"executor_id": "0",
"sender_user_id": "1",
"receiver_user_id": "0",
"transfer_sender_store_doc_id": "0",
"total": "0.0000000000",
"store": {
"id": "3",
"title": "склад1",
"assigned_user_id": "1",
"type": "sale",
"inventarization_date": "2021-09-22 14:38:23",
"status": "active",
"clinic_id": "1"
},
"storeDocumentOperations": [
{
"id": "630",
"document_id": "226",
"status": "add",
"good_id": "118",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "1",
"add_dt": "2021-09-22 14:47:17",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000"
},
{
"id": "633",
"document_id": "226",
"status": "edit",
"good_id": "118",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "2",
"add_dt": "2021-09-22 14:52:41",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000"
},
{
"id": "629",
"document_id": "226",
"status": "add",
"good_id": "119",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "1",
"add_dt": "2021-09-22 14:47:17",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000"
},
{
"id": "632",
"document_id": "226",
"status": "edit",
"good_id": "119",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "2",
"add_dt": "2021-09-22 14:52:41",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000"
},
{
"id": "631",
"document_id": "226",
"status": "add",
"good_id": "120",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "1",
"add_dt": "2021-09-22 14:47:17",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000"
},
{
"id": "634",
"document_id": "226",
"status": "edit",
"good_id": "120",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "2",
"add_dt": "2021-09-22 14:52:41",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000"
}
]
}
}
}Пример StoreDocumentOperation
curl --location -g --request GET 'https://{DOMAIN NAME}/rest/api/StoreDocumentOperation/?filter=[{"property":"document_id","value":226,"operator":"="}]' \
--header 'X-REST-API-KEY: {REST API KEY}' \
--header 'Content-Type: application/json'Ответ сервера
{
"success": true,
"message": "Records Retrieved Successfully",
"data": {
"totalCount": "6",
"storeDocumentOperation": [
{
"id": "630",
"document_id": "226",
"status": "add",
"good_id": "118",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "1",
"add_dt": "2021-09-22 14:47:17",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000",
"document": {
"id": "226",
"document_type": "inventar",
"status": "save",
"store_id": "3",
"receiver_store_id": "0",
"supplier_id": "1",
"add_dt": "2021-09-22 14:47:17",
"edit_dt": "2021-09-22 14:52:41",
"exec_dt": "0000-00-00 00:00:00",
"receiver_id": "0",
"prihod_number": "",
"prihod_date": "0000-00-00",
"creator_id": "1",
"executor_id": "0",
"sender_user_id": "1",
"receiver_user_id": "0",
"transfer_sender_store_doc_id": "0",
"total": "0.0000000000"
},
"good": {
"id": "118",
"group_id": "69",
"title": "!113товар",
"unit_storage_id": "9",
"is_warehouse_account": "1",
"is_active": "1",
"code": "",
"is_call": "0",
"is_for_sale": "1",
"barcode": "",
"create_date": null,
"description": "",
"prime_cost": "0.0000000000",
"category_id": null
}
},
{
"id": "633",
"document_id": "226",
"status": "edit",
"good_id": "118",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "2",
"add_dt": "2021-09-22 14:52:41",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000",
"document": {
"id": "226",
"document_type": "inventar",
"status": "save",
"store_id": "3",
"receiver_store_id": "0",
"supplier_id": "1",
"add_dt": "2021-09-22 14:47:17",
"edit_dt": "2021-09-22 14:52:41",
"exec_dt": "0000-00-00 00:00:00",
"receiver_id": "0",
"prihod_number": "",
"prihod_date": "0000-00-00",
"creator_id": "1",
"executor_id": "0",
"sender_user_id": "1",
"receiver_user_id": "0",
"transfer_sender_store_doc_id": "0",
"total": "0.0000000000"
},
"good": {
"id": "118",
"group_id": "69",
"title": "!113товар",
"unit_storage_id": "9",
"is_warehouse_account": "1",
"is_active": "1",
"code": "",
"is_call": "0",
"is_for_sale": "1",
"barcode": "",
"create_date": null,
"description": "",
"prime_cost": "0.0000000000",
"category_id": null
}
},
{
"id": "629",
"document_id": "226",
"status": "add",
"good_id": "119",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "1",
"add_dt": "2021-09-22 14:47:17",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000",
"document": {
"id": "226",
"document_type": "inventar",
"status": "save",
"store_id": "3",
"receiver_store_id": "0",
"supplier_id": "1",
"add_dt": "2021-09-22 14:47:17",
"edit_dt": "2021-09-22 14:52:41",
"exec_dt": "0000-00-00 00:00:00",
"receiver_id": "0",
"prihod_number": "",
"prihod_date": "0000-00-00",
"preator_id": "1",
"executor_id": "0",
"sender_user_id": "1",
"receiver_user_id": "0",
"transfer_sender_store_doc_id": "0",
"total": "0.0000000000"
},
"good": {
"id": "119",
"group_id": "69",
"title": "!111товар1",
"unit_storage_id": "9",
"is_warehouse_account": "1",
"is_active": "1",
"code": "",
"is_call": "0",
"is_for_sale": "1",
"barcode": "",
"create_date": null,
"description": "",
"prime_cost": "0.0000000000",
"category_id": null
}
},
{
"id": "632",
"document_id": "226",
"status": "edit",
"good_id": "119",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "2",
"add_dt": "2021-09-22 14:52:41",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000",
"document": {
"id": "226",
"document_type": "inventar",
"status": "save",
"store_id": "3",
"receiver_store_id": "0",
"supplier_id": "1",
"add_dt": "2021-09-22 14:47:17",
"edit_dt": "2021-09-22 14:52:41",
"exec_dt": "0000-00-00 00:00:00",
"receiver_id": "0",
"prihod_number": "",
"prihod_date": "0000-00-00",
"creator_id": "1",
"executor_id": "0",
"sender_user_id": "1",
"receiver_user_id": "0",
"transfer_sender_store_doc_id": "0",
"total": "0.0000000000"
},
"good": {
"id": "119",
"group_id": "69",
"title": "!111товар1",
"unit_storage_id": "9",
"is_warehouse_account": "1",
"is_active": "1",
"code": "",
"is_call": "0",
"is_for_sale": "1",
"barcode": "",
"create_date": null,
"description": "",
"prime_cost": "0.0000000000",
"category_id": null
}
},
{
"id": "631",
"document_id": "226",
"status": "add",
"good_id": "120",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "1",
"add_dt": "2021-09-22 14:47:17",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000",
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000",
"document": {
"id": "226",
"document_type": "inventar",
"status": "save",
"store_id": "3",
"receiver_store_id": "0",
"supplier_id": "1",
"add_dt": "2021-09-22 14:47:17",
"edit_dt": "2021-09-22 14:52:41",
"exec_dt": "0000-00-00 00:00:00",
"receiver_id": "0",
"prihod_number": "",
"prihod_date": "0000-00-00",
"creator_id": "1",
"executor_id": "0",
"sender_user_id": "1",
"receiver_user_id": "0",
"transfer_sender_store_doc_id": "0",
"total": "0.0000000000"
},
"good": {
"id": "120",
"group_id": "69",
"title": "!114товар",
"unit_storage_id": "9",
"is_warehouse_account": "1",
"is_active": "1",
"code": "",
"is_call": "0",
"is_for_sale": "1",
"barcode": "",
"create_date": null,
"description": "",
"prime_cost": "0.0000000000",
"category_id": null
}
},
{
"id": "634",
"document_id": "226",
"status": "edit",
"good_id": "120",
"characteristic_id": "0",
"quantity": "10.0000000000",
"price": "0.0000000000",
"quantity_fakt": "8.0000000000",
"history_num": "2",
"add_dt": "2021-09-22 14:52:41",
"party_account_id": "41",
"party_account_id_by_transfer": "0",
"invoice_document_id": "0",
"inventar_quantity_fakt": "8.0000000000",
"inventar_quantity_before": "10.0000000000"
"price_no_nds": "0.0000000000",
"cost_no_nds": "0.0000000000",
"stavka_nds_percent": "0",
"sum_nds": "0.0000000000",
"cost": "0.0000000000",
"total_quantity_before_operation": "10.0000000000",
"good_quantity_before": "10.0000000000",
"good_quantity_after": "0.0000000000",
"total_good_cost_after": "0.0000000000",
"document": {
"id": "226",
"document_type": "inventar",
"status": "save",
"store_id": "3",
"receiver_store_id": "0",
"supplier_id": "1",
"add_dt": "2021-09-22 14:47:17",
"edit_dt": "2021-09-22 14:52:41",
"exec_dt": "0000-00-00 00:00:00",
"receiver_id": "0",
"prihod_number": "",
"prihod_date": "0000-00-00",
"creator_id": "1",
"executor_id": "0",
"sender_user_id": "1",
"receiver_user_id": "0",
"transfer_sender_store_doc_id": "0",
"total": "0.0000000000"
},
"good": {
"id": "120",
"group_id": "69",
"title": "!114товар",
"unit_storage_id": "9",
"is_warehouse_account": "1",
"is_active": "1",
"code": "",
"is_call": "0",
"is_for_sale": "1",
"barcode": "",
"create_date": null,
"description": "",
"prime_cost": "0.0000000000",
"category_id": null
}
}
]
}
}
Пример получения остатка товара на складах
curl --location --request GET 'https://{DOMAIN NAME}/rest/api/stores/RestOfGoodInWarehouse/?clinic_id=1&good_id=119' \
--header 'X-REST-API-KEY: {REST API KEY}' \
--header 'Content-Type: application/json'Ответ сервера
{
"success": true,
"message": "Records Retrieved Successfully",
"data": {
"totalCount": 1,
"rest_good_in_warehouse": {
"quantity": "22.000"
}
}
}Пример получения остатка товара на складах (разбивка по складам)
curl --location --request GET 'https://{DOMAIN NAME}/rest/api/Good/StockBalancesForProduct?clinic_id=1&good_id=119&user_id=1' \
--header 'X-REST-API-KEY: {REST API KEY}' \
--header 'Content-Type: application/json'Ответ сервера
{
"data": {
"stock_balances": [
{
"good_id": "119",
"good_title": "!111товар1",
"store_id": "1",
"store_title": "Склад клиники",
"qty": "12.000",
"unit_title": "гр"
},
{
"good_id": "119",
"good_title": "!111товар1",
"store_id": "3",
"store_title": "склад1",
"qty": "10.000",
"unit_title": "гр"
}
]
},
"success": true
}