Пример #1
0
  private List<SyncProductSupply> createPlannedSyncProductSupplies(
      final I_C_RfQResponseLine rfqResponseLine) {
    final I_C_Flatrate_Term contract = rfqResponseLine.getC_Flatrate_Term();
    Check.assumeNotNull(contract, "contract not null");

    final List<I_C_RfQResponseLineQty> rfqResponseLineQtys =
        pmmRfQDAO.retrieveResponseLineQtys(rfqResponseLine);
    if (rfqResponseLineQtys.isEmpty()) {
      return ImmutableList.of();
    }

    final String bpartner_uuid = SyncUUIDs.toUUIDString(contract.getDropShip_BPartner());
    final String contractLine_uuid = SyncUUIDs.toUUIDString(contract);
    final String product_uuid = SyncUUIDs.toUUIDString(contract.getPMM_Product());

    final List<SyncProductSupply> plannedSyncProductSupplies =
        new ArrayList<>(rfqResponseLineQtys.size());
    for (final I_C_RfQResponseLineQty rfqResponseLineQty : rfqResponseLineQtys) {
      final SyncProductSupply syncProductSupply = new SyncProductSupply();
      syncProductSupply.setBpartner_uuid(bpartner_uuid);
      syncProductSupply.setContractLine_uuid(contractLine_uuid);
      syncProductSupply.setProduct_uuid(product_uuid);

      syncProductSupply.setDay(rfqResponseLineQty.getDatePromised());
      syncProductSupply.setQty(rfqResponseLineQty.getQtyPromised());
      plannedSyncProductSupplies.add(syncProductSupply);
    }

    return plannedSyncProductSupplies;
  }
Пример #2
0
  private SyncContract createSyncContract(final I_C_Flatrate_Term term) {
    final SyncContract syncContract = new SyncContract();
    syncContract.setUuid(SyncUUIDs.toUUIDString(term));
    syncContract.setDateFrom(term.getStartDate());
    syncContract.setDateTo(term.getEndDate());

    final int rfqResponseLineId = term.getC_RfQResponseLine_ID();
    if (rfqResponseLineId > 0) {
      syncContract.setRfq_uuid(SyncUUIDs.toC_RfQReponseLine_UUID(rfqResponseLineId));
    }

    //
    // Contract Line: 1 line for our PMM_Product
    {
      final I_PMM_Product pmmProduct = term.getPMM_Product();
      if (pmmProduct == null) {
        logger.warn("Contract {} has no PMM_Product. Skip exporting.", term);
        return null;
      }

      final SyncProduct syncProduct = createSyncProduct(pmmProduct);
      if (syncProduct == null) {
        return null;
      }

      final SyncContractLine syncContractLine = new SyncContractLine();
      syncContractLine.setUuid(syncContract.getUuid());
      syncContractLine.setProduct(syncProduct);

      syncContract.getContractLines().add(syncContractLine);
    }

    return syncContract;
  }
Пример #3
0
  private Multimap<Integer, I_C_Flatrate_Term> getC_Flatrate_Terms_IndexedByBPartnerId() {
    if (_bpartnerId2contract_fullyLoadedRequired && !_bpartnerId2contract_fullyLoaded) {
      _bpartnerId2contract.clear(); // clear all first

      final List<I_C_Flatrate_Term> terms = pmmContractsDAO.retrieveAllRunningContractsOnDate(date);
      for (final I_C_Flatrate_Term term : terms) {
        final int bpartnerId = term.getDropShip_BPartner_ID();
        _bpartnerId2contract.put(bpartnerId, term);
      }

      _bpartnerId2contract_fullyLoaded = true;
    }
    return _bpartnerId2contract;
  }