Package net.sf.chellow.billing

Examples of net.sf.chellow.billing.SupplierContract


      }

      String importMpanStr = GeneralImport.addField(csvElement,
          "Import MPAN Core", values, 20);
      Integer importAgreedSupplyCapacity = null;
      SupplierContract importSupplierContract = null;
      String importLlfcCode = GeneralImport.addField(csvElement,
          "Import LLFC", values, 21);
      String importAgreedSupplyCapacityStr = GeneralImport.addField(
          csvElement, "Import Agreed Supply Capacity", values, 22);
      String importSupplierContractName = GeneralImport.addField(
          csvElement, "Import Supplier Contract", values, 23);
      String importSupplierAccount = GeneralImport.addField(csvElement,
          "Import Supplier Account", values, 24);
      if (importMpanStr != null && importMpanStr.length() != 0) {
        try {
          importAgreedSupplyCapacity = new Integer(
              importAgreedSupplyCapacityStr);
        } catch (NumberFormatException e) {
          throw new UserException(
              "The import supply capacity must be an integer."
                  + e.getMessage());
        }
        importSupplierContract = SupplierContract
            .getSupplierContract(importSupplierContractName);
      }
      SupplierContract exportSupplierContract = null;
      Integer exportAgreedSupplyCapacity = null;
      String exportLlfcCode = null;
      String exportMpanStr = null;
      String exportSupplierAccount = null;
      if (values.length > 25) {
View Full Code Here


      }
    }

    String importMpanCoreStr = null;
    String importLlfcCode = null;
    SupplierContract importSupplierContract = null;
    String importSupplierAccount = null;
    Integer importAgreedSupplyCapacity = null;
    Mpan importMpan = templateGeneration.getImportMpan();
    if (importMpan != null) {
      importMpanCoreStr = importMpan.getCore().toString();
      importLlfcCode = importMpan.getLlfc().toString();
      importSupplierContract = importMpan.getSupplierContract();
      importSupplierAccount = importMpan.getSupplierAccount();
      importAgreedSupplyCapacity = importMpan.getAgreedSupplyCapacity();
    }
    String exportMpanCoreStr = null;
    String exportLlfcCode = null;
    SupplierContract exportSupplierContract = null;
    String exportSupplierAccount = null;
    Integer exportAgreedSupplyCapacity = null;
    Mpan exportMpan = templateGeneration.getExportMpan();
    if (exportMpan != null) {
      exportMpanCoreStr = exportMpan.getCore().toString();
View Full Code Here

        Ssc ssc = null;
        sscCode = sscCode.trim();
        if (sscCode.length() > 0) {
          ssc = Ssc.getSsc(sscCode);
        }
        SupplierContract importSupplierContract = null;
        String importSupplierAccount = null;
        Integer importAgreedSupplyCapacity = null;
        String importLlfcCode = null;
        if (importMpanCoreStr.trim().length() > 0) {
          importLlfcCode = inv.getString("import-llfc-code");
          Long importSupplierContractId = inv
              .getLong("import-supplier-contract-id");
          importSupplierAccount = inv
              .getString("import-supplier-account");
          String importAgreedSupplyCapacityStr = inv
              .getString("import-agreed-supply-capacity");
          if (!inv.isValid()) {
            throw new UserException();
          }
          importSupplierContract = SupplierContract
              .getSupplierContract(importSupplierContractId);
          try {
            importAgreedSupplyCapacity = new Integer(
                importAgreedSupplyCapacityStr);
          } catch (NumberFormatException e) {
            throw new UserException(
                "The import supply capacity must be an integer."
                    + e.getMessage());
          }
        }
        SupplierContract exportSupplierContract = null;
        String exportLlfcCode = null;
        Integer exportAgreedSupplyCapacity = null;
        String exportSupplierAccount = null;
        if (exportMpanCoreStr.trim().length() > 0) {
          exportLlfcCode = inv.getString("export-llfc-code");
View Full Code Here

      String importMpanCoreStr = GeneralImport.addField(csvElement,
          "Import MPAN Core", values, 17);
      String importLlfcCode = null;
      Integer importAgreedSupplyCapacity = null;
      SupplierContract importSupplierContract = null;
      String importSupplierAccount = null;
      Mpan existingImportMpan = supplyGeneration.getImportMpan();
      if (importMpanCoreStr.equals(GeneralImport.NO_CHANGE)) {
        importMpanCoreStr = existingImportMpan == null ? null
            : existingImportMpan.getCore().toString();
      } else if (importMpanCoreStr.length() == 0) {
        importMpanCoreStr = null;
      }
      if (importMpanCoreStr != null) {
        importLlfcCode = GeneralImport.addField(csvElement,
            "Import LLFC", values, 18);
        if (importLlfcCode.equals(GeneralImport.NO_CHANGE)) {
          importLlfcCode = existingImportMpan == null ? null
              : existingImportMpan.getLlfc().toString();
        }
        String importAgreedSupplyCapacityStr = GeneralImport
            .addField(csvElement, "Import Agreed Supply Capacity",
                values, 19);
        if (importAgreedSupplyCapacityStr
            .equals(GeneralImport.NO_CHANGE)) {
          if (existingImportMpan == null) {
            throw new UserException(
                "There isn't an existing import MPAN.");
          } else {
            importAgreedSupplyCapacity = existingImportMpan
                .getAgreedSupplyCapacity();
          }
        } else {
          try {
            importAgreedSupplyCapacity = Integer
                .parseInt(importAgreedSupplyCapacityStr);
          } catch (NumberFormatException e) {
            throw new UserException(
                "The import agreed supply capacity must be an integer. "
                    + e.getMessage());
          }
        }
        String importSupplierContractName = GeneralImport.addField(
            csvElement, "Import Supplier Contract", values, 20);
        if (importSupplierContractName.equals(GeneralImport.NO_CHANGE)) {
          if (existingImportMpan == null) {
            throw new UserException(
                "There isn't an existing import supplier.");
          }
          importSupplierContract = existingImportMpan
              .getSupplierContract();
        } else {
          importSupplierContract = SupplierContract
              .getSupplierContract(importSupplierContractName);
        }
        importSupplierAccount = GeneralImport.addField(csvElement,
            "Import Supplier Account", values, 21);
        if (importSupplierAccount.equals(GeneralImport.NO_CHANGE)) {
          if (existingImportMpan == null) {
            throw new UserException(
                "There isn't an existing import supplier account.");
          }
          importSupplierAccount = existingImportMpan
              .getSupplierAccount();
        }
      }
      String exportMpanCoreStr = null;
      String exportLlfcCode = null;
      SupplierContract exportSupplierContract = null;
      String exportSupplierAccount = null;
      Integer exportAgreedSupplyCapacity = null;
      if (values.length > 22) {
        exportMpanCoreStr = GeneralImport.addField(csvElement,
            "Eport MPAN Core", values, 22);
        Mpan existingExportMpan = supplyGeneration.getExportMpan();
        if (exportMpanCoreStr.equals(GeneralImport.NO_CHANGE)) {
          exportMpanCoreStr = existingExportMpan == null ? null
              : existingExportMpan.getCore().toString();
        } else if (exportMpanCoreStr.length() == 0) {
          exportMpanCoreStr = null;
        }
        if (exportMpanCoreStr != null) {
          exportLlfcCode = GeneralImport.addField(csvElement,
              "Export LLFC", values, 23);
          if (exportLlfcCode.equals(GeneralImport.NO_CHANGE)) {
            exportLlfcCode = existingExportMpan == null ? null
                : existingExportMpan.getLlfc().toString();
          }
          String exportAgreedSupplyCapacityStr = GeneralImport
              .addField(csvElement,
                  "Export Agreed Supply Capacity", values, 24);
          if (exportAgreedSupplyCapacityStr
              .equals(GeneralImport.NO_CHANGE)) {
            if (existingExportMpan == null) {
              throw new UserException(
                  "There isn't an existing export MPAN.");
            } else {
              exportAgreedSupplyCapacity = existingExportMpan
                  .getAgreedSupplyCapacity();
            }
          } else {
            try {
              exportAgreedSupplyCapacity = new Integer(
                  exportAgreedSupplyCapacityStr);
            } catch (NumberFormatException e) {
              throw new UserException(
                  "The export supply capacity must be an integer. "
                      + e.getMessage());
            }
          }
          String exportSupplierContractName = GeneralImport.addField(
              csvElement, "Export Supplier Contract", values, 25);
          if (exportSupplierContractName
              .equals(GeneralImport.NO_CHANGE)) {
            if (existingExportMpan == null) {
              throw new UserException(
                  "There isn't an existing export supplier contract.");
            }
            exportSupplierContract = existingExportMpan
                .getSupplierContract();
          } else {
            exportSupplierContract = SupplierContract
                .getSupplierContract(exportSupplierContractName);
          }
          exportSupplierAccount = GeneralImport.addField(csvElement,
              "Export Supplier Account", values, 26);
          if (exportSupplierAccount.equals(GeneralImport.NO_CHANGE)) {
            if (existingExportMpan == null) {
              throw new UserException(
                  "There isn't an existing export MPAN.");
            }
            exportSupplierAccount = existingExportMpan
                .getSupplierAccount();
          }
        }
      }
      supply.updateGeneration(
          supplyGeneration,
          startDateStr.equals(GeneralImport.NO_CHANGE) ? supplyGeneration
              .getStartDate() : new HhStartDate(startDateStr),
          finishDateStr.length() == 0 ? null : (finishDateStr
              .equals(GeneralImport.NO_CHANGE) ? supplyGeneration
              .getFinishDate() : new HhStartDate(finishDateStr)),
          mopContract, mopAccount, hhdcContract, hhdcAccount,
          meterSerialNumber, pc, mtcCode, cop, ssc,
          importMpanCoreStr, importLlfcCode, importSupplierContract,
          importSupplierAccount, importAgreedSupplyCapacity,
          exportMpanCoreStr, exportLlfcCode, exportSupplierContract,
          exportSupplierAccount, exportAgreedSupplyCapacity);
    } else if (action.equals("delete")) {
      String mpanCoreStr = GeneralImport.addField(csvElement,
          "MPAN Core", values, 0);
      MpanCore mpanCore = MpanCore.getMpanCore(mpanCoreStr);
      Supply supply = mpanCore.getSupply();
      String dateStr = GeneralImport.addField(csvElement, "Date", values,
          1);

      SupplyGeneration supplyGeneration = supply.getGeneration(dateStr
          .length() == 0 ? null : new HhStartDate(dateStr));
      if (supplyGeneration == null) {
        throw new UserException(
            "There isn't a generation at this date.");
      }
      supply.deleteGeneration(supplyGeneration);
    } else if (action.equals("insert")) {
      String mpanCoreStr = GeneralImport.addField(csvElement,
          "MPAN Core", values, 0);
      Supply supply = MpanCore.getMpanCore(mpanCoreStr).getSupply();
      String startDateStr = GeneralImport.addField(csvElement,
          "Start date", values, 1);
      HhStartDate startDate = startDateStr.length() == 0 ? null
          : new HhStartDate(startDateStr);
      SupplyGeneration existingGeneration = supply
          .getGeneration(startDate);
      if (existingGeneration == null) {
        SupplyGeneration firstGeneration = supply.getGenerationFirst();
        if (startDate.before(firstGeneration.getStartDate())) {
          existingGeneration = firstGeneration;
        }
      }
      if (existingGeneration == null) {
        throw new UserException(
            "The start date is after end of the supply.");
      }

      String siteCode = GeneralImport.addField(csvElement, "Site Code",
          values, 2);
      Site physicalSite = null;
      List<Site> logicalSites = new ArrayList<Site>();
      if (siteCode.equals(GeneralImport.NO_CHANGE)) {
        for (SiteSupplyGeneration ssgen : existingGeneration
            .getSiteSupplyGenerations()) {
          if (ssgen.getIsPhysical()) {
            physicalSite = ssgen.getSite();
          } else {
            logicalSites.add(ssgen.getSite());
          }
        }
      } else {
        physicalSite = Site.getSite(siteCode);
      }

      String mopContractName = GeneralImport.addField(csvElement,
          "MOP Contract", values, 3);
      MopContract mopContract = null;
      if (mopContractName.equals(GeneralImport.NO_CHANGE)) {
        mopContract = existingGeneration.getMopContract();
      } else {
        if (mopContractName.length() > 0) {
          mopContract = MopContract.getMopContract(mopContractName);
        }
      }
      String mopAccount = GeneralImport.addField(csvElement,
          "MOP Account Reference", values, 4);
      if (mopAccount.equals(GeneralImport.NO_CHANGE)) {
        mopAccount = existingGeneration.getMopAccount();
      }

      String hhdcContractName = GeneralImport.addField(csvElement,
          "HHDC Contract", values, 5);
      HhdcContract hhdcContract = null;
      if (hhdcContractName.equals(GeneralImport.NO_CHANGE)) {
        hhdcContract = existingGeneration.getHhdcContract();
      } else {
        if (hhdcContractName.length() > 0) {
          hhdcContract = HhdcContract
              .getHhdcContract(hhdcContractName);
        }
      }
      String hhdcAccount = GeneralImport.addField(csvElement,
          "HHDC Account Reference", values, 6);
      if (hhdcAccount.equals(GeneralImport.NO_CHANGE)) {
        hhdcAccount = existingGeneration.getHhdcAccount();
      }

      String hasImportKwhStr = GeneralImport.addField(csvElement,
          "Has HH import kWh", values, 7);
      boolean hasImportKwh = hasImportKwhStr
          .equals(GeneralImport.NO_CHANGE) ? existingGeneration
          .getChannel(true, true) != null : Boolean
          .parseBoolean(hasImportKwhStr);
      String hasImportKvarhStr = GeneralImport.addField(csvElement,
          "Has HH import kVArh", values, 8);
      boolean hasImportKvarh = hasImportKvarhStr
          .equals(GeneralImport.NO_CHANGE) ? existingGeneration
          .getChannel(true, false) != null : Boolean
          .parseBoolean(hasImportKvarhStr);
      String hasExportKwhStr = GeneralImport.addField(csvElement,
          "Has HH export kWh", values, 9);
      boolean hasExportKwh = hasImportKwhStr
          .equals(GeneralImport.NO_CHANGE) ? existingGeneration
          .getChannel(false, true) != null : Boolean
          .parseBoolean(hasExportKwhStr);
      String hasExportKvarhStr = GeneralImport.addField(csvElement,
          "Has HH export kVArh", values, 10);
      boolean hasExportKvarh = hasImportKwhStr
          .equals(GeneralImport.NO_CHANGE) ? existingGeneration
          .getChannel(false, false) != null : Boolean
          .parseBoolean(hasExportKvarhStr);

      String meterSerialNumber = GeneralImport.addField(csvElement,
          "Meter Serial Number", values, 11);
      if (meterSerialNumber.equals(GeneralImport.NO_CHANGE)) {
        meterSerialNumber = existingGeneration.getMeterSerialNumber();
      }

      String pcStr = GeneralImport.addField(csvElement, "Profile Class",
          values, 12);
      Pc pc = null;

      if (pcStr.equals(GeneralImport.NO_CHANGE)) {
        pc = existingGeneration.getPc();
      } else {
        pc = Pc.getPc(pcStr);
      }

      String mtcCode = GeneralImport.addField(csvElement,
          "Meter Timeswitch Class", values, 13);
      if (mtcCode.equals(GeneralImport.NO_CHANGE)) {
        mtcCode = existingGeneration.getMtc().toString();
      }

      Cop cop = null;
      String copStr = GeneralImport.addField(csvElement, "CoP", values,
          14);
      if (copStr.equals(GeneralImport.NO_CHANGE)) {
        cop = existingGeneration.getCop();
      } else {
        cop = Cop.getCop(copStr);
      }

      Ssc ssc = null;
      String sscCode = GeneralImport.addField(csvElement,
          "Standard Settlement Configuration", values, 15);
      if (sscCode.equals(GeneralImport.NO_CHANGE)) {
        ssc = existingGeneration.getSsc();
      } else if (sscCode.length() > 0) {
        ssc = Ssc.getSsc(sscCode);
      }

      String importMpanCoreStr = GeneralImport.addField(csvElement,
          "Import MPAN Core", values, 16);
      Mpan existingImportMpan = existingGeneration.getImportMpan();
      if (importMpanCoreStr.equals(GeneralImport.NO_CHANGE)) {
        if (existingImportMpan == null) {
          importMpanCoreStr = "";
        } else {
          importMpanCoreStr = existingImportMpan.getCore().toString();
        }
      }

      SupplierContract importSupplierContract = null;
      String importSupplierAccount = null;
      Integer importAgreedSupplyCapacity = null;
      String importLlfcCode = null;
      String importAgreedSupplyCapacityStr = null;
      String importContractSupplierName = null;

      if (importMpanCoreStr.length() > 0) {
        importLlfcCode = GeneralImport.addField(csvElement,
            "Import Line Loss Factor Class", values, 17);
        if (importLlfcCode.equals(GeneralImport.NO_CHANGE)) {
          if (existingImportMpan == null) {
            throw new UserException(
                "There ins't an existing import MPAN.");
          } else {
            importLlfcCode = existingImportMpan.getLlfc()
                .toString();
          }
        }
        importAgreedSupplyCapacityStr = GeneralImport
            .addField(csvElement, "Import Agreed Supply Capacity",
                values, 18);
        if (importAgreedSupplyCapacityStr
            .equals(GeneralImport.NO_CHANGE)) {
          if (existingImportMpan != null) {
            importAgreedSupplyCapacity = existingImportMpan
                .getAgreedSupplyCapacity();
          }
        } else {

          try {
            importAgreedSupplyCapacity = Integer
                .parseInt(importAgreedSupplyCapacityStr);
          } catch (NumberFormatException e) {
            throw new UserException(
                "The import agreed supply capacity must be an integer. "
                    + e.getMessage());
          }
        }
        importContractSupplierName = GeneralImport.addField(csvElement,
            "Import Supplier Contract", values, 19);
        if (importContractSupplierName.equals(GeneralImport.NO_CHANGE)) {
          if (existingImportMpan != null) {
            importSupplierContract = existingImportMpan
                .getSupplierContract();
          }
        } else {
          importSupplierContract = SupplierContract
              .getSupplierContract(importContractSupplierName);
        }
        importSupplierAccount = GeneralImport.addField(csvElement,
            "Import Supplier Account Reference", values, 20);
        if (importSupplierAccount.equals(GeneralImport.NO_CHANGE)) {
          if (existingImportMpan == null) {
            importSupplierAccount = null;
          } else {
            importSupplierAccount = existingImportMpan
                .getSupplierAccount();
          }
        }
      }

      String exportMpanCoreStr = null;
      String exportLlfcCode = null;
      SupplierContract exportSupplierContract = null;
      String exportSupplierAccount = null;
      Integer exportAgreedSupplyCapacity = null;

      if (values.length > 21) {
        Mpan existingExportMpan = existingGeneration.getExportMpan();
View Full Code Here

      HhdcContract hhdcContract, String hhdcAccount,
      String meterSerialNumber, Pc pc, String mtcCode, Cop cop, Ssc ssc)
      throws HttpException {
    String importLlfcCode = null;
    String importMpanCoreStr = null;
    SupplierContract importSupplierContract = null;
    String importSupplierAccount = null;
    Integer importAgreedSupplyCapacity = null;
    String exportMpanCoreStr = null;
    String exportLlfcCode = null;
    SupplierContract exportSupplierContract = null;
    String exportSupplierAccount = null;
    Integer exportAgreedSupplyCapacity = null;
    if (importMpan != null) {
      importLlfcCode = importMpan.getLlfc().toString();
      importMpanCoreStr = importMpan.getCore().toString();
View Full Code Here

        }
      }
    }
    Hiber.flush();
    for (Mpan mpan : mpans) {
      SupplierContract supplierContract = mpan.getSupplierContract();
      if (supplierContract.getStartRateScript().getStartDate()
          .after(startDate)) {
        throw new UserException(
            "The supplier contract starts after the supply generation.");
      }
      if (HhStartDate.isBefore(supplierContract.getFinishRateScript()
          .getFinishDate(), finishDate)) {
        throw new UserException(
            "The supplier contract finishes before the supply generation.");
      }
    }
View Full Code Here

        String importMpanCoreStr = null;
        Integer importAgreedSupplyCapacity = null;
        MopContract mopContract = null;
        HhdcContract hhdcContract = null;
        SupplierContract importSupplierContract = null;
        String importSupplierAccount = null;
        boolean isEnded = inv.getBoolean("is-ended");
        if (isEnded) {
          Date finishDateRaw = inv.getDateTime("finish");
          if (!inv.isValid()) {
            throw new UserException();
          }
          finishDate = new HhStartDate(finishDateRaw);
        }
        String mopAccount = null;
        if (mopContractId != null) {
          mopContract = MopContract.getMopContract(mopContractId);
          mopAccount = inv.getString("mop-account");
        }
        String hhdcAccount = null;
        if (hhdcContractId != null) {
          hhdcContract = HhdcContract.getHhdcContract(hhdcContractId);
          hhdcAccount = inv.getString("hhdc-account");
        }
        Pc pc = Pc.getPc(pcId);
        boolean hasImportMpan = inv.getBoolean("has-import-mpan");
        String importLlfcCode = null;

        if (hasImportMpan) {
          importMpanCoreStr = inv.getString("import-mpan-core");
          importLlfcCode = inv.getString("import-llfc-code");
          Long importSupplierContractId = inv
              .getLong("import-supplier-contract-id");
          importSupplierAccount = inv
              .getString("import-supplier-account");
          importAgreedSupplyCapacity = inv
              .getInteger("import-agreed-supply-capacity");

          if (!inv.isValid()) {
            throw new UserException(document());
          }

          importSupplierContract = SupplierContract
              .getSupplierContract(importSupplierContractId);
        }
        String exportMpanCoreStr = null;
        String exportLlfcCode = null;
        Integer exportAgreedSupplyCapacity = null;
        String exportSupplierAccount = null;
        SupplierContract exportSupplierContract = null;
        boolean hasExportMpan = inv.getBoolean("has-export-mpan");
        if (hasExportMpan) {
          exportMpanCoreStr = inv.getString("export-mpan-core");
          exportLlfcCode = inv.getString("export-llfc-code");
          exportAgreedSupplyCapacity = inv
View Full Code Here

TOP

Related Classes of net.sf.chellow.billing.SupplierContract

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.