Skip to content

Commit

Permalink
#5800 Support PaymentRule = DirectDebit in OLCand EndPoint (#5959)
Browse files Browse the repository at this point in the history
#5800 Support PaymentRule = DirectDebit in OLCand EndPoint
  • Loading branch information
metas-ts committed Dec 20, 2019
2 parents c4fea40 + e7240e1 commit 156a2db
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 2 deletions.
Expand Up @@ -352,6 +352,11 @@ public PaymentRule getPaymentRule(final JsonOLCandCreateRequest request)
return PaymentRule.OnCredit;
}

if (JSONPaymentRule.DirectDebit.equals(jsonPaymentRule))
{
return PaymentRule.DirectDebit;
}

throw MissingResourceException.builder()
.resourceName("paymentRule")
.resourceIdentifier(jsonPaymentRule.getCode())
Expand Down
Expand Up @@ -488,6 +488,84 @@ public void test_CreateProductPrice_WarehouseDestId()
assertThat(olCand.getWarehouseDestId()).isEqualTo(testWarehouseDestId.getRepoId());
}


@Test
public void test_CreateProductPrice_WarehouseDestId_DirectDebit()
{
//
// Masterdata: pricing
final TaxCategoryId taxCategoryId = testMasterdata.createTaxCategory();
final PricingSystemId pricingSystemId = testMasterdata.createPricingSystem();
final PriceListId priceListId = testMasterdata.createSalesPriceList(pricingSystemId, countryId_DE, currencyId_EUR, taxCategoryId);
testMasterdata.createPriceListVersion(priceListId, LocalDate.of(2019, Month.SEPTEMBER, 1));
testMasterdata.createPricingRules();

//
// Masterdata: BPartner & Location
testMasterdata.prepareBPartnerAndLocation()
.bpValue("bpCode")
.salesPricingSystemId(pricingSystemId)
.countryId(countryId_DE)
.gln(GLN.ofString("gln1"))
.build();

//
// Masterdata: Warehouse
final WarehouseId testWarehouseDestId = testMasterdata.createWarehouse("testWarehouseDest");

startInterceptors();

final JsonOLCandCreateBulkRequest request = JsonOLCandCreateBulkRequest.of(JsonOLCandCreateRequest.builder()
.dataSource("int-" + DATA_SOURCE_INTERNALNAME)
.dataDest("int-" + DATA_DEST_INVOICECANDIDATE)
.dateOrdered(LocalDate.of(2019, Month.SEPTEMBER, 10))
.dateRequired(LocalDate.of(2019, Month.SEPTEMBER, 15))
.qty(new BigDecimal("66"))
.externalHeaderId("externalHeaderId")
.externalLineId("externalLineId")
.poReference("poRef")
.product(JsonProductInfo.builder()
.code("productCode")
.name("productName")
.type(Type.ITEM)
.uomCode(UOM_CODE)
.priceStd(new BigDecimal("13.24"))
.syncAdvise(SyncAdvise.JUST_CREATE_IF_NOT_EXISTS)
.build())
.bpartner(JsonRequestBPartnerLocationAndContact.builder()
.bpartner(JsonRequestBPartner.builder()
.code("bpCode")
.build())
.location(JsonRequestLocation.builder()
.gln("gln1")
.build())
.build())
.shipper("val-DPD")
.salesPartnerCode("SalesRep")
.paymentRule(JSONPaymentRule.DirectDebit)
.orderDocType(OrderDocType.PrepayOrder)
.shipper("val-DPD")
.warehouseDestCode("testWarehouseDest")
.invoiceDocType(JsonDocTypeInfo.builder()
.docBaseType("ARI")
.docSubType("KV")
.build())
.build());

final JsonOLCandCreateBulkResponse response = orderCandidatesRestControllerImpl
.createOrderLineCandidates(request)
.getBody();

final List<JsonOLCand> olCands = response.getResult();
assertThat(olCands).hasSize(1);

final JsonOLCand olCand = olCands.get(0);
System.out.println(olCand);

assertThat(olCand.getPrice()).isEqualByComparingTo(new BigDecimal("13.24"));
assertThat(olCand.getWarehouseDestId()).isEqualTo(testWarehouseDestId.getRepoId());
}

@Test
public void test_sameBPartner_DifferentLocations()
{
Expand Down Expand Up @@ -682,6 +760,115 @@ public void test_no_location_specified()
.contains(tuple(dropShipBpartnerAndLocation.getBpartnerId().getRepoId(), expectedDropShipLocation.getRepoId()));
}


@Test
public void test_no_location_specified_DirectDebit()
{
//
// Masterdata: pricing
final TaxCategoryId taxCategoryId = testMasterdata.createTaxCategory();
final PricingSystemId pricingSystemId = testMasterdata.createPricingSystem();
final PriceListId priceListId = testMasterdata.createSalesPriceList(pricingSystemId, countryId_DE, currencyId_EUR, taxCategoryId);
testMasterdata.createPriceListVersion(priceListId, LocalDate.of(2019, Month.SEPTEMBER, 1));
testMasterdata.createPricingRules();

//
// Masterdata: BPartner & Location
final BPartnerLocationId bpartnerAndLocation = testMasterdata.prepareBPartnerAndLocation()
.bpValue("mainPartner")
.salesPricingSystemId(pricingSystemId)
.countryId(countryId_DE)
.build();

final BPartnerLocationId billBpartnerAndLocation = testMasterdata.prepareBPartnerAndLocation()
.bpValue("billPartner")
.salesPricingSystemId(pricingSystemId)
.countryId(countryId_DE)
.build();

final BPartnerLocationId dropShipBpartnerAndLocation = testMasterdata.prepareBPartnerAndLocation()
.bpValue("droptShipPartner")
.salesPricingSystemId(pricingSystemId)
.gln(GLN.ofString("redHerring!"))
.countryId(countryId_DE)
.build();
final BPartnerLocationId expectedDropShipLocation = testMasterdata.prepareBPartnerLocation().bpartnerId(dropShipBpartnerAndLocation.getBpartnerId())
.countryId(countryId_DE)
.gln(GLN.ofString("expectedDropShipLocation"))
.build();

startInterceptors();

final JsonOLCandCreateBulkRequest request = JsonOLCandCreateBulkRequest.of(JsonOLCandCreateRequest.builder()
.dataSource("int-" + DATA_SOURCE_INTERNALNAME)
.dataDest("int-" +DATA_DEST_INVOICECANDIDATE)
.dateOrdered(LocalDate.of(2019, Month.SEPTEMBER, 10))
.dateRequired(LocalDate.of(2019, Month.SEPTEMBER, 15))
.qty(new BigDecimal("66"))
.externalHeaderId("externalHeaderId")
.externalLineId("externalLineId")
.poReference("poRef")
.shipper("val-DPD")
.salesPartnerCode("SalesRep")
.paymentRule(JSONPaymentRule.DirectDebit)
.orderDocType(OrderDocType.PrepayOrder)
.shipper("val-DPD")


.product(JsonProductInfo.builder()
.code("productCode")
.name("productName")
.type(Type.ITEM)
.uomCode(UOM_CODE)
.priceStd(new BigDecimal("13.24"))
.syncAdvise(SyncAdvise.JUST_CREATE_IF_NOT_EXISTS)
.build())
.bpartner(JsonRequestBPartnerLocationAndContact.builder()
.bpartner(JsonRequestBPartner.builder()
.code("mainPartner")
.build()) // no location specified!
.build())
.billBPartner(JsonRequestBPartnerLocationAndContact.builder()
.bpartner(JsonRequestBPartner.builder()
.code("billPartner")
.build()) // again, no location specified!
.build())
.dropShipBPartner(JsonRequestBPartnerLocationAndContact.builder()
.bpartner(JsonRequestBPartner.builder()
.code("droptShipPartner")
.build())
.location(JsonRequestLocation.builder()
.gln("expectedDropShipLocation")
.build())
.build())

.build());

final JsonOLCandCreateBulkResponse response = orderCandidatesRestControllerImpl
.createOrderLineCandidates(request)
.getBody();

final List<JsonOLCand> olCands = response.getResult();
assertThat(olCands).hasSize(1);
final JsonOLCand olCand = olCands.get(0);

// assert That the OLCand record has the C_BPartner_Location_ID that was not specified in JSON, but looked up
final List<I_C_OLCand> olCandRecords = POJOLookupMap.get().getRecords(I_C_OLCand.class);
assertThat(olCandRecords).hasSize(1)
.extracting(COLUMNNAME_C_OLCand_ID)
.contains(olCand.getId());

assertThat(olCandRecords).extracting(COLUMNNAME_C_BPartner_ID, COLUMNNAME_C_BPartner_Location_ID)
.contains(tuple(bpartnerAndLocation.getBpartnerId().getRepoId(), bpartnerAndLocation.getRepoId()));

assertThat(olCandRecords).extracting(COLUMNNAME_Bill_BPartner_ID, COLUMNNAME_Bill_Location_ID)
.contains(tuple(billBpartnerAndLocation.getBpartnerId().getRepoId(), billBpartnerAndLocation.getRepoId()));

assertThat(olCandRecords).extracting(COLUMNNAME_DropShip_BPartner_ID, COLUMNNAME_DropShip_Location_ID)
.contains(tuple(dropShipBpartnerAndLocation.getBpartnerId().getRepoId(), expectedDropShipLocation.getRepoId()));
}


private static class DummyOLCandWithUOMForTUsCapacityProvider implements IOLCandWithUOMForTUsCapacityProvider
{
@Override
Expand Down
Expand Up @@ -32,7 +32,10 @@ public enum JSONPaymentRule
Paypal("L"),

@ApiEnum("Specifies that the order will have paymentRule = On Credit")
OnCredit("P");
OnCredit("P"),

@ApiEnum("Specifies that the order will have paymentRule = Direct Debit")
DirectDebit("D");

@Getter
private final String code;
Expand All @@ -42,5 +45,4 @@ public enum JSONPaymentRule
this.code = code;
}


}

0 comments on commit 156a2db

Please sign in to comment.