Skip to content

Commit

Permalink
feat(journal): Filter on Transaction Types
Browse files Browse the repository at this point in the history
- Adding element form for research by filter service
- Update procedures SQL adding origin_id on cash_payment
  • Loading branch information
lomamech authored and jniles committed Apr 19, 2017
1 parent 3f7629e commit f15c5cc
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 14 deletions.
2 changes: 2 additions & 0 deletions client/src/i18n/en/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
"CASHBOX":"Cashbox",
"CASHIER":"Cashier",
"CASH_ACCOUNT":"Cash Account",
"CASH_PAYMENTS": "Cash Payments",
"CAUTION":"Caution",
"CHARGE":"Charge",
"CLIENT":"Client",
Expand Down Expand Up @@ -398,6 +399,7 @@
"TRANS_ID":"Transaction ID",
"TRANSACTION":"Transaction",
"TRANSACTION_DATE":"Transaction Date",
"TRANSACTION_TYPE":"Transaction type",
"TRANSFER_ACCOUNT":"Transfer Account",
"TRANSFER_TYPE":"Transfer Type",
"TRANSACTION_TYPE":"Transaction Type",
Expand Down
2 changes: 2 additions & 0 deletions client/src/i18n/fr/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
"CASHBOX":"Caisse",
"CASHIER":"Caissier",
"CASH_ACCOUNT":"Compte caisse",
"CASH_PAYMENTS": "Paiements",
"CAUTION":"Caution",
"CHARGE":"Charge",
"CLIENT":"Client",
Expand Down Expand Up @@ -397,6 +398,7 @@
"TO_LOCK":"Bloquer",
"TRANS_ID":"ID de la transaction",
"TRANSACTION":"Transaction",
"TRANSACTION_TYPE":"Type de transaction",
"TRANSFER_ACCOUNT":"Compte transfert",
"TRANSFER_TYPE":"Type de Transfert",
"TRANSACTION_TYPE":"Type de transaction",
Expand Down
1 change: 1 addition & 0 deletions client/src/modules/journal/journal.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function JournalService(Api) {
{ field: 'dateTo', displayName: 'FORM.LABELS.DATE', comparitor: '<', ngFilter: 'date' },
{ field: 'amount', displayName: 'FORM.LABELS.AMOUNT' },
{ field: 'project_id', displayName: 'FORM.LABELS.PROJECT' },
{ field: 'origin_id', displayName: 'FORM.LABELS.TRANSACTION_TYPE' },
];

// returns columns from filters
Expand Down
16 changes: 15 additions & 1 deletion client/src/modules/journal/modals/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ol>
</div>

<div class="modal-body modal-tall">
<div class="modal-body modal-tall" style="max-height : 700px; overflow: auto;">

<!-- date parameters -->
<bh-date-interval
Expand Down Expand Up @@ -98,6 +98,20 @@
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>

<div class="form-group" ng-class="{ 'has-error' : ModalForm.$submitted && ModalForm.transaction_type.$invalid }">
<label class="control-label" translate>FORM.LABELS.TRANSACTION_TYPE</label>
<select
class="form-control"
name="transaction_type"
ng-model="ModalCtrl.options.origin_id"
ng-options="transaction_type.id as transaction_type.hrText for transaction_type in ModalCtrl.types">
<option disabled="disabled" value="" translate>FORM.SELECT.TYPE</option>
</select>
<div class="help-block" ng-messages="ModalForm.transaction_type.$error" ng-show="ModalForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<div class="modal-footer">
Expand Down
18 changes: 15 additions & 3 deletions client/src/modules/journal/modals/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ angular.module('bhima.controllers')
.controller('JournalSearchModalController', JournalSearchModalController);

JournalSearchModalController.$inject = [
'$uibModalInstance', 'UserService', 'ProjectService', 'NotifyService', 'options'
'$uibModalInstance', 'UserService', 'ProjectService', 'NotifyService', 'options', 'VoucherService', '$translate'
];

function JournalSearchModalController(Instance, Users, Projects, Notify, options) {
function JournalSearchModalController(Instance, Users, Projects, Notify, options, Vouchers, $translate) {
var vm = this;

vm.options = options || {};
Expand All @@ -26,6 +26,19 @@ function JournalSearchModalController(Instance, Users, Projects, Notify, options
vm.options.account_id = account.id;
};

// format voucher types and bind to the view
Vouchers.transactionType()
.then(function (list) {
// make sure that the items are translated
list.data.forEach(function (item) {
item.hrText = $translate.instant(item.text);
});

// bind to the view
vm.types = list.data;
})
.catch(Notify.handleError);

// deletes a filter from the options/parameters
vm.clear = function clear(key) {
delete vm.options[key];
Expand All @@ -38,7 +51,6 @@ function JournalSearchModalController(Instance, Users, Projects, Notify, options
// returns the filters to the journal to be used to refresh the page
vm.submit = function submit(form) {
if (form.$invalid) { return; }

// return values to the JournalController
return Instance.close(vm.options);
};
Expand Down
1 change: 1 addition & 0 deletions server/controllers/finance/journal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function find(options, source) {
filters.setOrder('ORDER BY p.trans_date DESC');

const query = filters.applyQuery(sql);

const parameters = filters.parameters();
return db.exec(query, parameters);
}
Expand Down
20 changes: 10 additions & 10 deletions server/models/procedures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,11 @@ BEGIN
INSERT INTO posting_journal (
uuid, project_id, fiscal_year_id, period_id, trans_id, trans_date,
record_uuid, description, account_id, debit, credit, debit_equiv,
credit_equiv, currency_id, entity_uuid, user_id
credit_equiv, currency_id, entity_uuid, user_id, origin_id
) SELECT
HUID(UUID()), cashProjectId, currentFiscalYearId, currentPeriodId, transactionId, c.date, c.uuid,
c.description, dg.account_id, 0, c.amount, 0, (c.amount * (1 / currentExchangeRate)), c.currency_id,
c.debtor_uuid, c.user_id
c.debtor_uuid, c.user_id, cashPaymentOriginId
FROM cash AS c
JOIN debtor AS d ON c.debtor_uuid = d.uuid
JOIN debtor_group AS dg ON d.group_uuid = dg.uuid
Expand All @@ -636,11 +636,11 @@ BEGIN
INSERT INTO posting_journal (
uuid, project_id, fiscal_year_id, period_id, trans_id, trans_date,
record_uuid, description, account_id, debit, credit, debit_equiv,
credit_equiv, currency_id, entity_uuid, user_id, reference_uuid
credit_equiv, currency_id, entity_uuid, user_id, reference_uuid, origin_id
) SELECT
HUID(UUID()), cashProjectId, currentFiscalYearId, currentPeriodId, transactionId, c.date, c.uuid,
c.description, dg.account_id, 0, ci.amount, 0, (ci.amount * (1 / currentExchangeRate)), c.currency_id,
c.debtor_uuid, c.user_id, ci.invoice_uuid
c.debtor_uuid, c.user_id, ci.invoice_uuid, cashPaymentOriginId
FROM cash AS c
JOIN cash_item AS ci ON c.uuid = ci.cash_uuid
JOIN debtor AS d ON c.debtor_uuid = d.uuid
Expand Down Expand Up @@ -696,10 +696,10 @@ BEGIN
INSERT INTO posting_journal (
uuid, project_id, fiscal_year_id, period_id, trans_id, trans_date,
record_uuid, description, account_id, debit, credit, debit_equiv,
credit_equiv, currency_id, user_id
credit_equiv, currency_id, user_id, origin_id
) SELECT
HUID(UUID()), cashProjectId, currentFiscalYearId, currentPeriodId, transactionId, c.date, c.uuid, c.description,
gain_account_id, 0, remainder, 0, (remainder * (1 / currentExchangeRate)), c.currency_id, c.user_id
gain_account_id, 0, remainder, 0, (remainder * (1 / currentExchangeRate)), c.currency_id, c.user_id, cashPaymentOriginId
FROM cash AS c
JOIN debtor AS d ON c.debtor_uuid = d.uuid
JOIN debtor_group AS dg ON d.group_uuid = dg.uuid
Expand All @@ -723,11 +723,11 @@ BEGIN
INSERT INTO posting_journal (
uuid, project_id, fiscal_year_id, period_id, trans_id, trans_date,
record_uuid, description, account_id, debit, credit, debit_equiv,
credit_equiv, currency_id, entity_uuid, user_id, reference_uuid
credit_equiv, currency_id, entity_uuid, user_id, reference_uuid, origin_id
) SELECT
HUID(UUID()), cashProjectId, currentFiscalYearId, currentPeriodId, transactionId, c.date, c.uuid, c.description,
dg.account_id, 0, remainder, 0, (remainder * (1 / currentExchangeRate)), c.currency_id,
c.debtor_uuid, c.user_id, lastInvoiceUuid
c.debtor_uuid, c.user_id, lastInvoiceUuid, cashPaymentOriginId
FROM cash AS c
JOIN debtor AS d ON c.debtor_uuid = d.uuid
JOIN debtor_group AS dg ON d.group_uuid = dg.uuid
Expand All @@ -737,10 +737,10 @@ BEGIN
INSERT INTO posting_journal (
uuid, project_id, fiscal_year_id, period_id, trans_id, trans_date,
record_uuid, description, account_id, debit, credit, debit_equiv,
credit_equiv, currency_id, user_id
credit_equiv, currency_id, user_id, origin_id
) SELECT
HUID(UUID()), cashProjectId, currentFiscalYearId, currentPeriodId, transactionId, c.date, c.uuid, c.description,
loss_account_id, remainder, 0, (remainder * (1 / currentExchangeRate)), 0, c.currency_id, c.user_id
loss_account_id, remainder, 0, (remainder * (1 / currentExchangeRate)), 0, c.currency_id, c.user_id, cashPaymentOriginId
FROM cash AS c
JOIN debtor AS d ON c.debtor_uuid = d.uuid
JOIN debtor_group AS dg ON d.group_uuid = dg.uuid
Expand Down

0 comments on commit f15c5cc

Please sign in to comment.