found a way to do part two as well, although I had to use some scripting and database manipulation (made for SambaPOS 3 with SQL Server, can be used in V4 or without SQL server with some adaption):
I created stored procedures in SQL server to make Inventory Transaction Documents and Inventory Transactions:
USE SambaPOS3;
– ================================================
IF OBJECT_ID (N’dbo.NewInventoryItemTransactionDocument’) IS NOT NULL
DROP PROCEDURE dbo.NewInventoryItemTransactionDocument
GO
– ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
– =============================================
CREATE PROCEDURE NewInventoryItemTransactionDocument
– Add the parameters for the stored procedure here
AS
BEGIN
– SET NOCOUNT ON added to prevent extra result sets from
– interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO dbo.InventoryTransactionDocuments
VALUES (GETDATE(), convert(varchar, GETDATE(),113));
SELECT cast(SCOPE_IDENTITY() as int) AS 'ID'
END
GO
and:
USE SambaPOS3;
– ================================================
IF OBJECT_ID (N’dbo.NewInventoryTransaction’) IS NOT NULL
DROP PROCEDURE dbo.NewInventoryTransaction
GO
– ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
– =============================================
CREATE PROCEDURE NewInventoryTransaction
– Add the parameters for the stored procedure here
@InventoryTransactionDocumentID int,
@InventoryTransactionType int,
@Quantity decimal(16,3),
@Price decimal (16,2),
@InventoryItemID int
AS
BEGIN
– SET NOCOUNT ON added to prevent extra result sets from
– interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
DECLARE @SourceWarehouseID int
SELECT @SourceWarehouseID = DefaultSourceWarehouseId
FROM InventoryTransactionTypes
WHERE Id = @InventoryTransactionType
DECLARE @TargetWarehouseID int
SELECT @TargetWarehouseID = DefaultTargetWarehouseId
FROM InventoryTransactionTypes
WHERE Id = @InventoryTransactionType
DECLARE @unit nvarchar(max)
SELECT @unit = TransactionUnit
FROM InventoryItems
WHERE Id = @InventoryItemID
DECLARE @Multiplier int
SELECT @Multiplier = TransactionUnitMultiplier
FROM InventoryItems
WHERE Id = @InventoryItemID
INSERT INTO dbo.InventoryTransactions
VALUES (@InventoryTransactionDocumentID,
@InventoryTransactionType,
@SourceWarehouseID,
@TargetWarehouseID,
GETDATE(),
@Unit,
@Multiplier,
@Quantity,
@Price,
@InventoryItemID
);
END
GO
Then I made a batch file to access these stored procedures (AddInventory.bat):
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
set InventoryName=%1
set InventoryAmount=%2
set InventoryTransactionType=4
set SName=localhost\SAMBAPOS3
set DbName=SambaPOS3
set UserName=“sa”
set Password=“mypassword”
set ERRFILE=“C:\SambaPOS3\_ErrFile_Report.txt”
if exist %ERRFILE% del %ERRFILE%
cls
::----------find the InventoryItem ID--------------------------
::-------------------------------------------------------------
set SQL=“SELECT ID FROM InventoryItems WHERE Name = ‘%InventoryName%’”
sqlcmd -S %SName% -d %DbName% -U %UserName% -P %Password% -I -h-1 -Q %SQL% > result.txt
set /p InventoryItemID=< result.txt
:trimLeadingSpace
if “%InventoryItemID:~0,1%” equ " " (
set InventoryItemID=%InventoryItemID:~1%
goto :trimLeadingSpace
)
::----------make new inventory transaction document, get its ID
::-------------------------------------------------------------
sqlcmd -S %SName% -d %DbName% -U %UserName% -P %Password% -I -h-1 -Q “exec NewInventoryItemTransactionDocument” > result.txt
set /p TransactionDocumentID=< result.txt
:trimLeadingSpace2
if “%TransactionDocumentID:~0,1%” equ " " (
set TransactionDocumentID=%TransactionDocumentID:~1%
goto :trimLeadingSpace2
)
::----------make new inventory transaction---------------------
::-------------------------------------------------------------
sqlcmd -S %SName% -d %DbName% -U %UserName% -P %Password% -I -Q “exec NewInventoryTransaction $(p1), $(p2), $(p3), $(p4), $(p5)” /v p1=%TransactionDocumentID% p2=%InventoryTransactionType% p3=%InventoryAmount% p4=‘0’ p5=%InventoryItemID%
The parts in bold will have to be changed for other people:
- InventoryTransactionType should be the ID of the InventoryTransactionType for a purchase (you can create a new one for ‘half product creation transaction’ and check its ID in SQL server)
- SName is the name of your SQL Server instance
- DBName is the name of your database
Then I created an action to call this batch file:
Then I added a rule to gift the product and make an inventory transaction when an order is added:
with mapping only for the Kitchen department:
and a rule to decrease the inventory (make an inverse inventory transaction) when an order is cancelled:
(also with mapping only to Kitchen department)
And that’s pretty much it. Now I can ‘sell’ things in my Kitchen department (for free), which automatically creates inventory for these ‘half products’, and keeps track of the inventory of ingredients used at the same time. I can keep track of ingredient inventory and ‘half product’ inventory in the Warehouse screen, do end-of-day records, etc…
It’s important though to name the products in the Kitchen department the same as the inventory item associated with it.