/** * <p>Evaluate start of period nearest to pDateFor. * Tested in beige-common org.beigesoft.test.CalendarTest.</p> * @param pDateFor date for * @return Start of period nearest to pDateFor * @throws Exception - an exception **/ @Override public final synchronized Date evalDatePeriodStartFor( final Date pDateFor) throws Exception { if (!(evalBalanceStorePeriod().equals(EPeriod.MONTHLY) || evalBalanceStorePeriod().equals(EPeriod.WEEKLY) || evalBalanceStorePeriod().equals(EPeriod.DAILY))) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "stored_balance_period_must_be_dwm"); } Calendar cal = Calendar.getInstance(); cal.setTime(pDateFor); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); //Daily is ready if (evalBalanceStorePeriod().equals(EPeriod.MONTHLY)) { cal.set(Calendar.DAY_OF_MONTH, 1); } else if (evalBalanceStorePeriod().equals(EPeriod.WEEKLY)) { cal.set(Calendar.DAY_OF_WEEK, 1); } return cal.getTime(); }
if (!(evalBalanceStorePeriod().equals(EPeriod.MONTHLY) || evalBalanceStorePeriod().equals(EPeriod.WEEKLY) || evalBalanceStorePeriod().equals(EPeriod.DAILY))) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "stored_balance_period_must_be_dwm"); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); if (evalBalanceStorePeriod().equals(EPeriod.DAILY)) { cal.add(Calendar.DATE, 1); } else if (evalBalanceStorePeriod().equals(EPeriod.MONTHLY)) { cal.add(Calendar.MONTH, 1); cal.set(Calendar.DAY_OF_MONTH, 1); } else if (evalBalanceStorePeriod().equals(EPeriod.WEEKLY)) { cal.add(Calendar.DAY_OF_YEAR, 7); cal.set(Calendar.DAY_OF_WEEK, 1);
public final synchronized Date evalDatePeriodStartFor( final Map<String, Object> pAddParam, final Date pDateFor) throws Exception { EPeriod period = evalBalanceStorePeriod(pAddParam); if (!(period.equals(EPeriod.MONTHLY) || period.equals(EPeriod.WEEKLY)
final Map<String, Object> pAddParam, final Date pDateFor) throws Exception { EPeriod period = evalBalanceStorePeriod(pAddParam); if (!(period.equals(EPeriod.MONTHLY) || period.equals(EPeriod.WEEKLY)
final Map<String, Object> pAddParam, final Date pDateFor) throws Exception { evalBalanceStorePeriod(pAddParam); evalDateBalanceStoreStart(pAddParam); Date datePeriodStartFor = evalDatePeriodStartFor(pAddParam, pDateFor);
/** * <p>Recalculate if need for all balances for all dates less * or equals pDateFor, this method is always invoked by report ledger.</p> * @param pDateFor date for * @throws Exception - an exception **/ @Override public final synchronized void recalculateAllIfNeed( final Date pDateFor) throws Exception { evalBalanceStorePeriod(); //must be before evalDateBalanceStoreStart!!! evalDateBalanceStoreStart(); Date datePeriodStartFor = evalDatePeriodStartFor(pDateFor); if (datePeriodStartFor.getTime() > lazyGetBalanceAtAllDirtyCheck() .getCurrentBalanceDate().getTime() || lazyGetBalanceAtAllDirtyCheck() .getLeastAccountingEntryDate() .getTime() < lazyGetBalanceAtAllDirtyCheck() .getCurrentBalanceDate().getTime()) { recalculateAll(pDateFor, false); } }
+ lazyGetBalanceAtAllDirtyCheck()); if (pIsPrepareNeed) { evalBalanceStorePeriod(); //must be before evalDateBalanceStoreStart!!! evalDateBalanceStoreStart();
if (pIsPrepareNeed) { evalBalanceStorePeriod(pAddParam); evalDateBalanceStoreStart(pAddParam);