예제 #1
0
  @Override
  public void migrate(Company company) throws AccounterException {
    log.info("Started Migrator24");
    for (Payee payee : company.getPayees()) {

      Double pBalance =
          (Double)
              getSession()
                  .getNamedQuery("get.Payee.Balance")
                  .setParameter("payeeId", payee.getID())
                  .uniqueResult();
      if (pBalance == null
          || DecimalUtil.isEquals(pBalance, 0.00D)
          || DecimalUtil.isEquals(pBalance, -0.00D)) {
        pBalance = 0.00D;
      }
      if (payee.isCustomer() && !DecimalUtil.isEquals(pBalance, 0.00D)) {
        pBalance = -pBalance;
      }
      if (DecimalUtil.isEquals(payee.getBalance(), pBalance)) {
        continue;
      }
      log.info(
          "***Updating Payee Balance: "
              + payee.getID()
              + " Name: "
              + payee.getName()
              + " with "
              + pBalance);
      payee.setBalance(pBalance);
      getSession().saveOrUpdate(payee);
    }
    log.info("Finished Migrator24");
  }
  private void adjustBalance(double amount) {
    ClientCustomerPrePayment customerPrePayment = transaction;
    enteredBalance = amount;

    if (DecimalUtil.isLessThan(enteredBalance, 0)
        || DecimalUtil.isGreaterThan(enteredBalance, 1000000000000.00)) {
      amountText.setAmount(0D);
      enteredBalance = 0D;
    }
    if (getCustomer() != null) {
      if (isInViewMode()
          && getCustomer().getID() == (customerPrePayment.getCustomer())
          && !DecimalUtil.isEquals(enteredBalance, 0)) {
        double cusBal =
            DecimalUtil.isLessThan(getCustomer().getBalance(), 0)
                ? -1 * getCustomer().getBalance()
                : getCustomer().getBalance();
        toBeSetCustomerBalance = (cusBal - transaction.getTotal()) + enteredBalance;
      } else {
        toBeSetCustomerBalance = getCustomer().getBalance() - enteredBalance;
      }
      // customerBalText.setAmount(toBeSetCustomerBalance);

    }
    if (depositInAccount != null) {
      double balanceToBeUpdate;
      if (depositInAccount.getCurrency() == getPreferences().getPrimaryCurrency().getID()) {
        balanceToBeUpdate = enteredBalance;
      } else {
        balanceToBeUpdate = enteredBalance;
      }

      if (depositInAccount.isIncrease()) {
        toBeSetEndingBalance =
            depositInAccount.getTotalBalanceInAccountCurrency() - balanceToBeUpdate;
      } else {
        toBeSetEndingBalance =
            depositInAccount.getTotalBalanceInAccountCurrency() + balanceToBeUpdate;
      }
      if (isInViewMode()
          && depositInAccount.getID() == (customerPrePayment.getDepositIn())
          && !DecimalUtil.isEquals(balanceToBeUpdate, 0)) {
        toBeSetEndingBalance = toBeSetEndingBalance - transaction.getTotal();
      }
      // endBalText.setAmount(toBeSetEndingBalance);

    }
  }
예제 #3
0
 @Override
 public ValidationResult validate() {
   clearAllErrors();
   ValidationResult result = new ValidationResult();
   if (!DecimalUtil.isEquals(difference.getAmount(), 0.00D)) {
     result.addError(difference, messages.differenceValidate());
   }
   if (clearedTransactions.isEmpty()) {
     result.addError(clearedTransactions, messages.thereIsNoTransactionsToReconcile());
   }
   return result;
 }
  @Override
  protected void updateTransaction() {
    super.updateTransaction();

    transaction.setNumber(transactionNumber.getValue().toString());
    if (customer != null) transaction.setCustomer(getCustomer().getID());

    if (billingAddress != null) transaction.setAddress(billingAddress);
    if (depositInAccount != null) transaction.setDepositIn(depositInAccount.getID());
    if (!DecimalUtil.isEquals(enteredBalance, 0.00)) transaction.setTotal(enteredBalance);
    this.paymentMethod = paymentMethodCombo.getSelectedValue();
    if (paymentMethod != null) {
      transaction.setPaymentMethod(paymentMethod);
      if (paymentMethod.equalsIgnoreCase(messages.cheque())) {
        if (checkNo.getValue() != null && !checkNo.getValue().equals("")) {
          String value = String.valueOf(checkNo.getValue());
          transaction.setCheckNumber(value);
        } else {
          transaction.setCheckNumber("");
        }
      } else {
        transaction.setCheckNumber("");
      }
    }
    // if (transaction.getID() != 0)
    //
    // printCheck.setValue(transaction.isToBePrinted());
    // else
    // printCheck.setValue(true);

    if (transactionDate != null)
      transaction.setDate(transactionDateItem.getEnteredDate().getDate());
    transaction.setMemo(getMemoTextAreaItem());
    if (isTrackClass() && classListCombo.getSelectedValue() != null) {
      transaction.setAccounterClass(classListCombo.getSelectedValue().getID());
    }

    // if (toBeSetEndingBalance != null)
    // transaction.setEndingBalance(toBeSetEndingBalance);
    if (toBeSetCustomerBalance != null) transaction.setCustomerBalance(toBeSetCustomerBalance);

    transaction.setType(ClientTransaction.TYPE_CUSTOMER_PREPAYMENT);

    if (isTrackJob()) {
      if (jobListCombo.getSelectedValue() != null)
        transaction.setJob(jobListCombo.getSelectedValue().getID());
    }
    if (currency != null) transaction.setCurrency(currency.getID());
    transaction.setCurrencyFactor(currencyWidget.getCurrencyFactor());
  }
예제 #5
0
 private void checkCreditsAndDebits() throws AccounterException {
   double creditTotal = 0, debitTotal = 0;
   for (TransactionItem rec : getTransactionItems()) {
     if (rec.getLineTotal() != null) {
       if (DecimalUtil.isGreaterThan(rec.getLineTotal(), 0)) {
         debitTotal += rec.getLineTotal();
       } else {
         creditTotal += (-1 * rec.getLineTotal());
       }
     }
   }
   if (!DecimalUtil.isEquals(creditTotal, debitTotal)) {
     throw new AccounterException(AccounterException.ERROR_CREDIT_DEBIT_TOTALS_NOT_EQUAL);
   } else {
     setCreditTotal(creditTotal);
     setDebitTotal(debitTotal);
   }
 }