private fun cmd_annotateDifference() { val previousValue: BigDecimal val actualValue: BigDecimal val difference: BigDecimal previousValue = v_previousBalance.getValue() as BigDecimal actualValue = v_ActualBalance.getValue() as BigDecimal difference = actualValue.subtract(previousValue) val cashBook = MCashBook(p_ctx, p_pos.getC_CashBook_ID(), null) val today: Timestamp = TimeUtil.getDay(System.currentTimeMillis()) var cash: MCash = MCash.get(p_ctx, cashBook.getC_CashBook_ID(), today, null) if (cash != null && cash.get_ID() !== 0 && difference.compareTo(cash.getStatementDifference()) !== 0) { val cl = MCashLine(cash) cl.setCashType(MCashLine.CASHTYPE_Difference) cl.setAmount(difference) cl.setDescription( Msg.translate( p_pos.getCtx(), "Cash Scrutiny -> Before: " ) + previousValue + " Now: " + actualValue ) cl.saveEx() } cash = MCash.get(p_pos.getCtx(), p_pos.getC_CashBook_ID(), today, null) v_previousBalance.setValue(cash.getEndingBalance()) v_ActualBalance.setValue(Env.ZERO) v_difference.setValue(Env.ZERO) }
Annotate the difference between previous balance and actual from cash scrutiny in the cash book