Skip to content

Commit

Permalink
fix(cashboxes): display all cashboxes in selection
Browse files Browse the repository at this point in the history
This commit allows a user to select any project's cashbox from the
cashbox selection page.  As designed, BHIMA assumes that users will have
separate projects and use their own cashboxes, so those are cleanly
separated from the remaining cashboxes.  However, it does give the user
the possibility of using any registered cashbox.

Closes #1976.
  • Loading branch information
jniles committed Aug 22, 2017
1 parent 75a8a95 commit 3387e72
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 118 deletions.
114 changes: 68 additions & 46 deletions client/src/i18n/en/cash.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,68 @@
{"CASH":{"CAUTION":"Caution",
"CAUTION_COVER":"Invoice(s) covered by the caution",
"CAUTION_PAYMENT":"Caution Payment",
"CAUTION_REMAINING":"Remaining Caution",
"CONFIRM_PAYMENT_WHEN_CAUTION":"The debtor has a positive balance with the hospital. Accepting cash from the debtor will increase their credit with the hospital. Are you sure you want to accept payment?",
"CURRENT_CASHBOX":"Current Cashbox",
"DEBTOR_INVOICES":"Debtor Invoices",
"PAYMENT":"Payment",
"PAYMENT_DESCRIPTION":"Cash payment by {{patientName}} ({{patientReference}}) against invoice(s) {{invoiceReferences}}.",
"PREPAYMENT_DESCRIPTION":"Prepayment by {{patientName}} ({{patientReference}}).",
"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",
"TITLE":"Select a Cashbox"},
"TITLE":"Cash Window",
"RECEIPT":{"TITLE":"Cash Receipt",
"SUCCESS":"Successfully created a Cash Payment"},
"TRANSFER":{"TITLE":"New Cash Transfer",
"ACTION":"You are transferring funds out of the cashbox.",
"REMINDER":"Please perform a cash count and indicate both the currency and amount to be transferred in the form below.",
"SUCCESS":"Successfully transferred money out of the cash window.",
"DESCRIPTION":"Cash transfer of {{ amount }} from {{ fromLabel }} to {{ toLabel }} by {{ userName }}."},
"VOUCHER":{"CASHBOXES":{"AVAILABLE":"Available Cashboxes",
"CHANGE_CASHBOX":"Change Cashbox",
"CURRENT_CASHBOX":"Current Cashbox",
"LINK":"Click here to add it.",
"MISSING":"Don't see your cashbox?",
"TRANSFER":"Transfer Funds",
"NO_INVOICES_ASSIGNED":"You have not assigned any invoices. Please assign at least one invoice to the payment.",
"NO_CASHBOX_SELECTED":"You have no selected a cashbox. Please select a cashbox to continue.",
"SELECTED":"Selected cash"},
"BARCODE":{"SCAN":"Scan the barcode",
"AWAITING_INPUT":"Waiting input",
"AWAITING_HTTP":"Barcode done! search invoice...",
"READ_SUCCESS":"Invoice found",
"READ_ERROR":"Can't read barcode! Please enter code manually"},
"OPEN_BARCODE_MODAL":"Scan another barcode on successful payment.",
"DEBTOR_INVOICES":"Debtor Invoices",
"RECEIPTS_TITLE":"Cash Payment Receipt",
"REPORT":"Report",
"SLIP":"Cash Voucher",
"TITLE":"Cash Window",
"SELECTED":"Selected Invoices"},
"MOTIVE":"Notes"}}
{
"CASH":{
"CAUTION":"Caution",
"CAUTION_COVER":"Invoice(s) covered by the caution",
"CAUTION_PAYMENT":"Caution Payment",
"CAUTION_REMAINING":"Remaining Caution",
"CONFIRM_PAYMENT_WHEN_CAUTION":"The debtor has a positive balance with the hospital. Accepting cash from the debtor will increase their credit with the hospital. Are you sure you want to accept payment?",
"CURRENT_CASHBOX":"Current Cashbox",
"DEBTOR_INVOICES":"Debtor Invoices",
"PAYMENT":"Payment",
"PAYMENT_DESCRIPTION":"Cash payment by {{patientName}} ({{patientReference}}) against invoice(s) {{invoiceReferences}}.",
"PREPAYMENT_DESCRIPTION":"Prepayment by {{patientName}} ({{patientReference}}).",
"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",
"TITLE":"Select a Cashbox",
"CURRENT_PROJECT_CASHBOXES" : "Current Project Cashboxes",
"OTHER_PROJECT_CASHBOXES" : "Other Project Cashboxes",
"NO_OTHER_PROJECT_CASHBOXES" : "No cashboxes found registered to other projects.",
"NO_CURRENT_PROJECT_CASHBOXES" : "No cashboxes found registered to the current project."
},
"TITLE":"Cash Window",
"RECEIPT":{
"TITLE":"Cash Receipt",
"SUCCESS":"Successfully created a Cash Payment"
},
"TRANSFER":{
"TITLE":"New Cash Transfer",
"ACTION":"You are transferring funds out of the cashbox.",
"REMINDER":"Please perform a cash count and indicate both the currency and amount to be transferred in the form below.",
"SUCCESS":"Successfully transferred money out of the cash window.",
"DESCRIPTION":"Cash transfer of {{ amount }} from {{ fromLabel }} to {{ toLabel }} by {{ userName }}."
},
"VOUCHER":{
"CASHBOXES":{
"AVAILABLE":"Available Cashboxes",
"CHANGE_CASHBOX":"Change Cashbox",
"CURRENT_CASHBOX":"Current Cashbox",
"LINK":"Click here to add it.",
"MISSING":"Don't see your cashbox?",
"TRANSFER":"Transfer Funds",
"NO_INVOICES_ASSIGNED":"You have not assigned any invoices. Please assign at least one invoice to the payment.",
"NO_CASHBOX_SELECTED":"You have no selected a cashbox. Please select a cashbox to continue.",
"SELECTED":"Selected cash"
},
"BARCODE":{
"SCAN":"Scan the barcode",
"AWAITING_INPUT":"Waiting input",
"AWAITING_HTTP":"Barcode done! search invoice...",
"READ_SUCCESS":"Invoice found",
"READ_ERROR":"Can't read barcode! Please enter code manually"
},
"OPEN_BARCODE_MODAL":"Scan another barcode on successful payment.",
"DEBTOR_INVOICES":"Debtor Invoices",
"RECEIPTS_TITLE":"Cash Payment Receipt",
"REPORT":"Report",
"SLIP":"Cash Voucher",
"TITLE":"Cash Window",
"SELECTED":"Selected Invoices"
},
"MOTIVE":"Notes"
}
}
5 changes: 3 additions & 2 deletions client/src/i18n/en/cashbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"DESCRIPTION":"This module is responsible for cashbox management",
"TITLE":"Cashbox Management",
"NO_SUPPORTED_CURRENCIES":"This cashbox does not have any supported currencies.",
"SET_CURRENCY_ACCOUNTS":"Set currency accounts for this cashbox."}
}
"SET_CURRENCY_ACCOUNTS":"Set currency accounts for this cashbox."
}
}
110 changes: 64 additions & 46 deletions client/src/i18n/fr/cash.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,64 @@
{"CASH":{"CAUTION":"Caution",
"CAUTION_COVER":"Facture(s) couvert par la caution",
"CAUTION_PAYMENT":"Paiement Caution",
"CAUTION_REMAINING":"Caution Restante",
"CONFIRM_PAYMENT_WHEN_CAUTION":"Procéder au paiement alors que le patient dispose d'une caution ?",
"CURRENT_CASHBOX":"Caisse courante",
"PAYMENT_DESCRIPTION":"Paiement par {{patientName}} ({{patientReference}}) contre les facture(s) {{invoiceReferences}}.",
"PREPAYMENT_DESCRIPTION":"Paiement caution par {{patientName}} ({{patientReference}}).",
"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",
"SUCCESS":"Créé avec succès un paiement en espèces"},
"SELECTION":{"GO_TO_CASHBOX_PAGE":"Allez a la page de gestion de caisse",
"MISSING_CASH":"Caisse manquante",
"TITLE":"Selection caisse"},
"TITLE":"Caisse Auxilliaire",
"TRANSFER":{"ACTION":"Vous avez transféré des fonds de la caisse.",
"TITLE":"Transfert",
"REMINDER":"S'il vous plaît effectuer un comptage de caisse et indiquent à la fois la devise et le montant à transférer dans le formulaire ci-dessous.",
"SUCCESS":"Transfer effectué vers le compte de transfer.",
"DESCRIPTION":"Transfer de {{ amount }} viens de {{ fromLabel }} à {{ toLabel }} par {{ userName }}."},
"VOUCHER":{"CASHBOXES":{"AVAILABLE":"Caisse disponibles",
"CHANGE_CASHBOX":"Changer de caisse",
"CURRENT_CASHBOX":"Caisse auxilliare courant",
"LINK":"Cliquez ici pour l'ajouter.",
"MISSING":"Vous ne trouvez pas votre caisse?",
"NO_INVOICES_ASSIGNED":"Vous n'avez pas sélectionné des factures! S'il vous plaît choisir des factures pour continuer.",
"NO_CASHBOX_SELECTED":"Vous n'avez pas sélectionné une caisse. S'il vous plaît choisir une caisse pour continuer.",
"SELECTED":"Selectionnée",
"TRANSFER":"Transférer Fonds"},
"BARCODE":{"SCAN":"Scanner le Code à Barres",
"AWAITING_INPUT":"En Attente d'Entrée",
"AWAITING_HTTP":"Code à barres lu! Recherche de factures ....",
"READ_SUCCESS":"Facture Trouvée",
"READ_ERROR":"Code à barres illisible! Entrez le code à barres manuellement."},
"OPEN_BARCODE_MODAL":"Numériser un autre code à barres lors d'un paiement réussi.",
"DEBTOR_INVOICES":"Factures des débiteurs",
"REPORT":"Rapport",
"RECEIPTS_TITLE":"Reçu de paiement des factures",
"SLIP":"Caisse en espèces",
"TITLE":"Recu de caisse",
"SELECTED":"Facture selectionnée"},
"MOTIVE":"Motif"}}
{
"CASH":{
"CAUTION":"Caution",
"CAUTION_COVER":"Facture(s) couvert par la caution",
"CAUTION_PAYMENT":"Paiement Caution",
"CAUTION_REMAINING":"Caution Restante",
"CONFIRM_PAYMENT_WHEN_CAUTION":"Procéder au paiement alors que le patient dispose d'une caution ?",
"CURRENT_CASHBOX":"Caisse courante",
"PAYMENT_DESCRIPTION":"Paiement par {{patientName}} ({{patientReference}}) contre les facture(s) {{invoiceReferences}}.",
"PREPAYMENT_DESCRIPTION":"Paiement caution par {{patientName}} ({{patientReference}}).",
"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",
"SUCCESS":"Créé avec succès un paiement en espèces"
},
"SELECTION":{
"GO_TO_CASHBOX_PAGE":"Allez a la page de gestion de caisse",
"MISSING_CASH":"Caisse manquante",
"TITLE":"Selection Caisse",
"CURRENT_PROJECT_CASHBOXES" : "Caisses pour ce Projet",
"OTHER_PROJECT_CASHBOXES" : "Caisses pour tous Projets",
"NO_OTHER_PROJECT_CASHBOXES" : "Il n'y a aucune caisses enregistrer pour les autres projets.",
"NO_CURRENT_PROJECT_CASHBOXES" : "Il n'y a aucune caisses enregistrer pour votre projet."
},
"TITLE":"Caisse Auxilliaire",
"TRANSFER":{
"ACTION":"Vous avez transféré des fonds de la caisse.",
"TITLE":"Transfert",
"REMINDER":"S'il vous plaît effectuer un comptage de caisse et indiquent à la fois la devise et le montant à transférer dans le formulaire ci-dessous.",
"SUCCESS":"Transfer effectué vers le compte de transfer.",
"DESCRIPTION":"Transfer de {{ amount }} viens de {{ fromLabel }} à {{ toLabel }} par {{ userName }}."},
"VOUCHER":{"CASHBOXES":{"AVAILABLE":"Caisse disponibles",
"CHANGE_CASHBOX":"Changer de caisse",
"CURRENT_CASHBOX":"Caisse auxilliare courant",
"LINK":"Cliquez ici pour l'ajouter.",
"MISSING":"Vous ne trouvez pas votre caisse?",
"NO_INVOICES_ASSIGNED":"Vous n'avez pas sélectionné des factures! S'il vous plaît choisir des factures pour continuer.",
"NO_CASHBOX_SELECTED":"Vous n'avez pas sélectionné une caisse. S'il vous plaît choisir une caisse pour continuer.",
"SELECTED":"Selectionnée",
"TRANSFER":"Transférer Fonds"
},
"BARCODE":{
"SCAN":"Scanner le Code à Barres",
"AWAITING_INPUT":"En Attente d'Entrée",
"AWAITING_HTTP":"Code à barres lu! Recherche de factures ....",
"READ_SUCCESS":"Facture Trouvée",
"READ_ERROR":"Code à barres illisible! Entrez le code à barres manuellement."},
"OPEN_BARCODE_MODAL":"Numériser un autre code à barres lors d'un paiement réussi.",
"DEBTOR_INVOICES":"Factures des débiteurs",
"REPORT":"Rapport",
"RECEIPTS_TITLE":"Reçu de paiement des factures",
"SLIP":"Caisse en espèces",
"TITLE":"Recu de caisse",
"SELECTED":"Facture selectionnée"
},
"MOTIVE":"Motif"
}
}
39 changes: 26 additions & 13 deletions client/src/modules/cash/modals/select-cashbox-modal.ctrl.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
angular.module('bhima.controllers')
.controller('SelectCashboxModalController', SelectCashboxModalController);
.controller('SelectCashboxModalController', SelectCashboxModalController);

SelectCashboxModalController.$inject = [
'SessionService', '$uibModalInstance', 'CashboxService', '$stateParams',
'NotifyService'
'NotifyService',
];

/**
Expand All @@ -12,23 +12,31 @@ SelectCashboxModalController.$inject = [
function SelectCashboxModalController(Session, Instance, Cashboxes, $stateParams, Notify) {
var vm = this;

var cashboxId = $stateParams.id;
vm.cashboxId = cashboxId;
vm.selectCashbox = selectCashbox;
var cashboxId = vm.cashboxId = $stateParams.id;

/* ------------------------------------------------------------------------ */

// loads a new set of cashboxes from the server.
function startup() {

toggleLoadingIndicator();

Cashboxes.read(undefined, {
project_id : Session.project.id,
is_auxiliary : 1
})
Cashboxes.read(undefined, { is_auxiliary : 1 })
.then(function (cashboxes) {
vm.cashboxes = cashboxes;

vm.currentProjectCashboxes = cashboxes.filter(function (cashbox) {
return cashbox.project_id === Session.project.id;
});

vm.otherProjectCashboxes = cashboxes.filter(function (cashbox) {
return cashbox.project_id !== Session.project.id;
});

// convenience variables to clean up view logic
vm.hasCurrentProjectCashboxes = vm.currentProjectCashboxes.length > 0;
vm.hasOtherProjectCashboxes = vm.otherProjectCashboxes.length > 0;

if (cashboxId) {
selectCashbox(cashboxId);
}
Expand All @@ -39,10 +47,15 @@ function SelectCashboxModalController(Session, Instance, Cashboxes, $stateParams

// fired when a user selects a cashbox from a list
function selectCashbox(id) {
vm.selectedCashbox = vm.cashboxes.reduce(function (selected, box) {
if (box.id === id) { selected = box; }
return selected;
}, null);
var selected;

vm.cashboxes.forEach(function (box) {
if (box.id === id) {
selected = box;
}
});

vm.selectedCashbox = selected;
}

function toggleLoadingIndicator() {
Expand Down
Loading

0 comments on commit 3387e72

Please sign in to comment.