removing unused fields in journal entry

This commit is contained in:
goutham-M
2013-05-24 15:00:39 +05:30
parent 6c5b751f10
commit f86ffd81ab
4 changed files with 15 additions and 46 deletions
+2 -11
View File
@@ -13752,18 +13752,11 @@ No Request Body:
<td class=fielddesc>An additional field that is used to store additional information about the entry (Ex: chequeNo) <td class=fielddesc>An additional field that is used to store additional information about the entry (Ex: chequeNo)
</td> </td>
</tr> </tr>
<tr class=alt>
<td>useAccountingRule</td>
</tr>
<tr>
<td class=fielddesc>This flag denotes the journal entry should post on basis of Predefined accounting rule or general Journal Entry procudure. <br>If the flag is true the journal entry is posted on basis of predefined accounting rule.
</td>
</tr>
<tr class=alt> <tr class=alt>
<td>accountingRule</td> <td>accountingRule</td>
</tr> </tr>
<tr> <tr>
<td class=fielddesc>Denotes the accounting rule id for posting journal entries, this parameter should pass in request body when <b>useAccountingRule</b> is true. <td class=fielddesc>Denotes the accounting rule id for posting journal entries.
</td> </td>
</tr> </tr>
</table> </table>
@@ -13966,7 +13959,7 @@ GET https://DomainName/api/v1/journalentries?transactionId=PB37X8Y21EQUY4S
<td><div class="mifosXHeading2">Mandatory Fields</div></td> <td><div class="mifosXHeading2">Mandatory Fields</div></td>
</tr> </tr>
<tr class=alt> <tr class=alt>
<td>officeId, transactionDate, useAccountingRule <td>officeId, transactionDate
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -14020,7 +14013,6 @@ Request Body:
"officeId": 1, "officeId": 1,
"transactionDate": "06 December 2012", "transactionDate": "06 December 2012",
"comments": "Gifts for staff", "comments": "Gifts for staff",
"useAccountingRule": "false",
"locale": "en" , "locale": "en" ,
"dateFormat": "dd MMMM yyyy", "dateFormat": "dd MMMM yyyy",
"credits":[{"glAccountId":1, "credits":[{"glAccountId":1,
@@ -14055,7 +14047,6 @@ Request Body:
"transactionDate": "23 May 2013", "transactionDate": "23 May 2013",
"referenceNumber": "547", "referenceNumber": "547",
"comments": "asdf", "comments": "asdf",
"useAccountingRule": "true",
"accountingRule": "2", "accountingRule": "2",
"amount": "547" "amount": "547"
} }
@@ -23,7 +23,6 @@ public class JournalEntryCommand {
private final LocalDate transactionDate; private final LocalDate transactionDate;
private final String comments; private final String comments;
private final String referenceNumber; private final String referenceNumber;
private final Boolean useAccountingRule;
private final Long accountingRuleId; private final Long accountingRuleId;
private final BigDecimal amount; private final BigDecimal amount;
@@ -32,28 +31,17 @@ public class JournalEntryCommand {
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, final Boolean useAccountingRule, final Long accountingRuleId, final BigDecimal amount) { final String referenceNumber, final Long accountingRuleId, final BigDecimal amount) {
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; this.referenceNumber = referenceNumber;
this.useAccountingRule = useAccountingRule;
this.accountingRuleId = accountingRuleId; this.accountingRuleId = accountingRuleId;
this.amount = amount; this.amount = amount;
} }
public JournalEntryCommand(final Long officeId, final LocalDate transactionDate, final String comments, final String referenceNumber,
final Boolean useAccountingRule, final Long accountingRuleId, final BigDecimal amount) {
this(officeId, transactionDate, comments, null, null, referenceNumber, useAccountingRule, accountingRuleId, amount);
}
public JournalEntryCommand(Long officeId, LocalDate transactionDate, String comments, SingleDebitOrCreditEntryCommand[] credits,
SingleDebitOrCreditEntryCommand[] debits, String referenceNumber, Boolean useAccountingRule) {
this(officeId, transactionDate, comments, credits, debits, referenceNumber, useAccountingRule, null,null);
}
public void validateForCreate() { public void validateForCreate() {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
@@ -66,11 +54,11 @@ public class JournalEntryCommand {
baseDataValidator.reset().parameter("comments").value(this.comments).ignoreIfNull().notExceedingLengthOf(500); baseDataValidator.reset().parameter("comments").value(this.comments).ignoreIfNull().notExceedingLengthOf(500);
baseDataValidator.reset().parameter("useAccountingRule").value(this.useAccountingRule).notNull();
baseDataValidator.reset().parameter("referenceNumber").value(this.referenceNumber).ignoreIfNull().notExceedingLengthOf(100); baseDataValidator.reset().parameter("referenceNumber").value(this.referenceNumber).ignoreIfNull().notExceedingLengthOf(100);
if (!this.useAccountingRule) { baseDataValidator.reset().parameter("accountingRule").value(this.accountingRuleId).ignoreIfNull().longGreaterThanZero();
if (this.accountingRuleId == null) {
baseDataValidator.reset().parameter("credits").value(this.credits).notNull(); baseDataValidator.reset().parameter("credits").value(this.credits).notNull();
@@ -102,7 +90,6 @@ public class JournalEntryCommand {
} }
} }
} else { } else {
baseDataValidator.reset().parameter("accountingRule").value(this.accountingRuleId).notNull().longGreaterThanZero();
baseDataValidator.reset().parameter("amount").value(this.amount).notNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("amount").value(this.amount).notNull().zeroOrPositiveAmount();
} }
@@ -147,8 +134,8 @@ public class JournalEntryCommand {
return this.referenceNumber; return this.referenceNumber;
} }
public Boolean getUseAccountingRule() { public Long getAccountingRuleId() {
return this.useAccountingRule; return this.accountingRuleId;
} }
} }
@@ -59,21 +59,12 @@ public final class JournalEntryCommandFromApiJsonDeserializer extends AbstractFr
JournalEntryJsonInputParams.TRANSACTION_DATE.getValue(), element); JournalEntryJsonInputParams.TRANSACTION_DATE.getValue(), element);
final String referenceNumber = this.fromApiJsonHelper.extractStringNamed(JournalEntryJsonInputParams.REFERENCE_NUMBER.getValue(), final String referenceNumber = this.fromApiJsonHelper.extractStringNamed(JournalEntryJsonInputParams.REFERENCE_NUMBER.getValue(),
element); element);
final Boolean isPredefinedRuleEntry = this.fromApiJsonHelper.extractBooleanNamed( final Long accountingRuleId = this.fromApiJsonHelper.extractLongNamed(JournalEntryJsonInputParams.ACCOUNTING_RULE.getValue(),
JournalEntryJsonInputParams.USE_ACCOUNTING_RULE.getValue(), element); element);
final Boolean useAccountingRule = isPredefinedRuleEntry == null ? false : isPredefinedRuleEntry;
final JsonObject topLevelJsonElement = element.getAsJsonObject(); final JsonObject topLevelJsonElement = element.getAsJsonObject();
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement);
if (useAccountingRule) { final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalNamed(JournalEntryJsonInputParams.AMOUNT.getValue(), element, locale);
final Long accountingRuleId = this.fromApiJsonHelper.extractLongNamed(JournalEntryJsonInputParams.ACCOUNTING_RULE.getValue(),
element);
final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalNamed(JournalEntryJsonInputParams.AMOUNT.getValue(), element,
locale);
return new JournalEntryCommand(officeId, transactionDate, comments, referenceNumber, useAccountingRule, accountingRuleId,
amount);
}
SingleDebitOrCreditEntryCommand[] credits = null; SingleDebitOrCreditEntryCommand[] credits = null;
SingleDebitOrCreditEntryCommand[] debits = null; SingleDebitOrCreditEntryCommand[] debits = null;
@@ -87,7 +78,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, referenceNumber, useAccountingRule); return new JournalEntryCommand(officeId, transactionDate, comments, credits, debits, referenceNumber, accountingRuleId, amount);
} }
/** /**
@@ -88,7 +88,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final Office office = this.officeRepository.findOne(officeId); final Office office = this.officeRepository.findOne(officeId);
if (office == null) { throw new OfficeNotFoundException(officeId); } if (office == null) { throw new OfficeNotFoundException(officeId); }
final boolean useAccountingRule = command.booleanPrimitiveValueOfParameterNamed(JournalEntryJsonInputParams.USE_ACCOUNTING_RULE.getValue()); final Long accountRuleId = command.longValueOfParameterNamed(JournalEntryJsonInputParams.ACCOUNTING_RULE.getValue());
validateBusinessRulesForJournalEntries(journalEntryCommand); validateBusinessRulesForJournalEntries(journalEntryCommand);
@@ -98,7 +98,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final String referenceNumber = journalEntryCommand.getReferenceNumber(); final String referenceNumber = journalEntryCommand.getReferenceNumber();
final boolean manualEntry = true; final boolean manualEntry = true;
if (useAccountingRule) { if (accountRuleId != null) {
final Long accountingRuleId = command.longValueOfParameterNamed(JournalEntryJsonInputParams.ACCOUNTING_RULE.getValue()); final Long accountingRuleId = command.longValueOfParameterNamed(JournalEntryJsonInputParams.ACCOUNTING_RULE.getValue());
final BigDecimal amount = command.bigDecimalValueOfParameterNamed(JournalEntryJsonInputParams.AMOUNT.getValue()); final BigDecimal amount = command.bigDecimalValueOfParameterNamed(JournalEntryJsonInputParams.AMOUNT.getValue());
@@ -218,7 +218,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().equals(transactionDate)) { throw new JournalEntryInvalidException( if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().equals(transactionDate)) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(), null, null); } GL_JOURNAL_ENTRY_INVALID_REASON.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(), null, null); }
} }
if(!command.getUseAccountingRule()) { if(command.getAccountingRuleId() == null) {
/*** check if credits and debits are valid **/ /*** check if credits and debits are valid **/
final SingleDebitOrCreditEntryCommand[] credits = command.getCredits(); final SingleDebitOrCreditEntryCommand[] credits = command.getCredits();
final SingleDebitOrCreditEntryCommand[] debits = command.getDebits(); final SingleDebitOrCreditEntryCommand[] debits = command.getDebits();