InventoryChanges
Query historical physical counts and adjustments on inventory items.
Table Specific Information
Select
The 本製品 uses the Square API to process search criteria that refer to the Type, CatalogObjectId, State and LocationId column, while other filters are processed client side within the 本製品. You can turn off the client-side execution of the query by setting SupportEnhancedSQL to false in which case any search criteria that refers to other columns will have an unfiltered response.
Select all the inventory changes:
SELECT * FROM InventoryChanges
Select all the inventory changes from a specific location ID:
SELECT * FROM InventoryChanges WHERE LocationId='Sandbox_Location_Id'
Select all the inventory changes with a specific type:
SELECT * FROM InventoryChanges WHERE Type='ADJUSTMENT'
Select all the inventory changes in a specific state:
SELECT * FROM InventoryChanges WHERE State='IN_STOCK'
Select all the inventory changes for a specific catalog object:
SELECT * FROM InventoryChanges WHERE CatalogObjectId='5QJP4XMEN5TQ4W4UY7YL'
Insert
To create an inventory change, you will need to specify the Type, CatalogObjectId, Quantity column.
Insert an inventory change of type 'PHYSICAL_COUNT' :
Insert INTO InventoryChanges(Type,CatalogObjectId,State,Quantity) Values('PHYSICAL_COUNT','5QJP4XMEN5TQ4W4UY7YL','IN_STOCK',16)
Insert an inventory change of type 'ADJUSTMENT' :
Insert INTO InventoryChanges(Type,CatalogObjectId,FromState,ToState,Quantity) Values('ADJUSTMENT','5QJP4XMEN5TQ4W4UY7YL','IN_STOCK','SOLD',5)
Columns
Name | Type | ReadOnly | Description |
Id [KEY] | String | False |
A unique ID generated by Square for the Inventory change. |
ReferenceId | String | False |
An optional ID provided by the application to tie the Inventory change to an external system. |
Type | String | False |
Indicates how the inventory change was applied. 使用できる値は次のとおりです。PHYSICAL_COUNT, ADJUSTMENT |
CatalogObjectId | String | False |
The Square generated ID of the CatalogObject being tracked. |
CatalogObjectType | String | False |
The CatalogObjectType of the CatalogObject being tracked. Tracking is only supported for the ITEM_VARIATION type. |
State | String | False |
The current InventoryState for the related quantity of items. |
LocationId | String | False |
The Square ID of the Location where the related quantity of items are being tracked. |
Quantity | String | False |
The number of items affected by the physical count as a decimal string. |
EmployeeId | String | False |
The Square ID of the Employee responsible for the physical count. |
OccurredAt | Datetime | False |
A client-generated timestamp in RFC 3339 format that indicates when the physical count took place. For write actions, the occurred_at timestamp cannot be older than 24 hours or in the future relative to the time of the request. |
CreatedAt | Datetime | False |
A read-only timestamp in RFC 3339 format that indicates when Square received the physical count. |
FromState | String | False |
The InventoryState of the related quantity of items before the adjustment. |
ToState | String | False |
The InventoryState of the related quantity of items before the adjustment. |
TotalPriceMoneyAmount | Integer | False |
The amount of the total price paid for goods associated with the adjustment. Present if and only if to_state is SOLD. Always non-negative. |
TotalPriceMoneyCurrency | String | False |
The currency of the total price paid for goods associated with the adjustment. Present if and only if to_state is SOLD. Always non-negative. |
TransactionId | String | False |
The read-only Square ID of the [Transaction][#type-transaction] that caused the adjustment. Only relevant for payment-related state transitions. |
RefundId | String | False |
The read-only Square ID of the Transaction that caused the adjustment. Only relevant for payment-related state transitions. |
PurchaseOrderId | String | False |
The read-only Square ID of the Refund that caused the adjustment. Only relevant for refund-related state transitions. |
GoodsReceiptId | String | False |
The read-only Square ID of the Square goods receipt that caused the adjustment. Only relevant for state transitions from the Square for Retail app. |
FromLocationId | String | False |
The Square ID of the Location where the related quantity of items were tracked before the transfer. |
ToLocationId | String | False |
The Square ID of the Location where the related quantity of items were tracked before the transfer. |