Package org.openbravo.erpCommon.utility

Examples of org.openbravo.erpCommon.utility.OBError


  }

  private OBError processButton(VariablesSecureApp vars, String strKey, String strProjectType,
      String strDateFrom, String windowId) {
    Connection conn = null;
    OBError myMessage = new OBError();
    if (strProjectType == null || strProjectType.equals("")) {
      try {
        releaseRollbackConnection(conn);
      } catch (Exception ignored) {
      }
      log4j.warn("Rollback in transaction");
      myMessage.setType("Error");
      myMessage.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
      myMessage.setMessage(Utility.messageBD(this, "NoProjectTypeSelected", vars.getLanguage()));
    } else {
      try {
        conn = this.getTransactionConnection();
        ProjectSetTypeData[] data = ProjectSetTypeData.select(this, strProjectType);
        ProjectSetTypeData[] dataProject = ProjectSetTypeData.selectProject(this, strKey);
        String strProjectPhase = "";
        String strProjectTask = "";
        // Variables used for Project Scheduling purposes
        DateFormat DateFormatter = Utility.getDateFormatter(vars);
        int firstProjectPhase = 0;
        String strPhaseStartDate = "";
        String strPhaseContractDate = "";
        String strTaskStartDate = "";
        String strTaskContractDate = "";
        String strLastContractDate = "";

        for (int i = 0; data != null && i < data.length; i++) {
          strProjectPhase = SequenceIdData.getUUID();

          // Calculates the Starting Date of the Phase
          if (firstProjectPhase == 0) {
            strPhaseStartDate = strDateFrom;
          } else {
            strPhaseStartDate = calculateStartDate(strLastContractDate, DateFormatter);
          }
          // Calculates the Contract Date of the Phase
          strPhaseContractDate = calculateContractDate(strPhaseStartDate, data[i].stdduration,
              DateFormatter);

          try {
            if (ProjectSetTypeData.insertProjectPhase(conn, this, strKey,
                dataProject[0].adClientId, dataProject[0].adOrgId, vars.getUser(),
                data[i].description, data[i].mProductId, data[i].cPhaseId, strProjectPhase,
                data[i].help, data[i].name, data[i].standardqty, strPhaseStartDate,
                strPhaseContractDate, data[i].seqno) == 1) {
              strLastContractDate = strPhaseContractDate;
              ProjectSetTypeData[] data1 = ProjectSetTypeData.selectTask(this, data[i].cPhaseId);
              int firstProjectTask = 0;
              for (int j = 0; data1 != null && j < data1.length; j++) {
                strProjectTask = SequenceIdData.getUUID();

                // Calculates the Starting Date of the Task
                if (firstProjectTask == 0) {
                  strTaskStartDate = strPhaseStartDate;
                } else {
                  strTaskStartDate = calculateStartDate(strLastContractDate, DateFormatter);
                }
                // Calculates the Contract Date of the Task
                strTaskContractDate = calculateContractDate(strTaskStartDate, data1[j].stdduration,
                    DateFormatter);

                try {
                  ProjectSetTypeData.insertProjectTask(conn, this, strProjectTask,
                      data1[j].cTaskId, dataProject[0].adClientId, dataProject[0].adOrgId, vars
                          .getUser(), data1[j].seqno, data1[j].name, data1[j].description,
                      data1[j].help, data1[j].mProductId, strProjectPhase, data1[j].standardqty,
                      strTaskStartDate, strTaskContractDate);
                } catch (ServletException ex) {
                  myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex
                      .getMessage());
                  releaseRollbackConnection(conn);
                  return myMessage;
                }

                strLastContractDate = strTaskContractDate;
                firstProjectTask++;
              }
              firstProjectPhase++;
            }
          } catch (ServletException ex) {
            myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
            releaseRollbackConnection(conn);
            return myMessage;
          }
        }

        // Updates project's Type and category
        String strProjectCategory = ProjectSetTypeData.selectProjectCategory(this, strProjectType);
        try {
          ProjectSetTypeData.update(conn, this, vars.getUser(), strProjectType, strProjectCategory,
              strKey);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          releaseRollbackConnection(conn);
          return myMessage;
        }

        // Updates project's Starting and Contract Dates
        ProjectSetTypeData[] dataDates = ProjectSetTypeData.selectDates(this, strKey);
        String strStartDate = strDateFrom.equals("") ? dataDates[0].startdate : strDateFrom;
        String strContractDate = strLastContractDate.equals("") ? dataDates[0].datecontract
            : strLastContractDate;
        try {
          ProjectSetTypeData.updateDates(conn, this, vars.getUser(), strStartDate, strContractDate,
              strKey);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          releaseRollbackConnection(conn);
          return myMessage;
        }

        releaseCommitConnection(conn);
        myMessage.setType("Success");
        myMessage.setTitle(Utility.messageBD(this, "Success", vars.getLanguage()));
      } catch (Exception e) {
        try {
          releaseRollbackConnection(conn);
        } catch (Exception ignored) {
        }
View Full Code Here


        strWindowPath = strDefaultServlet;

      String strKey = vars.getRequiredStringParameter("inpglJournalbatchId");
      String strGLJournalBatch = vars.getStringParameter("inpClave");

      OBError myError = processButton(vars, strKey, strGLJournalBatch, strWindow);
      vars.setMessage(strTab, myError);

      printPageClosePopUp(response, vars, strWindowPath);
    } else
      pageErrorPopUp(response);
View Full Code Here

  private OBError processButton(VariablesSecureApp vars, String strKey, String strGLJournalBatch,
      String windowId) {
    if (log4j.isDebugEnabled())
      log4j.debug("Save: GLJournal");
    if (strGLJournalBatch.equals(""))
      return new OBError();
    ;
    Connection conn = null;

    OBError myError = null;
    try {
      conn = this.getTransactionConnection();
      CopyFromGLJournalData[] data = CopyFromGLJournalData.select(this, strKey, strGLJournalBatch);
      for (int i = 0; data != null && i < data.length; i++) {
        String strSequence = SequenceIdData.getUUID();
        String strDocumentNo = Utility.getDocumentNo(this, vars, windowId, "GL_Journal", Utility
            .getContext(this, vars, "C_DocTypeTarget_ID", "132"), Utility.getContext(this, vars,
            "C_DocType_ID", "132"), false, true);
        try {
          if (CopyFromGLJournalData.insertGLJournal(conn, this, strSequence, vars.getClient(), vars
              .getOrg(), vars.getUser(), data[i].cAcctschemaId, data[i].cDoctypeId, "DR", "CO",
              data[i].isapproved, data[i].isprinted, data[i].description, data[i].postingtype,
              data[i].glCategoryId, data[i].datedoc, data[i].dateacct, data[i].cPeriodId,
              data[i].cCurrencyId, data[i].currencyratetype, data[i].currencyrate, strKey,
              data[i].controlamt, strDocumentNo, "N", "N", "N") == 0)
            log4j.warn("Save: GLJournal record " + i + " not inserted. Sequence = " + strSequence);
        } catch (ServletException ex) {
          myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          releaseRollbackConnection(conn);
          return myError;
        }
        CopyFromGLJournalData[] dataLines = CopyFromGLJournalData.selectLines(this,
            data[i].glJournalId);
        for (int j = 0; dataLines != null && j < dataLines.length; j++) {
          String strLineSequence = SequenceIdData.getUUID();
          try {
            if (CopyFromGLJournalData.insertGLJournalLine(conn, this, strLineSequence, vars
                .getClient(), vars.getOrg(), vars.getUser(), strSequence, dataLines[j].line,
                dataLines[j].isgenerated, dataLines[j].description, dataLines[j].amtsourcedr,
                dataLines[j].amtsourcecr, dataLines[j].cCurrencyId, dataLines[j].currencyratetype,
                dataLines[j].currencyrate, dataLines[j].amtacctdr, dataLines[j].amtacctcr,
                dataLines[j].cUomId, dataLines[j].qty, dataLines[j].cValidcombinationId) == 0)
              log4j.warn("Save: GLJournalLine record " + j + " not inserted. Sequence = "
                  + strLineSequence);
          } catch (ServletException ex) {
            myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
            releaseRollbackConnection(conn);
            return myError;
          }
        }
      }

      releaseCommitConnection(conn);
      myError = new OBError();
      myError.setType("Success");
      myError.setTitle("");
      myError.setMessage(Utility.messageBD(this, "Success", vars.getLanguage()));
    } catch (Exception e) {
      try {
        releaseRollbackConnection(conn);
      } catch (Exception ignored) {
      }
View Full Code Here

      String strDatefrom = vars.getStringParameter("inpDatefrom");
      String strDateto = vars.getStringParameter("inpDateto");
      String strProcessed = vars.getStringParameter("inpProcessed");
      String strGeneratePayment = vars.getStringParameter("inpGeneratePayment");
      String strProcessing = vars.getStringParameter("inpProcessing");
      OBError myMessage = CreateRegisters(vars, strTaxpaymentID, strDatefrom, strDateto,
          strProcessed, strGeneratePayment, strProcessing);
      // try this

      // String strWindowId = vars.getStringParameter("inpWindowId");
      String strTabId = vars.getStringParameter("inpTabId");
View Full Code Here

    xmlDocument.setParameter("theme", vars.getTheme());
    xmlDocument.setParameter("window", strWindow);
    xmlDocument.setParameter("tab", strTab);
    xmlDocument.setParameter("key", strKey);
    {
      OBError myMessage = vars.getMessage(strTab);
      vars.removeMessage(strTab);
      if (myMessage != null) {
        xmlDocument.setParameter("messageType", myMessage.getType());
        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
      }
    }
    response.setContentType("text/html; charset=UTF-8");
    PrintWriter out = response.getWriter();
    out.println(xmlDocument.print());
View Full Code Here

  private OBError CreateRegisters(VariablesSecureApp vars, String strTaxpaymentID,
      String strDatefrom, String strDateto, String strProcessed, String strGeneratePayment,
      String strProcessing) throws IOException, ServletException {
    // Connection conn = getTransactionConnection();
    OBError myMessage = null;
    TaxPayment[] taxpayment = TaxPayment.select(this, strTaxpaymentID);
    String strUser = vars.getUser();
    log4j.info("strTaxpaymentID: " + strTaxpaymentID + "strDatefrom: " + strDatefrom
        + "strDateto: " + strDateto + "strProcessed: " + strProcessed + "strGeneratePayment: "
        + strGeneratePayment);
    // If processing=n then i deleted all old record of tax register and
    // register lines
    if (strProcessed.equalsIgnoreCase("N")) {
      // check for already used periods)
      BigDecimal CrossPeriodCount = new BigDecimal(TaxPayment.selectCrossPeriodCount(this, vars
          .getClient(), strDatefrom, strDateto));
      if (CrossPeriodCount.intValue() > 0) {
        myMessage = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this,
            "PeriodsDontMatch", vars.getLanguage()));
        return myMessage;
      }

      try {
        TaxPayment.deleteRegisterLinesChild(this, strTaxpaymentID);
        TaxPayment.deleteRegisterChild(this, strTaxpaymentID);
      } catch (ServletException ex) {
        myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
        return myMessage;
      }

      // Select all active Register Type for create the Tax Registers
      TaxRegisterType[] taxregistertypes = TaxRegisterType.select(this, vars.getClient(), Tree
          .getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), taxpayment[0].adOrgId));
      log4j.info("2strTaxpaymentID: " + strTaxpaymentID + "strDatefrom: " + strDatefrom
          + "strDateto: " + strDateto + "strProcessed: " + strProcessed + "strGeneratePayment: "
          + strGeneratePayment);

      // For all active Register Type i create a Tax Register
      for (TaxRegisterType taxRegisterType : taxregistertypes) {
        String strSequence = SequenceIdData.getUUID();
        log4j.info("Sequence: " + strSequence);

        try {
          TaxRegister.insert(this, taxpayment[0].adClientId, taxpayment[0].adOrgId, strSequence,
              strTaxpaymentID, taxRegisterType.cTaxregisterTypeId, "0",
              taxRegisterType.registername, strUser, strUser);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          return myMessage;
        }
      }
      // For every TaxRegister i select the invoices with a specific
      // doctype
      // in that specific period and inser them in the respective
      // TaxRegisterLine
      log4j.info("3strTaxpaymentID: " + strTaxpaymentID + "strDatefrom: " + strDatefrom
          + "strDateto: " + strDateto + "strProcessed: " + strProcessed + "strGeneratePayment: "
          + strGeneratePayment);
      TaxRegister[] taxregisters = TaxRegister.selectChild(this, strTaxpaymentID);
      for (TaxRegister taxRegister : taxregisters) {
        CreateVatRegistersData[] invoices = CreateVatRegistersData.select(this, strTaxpaymentID,
            taxRegister.cTaxregisterTypeId, strDatefrom, DateTimeData.nDaysAfter(this, strDateto,
                "1"), Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()),
                taxpayment[0].adOrgId));
        for (CreateVatRegistersData myinvoice : invoices) {
          String strTaxBaseAmt = "0";
          String strTaxAmt = "0";
          String strTaxUndeducAmt = "0";
          String strExemptAmt = "0";
          String strTotalAmt = "0";
          String strNoVatAmt = "0";

          log4j.info("cTaxregisterTypeId: " + taxRegister.cTaxregisterTypeId + "strTaxpaymentID: "
              + strTaxpaymentID + "strDatefrom: " + strDatefrom + "strDateto: " + strDateto
              + "strGeneratePayment: " + strGeneratePayment);
          if ((myinvoice.istaxexempt.equals("N")) && (myinvoice.istaxundeductable.equals("N"))
              && (myinvoice.isnovat.equals("N"))) {
            strTaxBaseAmt = myinvoice.taxbaseamt;
            strTaxAmt = myinvoice.taxamt;
          } else if ((myinvoice.istaxexempt.equals("Y"))
              && (myinvoice.istaxundeductable.equals("N")) && (myinvoice.isnovat.equals("N"))) {
            strTaxAmt = myinvoice.taxamt;
            strExemptAmt = myinvoice.taxbaseamt;
          } else if ((myinvoice.istaxexempt.equals("N"))
              && (myinvoice.istaxundeductable.equals("Y")) && (myinvoice.isnovat.equals("N"))) {
            strTaxBaseAmt = myinvoice.taxbaseamt;
            strTaxUndeducAmt = myinvoice.taxamt;
          } else if ((myinvoice.istaxexempt.equals("N"))
              && (myinvoice.istaxundeductable.equals("N")) && (myinvoice.isnovat.equals("Y"))) {
            strNoVatAmt = myinvoice.taxbaseamt;
            strTaxAmt = myinvoice.taxamt;
          } else {
            // if (!(((myinvoice.istaxexempt.equals("Y") )
            // ^ (myinvoice.istaxundeductable.equals("Y"))
            // ^ (myinvoice.isnovat.equals("Y"))))) {
            // return
            // "InvoiceTax Error: istaxexempt, istaxundeduc or isnovat could have wrong values,  C_InvoiceTax_ID="+myinvoice.cInvoicetaxId;
            myMessage = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(
                this, "TaxCriteriaNotFound", vars.getLanguage()));
            return myMessage;
          }
          if (myinvoice.docbasetype.equals(DocInvoice.DOCTYPE_APCredit)
              || myinvoice.docbasetype.equals(DocInvoice.DOCTYPE_ARCredit)) {
            strTaxBaseAmt = (new BigDecimal(strTaxBaseAmt).negate()).toPlainString();
            strTaxAmt = (new BigDecimal(strTaxAmt).negate()).toPlainString();
            strTaxUndeducAmt = (new BigDecimal(strTaxUndeducAmt).negate()).toPlainString();
            strExemptAmt = (new BigDecimal(strExemptAmt).negate()).toPlainString();
            strNoVatAmt = (new BigDecimal(strNoVatAmt).negate()).toPlainString();
          }

          // Calculate totalamt
          log4j.info("4strTaxpaymentID: " + strTaxpaymentID + "strDatefrom: " + strDatefrom
              + "strDateto: " + strDateto + "strProcessed: " + strProcessed
              + "strGeneratePayment: " + strGeneratePayment);

          BigDecimal dbTotalAmt = new BigDecimal(strTaxBaseAmt).add(new BigDecimal(strTaxAmt)).add(
              new BigDecimal(strTaxUndeducAmt)).add(new BigDecimal(strExemptAmt)).add(
              new BigDecimal(strNoVatAmt));

          strTotalAmt = dbTotalAmt.toPlainString();

          String strSequence = SequenceIdData.getUUID();
          log4j.info("Sequence: " + strSequence);

          try {
            TaxRegister.insertLines(this, taxRegister.adClientId, taxRegister.adOrgId, strSequence,
                taxRegister.cTaxregisterId, myinvoice.cInvoicetaxId, myinvoice.documentno,
                myinvoice.cTaxId, strTaxBaseAmt, strTaxAmt, strTaxUndeducAmt, strExemptAmt,
                strNoVatAmt, strTotalAmt, myinvoice.taxdate, "RegisterLine", strUser, strUser);
          } catch (ServletException ex) {
            myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
            return myMessage;
          }

        }

        try {
          TaxRegister.updateTaxTotalAmt(this, taxRegister.cTaxregisterId);
          TaxRegister.updateRegAccumAmt(this, taxRegister.cTaxregisterId,
              taxRegister.cTaxregisterTypeId, strDatefrom);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          return myMessage;
        }
      }
      // if GeneratePayment= Y then i set the field processing = N so next
      // time i print only the tax registers
      // if (strProcessing.equalsIgnoreCase("Y")) {
      // TaxPayment
      // .updateProcessed(this, "Y", strUser, strTaxpaymentID);
      // }
      log4j.info("5strTaxpaymentID: " + strTaxpaymentID + "strDatefrom: " + strDatefrom
          + "strDateto: " + strDateto + "strProcessed: " + strProcessed + "strGeneratePayment: "
          + strGeneratePayment);

      try {
        if (new BigDecimal(TaxPayment.calculateVatPayment(this, strTaxpaymentID))
            .compareTo(BigDecimal.ZERO) > 0) {
          TaxPayment.updateGeneratePayment(this, "Y", strUser, strTaxpaymentID);
        } else
          TaxPayment.updateGeneratePayment(this, "N", strUser, strTaxpaymentID);
      } catch (NumberFormatException e) {
        myMessage = Utility.translateError(this, vars, vars.getLanguage(), Utility.messageBD(this,
            "NoDataSelected", vars.getLanguage()));
        return myMessage;
      }
      if (myMessage == null) {
        myMessage = new OBError();
        myMessage.setType("Success");
        myMessage.setTitle("");
        myMessage.setMessage(Utility.messageBD(this, "Success", vars.getLanguage()));
      }
      return myMessage;

    }
View Full Code Here

      xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
    } catch (Exception ex) {
      throw new ServletException(ex);
    }
    {
      OBError myMessage = vars.getMessage("ReportWorkRequirementJR");
      vars.removeMessage("ReportWorkRequirementJR");
      if (myMessage != null) {
        xmlDocument.setParameter("messageType", myMessage.getType());
        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
      }
    }

    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
    xmlDocument.setParameter("paramLanguage", "defaultLang=\"" + vars.getLanguage() + "\";");
View Full Code Here

    if (isDefault) {
      xmlDocument.setParameter("messageType", "");
      xmlDocument.setParameter("messageTitle", "");
      xmlDocument.setParameter("messageMessage", "");
    } else {
      OBError myMessage = new OBError();
      myMessage.setTitle("");
      if (log4j.isDebugEnabled())
        log4j.debug("CreateFile - before setMessage");
      if (strMessage == null || strMessage.equals(""))
        myMessage.setType("Success");
      else
        myMessage.setType("Error");
      if (strMessage != null && !strMessage.equals("")) {
        myMessage.setMessage(strMessage);
      } else
        Utility.translateError(this, vars, vars.getLanguage(), "Success");
      if (log4j.isDebugEnabled())
        log4j.debug("CreateFile - Message Type: " + myMessage.getType());
      vars.setMessage("CreateFile", myMessage);
      if (log4j.isDebugEnabled())
        log4j.debug("CreateFile - after setMessage");
      if (myMessage != null) {
        xmlDocument.setParameter("messageType", myMessage.getType());
        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
      }
    }

    response.setContentType("text/html; charset=UTF-8");
    PrintWriter out = response.getWriter();
View Full Code Here

      xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
    } catch (Exception ex) {
      throw new ServletException(ex);
    }
    {
      OBError myMessage = vars.getMessage("ShowSessionVariables");
      vars.removeMessage("ShowSessionVariables");
      if (myMessage != null) {
        xmlDocument.setParameter("messageType", myMessage.getType());
        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
      }
    }
    ShowSessionVariablesData[] windowsData = (vars.getLanguage().equals("en_US") ? ShowSessionVariablesData
        .select(this, strWindows.toString())
        : ShowSessionVariablesData.selectTrl(this, strWindows.toString(), vars.getLanguage()));
View Full Code Here

      printPageDataSheet(response, vars, strKey, strWindowId, strTabId, strPartDateFrom,
          strPartDateTo, strMaintType);
    } else if (vars.commandIn("SAVE")) {
      String strKey = vars.getStringParameter("inpmaMaintPartId");
      String strTabId = vars.getStringParameter("inpTabId");
      OBError myMessage = updateValues(request, vars, strKey);

      String strWindowPath = Utility.getTabURL(this, strTabId, "R");
      if (strWindowPath.equals(""))
        strWindowPath = strDefaultServlet;
View Full Code Here

TOP

Related Classes of org.openbravo.erpCommon.utility.OBError

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.