Skip to content

Commit

Permalink
#6915 Extend BPartner-Relation and add it as BPartner-Tab
Browse files Browse the repository at this point in the history
#10590

PR requested changes
  • Loading branch information
BodorAnnamaria committed Feb 9, 2021
1 parent e87bfb6 commit d4a268f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,6 @@ public boolean applyLocationChecks()
List<GeographicalCoordinatesWithBPartnerLocationId> getGeoCoordinatesByBPartnerLocationIds(Collection<Integer> bpartnerLocationRepoIds);

BPartnerLocationId retrieveCurrentBillLocationOrNull(BPartnerId partnerId);

I_C_BPartner_Location getBPartnerLocation(int c_bPartner_id, int c_bPartner_location_id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,8 @@ public I_C_BPartner_Location retrieveBillToLocation(
.firstOnly(I_C_BP_Relation.class); // just added an UC
if (billtoRelation != null)
{
return InterfaceWrapperHelper.create(getBPartnerLocationById(BPartnerLocationId.ofRepoId(billtoRelation.getC_BPartner_ID(), billtoRelation.getC_BPartnerRelation_Location_ID())), I_C_BPartner_Location.class);
I_C_BPartner_Location partnerRelationLocation = getBPartnerLocation(billtoRelation.getC_BPartner_ID(), billtoRelation.getC_BPartnerRelation_Location_ID());
return InterfaceWrapperHelper.create(partnerRelationLocation, I_C_BPartner_Location.class);
}
return null;
}
Expand Down Expand Up @@ -1683,4 +1684,11 @@ private static BPartnerPrintFormat toBPartnerPrintFormat(final I_C_BP_PrintForma
.build();
}

@Override
public I_C_BPartner_Location getBPartnerLocation(final int c_bPartner_id, final int c_bPartner_location_id)
{
BPartnerLocationId partnerLocationId = BPartnerLocationId.ofRepoId(c_bPartner_id, c_bPartner_location_id);
return getBPartnerLocationById(partnerLocationId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import org.compiere.model.I_C_BPartner;
import org.compiere.model.X_C_BP_Relation;
import org.compiere.util.Env;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Properties;
Expand All @@ -44,12 +44,13 @@ public class SubProducerAttributeDAOTest
{
private I_C_BPartner bp;
private I_C_BPartner bp2;
private final ISubProducerAttributeDAO dao = Services.get(ISubProducerAttributeDAO.class);
private ISubProducerAttributeDAO dao;

@Before
public void init()
@BeforeEach
public void before()
{
AdempiereTestHelper.get().init();
dao = Services.get(ISubProducerAttributeDAO.class);
final Properties ctx = Env.getCtx();
Env.setClientId(ctx, ClientId.METASFRESH);
Env.setOrgId(ctx, AdempiereTestHelper.createOrgWithTimeZone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
public class C_OLCand
{
private final OLCandValidatorService olCandValidatorService;
private final IBPartnerDAO bPartnerDAO = Services.get(IBPartnerDAO.class);

public C_OLCand(@NonNull final OLCandValidatorService olCandValidatorService)
{
Expand Down Expand Up @@ -284,7 +285,10 @@ private void updateHandoverLocationOverride(@NonNull final I_C_OLCand olCand)
}
else
{
org.compiere.model.I_C_BPartner_Location handOverLocation = Services.get(IBPartnerDAO.class).getBPartnerLocationById(BPartnerLocationId.ofRepoId(handoverRelation.getC_BP_Relation_ID(), handoverRelation.getC_BPartnerRelation_Location_ID()));
org.compiere.model.I_C_BPartner_Location handOverLocation =
bPartnerDAO
.getBPartnerLocation(handoverRelation.getC_BP_Relation_ID(),
handoverRelation.getC_BPartnerRelation_Location_ID());

if (handOverLocation == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*/

import de.metas.bpartner.BPartnerId;
import de.metas.bpartner.BPartnerLocationId;
import de.metas.bpartner.service.IBPartnerBL;
import de.metas.bpartner.service.IBPartnerDAO;
import de.metas.process.JavaProcess;
Expand Down Expand Up @@ -70,6 +69,8 @@ public class CreateBPRelationFromDocument extends JavaProcess
private boolean p_IsShipTo = false;

private final IBPartnerDAO bPartnersRepo = Services.get(IBPartnerDAO.class);
private final IBPartnerBL bPartnerBL = Services.get(IBPartnerBL.class);

@Override
protected void prepare()
{
Expand Down Expand Up @@ -209,12 +210,12 @@ private void setName(final I_C_BP_Relation rel)
{
final StringBuffer name = new StringBuffer();

final String nameFrom = Services.get(IBPartnerBL.class).getBPartnerName(BPartnerId.ofRepoId(rel.getC_BPartner_ID()));
final String nameFrom = bPartnerBL.getBPartnerName(BPartnerId.ofRepoId(rel.getC_BPartner_ID()));
name.append(nameFrom);

if (rel.getC_BPartner_Location_ID() > 0)
{
final I_C_BPartner_Location bPartnerLocation = bPartnersRepo.getBPartnerLocationById(BPartnerLocationId.ofRepoId(rel.getC_BPartner_ID(), rel.getC_BPartner_Location_ID()));
final I_C_BPartner_Location bPartnerLocation = bPartnersRepo.getBPartnerLocation(rel.getC_BPartner_ID(), rel.getC_BPartner_Location_ID());
final String locFrom = bPartnerLocation.getName();
name.append("(").append(locFrom).append(")");
}
Expand All @@ -226,7 +227,7 @@ private void setName(final I_C_BP_Relation rel)

if (rel.getC_BPartnerRelation_Location_ID() > 0)
{
final String locTo = bPartnersRepo.getBPartnerLocationById(BPartnerLocationId.ofRepoId(rel.getC_BPartnerRelation_ID(), rel.getC_BPartnerRelation_Location_ID())).getName();
final String locTo = bPartnersRepo.getBPartnerLocation(rel.getC_BPartnerRelation_ID(), rel.getC_BPartnerRelation_Location_ID()).getName();
name.append("(").append(locTo).append(")");
}
rel.setName(name.toString());
Expand Down

0 comments on commit d4a268f

Please sign in to comment.