Import data via csv files (version 1.5)

Import data via csv files (version 1.5)

You can download demo data here.

In order to load data to ForesightAI, you can either use one of our connectors if your data reside on the connected platforms or use this general import to include your data into the ForesightAI platform. The data should contain your product and sales information for optimum at least last 2 years in order to perfectly compute seasonality or any other trends.

This article describes the data structure exactly how we need it in order for ForesightAI to work correctly. Once you have the structure ready, you will be ready to upload the data and create a connection. If you are ready to do so, please read this article on how it is done. But first:

Data spaces

There are 2 data spaces for the ForesightAI.

  • Sales Data

  • Promotion Data

Sales Data contains all your product, warehouse and transaction information. Based on past transactions we can forecast future sales and based on product-warehouse data (current state of amount on stock for example) we can tell you what to order and when.

In order for perfectly analyse sales and predict future we need information about your promotions. Past promotions serve as a benchmark to see if the high sales are due to higher demand or due to promotion, future promotion serves us to higher the expected forecast because of it. In the best scenario both past and planned promotions will help us compute better forecast and orders.

Entity types

There are several entity types we import in order to compute all necessary data. Each fits into its own .csv file.

  • Warehouse - this entity holds information about warehouse or any other place where we store items (point of sales etc)

  • Product - basic information about product - name, category

  • Supplier - basic information about suppliers

  • Category - categorisation of the products (like product lines, brands etc.) - ForesightAI currently supports only one level of categories (so no nested or parent-child categories are taken into account)

  • Warehouse-product - In warehouse product connecting data are specific data for each product on given warehouse (so for example product A on Warehouse 1 has different inventory on hand or price than on Warehouse 2)

  • Transactions - Each transaction is one sales item, so if one order has 2 products sold, it is 2 transactions in ForesightAI. Data can be grouped per item per day (so all sold Product A per day from Warehouse 1)

  • Currency - Indicating primary and (if applicable) secondary currency of the system to be displayed.

Data

Currency (currency.csv)

Field

Type Comment

currency_id

ISO code of currency for example USD

default

tinyint 0/1 There should be only one default currency per file (the default one)

Warehouse (warehouse.csv)

Field Type Comment
warehouse_id generated id [0-9a-zA-Z_-]  
name Varchar 64  
parent_warehouse_id generated id [0-9a-zA-Z_-] ID of parent warehouse, for use in case of supplying your warehouse/shop from central warehouse for example

Product (product.csv)

Field Type Comment
product_id generated id [0-9a-zA-Z_-]  
name Varchar 64  
category_id FK - category_id FK = Foreign key - link to category based on the category_id (that category must exist)
shortcut Varchar 255 ID that is displayed to the user in the app as id of the product, if empty, it is filled with product_id
brand Varchar 255 tags which will help you to cluster your portfolio by brands (you can use it on the replenishment as a filter etc.)
collection Varchar 255 especially useful for fashion industry (limited collections etc)
product_id_by_supplier Varchar 255 Product ID which is helping your suppliers to identify items on the purchase orders
ean Varchar 255 EAN code (European Article Number (International Article Number))

Supplier (supplier.csv)

Field Type Comment
supplier_id generated id [0-9a-zA-Z_-]  
name Varchar 64  
currency_id ISO code of currency  

Category (category.csv)

Field Type Comment
category_id generated id [0-9a-zA-Z_-]  
name Varchar 64  

Warehouse product (warehouse_product.csv)

Field Type Comment
warehouse_id FK - warehouse_id link to warehouse via ID
product_id FK - product_id link to product via ID
available_supply Decimal available amount of this goods on stock
stock_price Decimal price of cost for this unit
sale_price Decimal usual selling price of this goods
supplier_id FK - supplier_id  
minimal_order_quantity Decimal minimal order quantity for this product, if not available empty value (as NULL)
minimal_order_set Decimal minimal order set (for example packaging) for this product, if not available empty value (as NULL) If the minimal quantity is 100 and minimal set is 10 the orders will be 100,110,120 etc. if minimal quantity is 0, the orders are in multiply of minimal_order_set (10,20,30..)
visible tinyint if 1 then product is processed by ForesightAI (is active), if 0 then product is skipped completely
order tinyint if 1 then product can be proposed in replenishment, if 0 product cannot be proposed
created_at string the exact date when the SKU/item was created,

Format W3C Y-m-d\TH:i:sP

example: 2005-08-15T15:52:01+00:00

similar_product_id FK - product_id ID of the predecessor, ForesightAI will automatically utilize the sales history from this predecessor
basestock_min Decimal minimum inventory you would like to keep
basestock_max Decimal maximum inventory you would like to keep
expiration_in_days Decimal real expiration in days after delivery to your warehouse
minimal_period Decimal purchase order period in days
leadtime Decimal lead time in days

Transaction (transaction.csv)

Field Type Comment
transaction_id generated id [0-9a-zA-Z_-] usually line number
transaction_type_id see transaction types  
warehouse_id FK - warehouse_id warehouse from which this product was sold
product_id FK - product_id  
date_of_transaction YYYY-MM-DD  
amount Decimal amount sold in units
price Decimal unit price of transaction, in case of sales transaction it is unit sell price, in case of other transactions it is unit stock price
stock_price Decimal cost of this goods (per unit)
supplier_id FK - supplier_id if the transaction is of type Purchase
promo_sale 0,1 If this sale had some discount or other promo
extreme_sale 0,1 if the sale is extreme(1) it is not used for forecasting
date_of_order YYYY-MM-DD if the transaction os of type Purchase, empty otherwise

Transaction types

In ForesightAI we can import multiple types of transaction (sales, purchase, stock-taking, transfer of goods etc.). The must for the integration are sales and purchase transaction. For explanation of the rest please contact us.

For the initial import, please consider using sales and purchase transactions - each has its own transaction_type_id.

1 = Sales Transaction (if the amount is <0 than it is Cancellation of the sales)

2 = Purchase Transaction (if the amount is <0 than it is Cancellation) - you are purchasing the product from your supplier

If you want to include cancelations (return of the goods) use the same transaction_type_id but use negative value in the amount field. The logic is always - positive amount = succesful transaction, negative amount = return or cancelation. ForesightAI does not calculate the cancelation exactly in the month as it occurred but tries to find the transaction which is cancelled and negate that previous sales. So that if you on 2020-31-07 sell 10 items and 1.8 ForesightAI see -10 items, you will see 0 sell in month 07 and 08 as well.

Read more information about transactions (and more deeper transaction types).

Replenishment

If you have multiple warehouses and want the orders to be generated only to the central warehouse please fill in the data as follows:

1) Central warehouse should be first in the warehouse file and its parent_warehouse_id should be empty

2) All stores which are replenished through central warehouse should :

  • in warehouse.csv have filled in parent_warehouse_id as central warehouse

  • for each item in warehouse_product which is replenished through central warehouse the "supplier_id" field should be empty

  • for each item in warehouse_product which is supplied directly - supplier_id should be filled in

3) please make sure that each good in replenished warehouse there is the same product on central warehouse.

Optional Delivery Data

In order to tell ForesightAI that you are already expecting some goods (goods in transit) you can fill data for future_delivery. Please put in future_delivery only the goods which might come in near future. If the order was partially fulfilled we expect that the fulfilled part is in transactions as transaction_type_id=2 and the unfulfilled amount (should it still arrive) should be inserted into future_delivery data. The second type is customer order you are expecting in the future to be delivered.

Future delivery or Inventory in transit or Customer Orders (future_delivery.csv)

Field Type Comment
future_delivery_id generated id [0-9a-zA-Z_-] Unique identifier of Inventory in transit
future_delivery_type use SUPPLIER_ORDER for Purchase Orders in Transit or CLIENT_ORDER for Customer Orders Optional. If you don't use column future_delivery_type at all. All records are considered type=SUPPLIER_ORDER
product_id FK - product_id link to the product - must exist in products and warehouse_product
warehouse_id FK - warehouse_id link to warehouse where the goods will be delivered
supplier_id FK - supplier_id link to supplier (empty if the order is between two locations (warehouses)
parent_warehouse_id FK - warehouse_id link to warehouse(empty if the order is from the supplier)
date_of_order YYYY-MM-DD when the purchase order was created
estimated_date_of_delivery YYYY-MM-DD when the purchase order will be delivered
amount Decimal amount of goods in transit
purchase_price Decimal purchasing unit price

If you wish to give us during the integration phase your minimal periods (how often you buy such goods) and leadtimes (how fast you can receive goods upon placing an order) you can give us data in this format.

Supplier configuration (supplier_configuration.csv)

Field Type Comment
supplier_id FK - supplier_id  
minimal_period int minimal purchase period
leadtime int usual lead time in days for this provider/supplier
leadtime_std int days of standard deviation for lead time

Later it is recommended to update the values in the ForesightAI application.

Promotion Data (promotion.csv)

Field Type Comment
promotion_type coupon, gift, discount, other, listing, delisting  
promotion_id generated id [0-9a-zA-Z_-] identifier of promotion to separate multiple promotions
product_id FK - product_id
warehouse_id FK - warehouse_id if empty applies to products on all warehouses
promotion_date_from YYYY-MM-DD start of the promotion
promotion_date_to YYYY-MM-DD end of the promotion
power Decimal power of the promotion (for example 10 represents 10% discount)
estimated_amount Decimal if you know how many you expect to sell during that promotion

Forecast only Sales data

If you need to compute only forecast and do not need to compute orders or help with stock, the minimal amount of information we need to get from you is this information.

The format of the files should be the same, the information not in the table below should be empty column or 0 for numbering fields.

entity

field

Type

Comment

WAREHOUSE

warehouse_id

generated id [0-9a-zA-Z_-]

 

name

Varchar 64

 

PRODUCT

product_id

generated id [0-9a-zA-Z_-]

 

name

Varchar 64

 

category_id

FK category_id

 

CATEGORY

category_id

generated id [0-9a-zA-Z_-]

 

name

Varchar 64

 

WAREHOUSE_PRODUCT

warehouse_id

FK - warehouse_id

 

product_id

FK - product_id

 

TRANSACTION

transaction_id

generated ID

usually line number

transaction_type_id

see transaction types

 

warehouse_id

FK - warehouse_id

warehouse from which this product was sold

product_id

FK - product

 

date_of_transaction

YYYY-MM-DD

 

amount

Decimal

amount sold in units

promo_sale

0,1

If this sale had some discount or other promo

extreme_sale

0,1

if the sale is extreme(1) it is not used in forecasting

Data Import CSV

Data are sent as CSV files. Entity type (entity type is for example Warehouse or Product) consists of all records of that entity type (so all warehouses are lines in one file warehouse.csv, we do not support multiple csv per type - for example it is not possible to send half of the products in one csv file and half in other csv file).

Foreign key - FK fields(connections between entities - like for example category to product link) must be filled and must match foreign entity, otherwise the row will not be inserted. For example if we find transaction which does not have product attached we ignore it for both forecast and orders suggestions.

Filename for each entity type is a possible to set up in initial setting, but should follow these naming conventions:

  • warehouse.csv

  • product.csv

  • supplier.csv

  • category.csv

  • warehouse_product.csv

  • transaction.csv

  • supplier_configuration.csv

  • currency.csv

Please also check the most common mistakes with data preparation when integrating ForesightAI with CSV files.

You can download demo data here.

Version

This document describes the data structure in following version:

  • Version of sales data - 1.5

  • Version of promotion data - 1.5

Was this article helpful?

Have more questions? Submit a request