use of de.metas.bpartner.BPartnerLocationId in project metasfresh-webui-api by metasfresh.
the class DefaultPackingItemCriteria method of.
public static Optional<DefaultPackingItemCriteria> of(final I_C_Order order, final ProductId productId) {
final BPartnerLocationId bpartnerLocationId = BPartnerLocationId.ofRepoIdOrNull(order.getC_BPartner_ID(), order.getC_BPartner_Location_ID());
final PricingSystemId pricingSystemId = PricingSystemId.ofRepoIdOrNull(order.getM_PricingSystem_ID());
final ZonedDateTime date = TimeUtil.asZonedDateTime(order.getDatePromised());
final SOTrx soTrx = SOTrx.ofBoolean(order.isSOTrx());
final boolean anyNull = Stream.of(bpartnerLocationId, pricingSystemId, date, productId).anyMatch(Objects::isNull);
if (anyNull) {
return Optional.empty();
}
return Optional.of(builder().bPartnerLocationId(bpartnerLocationId).productId(productId).pricingSystemId(pricingSystemId).date(date).soTrx(soTrx).build());
}
use of de.metas.bpartner.BPartnerLocationId in project metasfresh-webui-api by metasfresh.
the class DefaultPackingItemCriteria method of.
public static Optional<DefaultPackingItemCriteria> of(@NonNull final I_C_Invoice invoice, @NonNull final ProductId productId) {
final BPartnerLocationId bpartnerLocationId = BPartnerLocationId.ofRepoIdOrNull(invoice.getC_BPartner_ID(), invoice.getC_BPartner_Location_ID());
final PriceListId priceListId = PriceListId.ofRepoIdOrNull(invoice.getM_PriceList_ID());
final ZonedDateTime date = TimeUtil.asZonedDateTime(invoice.getDateInvoiced());
final boolean anyNull = Stream.of(bpartnerLocationId, priceListId, date, productId).anyMatch(Objects::isNull);
if (anyNull) {
return Optional.empty();
}
return Optional.of(builder().productId(productId).priceListId(priceListId).date(date).bPartnerLocationId(bpartnerLocationId).build());
}
use of de.metas.bpartner.BPartnerLocationId in project metasfresh-webui-api by metasfresh.
the class LetterRestController method createNewLetter.
@PostMapping
@ApiOperation("Creates a new letter")
public JSONLetter createNewLetter(@RequestBody final JSONLetterRequest request) {
userSession.assertLoggedIn();
final DocumentPath contextDocumentPath = JSONDocumentPath.toDocumentPathOrNull(request.getDocumentPath());
//
// Extract context BPartner, Location and Contact
final BoilerPlateContext context = documentCollection.createBoilerPlateContext(contextDocumentPath);
final BPartnerId bpartnerId = BPartnerId.ofRepoIdOrNull(context.getC_BPartner_ID(-1));
final BPartnerLocationId bpartnerLocationId = BPartnerLocationId.ofRepoIdOrNull(bpartnerId, context.getC_BPartner_Location_ID(-1));
final UserId contactId = UserId.ofRepoIdOrNull(context.getAD_User_ID(-1));
//
// Build BPartnerAddress
final PlainDocumentLocation documentLocation = PlainDocumentLocation.builder().bpartnerId(bpartnerId).bpartnerLocationId(bpartnerLocationId).contactId(contactId).build();
Services.get(IDocumentLocationBL.class).setBPartnerAddress(documentLocation);
final String bpartnerAddress = documentLocation.getBPartnerAddress();
final WebuiLetter letter = lettersRepo.createNewLetter(WebuiLetter.builder().contextDocumentPath(contextDocumentPath).ownerUserId(userSession.getLoggedUserId()).adOrgId(context.getAD_Org_ID(userSession.getOrgId().getRepoId())).bpartnerId(BPartnerId.toRepoId(bpartnerId)).bpartnerLocationId(BPartnerLocationId.toRepoId(bpartnerLocationId)).bpartnerContactId(UserId.toRepoId(contactId)).bpartnerAddress(bpartnerAddress));
return JSONLetter.of(letter);
}
Aggregations