Help or advise on this issues

Post your Gambas programming questions here.
Post Reply
AndyGable
Posts: 362
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Help or advise on this issues

Post by AndyGable »

Hi All,

I am getting on very well with my EPoS application but I am not sure how to do the following thing....

at the moment I am saving every item individually to a temp file so the file would look like this

Code: Select all

1,I,50201600,2,0.35,0.70
if I void one I would have to do the following

Code: Select all

1,IV,50201600,1,0.35,0.35
Is there a better way to store the information as the receipt would currently look like this

CREAME EGG
2 @ £0.35 £0.70
**Item Voided **
CREAM EGG -£0.35

Ideally I would like it just to show

CREAME EGG £0.35

In the Windows Version I am using a listarray and below is the code I am using (.net)

Code: Select all

Imports algPoSMultisavers (this is my custom write mutlisaver module that I need to some how convert to Gambas)

Public Class ReceiptData

    Inherits List(Of LineItem)

    Private _transactionId As Integer = 0

    Public Sub New()
    End Sub

    Public Shadows ReadOnly Property Count() As Integer
        Get
            Return (MyBase.Count)
        End Get
    End Property

    Default Public Shadows Property Item(ByVal anIndex As Integer) As LineItem
        Get
            Return (MyBase.Item(anIndex))
        End Get

        Set(ByVal value As LineItem)
            MyBase.Item(anIndex) = value
        End Set
    End Property

    Public Shadows Function Add(ByVal anItem As LineItem) As Integer
        _transactionId += 1

        anItem.TransactionIDNumber = _transactionId

        MyBase.Add(anItem)

        MultisaversComponent.OnProductAdded(anItem.TransactionIDNumber, New MultisaverProduct(anItem.ItemBarcodeNumber, anItem.Line1, SaleLocation_Main, anItem.LinePrice), anItem.QtySold, Now(), CBool(PriceOverrideValue > 0))

        Return (_transactionId)
    End Function

    Public Shadows Sub Remove(ByVal anItem As LineItem)
        Debug.Print("Item removed from receipt by reference.")
        MyBase.Remove(anItem)
    End Sub

    Public Shadows Sub RemoveAt(ByVal anIndex As Integer)
        Debug.Print("Item removed from receipt by index.")
        MyBase.RemoveAt(anIndex)
    End Sub

    Public Shadows Sub Clear()
        MyBase.Clear()
        MultisaversComponent.Reset()
        UpdateMSData()
        _transactionId = 0
    End Sub
End Class

and when I sell a item I add it like this

Code: Select all

RecData.Add(New LineItem(ItemType, RecData.Count, ItembarcodeNumber, Line1, Line2, Line3, Line4, LineTotal, LinePrice, VATCode, LocalLineNumber, LocalQtySold, "", 0, "", 0, 0, SaleLocationNumber))
and to remove it from the list I do this RecData.RemoveAt(LocationNumber)

I also use this to create the recipit that the system prints.

any advise is most welcome as I am not sure what aproach to take with this.
User avatar
BruceSteers
Posts: 1563
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Help or advise on this issues

Post by BruceSteers »

I would make a class to manage an array of transactions and then process/send the finished list when ready

I've added a basic example.

It has a Transaction.class that used statically can add/void items with I or IV , i made it to use your string but you could use natural datatypes or anything else you want.

It has a simple test form.

Used like this...

' Add 2 identical items
  Transaction("I,50201600,1,0.35")
  Transaction("I,50201600,1,0.35")

' void 1 of them
  Transaction("IV,50201600,1,0.35")


the List items button iterates through the pending transactions like this..
  For Each trans As Transaction In Transaction.All
    Print trans.ID, trans.Quantity, trans.Cost, trans.Total
  Next
You could modify that to send your strings to the device without any voids when ready.
All items will be your "I" type not "IV"
there is a GetText function for a Transaction will produce your string without the "I," something like this...
  For Each trans As Transaction In Transaction.All
    Print "I," & trans.GetText()
  Next
will print "I,50201600,1,0.35"

any multiple items will be listed as one ID with the relevant quantity

I really have no clue as to exactly how you need to do this but maybe this code will help?

Bruce
Attachments
Transactions-0.0.2.tar.gz
(12.81 KiB) Downloaded 69 times
If at first you don't succeed , try doing something differently.
BruceS
Post Reply