Merge pull request #252 from goutham-M/MIFOSX-307

MIFOSX-307
This commit is contained in:
Vishwas Babu A J
2013-05-03 00:15:31 -07:00
14 changed files with 53 additions and 22 deletions
@@ -0,0 +1,2 @@
alter table `acc_gl_journal_entry`
add column `ref_num` varchar(100) default NULL AFTER `reversed`;
@@ -76,7 +76,7 @@ public class GLClosuresApiResource {
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission);
final List<GLClosureData> glClosureDatas = this.glClosureReadPlatformService.retrieveAllGLClosures(officeId);
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return this.apiJsonSerializerService.serialize(settings, glClosureDatas, RESPONSE_DATA_PARAMETERS);
}
@@ -45,7 +45,8 @@ public class JournalEntriesApiResource {
private static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "officeId", "officeName",
"glAccountName", "glAccountId", "glAccountCode", "glAccountType", "transactionDate", "entryType", "amount", "transactionId",
"manualEntry", "entityType", "entityId", "createdByUserId", "createdDate", "createdByUserName", "comments", "reversed"));
"manualEntry", "entityType", "entityId", "createdByUserId", "createdDate", "createdByUserName", "comments", "reversed",
"referenceNumber"));
private final String resourceNameForPermission = "JOURNALENTRY";
@@ -74,7 +75,7 @@ public class JournalEntriesApiResource {
public String retrieveAllJournalEntries(@Context final UriInfo uriInfo, @QueryParam("officeId") final Long officeId,
@QueryParam("glAccountId") final Long glAccountId, @QueryParam("manualEntriesOnly") final Boolean onlyManualEntries,
@QueryParam("fromDate") final DateParam fromDateParam, @QueryParam("toDate") final DateParam toDateParam,
@QueryParam("transactionId") final String transactionId) {
@QueryParam("transactionId") final String transactionId ) {
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission);
@@ -13,7 +13,7 @@ import java.util.Set;
***/
public enum JournalEntryJsonInputParams {
OFFICE_ID("officeId"), TRANSACTION_DATE("transactionDate"), COMMENTS("comments"), CREDITS("credits"), DEBITS("debits"), LOCALE("locale"), DATE_FORMAT(
"dateFormat");
"dateFormat"), REFERENCE_NUMBER("referenceNumber") ;
private final String value;
@@ -21,17 +21,20 @@ public class JournalEntryCommand {
private final Long officeId;
private final LocalDate transactionDate;
private final String comments;
private final String referenceNumber;
private final SingleDebitOrCreditEntryCommand[] credits;
private final SingleDebitOrCreditEntryCommand[] debits;
public JournalEntryCommand(final Long officeId, final LocalDate transactionDate, final String comments,
final SingleDebitOrCreditEntryCommand[] credits, final SingleDebitOrCreditEntryCommand[] debits) {
final SingleDebitOrCreditEntryCommand[] credits, final SingleDebitOrCreditEntryCommand[] debits,
final String referenceNumber) {
this.officeId = officeId;
this.transactionDate = transactionDate;
this.comments = comments;
this.credits = credits;
this.debits = debits;
this.referenceNumber = referenceNumber;
}
public void validateForCreate() {
@@ -49,6 +52,8 @@ public class JournalEntryCommand {
baseDataValidator.reset().parameter("credits").value(this.credits).notNull();
baseDataValidator.reset().parameter("debits").value(this.debits).notNull();
baseDataValidator.reset().parameter("referenceNumber").value(this.referenceNumber).ignoreIfNull().notExceedingLengthOf(100);
// validation for credit array elements
if (this.credits != null) {
@@ -113,4 +118,8 @@ public class JournalEntryCommand {
return this.debits;
}
public String getReferenceNumber() {
return this.referenceNumber;
}
}
@@ -56,12 +56,14 @@ public class JournalEntryData {
private final String comments;
@SuppressWarnings("unused")
private final Boolean reversed;
@SuppressWarnings("unused")
private final String referenceNumber;
public JournalEntryData(final Long id, final Long officeId, final String officeName, final String glAccountName,
final Long glAccountId, final String glAccountCode, final EnumOptionData glAccountClassification,
final LocalDate transactionDate, final EnumOptionData entryType, final BigDecimal amount, final String transactionId,
final Boolean manualEntry, final EnumOptionData entityType, final Long entityId, final Long createdByUserId,
final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed) {
final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed, final String referenceNumber) {
this.id = id;
this.officeId = officeId;
this.officeName = officeName;
@@ -81,6 +83,7 @@ public class JournalEntryData {
this.createdByUserName = createdByUserName;
this.comments = comments;
this.reversed = reversed;
this.referenceNumber = referenceNumber;
}
}
@@ -73,12 +73,15 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
@SuppressWarnings("unused")
@Column(name = "entity_id")
private Long entityId;
@Column(name = "ref_num")
private String referenceNumber;
public static JournalEntry createNew(final Office office, final GLAccount glAccount, final String transactionId,
final boolean manualEntry, final Date transactionDate, final JournalEntryType journalEntryType, final BigDecimal amount,
final String description, final Integer entityType, final Long entityId) {
final String description, final Integer entityType, final Long entityId, final String referenceNumber) {
return new JournalEntry(office, glAccount, transactionId, manualEntry, transactionDate, journalEntryType.getValue(), amount,
description, entityType, entityId);
description, entityType, entityId, referenceNumber);
}
protected JournalEntry() {
@@ -87,7 +90,7 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
public JournalEntry(final Office office, final GLAccount glAccount, final String transactionId, final boolean manualEntry,
final Date transactionDate, final Integer type, final BigDecimal amount, final String description, final Integer entityType,
final Long entityId) {
final Long entityId, final String referenceNumber) {
this.office = office;
this.glAccount = glAccount;
this.reversalJournalEntry = null;
@@ -100,6 +103,8 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
this.description = StringUtils.defaultIfEmpty(description, null);
this.entityType = entityType;
this.entityId = entityId;
this.referenceNumber = referenceNumber;
}
public boolean isDebitEntry() {
@@ -134,4 +139,8 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
this.reversed = reversed;
}
public String getReferenceNumber() {
return this.referenceNumber;
}
}
@@ -57,6 +57,8 @@ public final class JournalEntryCommandFromApiJsonDeserializer extends AbstractFr
final String comments = this.fromApiJsonHelper.extractStringNamed(JournalEntryJsonInputParams.COMMENTS.getValue(), element);
final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(
JournalEntryJsonInputParams.TRANSACTION_DATE.getValue(), element);
final String referenceNumber = this.fromApiJsonHelper.extractStringNamed(
JournalEntryJsonInputParams.REFERENCE_NUMBER.getValue(), element);
final JsonObject topLevelJsonElement = element.getAsJsonObject();
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement);
@@ -73,7 +75,7 @@ public final class JournalEntryCommandFromApiJsonDeserializer extends AbstractFr
debits = populateCreditsOrDebitsArray(topLevelJsonElement, locale, debits, JournalEntryJsonInputParams.DEBITS.getValue());
}
}
return new JournalEntryCommand(officeId, transactionDate, comments, credits, debits);
return new JournalEntryCommand(officeId, transactionDate, comments, credits, debits,referenceNumber);
}
/**
@@ -236,7 +236,7 @@ public class AccountingProcessorHelper {
final String transactionId, final Date transactionDate, final BigDecimal amount) {
final boolean manualEntry = false;
final JournalEntry journalEntry = JournalEntry.createNew(office, account, transactionId, manualEntry, transactionDate,
JournalEntryType.CREDIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId);
JournalEntryType.CREDIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId, null);
this.glJournalEntryRepository.saveAndFlush(journalEntry);
}
@@ -244,7 +244,7 @@ public class AccountingProcessorHelper {
final String transactionId, final Date transactionDate, final BigDecimal amount) {
final boolean manualEntry = false;
final JournalEntry journalEntry = JournalEntry.createNew(office, account, transactionId, manualEntry, transactionDate,
JournalEntryType.DEBIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId);
JournalEntryType.DEBIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId, null);
this.glJournalEntryRepository.saveAndFlush(journalEntry);
}
@@ -42,7 +42,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
public String schema() {
return " journalEntry.id as journalEntryId, glAccount.classification_enum as classification ,"
+ " glAccount.name as glAccountName, glAccount.gl_code as glCode, journalEntry.account_id as glAccountId,"
+ " journalEntry.office_id as officeId, office.name as officeName, "
+ " journalEntry.office_id as officeId, office.name as officeName, journalEntry.ref_num as referenceNumber, "
+ " journalEntry.manual_entry as manualEntry,journalEntry.entry_date as transactionDate, "
+ " journalEntry.type_enum as entryType,journalEntry.amount as amount, journalEntry.transaction_id as transactionId,"
+ " journalEntry.entity_type_enum as entityType, journalEntry.entity_id as entityId, creatingUser.id as createdByUserId, "
@@ -82,10 +82,11 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
final String createdByUserName = rs.getString("createdByUserName");
final String comments = rs.getString("comments");
final Boolean reversed = rs.getBoolean("reversed");
final String referenceNumber = rs.getString("referenceNumber");
return new JournalEntryData(journalEntryId, officeId, officeName, glAccountName, glAccountId, glCode, accountType,
transactionDate, entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, createdDate,
createdByUserName, comments, reversed);
createdByUserName, comments, reversed, referenceNumber);
}
}
@@ -122,11 +122,11 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
if (journalEntry.isDebitEntry()) {
reversalJournalEntry = JournalEntry.createNew(journalEntry.getOffice(), journalEntry.getGlAccount(), reversalTransactionId,
manualEntry, journalEntry.getTransactionDate(), JournalEntryType.CREDIT, journalEntry.getAmount(), reversalComment,
null, null);
null, null, journalEntry.getReferenceNumber());
} else {
reversalJournalEntry = JournalEntry.createNew(journalEntry.getOffice(), journalEntry.getGlAccount(), reversalTransactionId,
manualEntry, journalEntry.getTransactionDate(), JournalEntryType.DEBIT, journalEntry.getAmount(), reversalComment,
null, null);
null, null, journalEntry.getReferenceNumber());
}
// save the reversal entry
this.glJournalEntryRepository.saveAndFlush(reversalJournalEntry);
@@ -216,8 +216,10 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
if (!StringUtils.isBlank(singleDebitOrCreditEntryCommand.getComments())) {
comments = singleDebitOrCreditEntryCommand.getComments();
}
String referenceNumber = command.getReferenceNumber();
final JournalEntry glJournalEntry = JournalEntry.createNew(office, glAccount, transactionId, manualEntry, transactionDate,
type, singleDebitOrCreditEntryCommand.getAmount(), comments, null, null);
type, singleDebitOrCreditEntryCommand.getAmount(), comments, null, null, referenceNumber);
this.glJournalEntryRepository.saveAndFlush(glJournalEntry);
}
}
@@ -54,12 +54,13 @@ public class CommandWrapper {
this.href = resourceGetUrl;
this.json = null;
this.transactionId = null;
}
public CommandWrapper(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId,
final String actionName, final String entityName, final Long entityId, final Long subentityId, final Long codeId,
final String supportedEntityType, final Long supportedEntityId, final String href, final String json, final String transactionId) {
final String supportedEntityType, final Long supportedEntityId, final String href, final String json, final String transactionId
) {
this.commandId = null;
this.officeId = officeId;
this.groupId = groupId;
@@ -77,6 +78,7 @@ public class CommandWrapper {
this.href = href;
this.json = json;
this.transactionId = transactionId;
}
public Long commandId() {
@@ -126,7 +128,8 @@ public class CommandWrapper {
public String getTransactionId() {
return this.transactionId;
}
public String getEntityName() {
return this.entityName;
}
@@ -28,7 +28,7 @@ public class CommandWrapperBuilder {
public CommandWrapper build() {
return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId, this.actionName,
this.entityName, this.entityId, this.subentityId, this.codeId, this.supportedEntityType, this.supportedEntityId, this.href,
this.json, this.transactionId);
this.json, this.transactionId );
}
public CommandWrapperBuilder withLoanId(final Long withLoanId) {
@@ -45,7 +45,6 @@ public final class JsonCommand {
private final String supportedEntityType;
private final Long supportedEntityId;
private final String transactionId;
public static JsonCommand from(final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper,
final String entityName, final Long resourceId, final Long subresourceId, final Long groupId, final Long clientId,
final Long loanId, final Long savingsId, final Long codeId, final String supportedEntityType, final Long supportedEntityId,