Package net.sourceforge.stripes.validation

Examples of net.sourceforge.stripes.validation.LocalizableError


  @ValidationMethod(on="save")
  public void validateTaxId(ValidationErrors ignore) {
    final String sTaxId = getParam("client.taxId");
    if (sTaxId==null)
      addError(new LocalizableError("com.zesped.action.SaveClient.taxId.valueNotPresent"));         
    else if (sTaxId.length()==0)
      addError(new LocalizableError("com.zesped.action.SaveClient.taxId.valueNotPresent"));         
  }
View Full Code Here


  public void validateBusinessName(ValidationErrors ignore) {
    final String sBusinessName = getParam("client.businessName");
    final String sTaxId = getParam("client.taxId");
    final String sFormerId = getParam("client.id");
    if (sBusinessName==null) {
      addError(new LocalizableError("com.zesped.action.SaveClient.businessName.valueNotPresent"));
    } else if (sBusinessName.length()==0) {
      addError(new LocalizableError("com.zesped.action.SaveClient.businessName.valueNotPresent"));
    } else {
      try {
        connect();
        CustomerAccount oAcc = new CustomerAccount(getSession().getDms(), getSessionAttribute("customer_account_docid"));
        Client oFoundClient = oAcc.clients(getSession()).seek(getSession(), sBusinessName);
        if (!oFoundClient.id().equals(sFormerId))
          addError(new LocalizableError("com.zesped.action.SaveClient.businessNameAlreadyExists"));
        oFoundClient = oAcc.clients(getSession()).seek(getSession(), sTaxId);
        if (!oFoundClient.id().equals(sFormerId))
          addError(new LocalizableError("com.zesped.action.SaveClient.taxIdAlreadyExists"));
      } catch (ElementNotFoundException clientnotfound) {
      } catch (Exception e) {
        Log.out.error("SaveClient.validateBusinessName("+sBusinessName+") "+e.getClass().getName()+" "+e.getMessage(), e);
      } finally {
        close();
View Full Code Here

  }
 
  @ValidationMethod(on="upload")
  public void requireOneItem(ValidationErrors errors) {
    if (getItems()==null)
      errors.add("items", new LocalizableError("com.zesped.action.InvoceUpload.oneItemIsRequired"));
    else if (getItems().size()==0)
      errors.add("items", new LocalizableError("com.zesped.action.InvoceUpload.oneItemIsRequired"));
  }
View Full Code Here

  }

  @ValidationMethod(on="save")
  public void validateBillerAndRecipient(ValidationErrors errors) {
    if (getBillerTaxPayer().length()>0 && getRecipientTaxPayer().length()>0 && getBillerTaxPayer().equals(getRecipientTaxPayer())) {
      errors.add("emisor", new LocalizableError("com.zesped.action.EditInvoice.BillerAndRecipientMayNotBeTheSame"));
    }
  }
View Full Code Here

  @ValidationMethod(on="save")
  public void validateBillDate(ValidationErrors errors) {
    if (getBillDay()>0 || getBillMonth()>0 || getBillYear()>0) {
      if (getBillDay()==0 || getBillMonth()==0 || getBillYear()==0)
        errors.add("fechaNota", new LocalizableError("com.zesped.action.EditBillNote.invalidDate"));
      else if (getBillDay()>Calendar.LastDay(getBillMonth()-1, getBillYear())) {
        errors.add("fechaNota", new LocalizableError("com.zesped.action.EditBillNote.invalidDate"));       
      }
       
    }
  }
View Full Code Here

    final String sBeanEmployeeUUID = getEmployee()==null ? "" : getEmployee();
    String sConcept = getConcept()==null ? "" : getConcept();
    Log.out.debug("validateBillNoteVsEmployee concept="+sConcept+" uuid="+sBeanEmployeeUUID);
    try {
      if (sConcept.length()==0)
        errors.add("concepto", new LocalizableError("com.zesped.action.EditBillNote.concept.valueNotPresent"));
      if (sBeanEmployeeUUID.length()==0)
        errors.add("empleado", new LocalizableError("com.zesped.action.EditBillNote.employee.valueNotPresent"));       
      if (sConcept.length()>0 && sBeanEmployeeUUID.length()>0) {
        connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
        Dms oDms = getSession().getDms();       
        TaxPayer txpy = new TaxPayer(oDms, getRecipientTaxPayer());
        BillNote bill = txpy.billnotes(getSession()).forConcept(getSession(), sConcept, sBeanEmployeeUUID);
        Log.out.debug("BillNote with Id "+bill.id()+" found for concept "+sConcept+" and employee "+sBeanEmployeeUUID);
        if (bill.isOpen()) {
          final String sBillEmployeeUUID = (bill.getEmployeeUuid()==null ? "" : bill.getEmployeeUuid());
          if (sBillEmployeeUUID.length()==0) {
            Log.out.debug("Assigning BillNote "+bill.id()+" to employee "+sBeanEmployeeUUID);
            bill.setEmployee(txpy.employees(getSession()).seek(getSession(), sBeanEmployeeUUID));
            bill.save(getSession());
            setBillNoteId(bill.id());
          } else if (sBillEmployeeUUID.equals(sBeanEmployeeUUID)) {
            setBillNoteId(bill.id());
          } else {
            errors.add("empleado", new LocalizableError("com.zesped.action.EditBillNote.employeeConceptMismatch"));         
          }         
        } else {
          errors.add("billnote", new LocalizableError("com.zesped.action.EditBillNote.billNoteIsClosed"));
        }
        disconnect();
      } else {
        setBillNoteId(null);
      }
View Full Code Here

      }
      if (getTotalAmount()==null) {
        setTotalAmount(getBaseAmount().add(getVat()));
      } else {
        if (getTotalAmount().subtract(getBaseAmount().add(getVat())).abs().floatValue()>0.02f) {
          errors.add("importe", new LocalizableError("com.zesped.action.EditBillNote.baseTotalVatMismatch", getBaseAmount().add(getVat()).toString(), getTotalAmount().toString()));
        }
      }
    }
  }
View Full Code Here

    try {
          connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
          Dms oDms = getSession().getDms();
      Client clnt = new Client(oDms, id);
      if (clnt.invoicesCount(oDms)>0)
        addError(new LocalizableError("com.zesped.action.CheckCanDeleteClient.hasInvoices",clnt.getBusinessName()));
      else if (clnt.ticketsCount(oDms)>0)
        addError(new LocalizableError("com.zesped.action.CheckCanDeleteClient.hasTickets",clnt.getBusinessName()));
      disconnect();
      } catch (Exception xcpt) {
        Log.out.error("CheckCanDeleteClient.form() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
      } finally {
        close();
View Full Code Here

  }

  @ValidationMethod(on="reject")
  public void validateComments(ValidationErrors errors) {
    if (getComments().trim().length()==0)
      errors.add("password", new LocalizableError("com.zesped.action.EditInvoice.rejectionCauseIsRequired"));
  }
View Full Code Here

  @ValidationMethod(on="save")
  public void validateBillerAndRecipient(ValidationErrors errors) {
    Log.out.debug("EditInvoice.validateBillerAndRecipient()");
    if (getBillerTaxPayer().length()>0 && getRecipientTaxPayer().length()>0 && getBillerTaxPayer().equals(getRecipientTaxPayer())) {
      errors.add("emisor", new LocalizableError("com.zesped.action.EditInvoice.BillerAndRecipientMayNotBeTheSame"));
    }
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.validation.LocalizableError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.