I tried to read the ‘warehouse’ property of an entity of type ‘shops’ in a rule based on the event ‘ticket closing’, but can’t figure out how to access this data.
I also tried with other events:
Order added to ticket
Entity selected
Ticket entity changed
I tried to access it with
{ENTITY DATA:Shop:Warehouse}
this gives me an empty string
{ENTITY WAREHOUSE:Shop}
this just prints “{ENTITY WAREHOUSE:Shop}”
Why can I not access {ENTITY DATA:Shop:Warehouse}?
How (and when) can I access this data?
All right. So how do I access this field from a rule?
I basically have entity buttons on an entity screen for ‘Shops’, and when I click one of the buttons, it opens a ticket linked to this shop.
I need to know the warehouse for this shop entity somewhere between clicking on the entity button and closing the ticket. So far I haven’t found any way to access this field.
Is there any event where I can read the entity’s warehouse field?
You can use departments to switch between warehouse use for tickets if you are trying to tell it what warehouse the ticket should use. Would be easier vs trying to do this in rules. Unless I am reading what your intentions are wrong.
I am working on a way to use the POS menu for other things than sales. The idea is to have entity screens with their own ticket type and menu. The menu doesn’t show real products, but for example inventory items, or half finished products (depending on which entity screen it’s in).
That way I can use the built in POS menu to create inventory (for half finished products), move inventory, repackage inventory, etc…
Part of that system is where I can select a shop in a “move inventory” entity screen (in the “Depot warehouse” department for example), which then opens a menu with all items that can be moved from the current location to the default warehouse attached to that shop entity.
@pipo, that’s something I thought of trying to do at one point in time when I was trying to figure out how to do Supplier Payouts out of a Payout Department, but I could never get it to work properly, so I gave up and went in a different direction.
I would be interested to know when/if you get that working to see your implementation and ideas about it.
I’m almost finished with it. I’ve already got the “create half-products” part ready and “repackage inventory” (which is basically the same). I’m still working on the “moving inventory” part now. It just uses a script in the background to update or move the inventory when the ticket closes.
I’ll post a tutorial about it when it’s finished.
I thought about this as well but It didn’t feel right moving inventory this way I wanted something that felt more official. I am stuck with mine atm so I have shelved it until later.
It’s not really that ‘unofficial’, the batch file just goes through the ticket to check the orders and creates an inventory transaction document and inventory transactions, just like SambaPOS would do. Quite simple actually.
The only reason I need a script for that is that you can’t loop through ticket orders in SambaPOS…
… and some data that can’t be read when I need it…
No I did not mean that. I meant it just didnt feel right. Using a POS screen thats meant to handle orders to do it. I wanted something that was clearly for moving inventory with its own structure.
I don’t know, to me it seems like the most natural way to do it, since users are already used to using the POS menu. If you can do the inventory the same way, these actions can go much faster I think (and a much shorter learning time).
Even though I would like to see what you’ve done, I’ve come up with my own using PHP. It would be nice to see if your SQL matches my SQL, because I don’t yet know for sure if I’m doing things correctly (in development).
I know what you mean about the visual separation. That’s why I want to make sure the menu’s don’t look too much the same, so users will never be confused about what the menu is for…
Well your solution is definitely a lot more sophisticated, I am very impressed by what you did there…
My SQL is very simple. I’m not really an expert on SQL, so I’m sure they could be improved on, but as long as it works I’m happy .
My query to make the Inventory Transaction Document:
SET NOCOUNT ON;
INSERT INTO dbo.InventoryTransactionDocuments
VALUES (GETDATE(), convert(varchar, GETDATE(),113));
SELECT cast(SCOPE_IDENTITY() as int) AS ‘ID’
The queries to create an Inventory Transaction:
SET NOCOUNT ON
DECLARE @InventoryTransactionType int
SELECT @InventoryTransactionType = Id
FROM InventoryTransactionTypes
WHERE Name = $(InventoryTransactionTypeName)
DECLARE @SourceWarehouseID int
SELECT @SourceWarehouseID = DefaultSourceWarehouseId
FROM InventoryTransactionTypes
WHERE Id = @InventoryTransactionType
DECLARE @TargetWarehouseID int
SELECT @TargetWarehouseID =
CASE $(WarehouseOverrideName)
WHEN ‘’ THEN WarehouseId
ELSE (SELECT Id FROM Warehouses WHERE Name = $(WarehouseOverrideName))
END
FROM Departments
WHERE name = $(DepartmentName)
DECLARE @unit nvarchar(max)
SELECT @unit = TransactionUnit
FROM InventoryItems
WHERE Id = $(InventoryItemID)
DECLARE @Multiplier int
SELECT @Multiplier = TransactionUnitMultiplier
FROM InventoryItems
WHERE Id = $(InventoryItemID)
It takes 3 parameters: ticket id, department name and warehouse name
The file will go through the ticket, and move the inventory (with same name as the product names) to either the warehouse provided or the default warehouse for the department given.
I pass it these variables at “ticket closing”:
{TICKET ID} “{DEPARTMENT}” “Central storage”
or:
{TICKET ID} “{DEPARTMENT}” “”
(then it will get the warehouse from the department)
Can you not use separate “.sql” files and parameters for your queries in PHP? That would probably make it easier to create your code (and especially easier to read), instead of building it line by line.
If you can’t, maybe executing sqlcmd in PHP is another option?