refrenceNumber added to journal entry

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