Skip to content

Commit

Permalink
FINERACT-2095: Support for string type primary keys - part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Marta Jankovics committed Jun 13, 2024
1 parent 111e28e commit f53577a
Show file tree
Hide file tree
Showing 356 changed files with 1,980 additions and 1,898 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ buildscript {

dependencies {
classpath 'com.bmuschko:gradle-cargo-plugin:2.9.0'
classpath 'org.eclipse.persistence:eclipselink:4.0.0'
classpath 'org.eclipse.persistence:eclipselink:4.0.2'
classpath 'jakarta.ws.rs:jakarta.ws.rs-api:3.1.0'
classpath 'com.google.cloud.tools:jib-layer-filter-extension-gradle:0.3.0'
classpath 'org.apache.commons:commons-lang3:3.14.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencyManagement {
dependency 'org.codehaus.janino:janino:3.1.11'


dependency 'org.eclipse.persistence:org.eclipse.persistence.jpa:4.0.0'
dependency 'org.eclipse.persistence:org.eclipse.persistence.jpa:4.0.2'
dependency 'com.google.guava:guava:32.0.0-jre'
dependency 'com.google.code.gson:gson:2.10.1'
dependency 'com.google.truth:truth:1.4.0'
Expand Down Expand Up @@ -239,5 +239,7 @@ dependencyManagement {
dependency 'org.apache.commons:commons-math3:3.6.1'

dependency 'org.mockito:mockito-inline:5.2.0'

dependency 'com.aventrix.jnanoid:jnanoid:2.0.0'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/
package com.acme.fineract.portfolio.note.service;

import java.util.Collection;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.portfolio.note.data.NoteData;
import org.apache.fineract.portfolio.note.domain.NoteType;
import org.apache.fineract.portfolio.note.service.NoteReadPlatformService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -37,12 +38,12 @@ public void afterPropertiesSet() throws Exception {
}

@Override
public NoteData retrieveNote(Long noteId, Long resourceId, Integer noteTypeId) {
public NoteData retrieveNote(Long noteId, String resourceId, NoteType noteType) {
return null;
}

@Override
public Collection<NoteData> retrieveNotesByResource(Long resourceId, Integer noteTypeId) {
public List<NoteData> retrieveNotesByResource(String resourceId, NoteType noteType) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
*/
package com.acme.fineract.portfolio.note.service;

import java.io.Serializable;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.note.domain.NoteType;
import org.apache.fineract.portfolio.note.service.NoteWritePlatformService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand Down Expand Up @@ -53,7 +54,7 @@ public CommandProcessingResult deleteNote(JsonCommand command) {
}

@Override
public void createAndPersistClientNote(Client client, JsonCommand command) {

public Long createEntityNote(NoteType type, Serializable resourceId, JsonCommand command) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Getter
public class FinancialActivityAccount extends AbstractPersistableCustom {
public class FinancialActivityAccount extends AbstractPersistableCustom<Long> {

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "gl_account_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class TrialBalance extends AbstractPersistableCustom {
public class TrialBalance extends AbstractPersistableCustom<Long> {

@Column(name = "office_id", nullable = false)
private Long officeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@Entity
@Getter
@Table(name = "acc_gl_journal_entry")
public class JournalEntry extends AbstractAuditableWithUTCDateTimeCustom {
public class JournalEntry extends AbstractAuditableWithUTCDateTimeCustom<Long> {

@ManyToOne
@JoinColumn(name = "office_id", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,4 @@ Page<JournalEntryData> retrieveAll(SearchParameters searchParameters, Long glAcc
JournalEntryAssociationParametersData associationParametersData);

OfficeOpeningBalancesData retrieveOfficeOpeningBalances(Long officeId, String currencyCode);

Page<JournalEntryData> retrieveJournalEntriesByEntityId(String transactionId, Long entityId, Integer entityType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@Entity
@Table(name = "acc_product_mapping", uniqueConstraints = { @UniqueConstraint(columnNames = { "product_id", "product_type",
"financial_account_type", "payment_type" }, name = "financial_action") })
public class ProductToGLAccountMapping extends AbstractPersistableCustom {
public class ProductToGLAccountMapping extends AbstractPersistableCustom<Long> {

@ManyToOne(optional = true)
@JoinColumn(name = "gl_account_id")
Expand All @@ -49,6 +49,9 @@ public class ProductToGLAccountMapping extends AbstractPersistableCustom {
@Column(name = "product_id", nullable = true)
private Long productId;

@Column(name = "product_identifier", nullable = true)
private String productIdentifier;

@ManyToOne
@JoinColumn(name = "payment_type", nullable = true)
private PaymentType paymentType;
Expand All @@ -69,5 +72,4 @@ public static ProductToGLAccountMapping createNew(final GLAccount glAccount, fin
return new ProductToGLAccountMapping().setGlAccount(glAccount).setProductId(productId).setProductType(productType)
.setFinancialAccountType(financialAccountType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,20 @@ List<ProductToGLAccountMapping> findAllPenaltyToIncomeAccountMappings(@Param("pr
@Param("productType") int productType);

List<ProductToGLAccountMapping> findByProductIdAndProductType(Long productId, int productType);

List<ProductToGLAccountMapping> findByProductIdentifierAndProductType(String productIdentifier, int productType);

@Query("select mapping from ProductToGLAccountMapping mapping where mapping.productIdentifier =:productIdentifier and mapping.productType =:productType and mapping.financialAccountType=:financialAccountType and mapping.paymentType is NULL and mapping.charge is NULL")
ProductToGLAccountMapping findCoreProductToFinAccountMapping(@Param("productIdentifier") String productIdentifier,
@Param("productType") int productType, @Param("financialAccountType") int financialAccountType);

/***
* The financial Account Type for a fund source will always be an asset (1)
***/
@Query("select mapping from ProductToGLAccountMapping mapping where mapping.productIdentifier =:productIdentifier and mapping.productType =:productType and mapping.financialAccountType=1 and mapping.paymentType is not NULL")
List<ProductToGLAccountMapping> findAllPaymentTypeToFundSourceMappings(@Param("productIdentifier") String productIdentifier,
@Param("productType") int productType);

ProductToGLAccountMapping findByProductIdentifierAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(String productIdentifier,
int productType, int financialAccountType, Long paymentType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public ProductToGLAccountMappingNotFoundException(final PortfolioProductType typ
super("error.msg.productToAccountMapping.not.found", "Mapping for product of type " + type.toString() + " with Id " + productId
+ " does not exist for an account of type " + accountType, type.toString(), productId, accountType);
}

public ProductToGLAccountMappingNotFoundException(final PortfolioProductType type, final String productId, final String accountType) {
super("error.msg.productToAccountMapping.not.found", "Mapping for product of type " + type + " with Identifier " + productId
+ " does not exist for an account of type " + accountType, type, productId, accountType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.LoanProductAccountingParams;
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository;
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper;
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGLAccountMapping;
Expand All @@ -52,13 +51,10 @@
@RequiredArgsConstructor
public class ProductToGLAccountMappingHelper {

protected static final List<GLAccountType> ASSET_LIABILITY_TYPES = List.of(GLAccountType.ASSET, GLAccountType.LIABILITY);

protected final GLAccountRepository accountRepository;
protected final ProductToGLAccountMappingRepository accountMappingRepository;
protected final FromJsonHelper fromApiJsonHelper;
private final ProductToGLAccountMappingRepository accountMappingRepository;
private final FromJsonHelper fromApiJsonHelper;
private final ChargeRepositoryWrapper chargeRepositoryWrapper;
protected final GLAccountRepositoryWrapper accountRepositoryWrapper;
private final GLAccountRepositoryWrapper accountRepositoryWrapper;
private final PaymentTypeRepositoryWrapper paymentTypeRepositoryWrapper;

public void saveProductToAccountMapping(final JsonElement element, final String paramName, final Long productId,
Expand Down
Loading

0 comments on commit f53577a

Please sign in to comment.