Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FINERACT-1981: Embeddable Progressive Loan Schedule generator #4212

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/build-embeddable-progressive-loan-jar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Fineract Build Progressive Loan Embeddable Jar & Test with a Sample Application
on: [push, pull_request]

permissions:
contents: read


jobs:
build:
runs-on: ubuntu-24.04

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4
with:
java-version: '17'
distribution: 'zulu'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
- name: Build Embeddable Jar
run: ./gradlew --no-daemon --console=plain :fineract-progressive-loan-embeddable-schedule-generator:shadowJar
- name: Pick up the JAR filename
run: |
EMBEDDABLE_JAR_FILE=(`ls fineract-progressive-loan-embeddable-schedule-generator/build/libs/*-all.jar | head -n 1`)
echo "EMBEDDABLE_JAR_FILE=$EMBEDDABLE_JAR_FILE" >> $GITHUB_ENV
- name: Build Sample Application
run: |
mkdir sample-app
javac -cp $EMBEDDABLE_JAR_FILE -d sample-app fineract-progressive-loan-embeddable-schedule-generator/misc/Main.java
env:
EMBEDDABLE_JAR_FILE: ${{ env.EMBEDDABLE_JAR_FILE }}

- name: Run Schedule Generator Sample Application
run: |
java -cp $EMBEDDABLE_JAR_FILE:sample-app Main
java -cp $EMBEDDABLE_JAR_FILE:sample-app Main 25
env:
EMBEDDABLE_JAR_FILE: ${{ env.EMBEDDABLE_JAR_FILE }}

- name: Archive test results
if: always()
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: test-results
path: |
build/reports/
fineract-progressive-loan-embeddable-schedule-generator/build/reports/
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ buildscript {
'fineract-avro-schemas',
'fineract-e2e-tests-core',
'fineract-e2e-tests-runner',
'fineract-progressive-loan'
'fineract-progressive-loan',
'fineract-progressive-loan-embeddable-schedule-generator'
].contains(it.name)
}
fineractPublishProjects = subprojects.findAll{
Expand All @@ -66,7 +67,8 @@ buildscript {
'fineract-report',
'fineract-branch',
'fineract-document',
'fineract-progressive-loan'
'fineract-progressive-loan',
'fineract-progressive-loan-embeddable-schedule-generator'
].contains(it.name)
}
npmRepository = 'https://npm.pkg.github.com'
Expand Down Expand Up @@ -109,6 +111,7 @@ plugins {
id 'se.thinkcode.cucumber-runner' version '0.0.11' apply false
id "com.github.davidmc24.gradle.plugin.avro-base" version "1.9.1" apply false
id 'org.openapi.generator' version '7.8.0' apply false
id 'com.gradleup.shadow' version '8.3.5' apply false
}

apply from: "${rootDir}/buildSrc/src/main/groovy/org.apache.fineract.release.gradle"
Expand Down Expand Up @@ -169,7 +172,7 @@ allprojects {

groovyGradle {
target '*.gradle', '**/*.gradle'
targetExclude '**/build/**'
targetExclude '**/build/**', '/**/build.gradle' // TODO: temporary disabled on build.gradle until someone fix this issue: https://github.com/diffplug/spotless/issues/1807
greclipse()
indentWithSpaces(4)
endWithNewline()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,12 @@ public static Money zeroToNull(Money value) {

/** @return parameter value or ZERO if it is negative */
public static Money negativeToZero(Money value) {
return value == null || isGreaterThanZero(value) ? value : Money.zero(value.getCurrency());
return value == null || isGreaterThanZero(value) ? value : Money.zero(value.getCurrencyData());
}

/** @return parameter value or ZERO if it is negative */
public static Money negativeToZero(Money value, MathContext mc) {
return value == null || isGreaterThanZero(value, mc) ? value : Money.zero(value.getCurrency(), mc);
return value == null || isGreaterThanZero(value, mc) ? value : Money.zero(value.getCurrencyData(), mc);
}

public static boolean isEmpty(Money value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ public CurrencyData toData() {
return new CurrencyData(this.code, this.name, this.decimalPlaces, this.inMultiplesOf, this.displaySymbol, this.nameCode);
}

public CurrencyData toData(final int digitsAfterDecimalSupported, final Integer inMultiplesOf) {
return new CurrencyData(this.code, this.name, digitsAfterDecimalSupported, inMultiplesOf, this.displaySymbol, this.nameCode);
}

public OrganisationCurrency toOrganisationCurrency() {
return new OrganisationCurrency(this.code, this.name, this.decimalPlaces, this.inMultiplesOf, this.nameCode, this.displaySymbol);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class MonetaryCurrency {
@Column(name = "currency_multiplesof")
private Integer inMultiplesOf;

private transient CurrencyData currencyData;

protected MonetaryCurrency() {
this.code = null;
this.digitsAfterDecimal = 0;
Expand All @@ -46,6 +48,13 @@ public MonetaryCurrency(final String code, final int digitsAfterDecimal, final I
this.inMultiplesOf = inMultiplesOf;
}

public MonetaryCurrency(final CurrencyData currencyData) {
this.currencyData = currencyData;
this.code = currencyData.getCode();
this.digitsAfterDecimal = currencyData.getDecimalPlaces();
this.inMultiplesOf = currencyData.getInMultiplesOf();
}

public MonetaryCurrency copy() {
return new MonetaryCurrency(this.code, this.digitsAfterDecimal, this.inMultiplesOf);
}
Expand All @@ -56,7 +65,14 @@ public static MonetaryCurrency fromApplicationCurrency(ApplicationCurrency appli
}

public static MonetaryCurrency fromCurrencyData(final CurrencyData currencyData) {
return new MonetaryCurrency(currencyData.getCode(), currencyData.getDecimalPlaces(), currencyData.getInMultiplesOf());
return new MonetaryCurrency(currencyData);
}

public CurrencyData toData() {
if (currencyData == null) {
currencyData = new CurrencyData(code, digitsAfterDecimal, inMultiplesOf);
}
return currencyData;
}

public String getCode() {
Expand Down
Loading
Loading