We've automated it a few different ways over the years for customers in our cloud, but our most common design was an escalation on ORGANIZATION that had actions for each (running the asset rollup reports, zeroing inventory YTD, zeroing labor, and zeroing asset costs). If you build the actions appropriately, you can use this to determine which organizations to run it on if you have it. Also make sure you set it to repeat (you don't want it to just work once).
We typically avoid counts as it's easy enough to iterate and you don't need to know the count. It causes an additional query to execute that might not be needed. We do something like this to loop:
laborMbo = laborSet.moveFirst()
while laborMbo:
laborMbo.zeroYTD(True,True,True)
laborMbo = laborSet.moveNext()
laborSet.save()
laborSet.close()
As for your questions
1) We used laborMbo.zeroYTD(True,True,True). Those 3 parameters are Reported, Overtime, and Refused and we assumed all customers would want all 3 to be zeroed out.
2) We like the escalation determining which organizations this should run on and then executing for all labor in that organization at once. In our design, we set laborSet.setLogLargFetchResultDisabled(True) because if you have more than 5000 records (or whatever your stop limit is) that would prevent it from retrieving the set. For most organizations, they won't have 5000 labor records so it won't be a big deal but because we wrote it generically I thought I'd call it out.
As for your future plans, inventory and asset zeroing of asset costs is even more straight forward. The biggest challenge is getting the asset cost rollup report executed and ensuring all costs are rolled up prior to zeroing asset costs.
Once you're sure asset costs are rolled up (checking the SERVRECTRANS, TOOLTRANS, MATUSETRANS, LABTRANS tables), zeroing the asset costs is easy because it's done at a set level (IE assetSet.zeroCosts(True,False)). First argument is YTD, second argument is TOTALCOST. Obviously for year end activities you don't want to zero the second.
For inventory, it's also at a set level but there are no arguments. You simply need to call inventorySet.zeroYTDQuantities().
In all of our automation, we put in additional checks as we had bugs on certain versions that caused escalations to run on the wrong date/time or run more than once. As long as you're on newer versions you probably don't need to worry about this, but it may be something worth tracking somewhere (potentially on the organization record) so you can avoid processing twice.
------------------------------
Steven Shull
Projetech Inc.
------------------------------