4 Replies Latest reply on Sep 25, 2015 12:13 AM by bigtom

    Decrease stock quantity from item sold when sales completed

    Kishan_Canoo

      I have a point of sale solution and i have also a stock module attached to the solution.

      Basically the main function will process each item sold from the Point of sale screen whatever the quantity and will reduce the stock quantity on the stock layout after complete the transaction.

      Also if ever i want to delete the complete sale i would like a script to re-update the stock quantity and delete the transaction.

      I am unable to perform this task and it was much harder than I thought.

      I have attached an example of my solution for your touch.

      I would also request if it could make it simple as possible.

        • 1. Re: Decrease stock quantity from item sold when sales completed
          electon

          I'd suggest using the same script you use to reduce the stock but multiply your quantities by -1.


          I'm personally not so keen on deleting invoices. But it will depend on requirements, I guess.

          I mark wrong invoices as VOID, once they have been issued and goods are not physically shipped / delivered yet.

          Just so there are no weird gaps for the tax man, they can see it as a page torn out of a book .

           

          In other cases a Return / Credit invoice takes care of that. With negative quantities.

           

          Are you unable to create a script that reduces the stock?

           

          In simplest form if go to related record of ITEM PORTAL and loop through all records:

           

          // default multiplier

          Set Variable ( $multiplier = 1 )

           

          If ( $delete = True )

          Set Variable ( $multiplier = -1 )

          End If

          // !!! you could set the $delete variable from a script parameter

           

          GoToRecord ( First )

          Loop

          SetField ( Stock::Quantity In Stock ; Stock::Quantity In Stock - ( Item Portal::Quantity * $multiplier  )  )

          GoToRecordNext ( ExitAfterLast )

           

          GoToLayout ( OriginalLayout )

           

           

          HTH.

          Thomas.

          • 2. Re: Decrease stock quantity from item sold when sales completed
            bigtom

            I concur that deleting invoices is a practice you should avoid in most cases. Mark them as void or cancelled.

             

            I do this with a layout based on invoices that has a portal with the line items and the total stock qty for the product. The script loops through the portal rows grabs the line item count and adjusts the stock qty. It is fast and I have it run on server as that seems to keep the data updated faster.

             

            There are other ways to get it done, but I think with the basic ideas you have here you should be able to get it working. depending on how you handle your invoices this can also keep the same invoice and just update stock if a line item qty goes up or down after the original data was entered.

            • 3. Re: Decrease stock quantity from item sold when sales completed
              Kishan_Canoo

              I have an issue regarding the calculation, actually everything is working well with the solution and the only problem may be happened if more items are added the system will get slower and slower.

              If there is a way to avoid the system to become slower by using the actual calculation?

              • 4. Re: Decrease stock quantity from item sold when sales completed
                bigtom

                It should not be slow at all. If it is there is a problem somewhere.