Package com.zesped.model

Examples of com.zesped.model.Invoice$PageNumComparator


    return new RedirectResolution(CaptureInvoice.class);
  }
 
  public Resolution save() {
    Log.out.debug("Begin EditInvoice.save()");
    Invoice oInv = saveInvoice();
    Dms oDms;
    Resolution oRes = new RedirectResolution(ListNewInvoices.class);
    try {
      connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
      oDms = getSession().getDms();
      SortableList<Document> oNext = oDms.query("(Invoice$is_processed='0') & (Invoice$recipient_taxpayer='"+getRecipientTaxPayer()+"')");
      if (!oNext.isEmpty()) {
        oRes = new RedirectResolution("/EditInvoice.action?a=0&id="+oNext.get(0).id());
        setParam("former_id", getId());
      }
      disconnect();
      if (oInv.hasMistakes()) {
        connect();
        User oMe = new User(getSession(), getSessionAttribute("user_docid"));
        User oTo = new User(getSession(), User.forUuid(oInv.getString("captured_by")));
        Messages.notify(getSession(), oMe.getFirstName()+" "+oMe.getLastName(),
                  oMe.getEmail(), oMe.getNickName(), oTo.getEmail(), oTo.getNickName(),
                  "Incidencia con la factura "+getId(), oInv.getComments(), getId());     
        disconnect();
      }
    } catch (Exception e) {
      Log.out.error("Invoice.save() "+e.getClass().getName()+" "+e.getMessage());
    } finally {
View Full Code Here


  public Resolution reject() {
      Log.out.debug("Begin EditInvoice.reject()");
      setApproved(false);
      setProcessed(false);
      setMistakes(true);
      Invoice oInv = saveInvoice();
      Dms oDms;
      Resolution oRes = new RedirectResolution(ListPendingInvoices.class);
      try {
        connect();
        oDms = getSession().getDms();
        Log.out.debug("Dms.query((Invoice$is_processed='1') & (Invoice$is_approved='0') & (Invoice$recipient_taxpayer='"+getRecipientTaxPayer()+"'))");
        SortableList<Document> oNext = oDms.query("(Invoice$is_processed='1') & (Invoice$is_approved='0') & (Invoice$recipient_taxpayer='"+getRecipientTaxPayer()+"')");
        if (!oNext.isEmpty()) {
          oRes = new RedirectResolution("/EditInvoice.action?a=1&id="+oNext.get(0).id());
          setParam("former_id", getId());
        }
        User oMe = new User(getSession(), getSessionAttribute("user_docid"));
        User oTo = new User(getSession(), User.forUuid(oInv.getString("captured_by")));
        Messages.notify(getSession(), oMe.getFirstName()+" "+oMe.getLastName(),
                  oMe.getEmail(), oMe.getNickName(), oTo.getEmail(), oTo.getNickName(),
                  "Incidencia con la factura "+getId(), oInv.getComments(), getId());
        disconnect();
      } catch (Exception e) {
        Log.out.error("Invoice.reject()"+e.getClass().getName()+" "+e.getMessage());
      } finally {
        close();
View Full Code Here

    final String sDocs = getParam("docs","");
    final String sCmmt = getParam("comments");
    if (sDocs.length()>0) {
      String[] aDocs = sDocs.split(",");
      try {
        Invoice oInv;
        connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
        Dms oDms = getSession().getDms();
        for (int d=0; d<aDocs.length; d++) {
          try {
            oInv = new Invoice(oDms, aDocs[d]);
            oInv.reject(getSession(), getSessionAttribute("user_uuid"), sCmmt);
              addDataLine("id",oInv.id());
          } catch (ElementNotFoundException enfe) {
            addError(new SimpleError("Invoice not found "+aDocs[d]));
          }
        }
        disconnect();
View Full Code Here

  public InvoiceThumbnail getThumbnail() {
    Log.out.debug("InvoiceThumbnail getThumbnail("+getId()+")");
    if (thumbnail==null) {
      try {
        connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
          Invoice oInv = new Invoice(getSession().getDms(), getId());
          thumbnail = oInv.thumbnail(getSession());
        } catch (Exception xcpt) {
            Log.out.error(xcpt.getMessage(), xcpt);
        } finally {
          close();
        }     
View Full Code Here

    }
  }
 
  private Invoice saveInvoice() {
      Log.out.debug("Begin EditInvoice.saveInvoice()");
      Invoice invc = null;
      try {
          connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
          invc = new Invoice(getSession().getDms(), getId());
          invc.setBaseAmounts(getBaseAmounts());
          bindObject(this,invc);
          if (getBillDay()>0 && getBillMonth()>0 && getBillYear()>0) {
            invc.setInvoiceDate(new Date(getBillYear()-1900, getBillMonth()-1, getBillDay()));
          } else {
            invc.remove("year");
            invc.remove("quarter");
            invc.remove("month");
            invc.remove("invoice_date");
          }
          if (getDueDay()>0 && getDueMonth()>0 && getDueYear()>0)
            invc.setDueDate(new Date(getDueYear()-1900, getDueMonth()-1, getDueDay()));
          invc.save(getSession(), getSessionAttribute("user_uuid"), getProcessed(), getApproved(), getMistakes());
          BigDecimal total = invc.computeTotal();
          if (getTotalAmount().subtract(total).abs().floatValue()>0.04f) {
            Log.out.warn("Invoice "+invc.id()+" mismatch between supplied ("+getTotalAmount().toString()+") and computed ("+total.toString()+") total amounts");
            DAO.log(getSession(), invc.getDocument(), Invoice.class, "AMOUNT MISMATCH", Level.WARNING, "mismatch between supplied ("+getTotalAmount().toString()+") and computed ("+total.toString()+") total amounts");
          }
          disconnect();           
        } catch (Exception xcpt) {
          Log.out.error(xcpt.getMessage(), xcpt);
        } finally {
View Full Code Here

    } else {
      setParam("id", getId());
      Date dtToday = new Date();
      try {
          connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
          Invoice oInv = new Invoice(getSession().getDms(), getId());
          bindObject(oInv,this);
          setProcessed(oInv.isProcessed());
          setApproved(oInv.isApproved());
          setMistakes(oInv.hasMistakes());
          for (InvoicePage p : oInv.pages(getSession()))
            pages.add(p.id());
          if (oInv.getInvoiceDate()==null) {
            setBillMonth(dtToday.getMonth()+1);
            setBillYear(dtToday.getYear()+1900);
          } else {
            setBillDay(oInv.getInvoiceDate().getDate());
            setBillMonth(oInv.getInvoiceDate().getMonth()+1);
            setBillYear(oInv.getInvoiceDate().getYear()+1900);
          }
          if (oInv.getDueDate()!=null) {
            setDueDay(oInv.getDueDate().getDate());
            setDueMonth(oInv.getDueDate().getMonth()+1);
            setDueYear(oInv.getDueDate().getYear()+1900);
          }
          disconnect();
          sFwd = getParam("a","0").equals("1") ? APPROVEFORM : EDITFORM;
        } catch (Exception xcpt) {
          Log.out.error(xcpt.getMessage(), xcpt);
View Full Code Here

        try {
          connect();
          Dms oDms = getSession().getDms();
          for (int d=0; d<aDocs.length; d++) {
            try {
              Invoice oInv = new Invoice(oDms, aDocs[d]);
              oInv.approve(getSession(), getSessionAttribute("user_uuid"));
              addDataLine("docid", aDocs[d]);
              commit();
            } catch (Exception xcpt) {
              rollback();
              addError("document", new SimpleError (xcpt.getClass().getName()+" "+xcpt.getMessage()));
View Full Code Here

        String[] aDocs = sDocs.split(",");
        try {
          connect();
          Dms oDms = getSession().getDms();
          for (int d=0; d<aDocs.length; d++) {
            Invoice i = new Invoice(oDms, aDocs[d]);
            aInvoices.add(i);
            sIds += (sIds.length()==0 ? "" : ",")+i.id();
          }
          disconnect();
        } catch (StorageException e) {           
        } finally {
          close();
View Full Code Here

        connect(sNickN, sPassw);
        AtrilSession oSes = getSession();
        Dms oDms = oSes.getDms();
        if (sDocId.length()>0) {
          aLst = new QueryResultSet<Invoice>();
          aLst.add(new Invoice(oDms, sDocId));
        } else {
          TaxPayer oTxpr = new TaxPayer(oDms, sTaxPayer);
          if (dtFrom!=null || dtTo!=null)
            aLst = oTxpr.queryInvoices(oSes, bProcessed, bApproved, bHasMistakes, dtFrom, dtTo, sRecipient, sBiller, sServiceFlavor, iMaxRows, iOffset);
          else if (aAmountRange!=null || aMonthsRange!=null || aYearsRange!=null || sSearchStr.length()>0)
View Full Code Here

      AtrilSession oSes = openTestSession();
      User oUsr = new User(oSes, USRID);
      CustomerAccount oAcc = new CustomerAccount(oSes.getDms(), ACCID);
      Iterator<TaxPayer> oItr = oAcc.taxpayers(oSes).list(oSes).iterator();
    TaxPayer oTpr = oItr.next();
    Invoice oInv = oTpr.invoices(oSes).create(oSes, oUsr.getNickName(), CaptureServiceFlavor.BASIC, oTpr.id(), null, null);
    oInv.createPage(oSes, getClass().getResourceAsStream("BilleteIberia.jpg"), 1, "BilleteIberia");
    closeTestSession(oSes);
  }
View Full Code Here

TOP

Related Classes of com.zesped.model.Invoice$PageNumComparator

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.