Skip to content

Commit

Permalink
Merge pull request #696 from mbayopanda/cashflow_rebased
Browse files Browse the repository at this point in the history
Cashflow Report
  • Loading branch information
jniles committed Sep 9, 2016
2 parents 5e2dc3d + a6733d6 commit 971d46f
Show file tree
Hide file tree
Showing 38 changed files with 1,627 additions and 147 deletions.
27 changes: 21 additions & 6 deletions client/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"TITLE" : "Enterprise Management"
},
"ERRORS": {
"BAD_DATE_INTERVAL" : "Bad date interval",
"BAD_REQUEST" : "You are not allowed to perform this operation",
"ERR_INTERNET_DISCONNECTED" : "You are not connected to the network.",
"NO_EXCHANGE_RATE" : "No Exchange rate defined",
Expand Down Expand Up @@ -234,6 +235,7 @@
"FILTER" : "Filter",
"GROUP_BY_ACCOUNT" : "Group by Account",
"GROUP_BY_TRANSACTION" : "Group By Transaction",
"GENERATE" : "Generate",
"GROUPS_DEBTOR_UPDATE" : "Update Group Debtor",
"GROUPS_PATIENT_UPDATE" : "Update Group Assignments",
"LINK_SUBMISSION" : "Link to Submission",
Expand Down Expand Up @@ -387,6 +389,7 @@
"DEBTOR_GROUP_FORM" : "Form debtor group record",
"DESCRIPTION" : "Description",
"DESIGNATION" : "Designation",
"DETAILS" : "Details",
"DISTRIBUTABLE" : "Distributable",
"DOB" : "Date of Birth",
"DOCUMENT" : "Document",
Expand Down Expand Up @@ -520,13 +523,14 @@
"STATUS" : "Status",
"STOCK" : "Stock",
"SUBSIDIES" : "Subsidies Applied",
"SUMMARY" : "Summary",
"SUPPLIER" : "Supplier",
"TEL" : "TEL",
"TELEPHONE" : "Telephone",
"TEXT" : "Text",
"THIS_MONTH" : "This Month",
"THIS_WEEK" : "This week",
"THIS_YEAR" : "This year",
"THIS_YEAR" : "This Year",
"TITLE" : "Title",
"TITLE_ACCOUNT" : "Title Account",
"TODAY" : "Today",
Expand Down Expand Up @@ -596,6 +600,7 @@
"ACCOUNT" : "Select an Account",
"ACCOUNT_TYPE" : "Select Account Type",
"BALANCE_SECTION" : "Select Balance Sheet Section",
"CASHBOX" : "Select a cashbox",
"COST_CENTER" : "Select a Cost Center",
"COUNTRY" : "Select Country",
"CREDITOR" : "Select a Creditor",
Expand Down Expand Up @@ -909,17 +914,26 @@
"UPD_REFERENCE" : "Update Reference Group"
},
"REPORT" : {
"AGED_DEBTORS" : {
"AGED_DEBTORS" : {
"TITLE": "Aged Debtors",
"THIRTY_DAYS" : "Less Than 30 Days",
"SIXTY_DAYS" : "Less Than 60 Days",
"NINETY_DAYS" : "Less Than 90 Days",
"OVER_NINETY_DAYS" : "Over 90 Days"
},
"SINCE" : "Since",
"PRODUCED_BY" : "Produced by",
"PRODUCED_DATE" : "Production Date",
"PRODUCED_ON" : "Produced on"
"CASH_EXPENSE" : "Expenses",
"CASH_INCOME" : "Incomes",
"CLOSING_BALANCE" : "Closing Balance",
"CONFIGURATION" : "Report Configuration",
"GENERATED" : "Generated Report",
"MONTHLY_BALANCE" : "Monthly Balance",
"OPENNING_BALANCE" : "Openning Balance",
"PERIOD_START" : "Start",
"PERIOD_STOP" : "Stop",
"PRODUCED_BY" : "Produced by",
"PRODUCED_DATE" : "Production Date",
"PRODUCED_ON" : "Produced on",
"SINCE" : "Since"
},
"SECTION_BILAN": {
"ADD_SECTION_BILAN" : "Add a bilan Section",
Expand Down Expand Up @@ -1127,6 +1141,7 @@
"ADMIN" : "Admin",
"BILLING_SERVICES" : "Billing Services",
"CASHBOX_MANAGEMENT" : "Cashbox Management",
"CASHFLOW" : "Cashflow",
"CASH_WINDOW" : "Cash Window",
"COMPLEX_JOURNAL_VOUCHER" : "Journal Vouchers",
"COST_CENTER_MGMT" : "Cost Center Management",
Expand Down
48 changes: 29 additions & 19 deletions client/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@
"TITLE" : "Gestion des entreprises"
},
"ERRORS": {
"BAD_REQUEST" : "Vous n'etes pas authorisé à faire cette operation",
"BAD_DATE_INTERVAL" : "Mauvais interval de date",
"BAD_REQUEST" : "Vous n'etes pas authorisé à faire cette operation",
"ERR_INTERNET_DISCONNECTED" : "Vous n'êtes pas connecté à un réseau.",
"NO_EXCHANGE_RATE" : "Aucun taux de change defini",
"NOT_ALLOWED" : "Vous n'etes pas authorisé à faire cette action",
Expand Down Expand Up @@ -239,6 +240,7 @@
"ENTER_FULL_DATE" : "Saisie Date Exact",
"ENTITY" : "Entité",
"FILTER" : "Filtre",
"GENERATE" : "Générer",
"GROUP_BY_ACCOUNT" : "Grouper Par Compte",
"GROUP_BY_TRANSACTION" : "Grouper Par Transaction",
"GROUPS_DEBTOR_UPDATE" : "L'assignation au groupe débiteur est à jour",
Expand Down Expand Up @@ -393,6 +395,7 @@
"DEBTOR_GROUP" : "Groupe Débiteur",
"DEBTOR_GROUP_FORM" : "Formulaire d'enregistrement de groupe débiteur",
"DESCRIPTION" : "Description",
"DETAILS" : "Details",
"DESIGNATION" : "Désignation",
"DISTRIBUTABLE" : "Distribuable",
"DOB" : "Date de Naissance",
Expand Down Expand Up @@ -530,13 +533,14 @@
"STATUS" : "Etat",
"STOCK" : "Stock",
"SUBSIDIES" : "Les subventions appliqués",
"SUMMARY" : "Résumé",
"SUPPLIER" : "Fournisseur",
"TEL" : "Tél",
"TELEPHONE" : "Téléphone",
"TEXT" : "Texte",
"THIS_MONTH" : "Ce Mois",
"THIS_WEEK" : "Cette Semaine",
"THIS_YEAR" : "Cetter Année",
"THIS_YEAR" : "Cette Année",
"TITLE" : "Titre",
"TITLE_ACCOUNT" : "Comptes Titre",
"TO" : "à",
Expand Down Expand Up @@ -606,12 +610,13 @@
"ACCOUNT" : "Sélectionner compte",
"ACCOUNT_TYPE" : "Sélectionner Type de Compte",
"BALANCE_SECTION" : "Sélectionner la section du bilan",
"CASHBOX" : "Sélectionner une caisse",
"COST_CENTER" : "Sélectionner centre de cout",
"COUNTRY" : "Sélectionner pays",
"CREDITOR" : "Sélectionner un Créditeur",
"CREDITOR_GROUP" : "Sélectionner Groupe de créditeurs",
"DATE_INTERVAL" : "Sélectionner un intervalle de date",
"DEBTOR_GROUP" : "Sélectionner Groupe de Débiteurs",
"DEBTOR_GROUP" : "Sélectionner Groupe de Débiteurs",
"ENTERPRISE" : "Sélectionner entreprise",
"FUNCTION" : "Sélectionner une fonction",
"GRADE" : "Sélectionner un Grade",
Expand Down Expand Up @@ -961,10 +966,19 @@
"NINETY_DAYS" : "Moins de 90 jours",
"OVER_NINETY_DAYS" : "Audela de 90 jours"
},
"SINCE" : "Depuis",
"PRODUCED_BY" : "Produit par",
"PRODUCED_DATE" : "Date de generation",
"PRODUCED_ON" : "Produit sur"
"CASH_EXPENSE" : "Depenses",
"CASH_INCOME" : "Recettes",
"CLOSING_BALANCE" : "Balance à la cloture",
"CONFIGURATION" : "Configuration rapport",
"GENERATED" : "Rapport généré",
"MONTHLY_BALANCE" : "Balance mensuelle",
"OPENNING_BALANCE" : "Balance d'ouverture",
"PERIOD_START" : "Debut",
"PERIOD_STOP" : "Fin",
"PRODUCED_BY" : "Produit par",
"PRODUCED_DATE" : "Date de generation",
"PRODUCED_ON" : "Produit sur",
"SINCE" : "Depuis"
},
"SECTION_BILAN": {
"ADD_SECTION_BILAN" : "Ajouter une section Bilan",
Expand Down Expand Up @@ -1173,6 +1187,7 @@
"ADMIN" : "Admin",
"BILLING_SERVICES" : "Services de facturation",
"CASHBOX_MANAGEMENT" : "Caisses et Banques",
"CASHFLOW" : "Cashflow",
"CASH_WINDOW" : "Paiements",
"COMPLEX_JOURNAL_VOUCHER" : "Ajout de transactions",
"COST_CENTER_MGMT" : "Centres de coûts",
Expand Down Expand Up @@ -1289,17 +1304,12 @@
},
"REPORT" : "Rapport"
},
"REPORT" : {
"SINCE": "Depuis",
"PRODUCED_BY" : "Produit Par",
"PRODUCED_DATE" : "Date Production",
"PRODUCED_ON" : "Produit le",
"AGED_DEBTORS" : {
"TITLE": "Age debiteur",
"THIRTY_DAYS" : "Moins de 30 jours",
"SIXTY_DAYS" : "Moins de 60 jours",
"NINETY_DAYS" : "Moins de 90 jours",
"OVER_NINETY_DAYS" : "Plus de 90 jours"
}
"GRAPHS" : {
"PATIENT_REGISTRATIONS" : "Enregistrement des patients",
"PATIENT_INVOICES" : "Factation des patients",
"MEDICINE_DISTRIBUTIONS" : "Distribution des medicaments",
"LOGINS" : "Connexion",
"PURCHASES" : "Achats"
}

}
1 change: 0 additions & 1 deletion client/src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ function bhimaConfig($stateProvider, $urlRouterProvider, $urlMatcherFactoryProvi
})

/* creditor routes */

.state('suppliers', {
url : '/suppliers',
controller: 'SupplierController as SupplierCtrl',
Expand Down
1 change: 0 additions & 1 deletion client/src/js/components/bhDateInterval.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ bhDateInterval.$inject = ['DateService'];
// controller definition
function bhDateInterval(Dates) {
/* global moment */

var vm = this;

vm.options = [
Expand Down
20 changes: 20 additions & 0 deletions client/src/js/services/CashflowService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

/**
* @name CashflowService
* @description
* The `CashflowService` component provide a mean to get cashflow data by requesting
* to the /finance/cashflow API
*/
angular.module('bhima.services')
.factory('CashflowService', CashflowService);

// dependencies injection
CashflowService.$inject = ['PrototypeApiService'];

// service definition
function CashflowService(PrototypeApiService) {
var service = new PrototypeApiService('/finance/cashflow/');

return service;
}
18 changes: 0 additions & 18 deletions client/src/js/services/VoucherService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,6 @@ function VoucherService(Api, $http, util, TransactionTypeStore) {
// @tdoo - remove this reference to baseUrl
var baseUrl = '/journal/';

/**
* transfer type
* @deprecated use transactionType in place...
* @todo remove securely this array i.e. be sure that no module use this element
*/
service.transferType = [
{ id: 0, text: 'VOUCHERS.SIMPLE.GENERIC_INCOME', incomeExpense: 'income', prefix: 'REC. GEN' },
{ id: 1, text: 'VOUCHERS.SIMPLE.CASH_PAYMENT', incomeExpense: 'income', prefix: 'CASH' },
{ id: 2, text: 'VOUCHERS.SIMPLE.CONVENTION_PAYMENT', incomeExpense: 'income', prefix: 'CONV' },
{ id: 3, text: 'VOUCHERS.SIMPLE.SUPPORT_INCOME', incomeExpense: 'income', prefix: 'PEC' },
{ id: 4, text: 'VOUCHERS.SIMPLE.TRANSFER', incomeExpense: 'income', prefix: 'TRANSF' },
{ id: 5, text: 'VOUCHERS.SIMPLE.GENERIC_EXPENSE', incomeExpense: 'expense', prefix: 'DEP. GEN' },
{ id: 6, text: 'VOUCHERS.SIMPLE.SALARY_PAYMENT', incomeExpense: 'expense', prefix: 'SALAIRE' },
{ id: 7, text: 'VOUCHERS.SIMPLE.CASH_RETURN', incomeExpense: 'expense', prefix: 'PAYBACK' },
{ id: 8, text: 'VOUCHERS.SIMPLE.PURCHASES', incomeExpense: 'expense', prefix: 'ACHAT' },
{ id: 9, text: 'VOUCHERS.SIMPLE.CREDIT_NOTE', incomeExpense: 'creditNote', prefix: 'CREDIT NOTE' },
];

service.createSimple = createSimple;
service.create = create;
service.reverse = reverse;
Expand Down
16 changes: 16 additions & 0 deletions client/src/js/services/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,20 @@ function UtilService(moment) {
return fn.apply(this, arguments);
};
};

/**
* @function uniquelize
* @param {array} array An array in which we want to get only unique values
* @description return an array which contain only unique values
*/
service.uniquelize = function uniquelize (array) {
// the second param is the next value in the array.
return array.reduce(function (uniq, value) {

// if we haven't seen the value yet, add it to the array (otherwise, ignore it).
if (uniq.indexOf(value) === -1) { uniq.push(value); }
return uniq;

}, []); // initialize with an empty array
};
}
25 changes: 25 additions & 0 deletions client/src/partials/finance/cashflow/cashflow.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
angular.module('bhima.routes')
.config(['$stateProvider', function ($stateProvider) {
$stateProvider

/* cashflow page */
.state('cashflow', {
url : '/finance/cashflow',
params: { dateFrom: null, dateTo: null, cashbox: null },
controller : 'CashflowController as CashflowIndexCtrl',
templateUrl : 'partials/finance/cashflow/index.html'
})

/* cashflow configuration */
.state('cashflow.configure', {
controller : 'CashflowConfigController as CashflowConfigCtrl',
templateUrl : 'partials/finance/cashflow/config.html'
})

/* cashflow report */
.state('cashflow.report', {
controller : 'CashflowReportController as CashflowReportCtrl',
templateUrl : 'partials/finance/cashflow/report.html'
});

}]);
40 changes: 40 additions & 0 deletions client/src/partials/finance/cashflow/config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- configuration panel -->
<div class="col-md-6 col-md-offset-3 panel panel-default">
<div class="panel-body">
<form name="ConfigForm" bh-submit="CashflowConfigCtrl.generate()" bh-form-defaults novalidate>

<!-- Date interval -->
<bh-date-interval
date-from="CashflowConfigCtrl.dateFrom"
date-to="CashflowConfigCtrl.dateTo">
</bh-date-interval>

<!-- cashbox selection -->
<div class="form-group"
ng-class="{ 'has-error' : ConfigForm.$submitted && ConfigForm.cashbox.$invalid }">
<label class="control-label">
<span class="fa fa-briefcase"></span> {{ 'FORM.SELECT.CASHBOX' | translate }}
</label>
<select
class="form-control"
name="cashbox"
ng-model="CashflowConfigCtrl.cashbox"
ng-options="cash as cash.hrlabel for cash in CashflowConfigCtrl.cashboxes"
required>
<option value="" disabled>-- {{ 'FORM.SELECT.CASHBOX' | translate }} --</option>
</select>
<div class="help-block" ng-messages="ConfigForm.cashbox.$error" ng-show="ConfigForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
</div>

<div data-submit-area class="text-right">
<bh-loading-button loading-state="ConfigForm.$loading"
ng-disabled="ConfigForm.$invalid">
{{ "FORM.BUTTONS.GENERATE" | translate }}
</bh-loading-button>
</div>

</form>
</div>
</div>
43 changes: 43 additions & 0 deletions client/src/partials/finance/cashflow/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

angular.module('bhima.controllers')
.controller('CashflowConfigController', CashflowConfigController);

// dependencies injection
CashflowConfigController.$inject = [ '$state', 'CashboxService', 'NotifyService' ];

/**
* Cashflow config controller
*
* @description
* This controller is responsible of cash flow report, that report include
* all incomes minus all depenses
*/
function CashflowConfigController($state, Cashbox, Notify) {
var vm = this;

// expose to the view
vm.generate = generate;

/** init */
Cashbox.read(null, { detailed: 1, is_auxiliary: 0})
.then(function (list) {
list.forEach(function (cashbox) {
cashbox.hrlabel = cashbox.label + ' ' + cashbox.symbol;
});
vm.cashboxes = list;
})
.catch(Notify.errorHandler);

/** generate cashflow report */
function generate() {
if (!vm.cashbox || !vm.dateFrom || !vm.dateTo) { return ; }
var params = {
dateFrom : vm.dateFrom,
dateTo : vm.dateTo,
cashbox : vm.cashbox
};
$state.go('cashflow.report', params);
}

}
Loading

0 comments on commit 971d46f

Please sign in to comment.