wandored / stockcount

MIT License
0 stars 0 forks source link

previous_total not correct #7

Closed wandored closed 5 months ago

wandored commented 6 months ago

Calculation for previous_count not calculation correctly for each item. line 90 in count route

`

get previous count

    for count_entry in multi_form.counts.data:
        items_object = InvItems.query.filter_by(id=count_entry["item_id"]).first()
        filter_item = InvCount.query.filter(
            InvCount.store_id == session["store"],
            InvCount.item_id == multi_form.counts.data[0]["item_id"],
        )
        previous_count = filter_item.order_by(InvCount.trans_date.desc()).first()
        if previous_count is None:
            total_previous = 0
        else:
            total_previous = previous_count.count_total

`

wandored commented 6 months ago

Might be better to calculate previous count on the fly rather then writing to the database. Only used in the details route