protected String assignPermissionName(final B2BPermissionForm b2BPermissionForm) {
    final StringBuilder permissionCode = new StringBuilder();
    final String permissionType = b2BPermissionForm.getB2BPermissionTypeData().getCode();

    if (!B2BPermissionTypeEnum.B2BBUDGETEXCEEDEDPERMISSION.equals(
        B2BPermissionTypeEnum.valueOf(permissionType))) {
      final String currency = b2BPermissionForm.getCurrency();
      permissionCode.append((StringUtils.isNotEmpty(currency) ? currency : ""));
      permissionCode.append(SINGLE_WHITEPSACE);
      permissionCode.append(b2BPermissionForm.getValue());
      permissionCode.append(SINGLE_WHITEPSACE);
      permissionCode.append(
          getMessageSource()
              .getMessage(
                  "text.company.managePermissions.assignName.per",
                  null,
                  getI18nService().getCurrentLocale()));
      permissionCode.append(SINGLE_WHITEPSACE);
      final String timespan = b2BPermissionForm.getTimeSpan();
      permissionCode.append(
          (StringUtils.isNotEmpty(timespan)
              ? timespan
              : getMessageSource()
                  .getMessage(
                      "text.company.managePermissions.assignName.order",
                      null,
                      getI18nService().getCurrentLocale())));
    } else {
      permissionCode.append(
          getMessageSource()
              .getMessage(
                  "text.company.managePermissions.assignName.budget",
                  null,
                  getI18nService().getCurrentLocale()));
      permissionCode.append(SINGLE_WHITEPSACE);
      permissionCode.append(b2BPermissionForm.getParentUnitName());
    }

    b2BPermissionForm.setCode(permissionCode.toString());
    return permissionCode.toString();
  }
  public String editPermission(final String permissionCode, final Model model)
      throws CMSItemNotFoundException {
    if (!model.containsAttribute("b2BPermissionForm")) {
      final B2BPermissionData b2BPermissionData =
          b2bCommercePermissionFacade.getPermissionDetails(permissionCode);
      final B2BPermissionForm b2BPermissionForm = new B2BPermissionForm();
      b2BPermissionForm.setCode(b2BPermissionData.getCode());
      b2BPermissionForm.setOriginalCode(b2BPermissionData.getCode());
      b2BPermissionForm.setParentUnitName(b2BPermissionData.getUnit().getUid());
      b2BPermissionForm.setPermissionType(b2BPermissionData.getB2BPermissionTypeData().getName());
      b2BPermissionForm.setB2BPermissionTypeData(b2BPermissionData.getB2BPermissionTypeData());
      if (!(B2BPermissionTypeEnum.B2BBUDGETEXCEEDEDPERMISSION.equals(
          B2BPermissionTypeEnum.valueOf(b2BPermissionData.getB2BPermissionTypeData().getCode())))) {
        b2BPermissionForm.setTimeSpan(b2BPermissionData.getTimeSpan());
        b2BPermissionForm.setValue(
            formatFactory.createNumberFormat().format(b2BPermissionData.getValue()));
        b2BPermissionForm.setCurrency(b2BPermissionData.getCurrency().getIsocode());
      }

      model.addAttribute(b2BPermissionForm);
    }
    storeCmsPageInModel(model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    setUpMetaDataForContentPage(
        model, getContentPageForLabelOrId(ORGANIZATION_MANAGEMENT_CMS_PAGE));
    final List<Breadcrumb> breadcrumbs =
        myCompanyBreadcrumbBuilder.createManagePermissionsBreadcrumb();
    breadcrumbs.add(
        new Breadcrumb(
            String.format(MANAGE_PERMISSIONS_EDIT_URL, permissionCode),
            getMessageSource()
                .getMessage(
                    "text.company.managePermissions.edit.page",
                    new Object[] {permissionCode},
                    "Edit Order Threshold {0}",
                    getI18nService().getCurrentLocale()),
            null));
    model.addAttribute("breadcrumbs", breadcrumbs);
    model.addAttribute("metaRobots", "no-index,no-follow");
    return ControllerConstants.Views.Pages.MyCompany.MyCompanyManagePermissionsEditPage;
  }