コード例 #1
0
  @Override
  protected void customerSelected(ClientCustomer customer) {
    if (customer == null) return;

    // Job Tracking
    if (isTrackJob()) {
      jobListCombo.setValue("");
      jobListCombo.setEnabled(!isInViewMode());
      jobListCombo.setCustomer(customer);
    }
    ClientCurrency clientCurrency = getCurrency(customer.getCurrency());
    amountText.setCurrency(clientCurrency);
    bankBalText.setCurrency(clientCurrency);
    customerBalText.setCurrency(clientCurrency);

    this.setCustomer(customer);
    if (customerCombo != null) {
      customerCombo.setComboItem(customer);
    }
    this.addressListOfCustomer = customer.getAddress();
    initBillToCombo();
    customerBalText.setAmount(customer.getBalance());
    adjustBalance(amountText.getAmount());
    currencyWidget.setSelectedCurrencyFactorInWidget(
        clientCurrency, transactionDateItem.getDate().getDate());
  }
コード例 #2
0
 @Override
 protected void accountSelected(ClientAccount account) {
   if (account == null) return;
   this.depositInAccount = account;
   depositInCombo.setValue(depositInAccount);
   bankBalText.setAmount(depositInAccount.getTotalBalance());
   // if (account != null && !(Boolean) printCheck.getValue()) {
   // setCheckNumber();
   // } else if (account == null)
   // checkNo.setValue("");
   adjustBalance(amountText.getAmount());
 }
コード例 #3
0
  @Override
  public ValidationResult validate() {
    ValidationResult result = super.validate();

    if (AccounterValidator.isInPreventPostingBeforeDate(this.transactionDate)) {
      result.addError(transactionDateItem, messages.invalidateDate());
    }

    result.add(payForm.validate());

    if (!AccounterValidator.isPositiveAmount(amountText.getAmount())) {
      amountText.textBox.addStyleName("highlightedFormItem");
      result.addError(amountText, messages.valueCannotBe0orlessthan0(messages.amount()));
    }
    ClientAccount bankAccount = depositInCombo.getSelectedValue();
    // check if the currency of accounts is valid or not
    if (bankAccount != null) {
      ClientCurrency bankCurrency = getCurrency(bankAccount.getCurrency());
      ClientCurrency customerCurrency = getCurrency(customer.getCurrency());
      if (bankCurrency != getBaseCurrency() && bankCurrency != customerCurrency) {
        result.addError(depositInCombo, messages.selectProperBankAccount());
      }
    }
    return result;
  }
コード例 #4
0
 protected void enableFormItems() {
   setMode(EditMode.EDIT);
   customerCombo.setEnabled(!isInViewMode());
   transactionDateItem.setEnabled(!isInViewMode());
   transactionNumber.setEnabled(!isInViewMode());
   // printCheck.setDisabled(isInViewMode());
   amountText.setEnabled(!isInViewMode());
   paymentMethodCombo.setEnabled(!isInViewMode());
   paymentMethodSelected(paymentMethodCombo.getSelectedValue());
   // if (printCheck.getValue().toString().equalsIgnoreCase("true")) {
   // checkNo.setValue(messages.toBePrinted());
   // checkNo.setDisabled(true);
   // }
   // if (paymentMethodCombo.getSelectedValue().equalsIgnoreCase(
   // messages.cheque())
   // && printCheck.getValue().toString().equalsIgnoreCase("true")) {
   // checkNo.setValue(messages.toBePrinted());
   checkNo.setEnabled(!isInViewMode());
   // }
   memoTextAreaItem.setDisabled(false);
   if (locationTrackingEnabled) locationCombo.setEnabled(!isInViewMode());
   if (isTrackClass()) classListCombo.setEnabled(!isInViewMode());
   if (isTrackJob()) {
     jobListCombo.setEnabled(!isInViewMode());
   }
   if (currencyWidget != null) {
     currencyWidget.setEnabled(!isInViewMode());
   }
   super.onEdit();
 }
コード例 #5
0
 private void settabIndexes() {
   customerCombo.setTabIndex(1);
   billToCombo.setTabIndex(2);
   depositInCombo.setTabIndex(3);
   amountText.setTabIndex(4);
   paymentMethodCombo.setTabIndex(5);
   // printCheck.setTabIndex(6);
   checkNo.setTabIndex(7);
   memoTextAreaItem.setTabIndex(8);
   transactionDateItem.setTabIndex(9);
   transactionNumber.setTabIndex(10);
   bankBalText.setTabIndex(11);
   customerBalText.setTabIndex(12);
   if (saveAndCloseButton != null) saveAndCloseButton.setTabIndex(13);
   if (saveAndNewButton != null) saveAndNewButton.setTabIndex(14);
   cancelButton.setTabIndex(15);
 }
コード例 #6
0
 public void resetElements() {
   this.setCustomer(null);
   this.addressListOfCustomer = null;
   this.depositInAccount = null;
   this.paymentMethod = UIUtils.getpaymentMethodCheckBy_CompanyType(messages.check());
   amountText.setAmount(0D);
   // endBalText.setAmount(getAmountInTransactionCurrency(0D));
   // customerBalText.setAmount(getAmountInTransactionCurrency(0D));
   memoTextAreaItem.setValue("");
 }
コード例 #7
0
  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);

    }
  }
コード例 #8
0
 @Override
 public void updateAmountsFromGUI() {
   adjustBalance(amountText.getAmount());
 }
コード例 #9
0
 @Override
 protected void depositInAccountSelected(ClientAccount depositInAccount2) {
   super.depositInAccountSelected(depositInAccount2);
   adjustBalance(amountText.getAmount());
 }
コード例 #10
0
  @Override
  protected void createControls() {
    Label lab1 = new Label(messages.payeePrePayment(Global.get().Customer()));
    lab1.setStyleName("label-title");
    // lab1.setHeight("35px");
    transactionDateItem = createTransactionDateItem();

    transactionNumber = createTransactionNumberItem();

    listforms = new ArrayList<DynamicForm>();
    locationCombo = createLocationCombo();
    DynamicForm dateNoForm = new DynamicForm("datenumber-panel");
    dateNoForm.add(transactionDateItem, transactionNumber);

    StyledPanel datepanel = new StyledPanel("datepanel");
    datepanel.add(dateNoForm);

    StyledPanel labeldateNoLayout = new StyledPanel("labeldateNoLayout");
    labeldateNoLayout.add(lab1);
    labeldateNoLayout.add(datepanel);
    // customer and address
    customerCombo = createCustomerComboItem(messages.payeeName(Global.get().Customer()));

    billToCombo = createBillToComboItem(messages.address());
    billToCombo.setEnabled(false);

    // Ending and Vendor Balance
    bankBalText = new AmountField(messages.bankBalance(), this, getBaseCurrency(), "bankBalText");
    bankBalText.setEnabled(false);

    customerBalText =
        new AmountField(
            messages.payeeBalance(Global.get().Customer()),
            this,
            getBaseCurrency(),
            "customerBalText");
    customerBalText.setEnabled(false);

    DynamicForm balForm = new DynamicForm("balForm");
    if (locationTrackingEnabled) balForm.add(locationCombo);
    classListCombo = createAccounterClassListCombo();
    if (isTrackClass()) {
      balForm.add(classListCombo);
    }
    jobListCombo = createJobListCombo();
    if (isTrackJob()) {
      jobListCombo.setEnabled(false);
      balForm.add(jobListCombo);
    }
    balForm.add(bankBalText, customerBalText);
    // balForm.getCellFormatter().setWidth(0, 0, "205px");

    // payment
    depositInCombo = createDepositInComboItem(bankBalText);
    // depositInCombo.setPopupWidth("500px");

    amountText = new AmountField(messages.amount(), this, getBaseCurrency(), "amountText");
    amountText.setRequired(true);
    amountText.addBlurHandler(getBlurHandler());

    paymentMethodCombo = createPaymentMethodSelectItem();
    paymentMethodCombo.setComboItem(UIUtils.getpaymentMethodCheckBy_CompanyType(messages.check()));
    // printCheck = new CheckboxItem(messages.toBePrinted());
    // printCheck.setValue(true);
    // printCheck.addChangeHandler(new ValueChangeHandler<Boolean>() {
    //
    // @Override
    // public void onValueChange(ValueChangeEvent<Boolean> event) {
    // isChecked = (Boolean) event.getValue();
    // if (isChecked) {
    // if (printCheck.getValue().toString()
    // .equalsIgnoreCase("true")) {
    // checkNo.setValue(messages.toBePrinted());
    // checkNo.setDisabled(true);
    // } else {
    // if (depositInAccount == null)
    // checkNo.setValue(messages
    // .toBePrinted());
    // else if (isInViewMode()) {
    // checkNo.setValue(((ClientCustomerPrePayment) transaction)
    // .getCheckNumber());
    // }
    // }
    // } else
    // // setCheckNumber();
    // checkNo.setValue("");
    // checkNo.setDisabled(false);
    //
    // }
    // });
    checkNo = createCheckNumberItm();
    // checkNo.setValue(messages.toBePrinted());
    // checkNo.setDisabled(true);
    checkNo.addChangeHandler(
        new ChangeHandler() {

          @Override
          public void onChange(ChangeEvent event) {
            checkNumber = checkNo.getValue().toString();
          }
        });
    checkNo.setEnabled(!isInViewMode());
    currencyWidget = createCurrencyFactorWidget();
    payForm = UIUtils.form(messages.payment());
    memoTextAreaItem = createMemoTextAreaItem();
    // refText = createRefereceText();
    // refText.setWidth(100);
    payForm.add(
        customerCombo,
        billToCombo,
        depositInCombo,
        amountText,
        paymentMethodCombo,
        checkNo,
        memoTextAreaItem);
    // memo and Reference
    ClientAccount selectedValue = depositInCombo.getSelectedValue();
    if (selectedValue != null) {
      bankBalText.setAmount(selectedValue.getTotalBalanceInAccountCurrency());
      bankBalText.setCurrency(getCompany().getCurrency(selectedValue.getCurrency()));
    }

    // payForm.getCellFormatter().setWidth(0, 0, "160px");

    StyledPanel leftPanel = new StyledPanel("leftPanel");
    leftPanel.add(payForm);
    // leftPanel.add(payForm);
    // leftPanel.add(memoForm);

    StyledPanel rightPanel = new StyledPanel("rightPanel");
    rightPanel.add(balForm);
    if (isMultiCurrencyEnabled()) {
      rightPanel.add(currencyWidget);
    }

    StyledPanel mainVLay = new StyledPanel("mainVLay");
    mainVLay.add(voidedPanel);
    mainVLay.add(labeldateNoLayout);
    StyledPanel hLay = getTopLayOut();
    if (hLay != null) {
      hLay.add(leftPanel);
      hLay.add(rightPanel);
      mainVLay.add(hLay);
    } else {
      mainVLay.add(leftPanel);
      mainVLay.add(rightPanel);
    }

    this.add(mainVLay);

    /* Adding dynamic forms in list */
    listforms.add(dateNoForm);
    listforms.add(balForm);
    listforms.add(payForm);
    // settabIndexes();
  }
コード例 #11
0
  @Override
  protected void initTransactionViewData() {
    if (transaction == null) {
      setData(new ClientCustomerPrePayment());
      initDepositInAccounts();
    } else {

      if (currencyWidget != null) {
        this.currency = getCompany().getCurrency(transaction.getCurrency());
        this.currencyFactor = transaction.getCurrencyFactor();
        currencyWidget.setSelectedCurrency(this.currency);
        // currencyWidget.currencyChanged(this.currency);
        currencyWidget.setCurrencyFactor(transaction.getCurrencyFactor());
        currencyWidget.setEnabled(!isInViewMode());
      }
      ClientCompany comapny = getCompany();

      ClientCustomer customer = comapny.getCustomer(transaction.getCustomer());
      customerSelected(comapny.getCustomer(transaction.getCustomer()));
      this.billingAddress = transaction.getAddress();
      if (billingAddress != null) billToaddressSelected(billingAddress);
      amountText.setEnabled(!isInViewMode());
      amountText.setAmount(transaction.getTotal());
      if (customer != null) {
        customerBalText.setAmount(customer.getBalance());
      }
      // bankBalText.setAmount(getAmountInTransactionCurrency(transaction.g));
      paymentMethodSelected(transaction.getPaymentMethod());
      this.depositInAccount = comapny.getAccount(transaction.getDepositIn());
      if (depositInAccount != null) {
        depositInCombo.setComboItem(depositInAccount);
        bankBalText.setAmount(depositInAccount.getTotalBalanceInAccountCurrency());
        bankBalText.setCurrency(getCompany().getCurrency(depositInAccount.getCurrency()));
      }
      if (isTrackClass()) {
        classListCombo.setComboItem(
            getCompany().getAccounterClass(transaction.getAccounterClass()));
      }
      paymentMethodCombo.setComboItem(transaction.getPaymentMethod());
      checkNo.setValue(transaction.getCheckNumber());
      // if (transaction.getPaymentMethod().equals(constants.check())) {
      // printCheck.setDisabled(isInViewMode());
      // checkNo.setDisabled(isInViewMode());
      // } else {
      // printCheck.setDisabled(true);
      // checkNo.setDisabled(true);
      // }

      // if (transaction.getCheckNumber() != null) {
      // if (transaction.getCheckNumber().equals(
      // messages.toBePrinted())) {
      // checkNo.setValue(messages.toBePrinted());
      // printCheck.setValue(true);
      // } else {
      // checkNo.setValue(transaction.getCheckNumber());
      // printCheck.setValue(false);
      // }
      // }
    }
    if (locationTrackingEnabled)
      locationSelected(getCompany().getLocation(transaction.getLocation()));
    if (isTrackJob()) {
      if (customer != null) {
        jobListCombo.setCustomer(customer);
      }
      jobSelected(Accounter.getCompany().getjob(transaction.getJob()));
    }
    initMemoAndReference();
    initCustomers();
    if (isMultiCurrencyEnabled()) {
      updateAmountsFromGUI();
    }
  }