Package com.zesped.model

Examples of com.zesped.model.Invoice


      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.process(oSes, new User(oSes, User.forEmail(TEST_USER_EMAIL)).getNickName());
    closeTestSession(oSes);
    Assert.assertEquals(true, oInv.isProcessed());
  }
View Full Code Here


      }
    } catch (StorageException e) { }
  }
 
  public Resolution upload() throws Exception {
    Invoice invc = null;
    capturedCount = 0;
    final int nItems = (getItems()==null ? 0 : getItems().size());
    if (nItems>0) {
      Log.out.debug("InvoiceUpload "+String.valueOf(nItems)+" items found");
      try {
        connect(getSessionAttribute("nickname"), getSessionAttribute("password"));

        Dms oDms = getSession().getDms();
        Document rcpt = oDms.getDocument(getRecipientTaxPayer());
        String sTaxPayerId = rcpt.type().name().equals("TaxPayer") ? getRecipientTaxPayer() : getSessionAttribute("taxpayer_docid");
        TaxPayer txpy = new TaxPayer(getSession().getDms(), sTaxPayerId);

        Invoices invs = txpy.invoices(getSession());
       
        invc = invs.create(getSession(), getSessionAttribute("user_uuid"), getServiceFlavor(),
                   sTaxPayerId, getBillerTaxPayer(), getRecipientTaxPayer());
        capureddocid = invc.id();
       
        for (FileBean attachment : getItems()) {
          if (attachment != null) {
            if (attachment.getSize() > 0) {
              InvoicePage page = invc.createPage(getSession(), attachment.getInputStream(), ++capturedCount, attachment.getFileName());
              if (capturedCount==1) {
                capuredpage1 = page.id();
              }
              attachment.delete();
            } else {
              ValidationError error = new SimpleError(attachment.getFileName()+ " is not a valid file." );
              getContext().getValidationErrors().add("items" , error);
            }
          }
          } // next
        disconnect();
        Log.out.debug("Done uploading items");
        if (capturedCount>0) {
          ThumbnailCreator.createThumbnailFor(capureddocid, capuredpage1);
        }
      } catch (Exception e) {
        Log.out.error("InvoiceUpload.upload() "+e.getClass().getName()+" "+e.getMessage(), e);
        getContext().getMessages().add(new SimpleMessage("ERROR "+e.getMessage(), items));     
      } finally { close(); }
     
    } else {
      Log.out.debug("InvoiceUpload no items found");
    }
    if (invc==null)
      return new RedirectResolution("/error.jsp");
    if (invc.getServiceFlavor().equals(CaptureServiceFlavor.BASIC))
      return new ForwardResolution("EditInvoice.action?id="+invc.id());
    else
      return new ForwardResolution(FORM);
  }
View Full Code Here

          Log.out.debug("getting sides for document "+oDdoc.id());
          NodeList<Document> oChlds = oDdoc.children();
          Invoice[] aInvs = invs.create(oSes, sUid, sFlavor, sTaxPayerId, sBiller, sRecipient, oChlds.size());
          int i = 0;
          for (Document oSide : oChlds) {
            Invoice oInvc = aInvs[i++];
            oStm.setLong(1, Long.parseLong(oInvc.id()));
            oStm.setLong(2, Long.parseLong(oSide.id()));
            Log.out.debug("UPDATE documento SET fkIdDocPadre="+oInvc.id()+" WHERE IdDoc="+oSide.id());
            oStm.executeUpdate();
            aSides.add(oSide);
            ThumbnailCreator.createThumbnailFor(oInvc.id(), oSide.id());
          }
          oCon.commit();
        }
        oStm.close();
        oStm=null;
View Full Code Here

TOP

Related Classes of com.zesped.model.Invoice

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.