Skip to content

Commit

Permalink
#gh10501 extended payment endpoint to support allocation lines (#10502)
Browse files Browse the repository at this point in the history
#10501 extended payment endpoint to support allocation lines
  • Loading branch information
adi-stefan committed Jan 14, 2021
1 parent d975768 commit d3caee1
Show file tree
Hide file tree
Showing 54 changed files with 2,932 additions and 3,374 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* #%L
* de.metas.adempiere.adempiere.base
* %%
* Copyright (C) 2021 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/

package de.metas.invoice;

import de.metas.document.DocBaseAndSubType;
import de.metas.organization.OrgId;
import de.metas.util.lang.ExternalId;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;

import javax.annotation.Nullable;

@Value
public class InvoiceQuery
{
Integer invoiceId;
ExternalId externalId;
OrgId orgId;
String documentNo;
DocBaseAndSubType docType;

@Builder(toBuilder = true)
public InvoiceQuery(@Nullable final Integer invoiceId,
@Nullable final ExternalId externalId,
@NonNull final OrgId orgId,
@Nullable final String documentNo,
@Nullable final DocBaseAndSubType docType)
{
this.invoiceId = invoiceId;
this.externalId = externalId;
this.orgId = orgId;
this.documentNo = documentNo;
this.docType = docType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* #%L
* de.metas.adempiere.adempiere.base
* %%
* Copyright (C) 2021 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/

package de.metas.order;

import de.metas.document.DocBaseAndSubType;
import de.metas.organization.OrgId;
import de.metas.util.lang.ExternalId;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;

import javax.annotation.Nullable;

@Value
public class OrderQuery
{
Integer orderId;
ExternalId externalId;
OrgId orgId;
String documentNo;
DocBaseAndSubType docType;

@Builder(toBuilder = true)
public OrderQuery(@Nullable final Integer orderId, @Nullable final ExternalId externalId, @NonNull final OrgId orgId, @Nullable final String documentNo, @Nullable final DocBaseAndSubType docType)
{
this.orderId = orderId;
this.externalId = externalId;
this.orgId = orgId;
this.documentNo= documentNo;
this.docType = docType;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package de.metas.rest_api.bpartner.impl;

import static de.metas.rest_api.bpartner.SwaggerDocConstants.BPARTNER_IDENTIFIER_DOC;
import static de.metas.rest_api.bpartner.SwaggerDocConstants.CONTACT_IDENTIFIER_DOC;
import static de.metas.rest_api.bpartner.SwaggerDocConstants.LOCATION_IDENTIFIER_DOC;
import static de.metas.rest_api.bpartner.SwaggerDocConstants.NEXT_DOC;
import static de.metas.rest_api.bpartner.SwaggerDocConstants.SINCE_DOC;
import static de.metas.common.rest_api.SwaggerDocConstants.BPARTNER_IDENTIFIER_DOC;
import static de.metas.common.rest_api.SwaggerDocConstants.CONTACT_IDENTIFIER_DOC;
import static de.metas.common.rest_api.SwaggerDocConstants.LOCATION_IDENTIFIER_DOC;
import static de.metas.common.rest_api.SwaggerDocConstants.NEXT_DOC;
import static de.metas.common.rest_api.SwaggerDocConstants.SINCE_DOC;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.metas.rest_api.bpartner.impl;

import static de.metas.rest_api.bpartner.SwaggerDocConstants.CONTACT_IDENTIFIER_DOC;
import static de.metas.rest_api.bpartner.SwaggerDocConstants.NEXT_DOC;
import static de.metas.rest_api.bpartner.SwaggerDocConstants.SINCE_DOC;
import static de.metas.common.rest_api.SwaggerDocConstants.CONTACT_IDENTIFIER_DOC;
import static de.metas.common.rest_api.SwaggerDocConstants.NEXT_DOC;
import static de.metas.common.rest_api.SwaggerDocConstants.SINCE_DOC;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.metas.rest_api.bpartner_pricelist;

import static de.metas.rest_api.bpartner.SwaggerDocConstants.BPARTNER_IDENTIFIER_DOC;
import static de.metas.common.rest_api.SwaggerDocConstants.BPARTNER_IDENTIFIER_DOC;

import java.time.LocalDate;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
package de.metas.rest_api.bpartner_pricelist;

import java.time.ZonedDateTime;
import java.util.Optional;

import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.I_M_ProductPrice;
import org.springframework.stereotype.Service;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;

import de.metas.bpartner.BPartnerId;
import de.metas.bpartner.service.BPartnerQuery;
import de.metas.bpartner.service.IBPartnerDAO;
Expand All @@ -20,6 +12,7 @@
import de.metas.location.CountryId;
import de.metas.location.ICountryDAO;
import de.metas.money.CurrencyId;
import de.metas.organization.OrgId;
import de.metas.pricing.PriceListId;
import de.metas.pricing.PriceListVersionId;
import de.metas.pricing.PricingSystemId;
Expand All @@ -31,6 +24,12 @@
import de.metas.rest_api.utils.IdentifierString.Type;
import de.metas.util.Services;
import lombok.NonNull;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.I_M_ProductPrice;
import org.springframework.stereotype.Service;

import java.time.ZonedDateTime;
import java.util.Optional;

/*
* #%L
Expand Down Expand Up @@ -107,37 +106,41 @@ public ImmutableMap<ProductId, String> getProductValues(ImmutableSet<ProductId>

// TODO move this method to de.metas.bpartner.service.IBPartnerDAO since it has nothing to do with price list
// TODO: IdentifierString must also be moved to the module containing IBPartnerDAO
// TODO it would be nice here if we would also use orgID when searching for the bpartner, since an ExternalId may belong to multiple users from different orgs
public Optional<BPartnerId> getBPartnerId(final IdentifierString bpartnerIdentifier)
public Optional<BPartnerId> getBPartnerId(final IdentifierString bpartnerIdentifier, OrgId orgId)
{
final BPartnerQuery query = createBPartnerQuery(bpartnerIdentifier);
final BPartnerQuery query = createBPartnerQuery(bpartnerIdentifier,orgId);
return bpartnersRepo.retrieveBPartnerIdBy(query);
}

private static BPartnerQuery createBPartnerQuery(@NonNull final IdentifierString bpartnerIdentifier)
private static BPartnerQuery createBPartnerQuery(@NonNull final IdentifierString bpartnerIdentifier, final OrgId orgId)
{
final Type type = bpartnerIdentifier.getType();
final BPartnerQuery.BPartnerQueryBuilder builder = BPartnerQuery.builder();
if (orgId != null)
{
builder.onlyOrgId(orgId);
}
if (Type.METASFRESH_ID.equals(type))
{
return BPartnerQuery.builder()
return builder
.bPartnerId(bpartnerIdentifier.asMetasfreshId(BPartnerId::ofRepoId))
.build();
}
else if (Type.EXTERNAL_ID.equals(type))
{
return BPartnerQuery.builder()
return builder
.externalId(bpartnerIdentifier.asExternalId())
.build();
}
else if (Type.VALUE.equals(type))
{
return BPartnerQuery.builder()
return builder
.bpartnerValue(bpartnerIdentifier.asValue())
.build();
}
else if (Type.GLN.equals(type))
{
return BPartnerQuery.builder()
return builder
.gln(bpartnerIdentifier.asGLN())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private JsonResponsePriceList execute0()
{
countryId = servicesFacade.getCountryIdByCountryCode(countryCode);

bpartnerId = servicesFacade.getBPartnerId(bpartnerIdentifier).orElse(null);
bpartnerId = servicesFacade.getBPartnerId(bpartnerIdentifier, null).orElse(null);
if (bpartnerId == null)
{
throw new AdempiereException("No BPartner found for " + bpartnerIdentifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,4 @@ private JsonInvoiceCandidatesResponseItem buildJSONItem(@NonNull final I_C_Invoi
.metasfreshId(MetasfreshId.of(invoiceCandidate.getC_Invoice_Candidate_ID()))
.build();
}

}

0 comments on commit d3caee1

Please sign in to comment.