Package br.com.visualmidia.business

Examples of br.com.visualmidia.business.Money


        page.addElement(insertBoldText("Impresso por: " + system.getLogged().getName(), posX+265, posY+20, 200));
       
        posY += 40;
       
        try {
            Money totalValueCredit = new Money(0);
            Money totalValueDebit = new Money(0);
            Money totalValue = new Money(0);
            for (Account account : accounts) {
                page.addElement(drawGrayRectangle(posX, posY, convert(190), 20, 3));
                page.addElement(insertBoldText("Conta: "+account.getName(), posX+10, posY+5, 160));
                page.addElement(insertRightText("Saldo Anterior: R$ "+getBalanceUntilLastDay(account.getId(), startDate).getFormatedValue(), posX+265, posY+5, 260));
               
                posY += 23;
               
                page.addElement(drawRectangle(posX, posY, convert(190), 15, 0));
                page.addElement(insertCenterBoldText("Num", posX+2, posY, 35));
                page.addElement(drawVerticalLine(posX+40, posY, 15));
                page.addElement(insertCenterBoldText("Data", posX+42, posY, 75));
                page.addElement(drawVerticalLine(posX+120, posY, 15));
                page.addElement(insertCenterBoldText("Descri��o", posX+122, posY, 210));
                page.addElement(drawVerticalLine(posX+335, posY, 15));
                page.addElement(insertCenterBoldText("Entrada", posX+337, posY, 60));
                page.addElement(drawVerticalLine(posX+400, posY, 15));
                page.addElement(insertCenterBoldText("Sa�da", posX+402, posY, 60));
                page.addElement(drawVerticalLine(posX+465, posY, 15));
                page.addElement(insertCenterBoldText("Balan�o", posX+467, posY, convert(190)-470));
               
                posY += 15;
                Map<String, Operation> operationsMap = (Map<String, Operation>) system.query(new GetOperationByAccountIdAndDate(account.getId(), startDate, finishDate));
               
                List<Operation> operations = new ArrayList<Operation>();
                for (Operation operation : operationsMap.values()) {
                    operations.add(operation);
                }
//                metodo original
//                if(operations.size() > 0) {
//                    MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
//                    sortAlgorithm.sortOperationsById(operations);
//                }
//                metodo alterado
                Comparator<Operation> comparator = new Comparator<Operation>() {

          @Override
          public int compare(Operation o1, Operation o2) {
            int result = -1;
           
            Calendar calendar1 = Calendar.getInstance();
            calendar1.setTime(o1.getDateTime().getDate());
            Calendar calendar2 = Calendar.getInstance();
            calendar2.setTime(o2.getDateTime().getDate());
           
            result = calendar1.compareTo(calendar2);
           
            return result;
          }
                };
               
                Collections.sort(operations, comparator);
               
                Money balanceValueCredit = new Money(0);
                Money balanceValueDebit = new Money(0);
                Money balanceValueTotal = new Money(getBalanceUntilLastDay(account.getId(), startDate).getValue());
                for (Operation operation : operations) {
                    if(operation.isCredit()) {
                        balanceValueCredit.credit(operation.getValue());
                        balanceValueTotal.credit(operation.getValue());
                    } else {
                        balanceValueTotal.debit(operation.getValue());
                        balanceValueDebit.credit(operation.getValue());
                    }
                    page.addElement(drawRectangle(posX, posY, convert(190), 15, 0));
                    page.addElement(insertNormalText(operation.getId(), posX+2, posY, 35, 15));
                    page.addElement(drawVerticalLine(posX+40, posY, 15));
          page.addElement(insertNormalText(new SimpleDateFormat("dd/MM/yyyy HH:mm").format(operation.getDateTime().getDate()), posX+42, posY, 75, 15));
                    page.addElement(drawVerticalLine(posX+120, posY, 15));
                    BillCategory billCategory = (BillCategory) system.query(new GetBillCategory(operation.getCategoryId()));
                    page.addElement(insertNormalText( operation.getDescription().trim().equals("") ? billCategory.getDescription() : operation.getDescription() , posX+122, posY, 217, 15));
                    page.addElement(drawVerticalLine(posX+335, posY, 15));
                    page.addElement(insertRightText(operation.isCredit() ? new Money(operation.getValue()).getFormatedValue():"", posX+337, posY, 60));
                    page.addElement(drawVerticalLine(posX+400, posY, 15));
                    page.addElement(insertRightText(operation.isCredit() ? "" : new Money(operation.getValue()).getFormatedValue(), posX+402, posY, 60));
                    page.addElement(drawVerticalLine(posX+465, posY, 15));
                    page.addElement(insertRightText(balanceValueTotal.getFormatedValue(), posX+467, posY, convert(190)-470));
                   
                    posY += 15;
                   
                   
                    if(posY > (convert(283)-10)){
                        page.addElement(insertFooter());
                        jasperPrint.addPage(page);
                        page = new JRBasePrintPage();
                        posY = convert(10);
                    }
                   
                }
                page.addElement(insertBoldText("Sub-total", posX+10, posY, 100));
                page.addElement(drawRectangle(posX+335, posY, 65, 15, 0));
                page.addElement(insertRightText(balanceValueCredit.getFormatedValue(), posX+337, posY, 60));
                page.addElement(drawRectangle(posX+400, posY, 65, 15, 0));
                page.addElement(insertRightText(balanceValueDebit.getFormatedValue(), posX+402, posY, 60));
                page.addElement(drawRectangle(posX+465, posY, 65, 15, 0));
                page.addElement(insertRightText(balanceValueTotal.getFormatedValue(), posX+467, posY, convert(190)-470));
               
                posY += 18;
                totalValueCredit.credit(balanceValueCredit);
                totalValueDebit.credit(balanceValueDebit);
                totalValue.credit(balanceValueTotal);
View Full Code Here


      beginDate.setMinuteOfHour(0);//(Calendar.MINUTE, 0);
      try {
        Map<String, Operation> operationsMap = (Map<String, Operation>) system.query(new GetOperationByAccountId(accountId));
        //Foi necess�rio alterar os calculos para Money, pois estavammos com problemas de arredondamento.
//      float balanceUntilLastDay = 0;
        Money balanceUntilLastDayMoney = new Money(0.0);

        for (Operation operation : operationsMap.values()) {
          GDDate operationDateTime = new GDDate(operation.getDateTime());
          if(operationDateTime.beforeDay(beginDate)){
//          float inMoney = (!operation.isCredit()) ? 0f : operation.getValue();
//          float outMoney = (operation.isCredit()) ? 0f : operation.getValue() * -1;
//          balanceUntilLastDay += (inMoney + outMoney);
            if (operation.isCredit()){
              balanceUntilLastDayMoney.credit(operation.getValue());
            }else{
              balanceUntilLastDayMoney.debit(operation.getValue());
            }
          }
        }
//      return new Money(balanceUntilLastDay);
        return balanceUntilLastDayMoney;
View Full Code Here

    }

    @Override
    protected void execute(PrevalentSystem system) throws BusinessException {
        int count = 0;
        Money total = new Money(0);
        String idOperation = getIdOperation(system);

        Account account = system.getAccounts().get(accountId);
        Expenditure expenditure = system.getExpenditure().get(expenditureId);
//        Expenditure myExpenditure = new Expenditure(expediture.getId(), expediture.getDescription(), expediture.getNextPaymentDate(), expediture.getFrequency(), expediture.getNumberOfOcurrencies(), expediture.getValue(), expediture.isFixedValue(), expediture.getCategoryId());
//        myExpenditure.setActive(false);

        Operation operation;
       
        if(typeOfPayment == null){
          typeOfPayment = system.getPaymentMoney();
        }else{
          if (typeOfPayment.getType().equals("Dinheiro")) {
            typeOfPayment = system.getPaymentMoney();
      } else if (typeOfPayment.getType().equals("D�bito autom�tico")) {
        typeOfPayment = system.getPaymentAutomaticDebit();
      } else if (typeOfPayment.getType().equals("Pagamento eletr�nico")) {
        typeOfPayment = system.getPaymentEletronic();
      } else if (typeOfPayment.getType().equals("Transfer�ncia eletr�nica")) {
        typeOfPayment = system.getPaymentEletronicTransfer();
      } else if (typeOfPayment.getType().equals("TED")) {
        typeOfPayment = system.getPaymentTED();
      } else if (typeOfPayment.getType().equals("DOC")) {
        typeOfPayment = system.getPaymentDOC();
      } else if (typeOfPayment.getType().equals("Saque cart�o")) {
        typeOfPayment = system.getPaymentGetMoney();
      }
        }
       
        if(idExtractItem == null){
            operation = new Operation(idOperation, account,expenditure.getCategoryId(),date, expenditure.getDescription(),new Money(value).getFloatValue(),typeOfPayment, true, expenditure.getId());
        } else {
            operation = new Operation(idOperation, account,expenditure.getCategoryId(),date, expenditure.getDescription(),new Money(value).getFloatValue(),typeOfPayment, true, expenditure.getId(), idExtractItem);
            operation.setOperationLinked(true);
            system.getExtractItemMap().remove(idExtractItem);
        }
        system.getOperations().put(idOperation, operation);

        expenditure.skip();
       
        if (expenditure.getLastPaymentDate() != null && (expenditure.getFrequency() == 0 || expenditure.getNextPaymentDate().afterDay(expenditure.getLastPaymentDate())) || (expenditure.getLastPaymentDate() == null && expenditure.getFrequency() == 0)) {
          expenditure.setActive(false);
        } else {
            if (!expenditure.isFixedValue()) {
                for (Operation operationTemp : system.getOperations().values()) {
                    if(operationTemp.isExpenditure()) {
                        if (operationTemp.getBillId().equals(expenditure.getId())) {
                            total.credit(operationTemp.getValue());
                            count++;
                        }
                    }
                }
                expenditure.setValue(new Money(total.getValue() / count));
            }
        }
    }
View Full Code Here

                  page = new JRBasePrintPage();
                  posY = convert(10);
                }
              }

              page.addElement(insertFooter(boldStyle, "Total de Alunos Ativos: "+totalPerAttendant+"         Total R$ "+new Money(total).getFormatedValue(), posY));
              int totalRegistrered = totalPerAttendant;
              float totalPayed = total;
              posY += 30;
              page.addElement(printImage("titleReport.gif", posX, posY, 535, 45));
            if(posY > (convert(277)-20)){
              jasperPrint.addPage(page);
              page = new JRBasePrintPage();
              posY = convert(10);
            }
              page.addElement(insertTitle("Alunos Matr�culados no per�odo, j� Finalizadas.", posX+35, posY+11, 410));
              page.addElement(printImage("corporateLogo.jpg", posX+456, posY, 77, 45));
              posY += 55;
              totalPerAttendant = 0;
              total = (float) 0.0;
              registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
              registrationList.clear();
              for (Registration registration : registrationMap.values()) {
                GDDate registrationDate = new GDDate(registration.getRegistrationDate());
                if(!registration.isActive() && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
                  registrationList.add(registration);
                }
              }      
              if(registrationList.size()>0){
                MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
                sortAlgorithm.sortRegistrationByDate(registrationList);
              }

              insertRegisteredtHeaderTable(page, posX);

              total = 0;

              for (Registration registration : registrationList) {
                insertRegisteredDataTable(page, posX, registration);
                totalPerAttendant++;
                if(posY > (convert(277)-20)){
                  jasperPrint.addPage(page);
                  page = new JRBasePrintPage();
                  posY = convert(10);
                }
              }
              page.addElement(insertFooter(boldStyle, "Total de Alunos Desativatos: "+totalPerAttendant+"         Total R$ "+new Money(total).getFormatedValue(), posY));
              posY += 30;
              page.addElement(insertFooter(boldStyle, "Total Geral de Alunos no Periodo: "+(totalRegistrered+totalPerAttendant)+"         Total R$ "+new Money(total+totalPayed).getFormatedValue(), posY));
              jasperPrint.addPage(page);
            }
            else if(type == 2){
              int totalStudents = 0;
              Money totalMoney = new Money(0.0);
              Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
              registrationList.clear();
              for (Registration registration : registrationMap.values()) {
                if(registration.isActive()) {
                  registrationList.add(registration);
                }
              }                 
              if(registrationList.size()>0){
                MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
                sortAlgorithm.sortRegistrationByDate(registrationList);
              }
              Map <String, Person> attendantMap = (Map<String, Person>) system.query(new GetEmployee());
              for (Person attendant : attendantMap.values()) {
                total = 0;
                int i = 0;
                totalPerAttendant = 0;
                for (Registration registration : registrationList) {
//                  String attendantName = ((Person) system.query(new GetEmployee(((Student) registration.getStudent().getPersonType("student")).getAttendanceResponsable()))).getName();
                  GDDate registrationDate = new GDDate(registration.getRegistrationDate());
                  if((registration.getEmployee().getName().equals(attendant.getName())) && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
                    if(i == 0) {
                      page.addElement(drawGrayRectangle(posX, posY, 535, 20, 3));
                      page.addElement(insertTitle(boldStyle, attendant.getName(), posX+5, posY+5));
                      posY += 25;
                      insertRegisteredByAttendentHeaderTable(page, posX);
                    }
                    boolean addinfo = true;
                    String paidParcelsAndTotalParcels = ("00 / " + (registration.getParcels().size() > 9 ? registration.getParcels().size() :"0"+registration.getParcels().size()));;
                    String parcelDate = "___/___/___";
                    String parcelPayDate = "___/___/___";
                    String parcelValueBeforeParcelDateExpiration = "R$_________";
                    List<Parcel> parcels = registration.getParcels();
                    int parcelid = 1;
                    for (int p = 0; p < parcels.size(); p++ ){
                      Parcel parcel = parcels.get(p);
                      if (!parcel.isRegistrationTax()){
                        if ( parcelid==1 ){
                          totalPerAttendant++; 
                          total += new Money(parcel.getValueBeforeParcelDateExpiration()).getFloatValue();
                          totalStudents++;
                          totalMoney.credit(parcel.getValueBeforeParcelDateExpiration());
                        }
                        if ( parcel.getPayDate() != null){
                          paidParcelsAndTotalParcels = (parcelid > 9 ? parcelid : "0"+(parcelid) ) + " / " ( registration.getParcels().size() > 9 ? registration.getParcels().size() :"0"+registration.getParcels().size());
                        }
                       
                        GDDate parcelGDDate = new GDDate(parcel.getDate());
                        if ( parcelGDDate.afterOrEqualsDay(startDate) && parcelGDDate.beforeOrEqualsDay(finishDate)){
                          parcelDate = parcel.getDate();
                          parcelPayDate = (parcel.getPayDate() == null ? "___/___/___":parcel.getPayDate().getFormatedDate());
                          parcelValueBeforeParcelDateExpiration = "R$ " + new Money(parcel.getValueBeforeParcelDateExpiration()).getFormatedValue();
                          addinfo = false;
                        }

                        if (addinfo && parcelid == parcels.size()){
                          parcelDate = parcel.getDate();
                          parcelPayDate = (parcel.getPayDate() == null ? "___/___/___":parcel.getPayDate().getFormatedDate());
                          parcelValueBeforeParcelDateExpiration = "R$ " + new Money(parcel.getValueBeforeParcelDateExpiration()).getFormatedValue();
                        }
                        parcelid++;
                      }
                    }

                    page.addElement(divLine(posX));
                      page.addElement(insertText(bodyStyle, registration.getRegistrationDate(), posX+5, 50));
                      page.addElement(divLine(posX+55));
                      page.addElement(insertText(bodyStyle, registration.getStudent().getName(), posX+60, 300));
                      page.addElement(divLine(posX+257));
                      page.addElement(insertText(bodyStyle, registration.getDuration()+" meses", posX+262, 70));
                      page.addElement(divLine(posX+307));
                    page.addElement(insertText(bodyStyle, paidParcelsAndTotalParcels, posX+315, 60));
              page.addElement(divLine(posX+350));
              page.addElement(insertText(bodyStyle, parcelDate , posX+358, 80));
              page.addElement(divLine(posX+413));
              page.addElement(insertText(bodyStyle, parcelPayDate, posX+421, 80));
              page.addElement(divLine(posX+475));
              page.addElement(insertText(bodyStyle, parcelValueBeforeParcelDateExpiration, posX+480, 100));

              page.addElement(divLine(posX+534));
                    posY += 13;
                    page.addElement(drawHorizontalLine(posX, posY, 535));

                    if(posY > (convert(277)-20)){
                      jasperPrint.addPage(page);
                      page = new JRBasePrintPage();
                      posY = convert(10);
                      insertRegisteredByAttendentHeaderTable(page, posX);
                    }
                    i++;
                  }
                  else
                  {
                    if((!registration.getEmployee().getName().equals(attendant.getName())) && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
//                      System.out.println(registration.getEmployee().getName());
                    }
                  }

                  if(posY > (convert(277)-20)){
                    jasperPrint.addPage(page);
                    page = new JRBasePrintPage();
                    posY = convert(10);
                  }
                }
                if(i > 0){
                  posY += 3;
//                  page.addElement(insertFooter(boldStyle, "Total de Alunos: "+totalPerAttendant+"         Total R$ "+new Money(total).getFormatedValue(), posY));
                  page.addElement(insertFooter(boldStyle, "Total de Alunos: "+totalPerAttendant, posY));
                  posY += 18;
                }
              }
              page.addElement(insertFooter(boldStyle, "Total Geral de Alunos: " + totalStudents/*+"     Total Geral R$ " + totalMoney.getFormatedValue()*/, posY));
              posY += 16;
              page.addElement(insertText(bodyStyle, "                     Obs: O campo Parcela exibe a Quantidade de Parcelas Pagas e o Total Geral de Parcelas (Pagas/Total)\n", posX+5, 510));
              posY += 10;
              page.addElement(insertText(bodyStyle, "O campo Pagamento exibe a Data de Pagamento, quando este n�o foi efetuado � exibido __/__/__ indicando que a parcela est� em aberto.", posX+79, 390,30));
              jasperPrint.addPage(page);
            } else if(type == 3){
              int totalhowDoYouKnowVisualmidia = 0;
                List <String> howDoYouKnowVisualmidiaList = (List<String>) system.query(new GetHowDoYouKnowVisualmidia());
                for (String howDoYouKnowVisualmidia : howDoYouKnowVisualmidiaList) {
                  int i = 0;
                   
                    Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
                   
                    registrationList.clear();
                    for (Registration registration : registrationMap.values()) {
                        registrationList.add(registration);
                    }                 
                    if(registrationList.size()>0){
                        MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
                        sortAlgorithm.sortRegistrationByDate(registrationList);
                    }
                   
                    for (Registration registration : registrationList) {
                        Student student = (Student) registration.getStudent().getPersonType("student");
                        GDDate registrationDate = new GDDate(registration.getRegistrationDate());
            if((student.getHowDoYouKnowVisualMidia().equals(howDoYouKnowVisualmidia)) &&  registration.isActive() && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
                            if(i == 0) {
                              page.addElement(drawGrayRectangle(posX, posY, 535, 20, 3));
                                page.addElement(insertTitle(boldStyle, howDoYouKnowVisualmidia, posX+5, posY+5));
                               
                                posY += 25;
                                totalPerAttendant = 0;
                               
                                page.addElement(drawRectangle(posX, posY, 535, 15, 0));
                                page.addElement(insertCenterBoldText("Data", posX+5, posY, 70));
                                page.addElement(divLine(posX+75));
                                page.addElement(insertCenterBoldText("Nome", posX+80, posY, 300));
                                page.addElement(divLine(posX+380));
                                page.addElement(insertCenterBoldText("Dura��o", posX+385, posY, 70));
                                page.addElement(divLine(posX+455));
                                page.addElement(insertCenterBoldText("Valor", posX+460, posY, 75));
                               
                                posY += 15;
                            }
             
              page.addElement(drawRectangle(posX, posY, 535, 15, 0));
                            page.addElement(insertText(bodyStyle, registration.getRegistrationDate(), posX+5, 70));
                            page.addElement(divLine(posX+75));
                            page.addElement(insertText(bodyStyle, registration.getStudent().getName(), posX+80, 300));
                            page.addElement(divLine(posX+380));
                            page.addElement(insertText(bodyStyle, registration.getDuration()+" meses", posX+385, 70));
                            page.addElement(divLine(posX+455));
                            Parcel parcel = registration.getParcel(0);
                            if(parcel != null){
                              page.addElement(insertText(bodyStyle, "R$ " + new Money(parcel.getValueBeforeParcelDateExpiration()).getFormatedValue(), posX+460, 75));
                            }else{
                              page.addElement(insertText(bodyStyle, "R$ ______", posX+460, 75));
                            }
                           
                            posY += 15;
                           
                            totalPerAttendant++;
                            if(posY > (convert(297)-20)){
                                jasperPrint.addPage(page);
                                page = new JRBasePrintPage();
                                posY = convert(10);
                            }
                            i++;
                        }
                    }
                    if(i > 0) {
                      page.addElement(insertFooter(boldStyle, "Total de Alunos: "+totalPerAttendant, posY+2));
                      posY += 15;
                      totalhowDoYouKnowVisualmidia += totalPerAttendant;
                    }
                   
                }
                posY += 7;
              page.addElement(insertFooter(boldStyle, "Total Geral de Alunos: "+totalhowDoYouKnowVisualmidia, posY+2));
                jasperPrint.addPage(page);
            } else if(type == 4) {
               
              totalPerAttendant = 0;
             
                page.addElement(drawRectangle(posX, posY, 535, 15, 0));
                page.addElement(insertCenterBoldText("Data", posX+5, posY, 70));
                page.addElement(divLine(posX+75));
                page.addElement(insertCenterBoldText("Nome", posX+80, posY, 230));
                page.addElement(divLine(posX+310));
                page.addElement(insertCenterBoldText("Telefone", posX+315, posY, 100));
                page.addElement(divLine(posX+415));
                page.addElement(insertCenterBoldText("Atendente", posX+420, posY, 115));
               
                posY += 15;
               
                Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
                registrationList.clear();
                for (Registration registration : registrationMap.values()) {
                    if(!registration.isActive()) {
                        registrationList.add(registration);
                    }
                }      
                if(registrationList.size()>0){
                    MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
                    sortAlgorithm.sortRegistrationByDate(registrationList);
                }
               
                total = 0;
               
                for (Registration registration : registrationList) {
                  if(!registration.isActive())   {
                   
                    page.addElement(drawRectangle(posX, posY, 535, 15, 0));
                    page.addElement(insertText(bodyStyle, registration.getRegistrationDate(), posX+5, 70));
                    page.addElement(divLine(posX+75));
                    page.addElement(insertText(bodyStyle, registration.getStudent().getName(), posX+80, 230));
                    page.addElement(divLine(posX+310));
                    page.addElement(insertText(bodyStyle, registration.getStudent().getPhone(), posX+315, 100));
                    page.addElement(divLine(posX+415));
                    page.addElement(insertText(bodyStyle, registration.getEmployee().getName(), posX+420, 115));
                   
                    posY += 15;
                   
                    totalPerAttendant++;
                    if(posY > (convert(297)-20)){
                      jasperPrint.addPage(page);
                      page = new JRBasePrintPage();
                      posY = convert(10);
                    }
                  }
                }
               
                page.addElement(insertFooter(boldStyle, "Total de Alunos: "+totalPerAttendant, posY));
               
                posY += 15;
           jasperPrint.addPage(page);
            } else if(type == 5) {
              Money totalDesistent = new Money(0.0);
              int totalStudents = 0;
                for (String status : statusList) {
                  total = (float) 0.0;
                  int i = 0;
                    Map<String, Registration> registrationMap = (Map<String, Registration>) system.query(new GetRegistration());
                    registrationList.clear();
                    for (Registration registration : registrationMap.values()) {
                        if(!registration.isActive()) {
                            registrationList.add(registration);
                        }
                    }                 
//                    if(registrationList.size()>0){
//                        MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
//                        sortAlgorithm.sortRegistrationByDate(registrationList);
//                    }
                   
                    Comparator<Registration> comparator = new Comparator<Registration>() {
                      @Override
                      public int compare(Registration o1, Registration o2) {
                        int result = -1;
                        Calendar calendar1 = Calendar.getInstance();
                        calendar1.setTime(o1.getEndDate().getDate());
                        Calendar calendar2 = Calendar.getInstance();
                        calendar2.setTime(o2.getEndDate().getDate());        
                        result = calendar1.compareTo(calendar2);
                       
                        return result;
                      }
                     
                    };
                    Collections.sort(registrationList,comparator);
                for (Registration registration : registrationList) {
                       
                        GDDate registrationDate = new GDDate(registration.getEndDate());
            if(checkStatus(status, registration.getEndStatus()) && (ignoreDate ? true : (registrationDate.afterOrEqualsDay(startDate) && registrationDate.beforeOrEqualsDay(finishDate)))) {
              if (i == 0){
                page.addElement(drawGrayRectangle(posX, posY, 535, 20, 3));
                page.addElement(insertTitle(boldStyle, status, posX+5, posY+5));
               
                posY += 25;
                totalPerAttendant = 0;
               
                insertEndedRegistrationHeaderTable(page, posX);
                i++;
              }
             
//                            page.addElement(drawRectangle(posX, posY, 535, 13, 0));
              page.addElement(divLine(posX));
              page.addElement(insertText(bodyStyle, registrationDate.getFormatedDate(), posX+5, 48));
                            page.addElement(divLine(posX+58));
                            page.addElement(insertText(bodyStyle, registration.getStudent().getName(), posX+63, 152));
                            page.addElement(divLine(posX+206));
                            String paidParcelsAndTotalParcels = (getParcelsValue(registration) > 9 ? getParcelsValue(registration) : "0"+getParcelsValue(registration) ) + " / " ( registration.getParcels().size() > 9 ? registration.getParcels().size() :"0"+registration.getParcels().size());
//                            page.addElement(insertText(bodyStyle, (getParcelsValue(registration) == 0 ? "" : new Money(getParcelsValue(registration)).getFormatedValue()), posX+275, 70));
                            page.addElement(insertText(bodyStyle, paidParcelsAndTotalParcels, posX+217, 70));
                            page.addElement(divLine(posX+258));
                            Parcel parcel0 = (registration.getParcels().size()> 0 ? registration.getParcel(0).isRegistrationTax() ? registration.getParcel(1) : registration.getParcel(0) : null);
                        if(parcel0 != null){
                          page.addElement(insertText(bodyStyle, "R$ " + new Money(parcel0.getValueBeforeParcelDateExpiration()).getFormatedValue(), posX+265, 100));
                          total += new Money(parcel0.getValueBeforeParcelDateExpiration()).getFloatValue();
                        } else{
                          page.addElement(insertText(bodyStyle, "R$ ______", posX+265, 100));
                        }
                            page.addElement(divLine(posX+320));
                            page.addElement(insertText(bodyStyle, registration.getEndStatus().get(0), posX+325, 86));
                            page.addElement(divLine(posX+410));
                            page.addElement(insertText(bodyStyle, registration.getEndEmployee().getName(), posX+415, 120));
                            page.addElement(divLine(posX+534));
                            posY += 13;
                           
                            page.addElement(drawHorizontalLine(posX, posY, 535));
                           
                            totalPerAttendant++;
                            if(posY > (convert(297)-20)){
                                jasperPrint.addPage(page);
                                page = new JRBasePrintPage();
                                posY = convert(10);
                                insertEndedRegistrationHeaderTable(page, posX);
                            }
                        }
                        if(posY > (convert(297)-20)){
                            jasperPrint.addPage(page);
                            page = new JRBasePrintPage();
                            posY = convert(10);
//                            insertHeaderTable(page, posX);
                        }
                    }
                   
                    if(i > 0){
                      totalDesistent.credit(total);
                      totalStudents+=totalPerAttendant;
                      page.addElement(insertFooter(boldStyle, "Total de Alunos: " +  totalPerAttendant + "          Total R$ " + new Money(total).getFormatedValue(), posY));
                      posY += 18;
                    }
                    if (status.equals(statusList.get(statusList.size()-1)) ){
                      page.addElement(insertFooter(boldStyle, "Total Geral de Alunos: " + totalStudents+"     Total Geral R$ " + totalDesistent.getFormatedValue(), posY));
                      posY += 16;
                      page.addElement(insertText(bodyStyle, "                     Obs: O campo Parcela exibe a Quantidade de Parcelas Pagas e o Total Geral de Parcelas (Pagas/Total)", posX+5, 510));
                    }
                }
               jasperPrint.addPage(page);
View Full Code Here

    Parcel parcel0 = null;
    if (registration.getParcels().size() > 2) {
      parcel0 = (registration.getParcel(0).isRegistrationTax() ? registration.getParcel(1) : registration.getParcel(0));
    }
    if(parcel0 != null){
      page.addElement(insertText(bodyStyle, "R$ " + new Money(parcel0.getValueBeforeParcelDateExpiration()).getFormatedValue(), posX+465, 100));
      total += new Money(parcel0.getValueBeforeParcelDateExpiration()).getFloatValue();
    } else{
      page.addElement(insertText(bodyStyle, "R$ ______", posX+465, 100));
    }
   
    posY += 15;
View Full Code Here

                if(bill2.getEnpenditure() == bill) {
                    tempMap.put(bill2.getId(), bill2);
                }
            }
           
            Money total = new Money(0);
           
            for (PaidExpenditure bills : tempMap.values()) {
                total.credit(bills.getValue());
            }
           
            bill.setValue(new Money(total.getValue()/tempMap.size()));
        }
       
        if (bill.getFrequency() == 0)
            bill.setActive(false);
    }
View Full Code Here

   
    @SuppressWarnings("unchecked")
  protected void buttonPressed(int buttonId) {
        if (buttonId == OK) {
            if(canBePaid) {
                if(new Money(receivedValueText.getText()).getFloatValue() >= new Money(payTotalText.getText()).getFloatValue()) {
                    String accountSelected = accountCombo.getText();
                    String accountId = "";
                    if(!accountSelected.equals("Selecione uma conta...")) {
                      String accountNameLogged = "";
                      Map<String, Account> accountMap;
View Full Code Here

  private void paydParcel(String accountId) {
      float ticket = 0;
      float mora = 0;
      float discount = 0;
      float payTotal = new Money(payTotalText.getText()).getFloatValue();//Float.parseFloat(clearString(payTotalText.getText()));
     
      if (!ticketText.getText().equals(""))
        ticket = new Money(ticketText.getText()).getFloatValue();//Float.parseFloat(clearString(ticketText.getText()));
     
      if (!moraText.getText().equals(""))
        mora = new Money(moraText.getText()).getFloatValue();//Float.parseFloat(clearString(moraText.getText()));
     
      if (!discountText.getText().equals(""))
        discount = new Money(discountText.getText()).getFloatValue();//Float.parseFloat(clearString(discountText.getText()));
     
      new MoneyTransaction().parcelPayment(registration, accountId, parcelId, ticket, mora, discount, payTotal, new GDDate(), paymentTypeCombo.getPaymentType(), new Money(receivedValueText.getText()));
     
      if (registrationParentScreen != null) {
        registrationParentScreen.updateTable();
      }
      if (dayleParentScreen != null) {
View Full Code Here

        GDDate graceDays = new GDDate(parcel.getDate());
    graceDays.addDays(Integer.valueOf(system.getProperty("gracedays")));
       
        if (today.afterDay(expirationDate) &&  today.afterDay(graceDays)) {
            float percent = (((gd.get("fine")== null) || (gd.get("fine").equals(""))) ? 0 : (new Money((String) gd.get("fine"))).getFloatValue());
           
            Money value = new Money(parcel.getValueAfterParcelDateExpiration());
            Money ticketValue = new Money(((value.getFloatValue()/100)*percent));
           
            ticketText.setText(ticketValue.getFormatedValue());
        }else{
            ticketText.setText("0,00");
        }
           
        GridData data = new GridData(GridData.FILL);
View Full Code Here

            int x = 0;
            while (expirationDate.beforeDay(today)) {
                x++;
                expirationDate.addDays(1);
            }
            float percent = (((gd.get("interestDeferredPayment")== null) || (gd.get("interestDeferredPayment").equals(""))) ? 0 : new Money((String) gd.get("interestDeferredPayment")).getFloatValue());
           
            Money value = new Money(parcel.getValueAfterParcelDateExpiration());
            Money moraValue = new Money(((value.getFloatValue()/100)*percent)*x);
           
            moraText.setText(moraValue.getFormatedValue());
        } else {
            moraText.setText("0,00");
        }

        GridData data = new GridData(GridData.FILL);
View Full Code Here

TOP

Related Classes of br.com.visualmidia.business.Money

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.