GetAuthValCode calls were positioned inside the loop,
despite the same values being supplied each time. Then
the conditional assignments would repeat the same calls again!
That means execution was liable to query the DB at least once
and as many as four times per item. With a large number of items
this is an unnecessary burden. By moving the calls outside
the loop, we can guarantee that we never have to call the DB for
that info more than twice (once for lost, once for damaged).