Skip to content

Commit 7b55951

Browse files
adamsaghygalovics
authored andcommitted
FINERACT-1681: Filter Journal entry by submitted on date
1 parent 4685e96 commit 7b55951

File tree

4 files changed

+95
-152
lines changed

4 files changed

+95
-152
lines changed

fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/api/JournalEntriesApiResource.java

+19-7
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@
7979
@RequiredArgsConstructor
8080
public class JournalEntriesApiResource {
8181

82-
private static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(
83-
Arrays.asList("id", "officeId", "officeName", "glAccountName", "glAccountId", "glAccountCode", "glAccountType",
84-
"transactionDate", "entryType", "amount", "transactionId", "manualEntry", "entityType", "entityId", "createdByUserId",
85-
"createdDate", "createdByUserName", "comments", "reversed", "referenceNumber", "currency", "transactionDetails"));
82+
private static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "officeId", "officeName", "glAccountName",
83+
"glAccountId", "glAccountCode", "glAccountType", "transactionDate", "entryType", "amount", "transactionId", "manualEntry",
84+
"entityType", "entityId", "createdByUserId", "createdDate", "submittedOnDate", "createdByUserName", "comments", "reversed",
85+
"referenceNumber", "currency", "transactionDetails"));
8686

8787
private final String resourceNameForPermission = "JOURNALENTRY";
8888

@@ -111,6 +111,8 @@ public String retrieveAll(@Context final UriInfo uriInfo,
111111
@QueryParam("manualEntriesOnly") @Parameter(description = "manualEntriesOnly") final Boolean onlyManualEntries,
112112
@QueryParam("fromDate") @Parameter(description = "fromDate") final DateParam fromDateParam,
113113
@QueryParam("toDate") @Parameter(description = "toDate") final DateParam toDateParam,
114+
@QueryParam("submittedOnDateFrom") @Parameter(description = "submittedOnDateFrom") final DateParam submittedOnDateFromParam,
115+
@QueryParam("submittedOnDateTo") @Parameter(description = "submittedOnDateTo") final DateParam submittedOnDateToParam,
114116
@QueryParam("transactionId") @Parameter(description = "transactionId") final String transactionId,
115117
@QueryParam("entityType") @Parameter(description = "entityType") final Integer entityType,
116118
@QueryParam("offset") @Parameter(description = "offset") final Integer offset,
@@ -135,13 +137,23 @@ public String retrieveAll(@Context final UriInfo uriInfo,
135137
toDate = toDateParam.getDate("toDate", dateFormat, locale);
136138
}
137139

140+
LocalDate submittedOnDateFrom = null;
141+
if (submittedOnDateFromParam != null) {
142+
submittedOnDateFrom = submittedOnDateFromParam.getDate("submittedOnDateFrom", dateFormat, locale);
143+
}
144+
LocalDate submittedOnDateTo = null;
145+
if (submittedOnDateToParam != null) {
146+
submittedOnDateTo = submittedOnDateToParam.getDate("submittedOnDateTo", dateFormat, locale);
147+
}
148+
138149
final SearchParameters searchParameters = SearchParameters.forJournalEntries(officeId, offset, limit, orderBy, sortOrder, loanId,
139150
savingsId);
140151
JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData(transactionDetails,
141152
runningBalance);
142153

143154
final Page<JournalEntryData> glJournalEntries = this.journalEntryReadPlatformService.retrieveAll(searchParameters, glAccountId,
144-
onlyManualEntries, fromDate, toDate, transactionId, entityType, associationParametersData);
155+
onlyManualEntries, fromDate, toDate, submittedOnDateFrom, submittedOnDateTo, transactionId, entityType,
156+
associationParametersData);
145157
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
146158
return this.apiJsonSerializerService.serialize(settings, glJournalEntries, RESPONSE_DATA_PARAMETERS);
147159
}
@@ -234,8 +246,8 @@ public String retrieveJournalEntries(@QueryParam("offset") final Integer offset,
234246
this.context.authenticatedUser();
235247
String transactionId = "P" + entryId;
236248
SearchParameters params = SearchParameters.forPagination(offset, limit);
237-
Page<JournalEntryData> entries = this.journalEntryReadPlatformService.retrieveAll(params, null, null, null, null, transactionId,
238-
PortfolioProductType.PROVISIONING.getValue(), null);
249+
Page<JournalEntryData> entries = this.journalEntryReadPlatformService.retrieveAll(params, null, null, null, null, null, null,
250+
transactionId, PortfolioProductType.PROVISIONING.getValue(), null);
239251
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
240252
return this.apiJsonSerializerService.serialize(settings, entries, RESPONSE_DATA_PARAMETERS);
241253
}

fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/data/JournalEntryData.java

+11-95
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.math.BigDecimal;
2222
import java.time.LocalDate;
2323
import java.util.List;
24+
import lombok.Getter;
2425
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
2526
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
2627
import org.apache.fineract.organisation.monetary.data.CurrencyData;
@@ -30,6 +31,7 @@
3031
*
3132
* Note: no getter/setters required as google will produce json from fields of object.
3233
*/
34+
@Getter
3335
public class JournalEntryData {
3436

3537
private final Long id;
@@ -76,6 +78,8 @@ public class JournalEntryData {
7678

7779
@SuppressWarnings("unused")
7880
private final TransactionDetailData transactionDetails;
81+
@SuppressWarnings("unused")
82+
private final LocalDate submittedOnDate;
7983

8084
// import fields
8185
private transient Integer rowIndex;
@@ -132,6 +136,7 @@ public JournalEntryData(Long officeId, LocalDate transactionDate, String currenc
132136
this.organizationRunningBalance = null;
133137
this.runningBalanceComputed = null;
134138
this.transactionDetails = null;
139+
this.submittedOnDate = null;
135140
}
136141

137142
public static JournalEntryData importInstance(Long officeId, LocalDate transactionDate, String currencyCode, Long paymentTypeId,
@@ -179,6 +184,7 @@ private JournalEntryData(Long officeId, LocalDate transactionDate, String curren
179184
this.entityType = null;
180185
this.entityId = null;
181186
this.createdByUserId = null;
187+
this.submittedOnDate = null;
182188
this.createdDate = null;
183189
this.createdByUserName = null;
184190
this.reversed = null;
@@ -209,7 +215,7 @@ public void addCredits(CreditDebit credit) {
209215
public JournalEntryData(final Long id, final Long officeId, final String officeName, final String glAccountName, final Long glAccountId,
210216
final String glAccountCode, final EnumOptionData glAccountClassification, final LocalDate transactionDate,
211217
final EnumOptionData entryType, final BigDecimal amount, final String transactionId, final Boolean manualEntry,
212-
final EnumOptionData entityType, final Long entityId, final Long createdByUserId, final LocalDate createdDate,
218+
final EnumOptionData entityType, final Long entityId, final Long createdByUserId, final LocalDate submittedOnDate,
213219
final String createdByUserName, final String comments, final Boolean reversed, final String referenceNumber,
214220
final BigDecimal officeRunningBalance, final BigDecimal organizationRunningBalance, final Boolean runningBalanceComputed,
215221
final TransactionDetailData transactionDetailData, final CurrencyData currency) {
@@ -228,7 +234,8 @@ public JournalEntryData(final Long id, final Long officeId, final String officeN
228234
this.entityType = entityType;
229235
this.entityId = entityId;
230236
this.createdByUserId = createdByUserId;
231-
this.createdDate = createdDate;
237+
this.createdDate = submittedOnDate;
238+
this.submittedOnDate = submittedOnDate;
232239
this.createdByUserName = createdByUserName;
233240
this.comments = comments;
234241
this.reversed = reversed;
@@ -240,40 +247,6 @@ public JournalEntryData(final Long id, final Long officeId, final String officeN
240247
this.currency = currency;
241248
}
242249

243-
public JournalEntryData(final Long id, final Long officeId, final String glAccountName, final Long glAccountId,
244-
final String glAccountCode, final EnumOptionData glAccountClassification, final LocalDate transactionDate,
245-
final EnumOptionData entryType, final BigDecimal amount, final String transactionId, final Boolean manualEntry,
246-
final EnumOptionData entityType, final Long entityId, final LocalDate createdDate, final String currencyCode,
247-
final Long savingTransactionId) {
248-
this.id = id;
249-
this.officeId = officeId;
250-
this.officeName = null;
251-
this.glAccountName = glAccountName;
252-
this.glAccountId = glAccountId;
253-
this.glAccountCode = glAccountCode;
254-
this.glAccountType = glAccountClassification;
255-
this.transactionDate = transactionDate;
256-
this.entryType = entryType;
257-
this.amount = amount;
258-
this.transactionId = transactionId;
259-
this.savingTransactionId = savingTransactionId;
260-
this.manualEntry = manualEntry;
261-
this.entityType = entityType;
262-
this.entityId = entityId;
263-
this.createdByUserId = null;
264-
this.createdDate = createdDate;
265-
this.createdByUserName = null;
266-
this.comments = null;
267-
this.reversed = false;
268-
this.referenceNumber = null;
269-
this.officeRunningBalance = null;
270-
this.organizationRunningBalance = null;
271-
this.runningBalanceComputed = null;
272-
this.transactionDetails = null;
273-
this.currency = null;
274-
this.currencyCode = currencyCode;
275-
}
276-
277250
public static JournalEntryData fromGLAccountData(final GLAccountData glAccountData) {
278251

279252
final Long id = null;
@@ -291,7 +264,7 @@ public static JournalEntryData fromGLAccountData(final GLAccountData glAccountDa
291264
final EnumOptionData entityType = null;
292265
final Long entityId = null;
293266
final Long createdByUserId = null;
294-
final LocalDate createdDate = null;
267+
final LocalDate submittedOnDate = null;
295268
final String createdByUserName = null;
296269
final String comments = null;
297270
final Boolean reversed = null;
@@ -302,65 +275,8 @@ public static JournalEntryData fromGLAccountData(final GLAccountData glAccountDa
302275
final TransactionDetailData transactionDetailData = null;
303276
final CurrencyData currency = null;
304277
return new JournalEntryData(id, officeId, officeName, glAccountName, glAccountId, glAccountCode, glAccountClassification,
305-
transactionDate, entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, createdDate,
278+
transactionDate, entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, submittedOnDate,
306279
createdByUserName, comments, reversed, referenceNumber, officeRunningBalance, organizationRunningBalance,
307280
runningBalanceComputed, transactionDetailData, currency);
308281
}
309-
310-
public Long getId() {
311-
return this.id;
312-
}
313-
314-
public Long getGlAccountId() {
315-
return this.glAccountId;
316-
}
317-
318-
public EnumOptionData getGlAccountType() {
319-
return this.glAccountType;
320-
}
321-
322-
public BigDecimal getAmount() {
323-
return this.amount;
324-
}
325-
326-
public EnumOptionData getEntryType() {
327-
return this.entryType;
328-
}
329-
330-
public Long getOfficeId() {
331-
return this.officeId;
332-
}
333-
334-
public String getTransactionId() {
335-
return transactionId;
336-
}
337-
338-
public Long getSavingTransactionId() {
339-
return this.savingTransactionId;
340-
}
341-
342-
public String getCurrencyCode() {
343-
return this.currencyCode;
344-
}
345-
346-
public boolean isManualEntry() {
347-
return this.manualEntry;
348-
}
349-
350-
public EnumOptionData getEntityType() {
351-
return this.entityType;
352-
}
353-
354-
public Long getEntityId() {
355-
return this.entityId;
356-
}
357-
358-
public LocalDate getCreatedDate() {
359-
return this.createdDate;
360-
}
361-
362-
public Long getPaymentTypeId() {
363-
return this.paymentTypeId;
364-
}
365-
366282
}

fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformService.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public interface JournalEntryReadPlatformService {
3030
JournalEntryData retrieveGLJournalEntryById(long glJournalEntryId, JournalEntryAssociationParametersData associationParametersData);
3131

3232
Page<JournalEntryData> retrieveAll(SearchParameters searchParameters, Long glAccountId, Boolean onlyManualEntries, LocalDate fromDate,
33-
LocalDate toDate, String transactionId, Integer entityType, JournalEntryAssociationParametersData associationParametersData);
33+
LocalDate toDate, LocalDate submittedOnDateFrom, LocalDate submittedOnDateTo, String transactionId, Integer entityType,
34+
JournalEntryAssociationParametersData associationParametersData);
3435

3536
OfficeOpeningBalancesData retrieveOfficeOpeningBalances(Long officeId, String currencyCode);
3637

0 commit comments

Comments
 (0)