Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subsidy client #181

Merged
merged 6 commits into from
Mar 9, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions client/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1170,13 +1170,15 @@
"REGISTER" : "Register Employee",
"REGISTER_SUCCESS" : "Register successfully",
"REGISTRATION_FORM" : "Registration Form",
"SAVE_SUCCES" : "Saved successfully",
"SEARCH_BY_CODE" : "Tap the code",
"SEARCH_BY_NAME" : "Tap the empoyee name",
"SERVICE" : "Service",
"SEX" : "Sex",
"SUBMIT_EDIT" : "Submit Details",
"SUBMIT_NEW" : "Submit Registration",
"TITLE" : "Employee Management"
"TITLE" : "Employee Management",
"UPDATE_SUCCES" : "Updated successfully"
},
"EMPLOYEE_STANDING": {
"ACCOUNT_BALANCE" : "Account Balance",
Expand Down Expand Up @@ -3006,13 +3008,19 @@
"TITLE" : "Stock Situation"
},
"SUBSIDY" : {
"DETAILS" : "",
"INFO" : "Subsidy management module",
"NEW_SUBSIDY" : "New subsidy",
"NO_SUBSIDY" : "No subsidy have been registered",
"REGISTERED" : "Registered subsidy",
"TITLE" : "Subsidy",
"UPDATE" : "Update"
"CONFIRM" : "Are you sure you want to delete this Subsidy",
"DATE_CREATION" : "Date of creation",
"DATE_UPDATE" : "Date of update",
"DETAILS" : "",
"DELETE_SUCCESS" : "Deleted successfully",
"INFO" : "Subsidy management module",
"NEW_SUBSIDY" : "New subsidy",
"NO_SUBSIDY" : "No subsidy have been registered",
"REGISTERED" : "Registered subsidy",
"SAVE_SUCCESS" : "Saved successfully",
"TITLE" : "Subsidy",
"UPDATE" : "Update",
"UPDATE_SUCCESS" : "Updated successfully"
},
"SUPPLIER": {
"ADDR_1" : "Address 1",
Expand Down
14 changes: 11 additions & 3 deletions client/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1176,13 +1176,15 @@
"REGISTER" : "Nouveau employé",
"REGISTER_SUCCESS" : "Enregistrement de l'employé avec succès",
"REGISTRATION_FORM" : "Formulaire d'enregistrement",
"SAVE_SUCCES" : "Enregistrement avec succès",
"SERVICE" : "Service",
"SEARCH_BY_CODE" : "Taper le code employee",
"SEARCH_BY_NAME" : "Taper le nom empoyee",
"SEX" : "Sexe",
"SUBMIT_EDIT" : "Envoyer les détails",
"SUBMIT_NEW" : "Soumettre l'enregistrement",
"TITLE" : "Gestion des employés"
"TITLE" : "Gestion des employés",
"UPDATE_SUCCESS" : "Mis à jour avec succès"
},
"EMPLOYEE_STANDING": {
"ACCOUNT_BALANCE" : "Balance Compte",
Expand Down Expand Up @@ -2994,13 +2996,19 @@
"TITLE" : "Situation des stocks"
},
"SUBSIDY" : {
"CONFIRM" : "Etes vous sure de vouloir supprimer cette subvention",
"DATE_CREATION" : "Date de la création",
"DATE_UPDATE" : "Date de mis à jour",
"DELETE_SUCCESS" : "Suppression avec succès",
"DETAILS" : "",
"INFO" : "Module de gestion des subventions",
"NEW_SUBSIDY" : "Nouvelle subvention",
"NO_SUBSIDY" : "Aucune subvention n'est enregistrée",
"REGISTERED" : "Subvention(s) enregistrée(s)",
"TITLE" : "Subventions",
"UPDATE" : "Mise à jour"
"SAVE_SUCCESS" : "Enregistrement avec succès",
"TITLE" : "Subventions",
"UPDATE" : "Mise à jour",
"UPDATE_SUCCESS" : "Mise à jour avec succès"
},
"SUPPLIER": {
"ADDR_1" : "Adresse 1",
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function bhimaconfig($routeProvider) {
templateUrl: 'partials/payroll/config_accounting/config_accounting.html'
})
.when('/subsidies', {
controller : 'subsidy',
controller : 'SubsidiesController as SubsidiesCtrl',
templateUrl : 'partials/subsidies/subsidies.html'
})
.when('/report/invoice/:target', {
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/services/AccountService.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function AccountService($http, util) {
// FIXME - make /accounts return the account type w/o query string
// and preformat the label elsewhere
accounts.forEach(function (account) {
account.label = account.account_number + ' ' + account.account_txt;
account.label = account.account_number + ' - ' + account.account_txt;
});

return accounts;
Expand Down
87 changes: 87 additions & 0 deletions client/src/js/services/SubsidiesService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
angular.module('bhima.services')
.service('SubsidiesService', SubsidiesService);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better name would be SubsidyService. Subsidie isn't a valid English spelling :).


SubsidiesService.$inject = ['$http', 'util'];

function SubsidiesService($http, util) {
var service = this;
var baseUrl = '/subsidies/';

service.read = read;
service.create = create;
service.update = update;
service.delete = del;

/**
* @desc Get an id (optionnal) and return back a list of subsidies or an subsidy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This are really great comments!

One small thing: JavaScript doesn't have a type or object called Integer. Instead of writing @param {Integer} it would be better to write @param {Number}, since that is JavaScript's numerical type.

Otherwise, this is excellent code documentation!

* @param {Integer} id, the id of the subsidy (optionnal)
* @return {object} a promise object, with the response.body inside.
* @example
* service.read()
* .then(function (subsidies){
* your code here
* });
**/
function read(id) {
var url = baseUrl.concat(id || '');
return $http.get(url)
.then(util.unwrapHttpResponse);
}

/**
* @desc It create an subsidy
* @param {object} subsidy, subsidy to create
* @example
* service.create(subsidy)
* .then(function (res){
* your code here
* });
**/
function create(subsidy) {
return $http.post(baseUrl, subsidy)
.then(util.unwrapHttpResponse);
}

/**
* @desc It updates an subsidy
* @param {Integer} id, subsidy id to update
* @param {object} subsidy, subsidy to update
* @example
* service.update(id, subsidy)
* .then(function (res){
* your code here
* });
**/
function update(id, subsidy) {
delete subsidy.id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going to submit subsidyClean to the server, I do not think you need to delete these properties.

delete subsidy.account_number;
delete subsidy.account_number;

var subsidyClean = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice construction.

label : subsidy.label,
value : subsidy.value,
account_id : subsidy.account_id,
description : subsidy.description
};

return $http.put(baseUrl.concat(id), subsidyClean)
.then(util.unwrapHttpResponse);
}

/**
* @desc It Delete a subsidy
* @param {Integer} id, subsidy id to delete
* @example
* service.del(id)
* .then(function (res){
* your code here
* });
**/

function del(id) {
return $http.delete(baseUrl + id)
.then(util.unwrapHttpResponse);
}

return service;
}
Loading