Skip to content

Commit

Permalink
Merge pull request #104 from nimble-platform/staging
Browse files Browse the repository at this point in the history
Pull Request for Release 17.0.16
  • Loading branch information
dogukan10 authored Feb 4, 2021
2 parents 1e4364a + 7024d0c commit 243f52f
Show file tree
Hide file tree
Showing 25 changed files with 201 additions and 274 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
<artifactId>logstash-logback-encoder</artifactId>
<version>4.7</version>
</dependency>
<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>20.30.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import eu.nimble.service.bp.model.billOfMaterial.BillOfMaterialItem;
import eu.nimble.service.bp.util.UBLUtility;
import eu.nimble.service.bp.util.bp.BusinessProcessUtility;
import eu.nimble.service.bp.util.bp.ClassProcessTypeMap;
import eu.nimble.service.bp.util.persistence.catalogue.CataloguePersistenceUtility;
import eu.nimble.service.bp.util.persistence.catalogue.ContractPersistenceUtility;
import eu.nimble.service.bp.util.persistence.catalogue.DocumentPersistenceUtility;
Expand All @@ -19,13 +18,13 @@
import eu.nimble.service.model.ubl.commonbasiccomponents.AmountType;
import eu.nimble.service.model.ubl.commonbasiccomponents.CodeType;
import eu.nimble.service.model.ubl.commonbasiccomponents.QuantityType;
import eu.nimble.service.model.ubl.commonbasiccomponents.TextType;
import eu.nimble.service.model.ubl.digitalagreement.DigitalAgreementType;
import eu.nimble.service.model.ubl.document.IDocument;
import eu.nimble.service.model.ubl.order.OrderType;
import eu.nimble.service.model.ubl.quotation.QuotationType;
import eu.nimble.service.model.ubl.requestforquotation.RequestForQuotationType;
import eu.nimble.utility.JsonSerializationUtility;
import eu.nimble.utility.bp.ClassProcessTypeMap;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
Expand Down Expand Up @@ -320,9 +319,9 @@ private static LineItemType createLineItem(CatalogueLineType catalogueLine, Quan
location = buyerParty.getPurchaseTerms().getDeliveryTerms().get(0).getDeliveryLocation();
}
else{
TextType countryName = new TextType();
CodeType countryIdentificationCode = new CodeType();
CountryType country = new CountryType();
country.setName(countryName);
country.setIdentificationCode(countryIdentificationCode);

AddressType address = new AddressType();

Expand Down
27 changes: 15 additions & 12 deletions src/main/java/eu/nimble/service/bp/contract/ContractGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import eu.nimble.service.model.ubl.requestforquotation.RequestForQuotationType;
import eu.nimble.utility.HttpResponseUtil;
import eu.nimble.utility.JsonSerializationUtility;
import eu.nimble.utility.country.CountryUtil;
import eu.nimble.utility.persistence.binary.BinaryContentService;
import feign.Response;
import org.apache.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -194,9 +195,10 @@ else if(tradingTermType.getID().contentEquals("$seller_tel")){
tradingTermType.getValue().setValue(Collections.singletonList(text));
}
}
else if(tradingTermType.getID().contentEquals("$buyer_country") && customerParty != null && customerParty.getPostalAddress() != null && customerParty.getPostalAddress().getCountry() != null && customerParty.getPostalAddress().getCountry().getName() != null){
else if(tradingTermType.getID().contentEquals("$buyer_country") && customerParty != null && customerParty.getPostalAddress() != null && customerParty.getPostalAddress().getCountry() != null
&& customerParty.getPostalAddress().getCountry().getIdentificationCode() != null){
CodeType code = new CodeType();
code.setValue(customerParty.getPostalAddress().getCountry().getName().getValue());
code.setValue(CountryUtil.getCountryNameByISOCode(customerParty.getPostalAddress().getCountry().getIdentificationCode().getValue()));
code.setListID(country_list_id);
tradingTermType.getValue().setValueCode(Collections.singletonList(code));
}
Expand Down Expand Up @@ -430,8 +432,8 @@ private List<XWPFDocument> fillPurchaseDetails(OrderType order,OrderResponseSimp
r.setText(text,0);
}
if(text.contains("$country_invoice_id")){
if(order.getBuyerCustomerParty().getParty().getPostalAddress().getCountry().getName() != null){
text = text.replace("$country_invoice_id",order.getBuyerCustomerParty().getParty().getPostalAddress().getCountry().getName().getValue());
if(order.getBuyerCustomerParty().getParty().getPostalAddress().getCountry().getIdentificationCode() != null){
text = text.replace("$country_invoice_id",CountryUtil.getCountryNameByISOCode(order.getBuyerCustomerParty().getParty().getPostalAddress().getCountry().getIdentificationCode().getValue()));
r.setText(text,0);
}
else {
Expand Down Expand Up @@ -460,8 +462,9 @@ private List<XWPFDocument> fillPurchaseDetails(OrderType order,OrderResponseSimp
}
}
if(text.contains("$country_id")){
if(orderLine.getLineItem().getDeliveryTerms().getDeliveryLocation().getAddress().getCountry().getName() != null && orderLine.getLineItem().getDeliveryTerms().getDeliveryLocation().getAddress().getCountry().getName().getValue() != null){
text = text.replace("$country_id",orderLine.getLineItem().getDeliveryTerms().getDeliveryLocation().getAddress().getCountry().getName().getValue());
if(orderLine.getLineItem().getDeliveryTerms().getDeliveryLocation().getAddress().getCountry().getIdentificationCode() != null
&& orderLine.getLineItem().getDeliveryTerms().getDeliveryLocation().getAddress().getCountry().getIdentificationCode().getValue() != null){
text = text.replace("$country_id",CountryUtil.getCountryNameByISOCode(orderLine.getLineItem().getDeliveryTerms().getDeliveryLocation().getAddress().getCountry().getIdentificationCode().getValue()));
r.setText(text,0);
}
else {
Expand Down Expand Up @@ -514,8 +517,8 @@ private List<XWPFDocument> fillPurchaseDetails(OrderType order,OrderResponseSimp
r.setText(text,0);
}
if(text.contains("$country_supplier")){
if(order.getSellerSupplierParty().getParty().getPostalAddress().getCountry().getName() != null){
text = text.replace("$country_supplier",order.getSellerSupplierParty().getParty().getPostalAddress().getCountry().getName().getValue());
if(order.getSellerSupplierParty().getParty().getPostalAddress().getCountry().getIdentificationCode() != null){
text = text.replace("$country_supplier",CountryUtil.getCountryNameByISOCode(order.getSellerSupplierParty().getParty().getPostalAddress().getCountry().getIdentificationCode().getValue()));
r.setText(text,0);
}
else {
Expand Down Expand Up @@ -1375,9 +1378,9 @@ private void fillNegotiationTable(XWPFDocument document, int itemIndex,RequestFo
r.setText(text,0);
}
if(text.contains("$nego_country")){
String country = quotation.getQuotationLine().get(itemIndex).getLineItem().getDeliveryTerms().getDeliveryLocation().getAddress().getCountry().getName().getValue();
if(country == null){
country = "";
String country = "";
if(quotation.getQuotationLine().get(itemIndex).getLineItem().getDeliveryTerms().getDeliveryLocation().getAddress().getCountry().getIdentificationCode() != null){
country = CountryUtil.getCountryNameByISOCode(quotation.getQuotationLine().get(itemIndex).getLineItem().getDeliveryTerms().getDeliveryLocation().getAddress().getCountry().getIdentificationCode().getValue());
}
text = text.replace("$nego_country",country);
r.setText(text,0);
Expand Down Expand Up @@ -1672,7 +1675,7 @@ private String getTradingTerms(List<TradingTermType> tradingTerms){
}

private String constructAddress(String company_name,AddressType address){
String country = address.getCountry().getName().getValue();
String country = CountryUtil.getCountryNameByISOCode(address.getCountry().getIdentificationCode().getValue());
if(country == null){
country = "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import eu.nimble.service.model.ubl.commonaggregatecomponents.*;
import eu.nimble.service.model.ubl.commonbasiccomponents.QuantityType;
import eu.nimble.service.model.ubl.digitalagreement.DigitalAgreementType;
import eu.nimble.utility.persistence.resource.EntityIdAwareRepositoryWrapper;
import eu.nimble.utility.persistence.repository.BinaryContentAwareRepositoryWrapper;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -33,8 +33,7 @@ public DigitalAgreementType createOrUpdateFrameContract(String sellerId, String
sellerId, buyerId,sellerFederationId,buyerFederationId, item, duration, quotationId);

} else {
frameContract = updateFrameContractDuration(
sellerId, frameContract, duration, quotationId);
frameContract = updateFrameContractDuration(frameContract, duration, quotationId);
}
return frameContract;
}
Expand Down Expand Up @@ -66,22 +65,22 @@ public DigitalAgreementType createDigitalAgreement(String sellerId, String buyer
frameContract.getParticipantParty().add(sellerParty);
frameContract.getParticipantParty().add(buyerParty);

EntityIdAwareRepositoryWrapper repository = new EntityIdAwareRepositoryWrapper(sellerId);
BinaryContentAwareRepositoryWrapper repository = new BinaryContentAwareRepositoryWrapper();
frameContract = repository.updateEntityForPersistCases(frameContract);
return frameContract;
}

/**
* Updates the duration of the frame contract duration
*/
public DigitalAgreementType updateFrameContractDuration(String sellerId, DigitalAgreementType frameContract, QuantityType duration, String quotationId) {
public DigitalAgreementType updateFrameContractDuration(DigitalAgreementType frameContract, QuantityType duration, String quotationId) {
XMLGregorianCalendar[] gregorianDates = getStartAndEndDatesInGregorianFormat(duration);
frameContract.getDigitalAgreementTerms().getValidityPeriod().setStartDate(gregorianDates[0]);
frameContract.getDigitalAgreementTerms().getValidityPeriod().setEndDate(gregorianDates[1]);

frameContract.getQuotationReference().setID(quotationId);

EntityIdAwareRepositoryWrapper repository = new EntityIdAwareRepositoryWrapper(sellerId);
BinaryContentAwareRepositoryWrapper repository = new BinaryContentAwareRepositoryWrapper();
frameContract = repository.updateEntity(frameContract);
return frameContract;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum NimbleExceptionMessageCode {
BAD_REQUEST_NO_PARTY("BAD_REQUEST.noParty"),
BAD_REQUEST_NO_PROCESS_DOCUMENT_METADATA("BAD_REQUEST.noProcessDocumentMetadata"),
BAD_REQUEST_NO_PRODUCT("BAD_REQUEST.noProduct"),
BAD_REQUEST_NO_STRIPE_ACCOUNT("BAD_REQUEST.noStripeAccount"),
BAD_REQUEST_NO_QUALIFYING_PARTY("BAD_REQUEST.noQualifyingParty"),
BAD_REQUEST_NO_VALID_REFERENCE("BAD_REQUEST.noValidReference"),
BAD_REQUEST_PARTY_NOT_INCLUDED_IN_PROCESS("BAD_REQUEST.partyNotIncludedInProcess"),
Expand All @@ -36,6 +37,7 @@ public enum NimbleExceptionMessageCode {
INTERNAL_SERVER_ERROR_CONTINUE_PROCESS("INTERNAL_SERVER_ERROR.continueProcess"),
INTERNAL_SERVER_ERROR_CREATE_NEGOTIATIONS_FOR_BOM("INTERNAL_SERVER_ERROR.createNegotiationsForBOM"),
INTERNAL_SERVER_ERROR_CREATE_ORDER("INTERNAL_SERVER_ERROR.createOrder"),
INTERNAL_SERVER_ERROR_CREATE_PAYMENT_INTENT("INTERNAL_SERVER_ERROR.createPaymentIntent"),
INTERNAL_SERVER_ERROR_CREATE_RATING_AND_REVIEW("INTERNAL_SERVER_ERROR.createRatingAndReview"),
INTERNAL_SERVER_ERROR_CREATE_RFQ("INTERNAL_SERVER_ERROR.createRfq"),
INTERNAL_SERVER_ERROR_DELETE_CATALOGUE("INTERNAL_SERVER_ERROR.deleteCatalogue"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import eu.nimble.service.bp.model.hyperjaxb.*;
import eu.nimble.service.bp.util.BusinessProcessEvent;
import eu.nimble.service.bp.util.bp.BusinessProcessUtility;
import eu.nimble.service.bp.util.bp.ClassProcessTypeMap;
import eu.nimble.service.bp.util.camunda.CamundaEngine;
import eu.nimble.service.bp.util.email.IEmailSenderUtil;
import eu.nimble.service.bp.util.persistence.bp.CollaborationGroupDAOUtility;
Expand All @@ -24,6 +23,7 @@
import eu.nimble.utility.ExecutionContext;
import eu.nimble.utility.JsonSerializationUtility;
import eu.nimble.utility.LoggerUtils;
import eu.nimble.utility.bp.ClassProcessTypeMap;
import eu.nimble.utility.exception.NimbleException;
import eu.nimble.service.bp.exception.NimbleExceptionMessageCode;
import eu.nimble.utility.persistence.JPARepositoryFactory;
Expand Down
Loading

0 comments on commit 243f52f

Please sign in to comment.