dddan

json file gets wrong (unstored) totals

Discussion created by dddan on Jul 18, 2016
Latest reply on Jul 18, 2016 by dddan

Hi

Just encountered a strange thing, was wondering if anyone else had seen this. I have a client (a shop) who has been using a FM system (v14 server plus 6 clients on Mac) for all his sales and purchases.  One of the things the system does is calculating (simplified explanation) the actual stock of each item by summarising all quantities that were purchased minus all quantities that were sold plus the opening stock which is manually entered.

Because this is done through relationships (UUID of each item to the sales and purchase lines that have the same Item UUID) the current stock count is an unstored value.

 

I am  working together with a web designer because the client wants to extend his webshop to display not only all products, but also their current stock count. The web designer uses PHP and has a script in place where he 'asks' FM Server for a json file of all current items. This works well. The json file contains the prices, brands, etc.

(he has access to one layout, there is a script that he calls when logging in which takes him to that layout, it finds all the Items that should be exported to the web shop, and then he generates his json file based on the found set)

 

But now I added the (unstored) stock counts to the layout/json file, and these counts in the json file are sometimes right, but more often wrong. It seems that if no sales or purchases were done with an item then it will grab the right opening stock (which is a stored value) but it seems that the more purchases and sales lines are associated with an item, the more the stock count is off.

My impression is that the generation of the json file doesn't 'wait' until FM has summarised all lines in the unstored field.

 

As a test I did an export to tab separated text and then I do get the right numbers.

 

Does anybody else have experience with pulling data from FMS14 to a json file with unstored fields? Is this a known limitation? Or is there a way around this? (thing is, I am experienced in FM, but not on PHP, and for the webdesigner the opposite is true ;-)

 

For now I created a work around where I run a script on the server every x hours, and this writes the current stock count into a number field (which is stored) and now it works ok. But we would like to have a 'live' connection.

 

Any help is appreciated.

 

Thanks, Daniel

Outcomes