Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 2 Next »

Base Url: /smartfin/api/v1/stockmgmt

The response of the following APIs will be returned as compressed form. To decompress it, please install https://www.npmjs.com/package/pako plugin and using the specific function ( inflate ) to decompress the response body.

During the implementation of HTTP service, HttpHeaders of each request need to be set as the format below:

headers: new HttpHeaders({
    'Content-Type': 'application/json'
}),
responseType: 'arraybuffer' as 'json' 


Retrieve Stock Details


POST /smartfin/api/v1/stockmgmt/select

Get all stocks that are visible to current user.

Authentication / Authorization

  • API Key

Headers

Schema


Headers:

  • Content-Type: application/json

Authorization:

  • string - JWT <<YOUR_API_KEY_HERE>> (required)

Request

Example:

JSON Body:

{
   "s_date":"2023-01-01",
   "e_date":"2023-12-15",
   "phy_trade_ids":[],
   "stock_lvls": ["EX"], // all the stock lvl in stock details are EX
   "is_ap": false //since stock lvl is EX, this will be false
}

Schema


s_date, e_date - string
  • Filter the stocks according to the given date range ( s_date = start date, e_date = end date )

phy_trade_ids - array[number]
  • Filter the stock details according to the physical trade id given in the body (each stock detail is assigned to a physical trade id. The response will only return the stock with the given physical trade id, regardless of s_date and e_date parsed.)

Response

Example:

{
    "error_code": 0,
    "value": {
        "dropdown_list":{
           "cost_name": ['1'],
           "d_port": ['1']
           "delivery_rule": [],
           "l_port": ['1'],
           "match_id":[
            {
               "bl_no": null,
               "brand":"INFO",
               "cargo_ops_id":39704,
               "contract_actual_price":"1",
               "contract_no": null,
               "match_id": 37427,
               "phy_trade_id":60538,
               "product":"TEST",
               "spec":"SPEC",
               ...
           },
           "stock_type": [
             {
               "value":1,
               "label": 'STOCK IN'
             },
             ...
          ]
          "stock_type": [
             {
               "value":1,
               "label": 'PHYSICAL'
             },
             ...
          ]
          "trans_supplier": ['1']
          "validation": ['stock_action', 'stock_type', 'wh_id', 'phy_trade_id']
          "wh_id": [
             {
               label: "PUR",
               value: 184,
               wh_add: "PUR",
               wh_entity: "PUR"
             },
             ...
          ],
          "phy_trade_id":[
            {
               "phy_trade_id":5546,
               "self_entity":"MAFINT COMPANY",
               "contract_no":null,
               "counterparty":"TEST",
               "qty":1007.0,
               "unit":"Metric Ton",
               "purchase_sale":"S",
               "product":"TEST",
               "spec":"SPEC",
               ...
           },
          ...
         ],
         "cost_name":[
            {
               "phy_trade_id":5546,
               "self_entity":"MAFINT COMPANY",
               "contract_no":null,
               "counterparty":"TEST",
               "qty":1007.0,
               "unit":"Metric Ton",
               "purchase_sale":"S",
               "product":"TEST",
               "spec":"SPEC"
            },
            ...
        ],
        "stmg": [
            {
              "bl_no": null,
              "brand": "INFO",
              "c_name": "MAF INFO",
              "cc_date":null,
              "cod_date":null,
              "con_stock_date": null,
              "contract_actual_price": 1,
              "contract_actual_qty": 50,
              "contract_no": null,
              "contract_tax_rate":null,
              "cost_amt": null,
              "cost_ccy":null,
              "cost_name": null,
              "counterparty": "CONCORD FORTUNE RESOURCES PTE. LIMITED",
              "create_by": 181,
              "create_time": 2023-11-01 10:14:45,
              "d_nor":null,
              "d_port":null,
              "do_date": null,
              "eta_note":null,
              "etd":null,
              "group_name": "Group A - Company Level INFO",
              "l_port": null,
              "link_phy_trade_id":null,
              "maf_group_id": 39
              "match_id": 37426,
              "pair_type": null,
              "phy_trade_id": 60538, 
              "phy_trade_mode": 4,
              "phy_trade_wh_id": null,
              "product": "INFO",
              "provisional_price": null,
              "purchase_sale":"P",
              "qty": 50,
              "remarks": null,
              "self_entity":"CONCORD FORTUNE RESOURCES PTE. LIMITED",
              "slot_no":null,
              "spec": "INFO",
              "stock_action": 1,
              "stock_brand": "INFO",
              "stock_contract_qty": 5000,
              "stock_date": "2023-11-01",
              "stock_e_date": null,
              "stock_id": 15998,
              "stock_qty": 1050,
              "stock_s_date": null,
              "stock_spec": "INFO",
              "stock_type": 1,
              "stock_user_id": 181,
              "stock_wh_id": 184,
              "ticket_ref_no": null,
              "trans_supplier": null,
              "u_name": null,
              "unit": "Metric Ton",
              "update_by": null,
              "update_time": null,
              "user_id": 181,
              "user_name": "MAF Info",
              "wh_add": "PUR",
              "wh_entity": "PUR",
              "wh_id": 184,
              "wh_name": "PUR"
            },
            ..
        ]
    }
}

Returns

  • a list of objects named stmg, each representing a stock detail (in descending order of stock_id)

  • a list of dropdown_list that consists variety of selection lists to be used when inserting/ updating stock details.

Schema


last_update_time, update_by_name, update_by - string

Information about last updated time for the data and the user who updating the data.

create_time, create_by, create_by_name - string

Information about created time for the data and the user who creating the data.

user_id, stock_id, phy_trade_id, wh_id - integer
  • user_id - User Id ( who the data belongs to)

  • stock_id - A unique ID assigned to the data. This ID can be used to retrieve stock details.

  • phy_trade_id - The physical trade id that assigned with the stock.

  • wh_id - The warehouse id that are assigned with the stock.

group_name - string
maf_group_id - integer
  • maf_group_id - A unique group ID where the stock belongs to.

wh_add, wh_entity, wh_name - string
wh_id - integer
  • wh_id - A unique warehouse ID where the stock belongs to.

  • wh_add, wh_entity, wh_name - related details of the warehouse.

Update / Insert Stock Details


Update:
POST /smartfin/api/v1/stockmgmt/execution_update

Insert:
POST /smartfin/api/v1/stockmgmt/execution_insert

Insert new or update existing stock details into database

Authentication / Authorization

  • API Key

Headers

Schema


Headers:

  • Content-Type: application/json

Authorization:

  • string - JWT <<YOUR_API_KEY_HERE>> (required)

Request ( Update )

Example:

JSON Body:

{
   "phy_trade_ids":[
      59106
   ],
   "update_list":[
      {
         "stock_id":35178,
         "stock_date":"2023-09-11",
         "stock_type":1,
         "phy_trade_id":59106,
         "stock_wh_id":184,
         "stock_action":1,
         "trans_supplier":"",
         "slot_no":"",
         "stock_qty":111,
         "match_id":35178,
         "stock_s_date":"",
         "stock_e_date":"",
         "eta_note":"",
         "cod_date":"",
         "cost_name":"",
         "cost_amt":"",
         "cost_ccy":"",
         "ticket_ref_no":"",
         "remarks":"",
         "bl_no":"9",
         "l_port":"",
         "etd":"",
         "d_port":"",
         "d_nor":"",
         "cc_date":"",
         "do_date":"",
         "stock_brand":"OFFSHOREP",
         "stock_spec":"OFFSHOREP",
         "cargo_ops_id":38301,
         "delivery_rule":"",
         "link_phy_trade_id":"",
         "stock_contract_qty":1111,
         "pair_type":null
      }
   ],
   "s_date":"2023-01-01",
   "e_date":"2023-12-15",
   "phy_products":[]
}

Request ( Insert )

Example:

JSON Body:

{
   "phy_trade_ids":[
      60667
   ],
   "insert_list":[
      {
         "stock_id":"",
         "stock_date":"2023-12-01",
         "stock_type":1,
         "phy_trade_id":60667,
         "stock_wh_id":183,
         "stock_action":2,
         "trans_supplier":"",
         "slot_no":"",
         "stock_qty":1000,
         "match_id":"",
         "stock_s_date":"",
         "stock_e_date":"",
         "eta_note":"",
         "cod_date":"",
         "cost_name":"",
         "cost_amt":"",
         "cost_ccy":"",
         "ticket_ref_no":"",
         "remarks":"",
         "bl_no":"",
         "l_port":"",
         "etd":"",
         "d_port":"",
         "d_nor":"",
         "cc_date":"",
         "do_date":"",
         "stock_brand":"",
         "stock_spec":"",
         "cargo_ops_id":39833,
         "delivery_rule":"",
         "link_phy_trade_id":"",
         "stock_contract_qty":1000
      }
   ],
   "s_date":"2023-01-01",
   "e_date":"2023-12-15",
   "phy_products":[
      
   ]
}

Schema


s_date, e_date - string
  • Filter the stocks according to the given date range ( s_date = start date, e_date = end date )

phy_trade_ids - array[number]
  • The physical trade id/s that will be updated ( when the valid id is parsed, the trade’s stock details will be updated ( stock quantity, un-stock quantity etc.) )

insert_list - array[object]

update_list - array[object]

Response:

Delete Stock Details


DELETE /smartfin/api/v1/stockmgmt/delete

Deletes single / multiple stock details according to its stock_id

Authentication / Authorization

  • API Key

Headers

Schema


Headers:

  • Content-Type: application/json

Authorization:

  • string - JWT <<YOUR_API_KEY_HERE>> (required)

Request

Example:

JSON Body:

{
   "del_ids":[1004],
   "phy_products":[],
   "phy_trade_ids":[54794],
   "s_date":"2023-01-01",
   "e_date":"2023-12-15",
   "pair_types":[],
   "stock_lvls": ["EX"], // all the stock lvl in stock details are EX
   "is_ap": false //since stock lvl is EX, this will be false
}
del_ids - array[integer]
  • An array that consists unique stock_id, that user would like to delete from.

phy_trade_ids - array[number]
  • The physical trade id/s that will be updated ( when the valid id is parsed, the trade’s stock details will be updated ( stock quantity, un-stock quantity etc.) )

Response:

  • No labels