Package com.zesped.model

Examples of com.zesped.model.CustomerAccount


 
  @Test public void processInvoice()
    throws DmsException, NotYetConnectedException, ClassCastException, IllegalStateException, NullPointerException, RuntimeException, IOException, InstantiationException, IllegalAccessException {
      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


 
  @Test public void createTicket()
    throws IllegalArgumentException,AuthorizationManagerAdminException,DuplicatedElementException,ElementNotFoundException,NotEnoughRightsException, DmsException, InstantiationException, IllegalAccessException {
      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();
    String sEmployeeUuid = "";
    BillNote oBln = oTpr.billnotes(oSes).create(oSes, oUsr.getNickName(), CaptureServiceFlavor.BASIC, oTpr.id(), "Test Concept", sEmployeeUuid);
    oBln.createTicket(oSes);
      closeTestSession(oSes);
View Full Code Here

    throws DmsException, NotYetConnectedException, ClassCastException, IllegalStateException, NullPointerException, RuntimeException, IOException, InstantiationException, IllegalAccessException {
      String sUsrId = User.forEmail(TEST_USER_EMAIL);
      String sAccId = CustomerAccount.forBusinessName(TEST_BUSINESSNAME);
      AtrilSession oSes = openTestSession();
      User oUsr = new User(oSes, sUsrId);
      CustomerAccount oAcc = new CustomerAccount(oSes.getDms(), sAccId);
      Iterator<TaxPayer> oItr = oAcc.taxpayers(oSes).list(oSes).iterator();
    TaxPayer oTpr = oItr.next();
    String sEmployeeUuid = "";
    BillNote oBln = oTpr.billnotes(oSes).create(oSes, oUsr.getNickName(), CaptureServiceFlavor.BASIC, oTpr.id(), "Test Concept", sEmployeeUuid);
    Ticket oTck = oBln.createTicket(oSes);
    oTck.createNote(oSes, getClass().getResourceAsStream("OutbackSteakhouse.jpg"), 1, "OutbackSteakhouse.jpg");
View Full Code Here

  public void run() {
    AtrilSession oSes = null;
    try {
      oSes = DAO.getAdminSession("AsyncAccountCreator");
      final String sTemporaryBusinessName = Gadgets.generateUUID();     
      CustomerAccount oCac = CustomerAccount.create(oSes, oUsr, sTemporaryBusinessName);
      oSes.commit();
      TaxPayer oTxp = TaxPayer.create(oSes, oCac, sTemporaryBusinessName, "", oUsr.getFirstName()+" "+oUsr.getLastName(), oUsr.getEmail(), true, DAO.getVolumesMountBase());
      oSes.commit();
      Employee oEmp = new Employee(oSes, oTxp.employees(oSes));
      oEmp.setActive(true);
View Full Code Here

    AtrilSession oSes = null;
      try {
          BigDecimal oCredits = oSrvFlv.credits();
        oSes = DAO.getAdminSession("CreditBurner");
        oSes.autoCommit(false);
        CustomerAccount oAcc = new CustomerAccount(oSes.getDms(), sCustAcc);
        oAcc.burnCredits(oSes, oCredits);
        oAcc.save(oSes);
        DAO.log(oSes, oAcc.getDocument(), CustomerAccount.class, "BURN CREDITS", AtrilEvent.Level.INFO, oCredits.toString()+";"+oSrvFlv.uid()+";"+sUser);
        switch (oAcc.getCreditsLeft().signum()) {
          case 0:
              DAO.log(oSes, oAcc.getDocument(), CustomerAccount.class, "NO CREDITS LEFT", AtrilEvent.Level.WARNING, "0;"+oSrvFlv.uid()+";"+sUser);
              break;
          case -1:
              DAO.log(oSes, oAcc.getDocument(), CustomerAccount.class, "NEGATIVE CREDITS", AtrilEvent.Level.WARNING, oAcc.getCreditsLeft().toString()+";"+oSrvFlv.uid()+";"+sUser);
              break;
        }
        oSes.commit();
        oSes.disconnect();
        oSes.close();
View Full Code Here

    }
     
      AtrilSession oSes = DAO.getAdminSession("AsyncSendInvitation");
      oSes.autoCommit(true);
      Dms oDms = oSes.getDms();
    CustomerAccount oAcc = new CustomerAccount(oDms, sAccId);
     
    for (int t=0; t<aTxprs.length; t++) {
      String sTxpId = aTxprs[t];
        TaxPayer oTxp = new TaxPayer (oDms, sTxpId);

        try {

          sUid = User.forEmail(sEmail);
        oUsr = new User(oSes, sUid);
        try {
          oUsr.allowTaxPayer(oSes, oTxp.id());
        } catch (Exception xcpt) {
          Log.out.error("AsyncSendInvitation User.allowTaxPayer() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
        }

        } catch (ElementNotFoundException enfe) {

        String sPwd = Gadgets.generateRandomId(6, "abcdefghjkmnpqrtuvwxyz", Character.LOWERCASE_LETTER);
        sUid = User.create(oSes, sRec1stName, sRec2ndName, sRecEmail, sPwd, false).id();
        oUsr = new User(oSes, sUid);
        oUsr.canApproveInvoices(bApprove);
        oUsr.canSettleBillNotes(bSettle);
        oUsr.canUsePremiumCaptureServiceFlavor(bPremium);
        oUsr.setRole(oSes, oAcc, Role.user);
        oUsr.save(oSes);     

        try {
          oUsr.allowTaxPayer(oSes, oTxp.id());
        } catch (Exception xcpt) {
          Log.out.error("AsyncSendInvitation User.allowTaxPayer() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
        }
       
        HashMap oMap = FastStreamReplacer.createMap(new String[] {"1","2","3","4","5","6"},
                              new String[] {oUsr.getFirstName(), sSender1stName, sSender2ndName, oTxp.getBusinessName() + (aTxprs.length>1 ? " y a otras " + String.valueOf(aTxprs.length-1) + " más": ""), oUsr.id(), sPwd});
          ByteArrayOutputStream oByOut = new ByteArrayOutputStream();
          PrintStream oPrt = new PrintStream(oByOut);             
          try {
              Log.out.debug("sending email");
          oHlr.sendMessage("Acceso a zesped", "Zesped", "noreply@zesped.com", "noreply@zesped.com",
                           new String[] {sEmail}, RecipientType.TO, oRpl.replace(oTxt, oMap), oRpl.replace(oHtm, oMap),
                           "ISO8859_1", null, null, null, oPrt);
        } catch (Exception xcpt) {
          Log.out.error("AsyncSendInvitation MailSessionHandler.sendMessage() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
        }
          oPrt.close();
          Log.out.info(oByOut.toString());
          try {
          oByOut.close();
        } catch (IOException ignore) { }
        DAO.log(oSes, oUsr.getDocument(), User.class, "SEND INVITATION", AtrilEvent.Level.INFO, sEmail);
      }
        if (bCreateEmp) {
        Employees oEms = oTxp.employees(oSes);
        try {
          oEms.seek(oSes, oUsr.getNickName());
        } catch (InstantiationException xcpt) {
          Log.out.error("AsyncSendInvitation Employees.seek() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
        } catch (IllegalAccessException xcpt) {
          Log.out.error("AsyncSendInvitation Employees.seek() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);     
        } catch (ElementNotFoundException enfe) {
              Log.out.debug("creating employee");
          Employee oEmp = new Employee(oSes, oEms);
            oEmp.setUuid(oUsr.getNickName());
            oEmp.setName(oUsr.getFirstName()+" "+oUsr.getLastName());
            oEmp.setEmployeeId("");
            oEmp.setTaxId("");
            oEmp.setActive(true);
            oEmp.save(oSes);
            if (0==t) oActivationInfo.put("employee_uuid", oUsr.getNickName());
        }
      }           
    } // next

    oActivationInfo.put("nickname", oUsr.getNickName());
    oActivationInfo.put("password", oUsr.getPassword());
    oActivationInfo.put("fullname", oUsr.getFirstName()+" "+oUsr.getLastName());
    oActivationInfo.put("email", oUsr.getEmail());
    oActivationInfo.put("user_docid", oUsr.id());
    oActivationInfo.put("user_uuid", oUsr.getString("user_uuid"));
    oActivationInfo.put("businessname", oAcc.getBusinessName());
    oActivationInfo.put("customer_acount", oAcc.getUuid());
    oActivationInfo.put("customer_account_docid", oAcc.id());
    oActivationInfo.put("taxpayer_docid", aTxprs[0]);
    oActivationInfo.put("can_approve", oUsr.getString("can_approve"));
    oActivationInfo.put("can_settle", oUsr.getString("can_settle"));
    oActivationInfo.put("can_premium", oUsr.getString("can_premium"));
    oActivationInfo.put("role", Role.user);
    oActivationInfo.put("hasorders", new Boolean(oAcc.orders(oSes).count()>0));
     
    try {
      Cache.putEntry(oUsr.id()+"activationinfo", oActivationInfo);
    } catch (Exception xcpt) {
      Log.out.error("AsyncSendInvitation Cache.putEntry() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
View Full Code Here

    } else if (sBusinessName.length()==0) {
      errors.add("business name", new LocalizableError("com.zesped.action.SaveClient.businessName.valueNotPresent"));
    } else {
      try {
        connect();
        CustomerAccount oAcc = new CustomerAccount(getSession().getDms(), getSessionAttribute("customer_account_docid"));
        TaxPayer oFoundTaxPayer = oAcc.taxpayers(getSession()).seek(getSession(), sBusinessName);
        if (!oFoundTaxPayer.id().equals(sFormerId))
          errors.add("business name", new LocalizableError("com.zesped.action.SaveClient.businessNameAlreadyExists"));
        oFoundTaxPayer = oAcc.taxpayers(getSession()).seek(getSession(), sTaxId);
        if (!oFoundTaxPayer.id().equals(sFormerId))
          errors.add("business name", new LocalizableError("com.zesped.action.SaveClient.taxIdAlreadyExists"));
      } catch (ElementNotFoundException clientnotfound) {
      } catch (Exception e) {
        Log.out.error("ActivateTaxPayer.validateBusinessName("+sBusinessName+") "+e.getClass().getName()+" "+e.getMessage(), e);
View Full Code Here

    final String sFormerId = getParam("id","");
    final String sRole = getParam("role","");
    if (sFormerId.length()>0 && !sRole.equals("admin")) {           
      try {
        connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
        CustomerAccount oAcc = new CustomerAccount(getSession().getDms(), getSessionAttribute("customer_account_docid"));
        int nAdminCount = 0;
        for (User oUsr : oAcc.getAdmins(getSession())) {
          if (!oUsr.id().equals(sFormerId)) nAdminCount++;
        }
        if (nAdminCount==0)
          addError(new LocalizableError("com.zesped.action.SaveUser.atLeastOneAdminIsRequired"));
        disconnect();
View Full Code Here

      Log.out.debug("SaveUser.save("+sFormerId+")");
      Log.out.debug("permissions is "+sPerms+" selected TaxPayers are "+sSelected);
      try {
        User oUsr;
        connect();
        CustomerAccount oAcc = new CustomerAccount(getSession().getDms(), getSessionAttribute("customer_account_docid"));
        Log.out.debug("Got customer account "+oAcc.id());
        if (sFormerId.length()>0) {
          oUsr = new User(getSession(), sFormerId);
          LoginInterceptor.expire(oUsr.getNickName(), oUsr.getPassword());
          oUsr.setFirstName(getParam("user.firstName"));
          oUsr.setLastName(getParam("user.lastName"));
View Full Code Here

TOP

Related Classes of com.zesped.model.CustomerAccount

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.