use of de.metas.document.model.impl.PlainDocumentLocation 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 int bpartnerId = context.getC_BPartner_ID(-1);
final int bpartnerLocationId = context.getC_BPartner_Location_ID(-1);
final int contactId = context.getAD_User_ID(-1);
//
// Build BPartnerAddress
final PlainDocumentLocation documentLocation = new PlainDocumentLocation(Env.getCtx(), bpartnerId, bpartnerLocationId, contactId, ITrx.TRXNAME_None);
Services.get(IDocumentLocationBL.class).setBPartnerAddress(documentLocation);
final String bpartnerAddress = documentLocation.getBPartnerAddress();
final WebuiLetter letter = lettersRepo.createNewLetter(WebuiLetter.builder().contextDocumentPath(contextDocumentPath).ownerUserId(userSession.getAD_User_ID()).adOrgId(context.getAD_Org_ID(userSession.getAD_Org_ID())).bpartnerId(bpartnerId).bpartnerLocationId(bpartnerLocationId).bpartnerAddress(bpartnerAddress).bpartnerContactId(contactId));
return JSONLetter.of(letter);
}
Aggregations