Skip to content

Commit

Permalink
feat(cash): filter out reversed records
Browse files Browse the repository at this point in the history
This commit uses the FilterParser to filter out reversed records on the
cash payments page.  It also gives the option to exclude all records but
those that are reversed.

Closes https://github.com/Vanga-Hospital/bhima-2.X/issues/19.
  • Loading branch information
Jonathan Niles authored and jniles committed Feb 19, 2017
1 parent e8f1290 commit e750947
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 9 deletions.
8 changes: 6 additions & 2 deletions client/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
"CURRENT_CASHBOX" : "Current Cashbox",
"DEBTOR_INVOICES" : "Debtor Invoices",
"PAYMENT" : "Payment",
"REGISTRY" : {
"INCLUDE_ONLY_REVERSED_RECORDS" : "Include only reversed cash payments",
"EXCLUDE_REVERSED_RECORDS" : "Exclude all reversed cash payments",
"REVERSED_RECORDS" : "Reversed Records"
},
"SELECTION": {
"GO_TO_CASHBOX_PAGE" : "Go to Cashbox Page",
"MISSING_CASH" : "Missing Cash",
Expand Down Expand Up @@ -1599,8 +1604,7 @@
"TITLE" : "Simple Voucher",
"TRANSFER" : "Money Transfer",
"TRANSFER_PATIENT_INVOICE_AMOUNT" : "Patient Invoice Debt Transfer"
},
"REPORT": "Report"
}
},
"TRANSACTIONS" : {
"SINGLE_ACCOUNT_TRANSACTION" : "This transaction only concerns a single account. Please select multiple accounts to complete the transaction.",
Expand Down
5 changes: 5 additions & 0 deletions client/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
"DEBTOR_INVOICES": {
"TITLE" : "Facture(s) debiteur"
},
"REGISTRY" : {
"INCLUDE_ONLY_REVERSED_RECORDS" : "Inclure uniquement les paiements inversees",
"EXCLUDE_REVERSED_RECORDS" : "Exclure toutes les paiements inversees",
"REVERSED_RECORDS" : "Paiements Inversees"
},
"PAYMENT" : "Paiement",
"RECEIPT": {
"TITLE" : "Recu",
Expand Down
3 changes: 2 additions & 1 deletion client/src/js/services/CashService.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ function CashService(Modal, Api, Exchange, Session, moment) {
{ field: 'reference', displayName: 'FORM.LABELS.REFERENCE' },
{ field: 'dateFrom', displayName: 'FORM.LABELS.DATE_FROM', comparitor: '>', ngFilter:'date' },
{ field: 'dateTo', displayName: 'FORM.LABELS.DATE_TO', comparitor: '<', ngFilter:'date' },
{ field: 'currency_id', displayName: 'FORM.LABELS.CURRENCY' }
{ field: 'currency_id', displayName: 'FORM.LABELS.CURRENCY' },
{ field: 'reversed', displayName: 'CASH.REGISTRY.REVERSED_RECORDS' },
];

// returns columns from filters
Expand Down
17 changes: 17 additions & 0 deletions client/src/partials/cash/payments/templates/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@
validation-trigger="CashVoucherForm.$submitted">
</bh-currency-select>


<div class="radio">
<p class="control-label" style="margin-bottom:5px;">
<strong translate>CASH.REGISTRY.REVERSED_RECORDS</strong>
</p>
<label>
<input type="radio" name="reversed" ng-value="1" ng-model="$ctrl.bundle.reversed">
<span translate>CASH.REGISTRY.INCLUDE_ONLY_REVERSED_RECORDS</span>
</label>
</div>

<div class="radio">
<label>
<input type="radio" name="reversed" ng-value="0" ng-model="$ctrl.bundle.reversed">
<span translate>CASH.REGISTRY.EXCLUDE_REVERSED_RECORDS</span>
</label>
</div>
</fieldset>
</div>

Expand Down
8 changes: 4 additions & 4 deletions client/src/partials/cash/payments/templates/search.modal.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
angular.module('bhima.controllers')
.controller('SearchCashPaymentModalController', SearchCashPaymentModalController);
.controller('SearchCashPaymentModalController', SearchCashPaymentModalController);

// dependencies injections
SearchCashPaymentModalController.$inject = [
'UserService', 'CashboxService', 'NotifyService', '$uibModalInstance', 'CurrencyService'
'UserService', 'CashboxService', 'NotifyService', '$uibModalInstance',
];

/**
* Search Cash Payment controller
*/
function SearchCashPaymentModalController(Users, Cashboxes, Notify, Instance, Currencies) {
function SearchCashPaymentModalController(Users, Cashboxes, Notify, Instance) {
var vm = this;

// global variables
Expand Down Expand Up @@ -51,7 +51,7 @@ function SearchCashPaymentModalController(Users, Cashboxes, Notify, Instance, Cu
function formatFilterParameters() {
var out = {};
for (var i in vm.bundle) {
if (vm.bundle[i]) {
if (angular.isDefined(vm.bundle[i])) {
out[i] = vm.bundle[i];
}
}
Expand Down
7 changes: 5 additions & 2 deletions server/controllers/finance/cash.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ function listPayment(options) {
cash.date, BUID(cash.debtor_uuid) AS debtor_uuid, cash.currency_id, cash.amount,
cash.description, cash.cashbox_id, cash.is_caution, cash.user_id,
d.text AS debtor_name, cb.label AS cashbox_label, u.display_name,
v.type_id, p.display_name AS patientName
voucher.type_id, p.display_name AS patientName
FROM cash
LEFT JOIN voucher v ON v.reference_uuid = cash.uuid
LEFT JOIN voucher ON voucher.reference_uuid = cash.uuid
JOIN project ON cash.project_id = project.id
JOIN debtor d ON d.uuid = cash.debtor_uuid
JOIN patient p on p.debtor_uuid = d.uuid
Expand All @@ -176,6 +176,9 @@ function listPayment(options) {
let referenceStatement = `CONCAT_WS('.', '${identifiers.CASH_PAYMENT.key}', project.abbr, cash.reference) = ?`;
filters.custom('reference', referenceStatement);

// filter reversed cash records
filters.reversed('reversed');

// @TODO Support ordering query (reference support for limit)?
filters.setOrder('ORDER BY cash.date DESC');

Expand Down

0 comments on commit e750947

Please sign in to comment.