I think that should work, but would it be possible using expression switches instead? I wanted to avoid functions, if at all possible.
The criteria is actually rather that quantity becomes > 0 when previously it was 0. (or the given item did not exist)
I've tried doing something like this, but it's not really working. I think the expression in the second switch is not doing what I expect.
[{"id":"f5c75d5369b36f29","type":"inject","z":"f6f2187d.f17ca8","name":"items","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"id\":1,\"qty\":0},{\"id\":2,\"qty\":2},{\"id\":3,\"qty\":1},{\"id\":4,\"qty\":0},{\"id\":5,\"qty\":5}]","payloadType":"json","x":750,"y":400,"wires":[["6c498efff6b4d46b"]]},{"id":"79e82e6b9fd7a355","type":"inject","z":"f6f2187d.f17ca8","name":"changed items","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"id\":1,\"qty\":0},{\"id\":2,\"qty\":0},{\"id\":3,\"qty\":3},{\"id\":4,\"qty\":0},{\"id\":5,\"qty\":1}]","payloadType":"json","x":720,"y":480,"wires":[["6c498efff6b4d46b"]]},{"id":"8e9356ac6db955bb","type":"debug","z":"f6f2187d.f17ca8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1370,"y":400,"wires":[]},{"id":"d11023f40c7e9649","type":"switch","z":"f6f2187d.f17ca8","name":"","property":"payload.qty","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":true,"outputs":1,"x":1050,"y":440,"wires":[["adc9b1b299e23d00"]]},{"id":"6c498efff6b4d46b","type":"split","z":"f6f2187d.f17ca8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":910,"y":440,"wires":[["d11023f40c7e9649"]]},{"id":"9d49fd57a50d89da","type":"join","z":"f6f2187d.f17ca8","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":1350,"y":480,"wires":[["d4fee21f15966565"]]},{"id":"d4fee21f15966565","type":"change","z":"f6f2187d.f17ca8","name":"","rules":[{"t":"set","p":"items2","pt":"flow","to":"payload","tot":"msg","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":1520,"y":480,"wires":[["c763ae08e1b98183"]]},{"id":"adc9b1b299e23d00","type":"switch","z":"f6f2187d.f17ca8","name":"","property":"$flowContext('items2')[id=$$.payload.id]","propertyType":"jsonata","rules":[{"t":"null"}],"checkall":"false","repair":true,"outputs":1,"x":1190,"y":440,"wires":[["9d49fd57a50d89da","8e9356ac6db955bb"]]},{"id":"c763ae08e1b98183","type":"debug","z":"f6f2187d.f17ca8","name":"Final","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1690,"y":440,"wires":[]}]