public CFAccFeeBuff lockDerived(CFSecurityAuthorization Authorization, CFAccFeePKey PKey) {
   final String S_ProcName = "CFAccRamFee.readDerived";
   CFAccFeePKey key = schema.getFactoryFee().newPKey();
   key.setRequiredTenantId(PKey.getRequiredTenantId());
   key.setRequiredFeeId(PKey.getRequiredFeeId());
   CFAccFeeBuff buff;
   if (dictByPKey.containsKey(key)) {
     buff = dictByPKey.get(key);
   } else {
     buff = null;
   }
   return (buff);
 }
  public void createFee(CFSecurityAuthorization Authorization, CFAccFeeBuff Buff) {
    final String S_ProcName = "createFee";
    CFAccFeePKey pkey = schema.getFactoryFee().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredFeeId(
        ((CFAccRamTenantTable) schema.getTableTenant())
            .nextFeeIdGen(Authorization, Buff.getRequiredTenantId()));
    Buff.setRequiredTenantId(pkey.getRequiredTenantId());
    Buff.setRequiredFeeId(pkey.getRequiredFeeId());
    CFAccFeeByDateIdxKey keyDateIdx = schema.getFactoryFee().newDateIdxKey();
    keyDateIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyDateIdx.setRequiredAccountId(Buff.getRequiredAccountId());
    keyDateIdx.setRequiredFeeDate(Buff.getRequiredFeeDate());

    CFAccFeeByTenantIdxKey keyTenantIdx = schema.getFactoryFee().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccFeeByAcctIdxKey keyAcctIdx = schema.getFactoryFee().newAcctIdxKey();
    keyAcctIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyAcctIdx.setRequiredAccountId(Buff.getRequiredAccountId());

    CFAccFeeByLedgerIdxKey keyLedgerIdx = schema.getFactoryFee().newLedgerIdxKey();
    keyLedgerIdx.setOptionalLedgerTenantId(Buff.getOptionalLedgerTenantId());
    keyLedgerIdx.setOptionalLedgerId(Buff.getOptionalLedgerId());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableAccount()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredAccountId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "Account", "Account", null);
        }
      }
    }

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableTenant()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Owner", "Tenant", "Tenant", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFAccFeePKey, CFAccFeeBuff> subdictDateIdx;
    if (dictByDateIdx.containsKey(keyDateIdx)) {
      subdictDateIdx = dictByDateIdx.get(keyDateIdx);
    } else {
      subdictDateIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByDateIdx.put(keyDateIdx, subdictDateIdx);
    }
    subdictDateIdx.put(pkey, Buff);

    Map<CFAccFeePKey, CFAccFeeBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
      subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
      subdictTenantIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);

    Map<CFAccFeePKey, CFAccFeeBuff> subdictAcctIdx;
    if (dictByAcctIdx.containsKey(keyAcctIdx)) {
      subdictAcctIdx = dictByAcctIdx.get(keyAcctIdx);
    } else {
      subdictAcctIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByAcctIdx.put(keyAcctIdx, subdictAcctIdx);
    }
    subdictAcctIdx.put(pkey, Buff);

    Map<CFAccFeePKey, CFAccFeeBuff> subdictLedgerIdx;
    if (dictByLedgerIdx.containsKey(keyLedgerIdx)) {
      subdictLedgerIdx = dictByLedgerIdx.get(keyLedgerIdx);
    } else {
      subdictLedgerIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByLedgerIdx.put(keyLedgerIdx, subdictLedgerIdx);
    }
    subdictLedgerIdx.put(pkey, Buff);
  }