use of de.metas.bpartner.service.IBPartnerDAO in project metasfresh-webui-api by metasfresh.
the class BPartnerProductsProposalViewFactory method createRowsLoaderFromRecord.
@Override
protected ProductsProposalRowsLoader createRowsLoaderFromRecord(TableRecordReference recordRef) {
final IBPartnerDAO bpartnersRepo = Services.get(IBPartnerDAO.class);
final IPriceListDAO priceListsRepo = Services.get(IPriceListDAO.class);
recordRef.assertTableName(I_C_BPartner.Table_Name);
final BPartnerId bpartnerId = BPartnerId.ofRepoId(recordRef.getRecord_ID());
final Set<CountryId> countryIds = bpartnersRepo.retrieveBPartnerLocationCountryIds(bpartnerId);
if (countryIds.isEmpty()) {
throw new AdempiereException("@NotFound@ @C_BPartner_Location_ID@");
}
final I_C_BPartner bpartnerRecord = bpartnersRepo.getById(bpartnerId);
PricingSystemId pricingSystemId = null;
SOTrx soTrx = null;
if (bpartnerRecord.isCustomer()) {
pricingSystemId = PricingSystemId.ofRepoIdOrNull(bpartnerRecord.getM_PricingSystem_ID());
soTrx = SOTrx.SALES;
}
if (pricingSystemId == null && bpartnerRecord.isVendor()) {
pricingSystemId = PricingSystemId.ofRepoIdOrNull(bpartnerRecord.getPO_PricingSystem_ID());
soTrx = SOTrx.PURCHASE;
}
if (pricingSystemId == null) {
throw new AdempiereException("@NotFound@ @M_PricingSystem_ID@");
}
final ZonedDateTime today = SystemTime.asZonedDateTime();
final Set<PriceListVersionId> priceListVersionIds = priceListsRepo.retrievePriceListsCollectionByPricingSystemId(pricingSystemId).filterAndStreamIds(countryIds).map(priceListId -> priceListsRepo.retrievePriceListVersionId(priceListId, today)).collect(ImmutableSet.toImmutableSet());
return ProductsProposalRowsLoader.builder().bpartnerProductStatsService(bpartnerProductStatsService).priceListVersionIds(priceListVersionIds).bpartnerId(bpartnerId).soTrx(soTrx).build();
}
use of de.metas.bpartner.service.IBPartnerDAO in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_Pick_ParametersFiller method createPickingSlotLabel.
private String createPickingSlotLabel(@NonNull final I_M_PickingSlot pickingslot) {
final StringBuilder result = new StringBuilder(pickingslot.getPickingSlot());
final BPartnerId bpartnerId = BPartnerId.ofRepoIdOrNull(pickingslot.getC_BPartner_ID());
if (bpartnerId != null) {
final IBPartnerDAO bpartnersRepo = Services.get(IBPartnerDAO.class);
final I_C_BPartner bpartner = bpartnersRepo.getById(bpartnerId);
result.append("_").append(bpartner.getName()).append("_").append(bpartner.getValue());
}
return result.toString();
}
Aggregations