UPDATE fixing receiptdetail algorithm