Skip to content

Commit

Permalink
Merge #2446
Browse files Browse the repository at this point in the history
2446: feat(account) prevent the user to set 0 as account number r=jniles a=jeremielodi

This PR  oblige the user to enter an account number different to 0.
closes #2433
  • Loading branch information
bors[bot] committed Jan 23, 2018
2 parents 36fb32e + 2431ae3 commit d386f37
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions client/src/i18n/en/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"NOT_BALANCED":"Accounts are not balanced",
"NOT_FOUND":"Not accounts found.",
"NOT_POSITIVE":"Contains not positive value",
"NOT_0_AS_ACCOUNT_NOMBER": "You cannot set 0 as account number",
"NUMBER":"Account Number",
"PROFIT_CENTER":"Profit Center",
"TITLE_ACCOUNT":"Title Account",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"NOT_BALANCED": "Comptes non balancés",
"NOT_FOUND": "Aucun compte enregistrés...",
"NOT_POSITIVE": "Contiens des valeurs non positives",
"NOT_0_AS_ACCOUNT_NOMBER":"Vous ne pouvez pas enregistrer 0 comme numéro de compte!",
"NUMBER": "Numéro de compte",
"PROFIT_CENTER": "Centre des profits",
"RECORDING": "Enregistrement",
Expand Down
32 changes: 20 additions & 12 deletions client/src/modules/accounts/edit/accounts.edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ function AccountEditController(
// states that are available as sibling states - these can be used to show and hide
// relevent components
vm.states = {
create : 'accounts.create',
edit : 'accounts.edit',
create: 'accounts.create',
edit: 'accounts.edit',
};

vm.state = angular.copy(vm.stateCurrent.name);
Expand All @@ -64,17 +64,17 @@ function AccountEditController(
vm.accountNotFound = null;

vm.rootAccount = {
id : 0,
number : 0,
type_id : Constants.accounts.TITLE,
label : 'ROOT ACCOUNT',
id: 0,
number: 0,
type_id: Constants.accounts.TITLE,
label: 'ROOT ACCOUNT',
};
vm.rootAccount.hrlabel = Accounts.label(vm.rootAccount);

/** @todo design how these are served for stores */
vm.notFound = {
status : 404,
code : 'ERRORS.NOT_FOUND',
status: 404,
code: 'ERRORS.NOT_FOUND',
};

settupPage()
Expand Down Expand Up @@ -196,6 +196,12 @@ function AccountEditController(
return;
}

var number = parseInt(vm.account.number, 10);
if (number === 0) {
Notify.danger('ACCOUNT.NOT_0_AS_ACCOUNT_NOMBER');
return;
}

// this will return all elements if requireDirty is set to false
var submit = util.filterFormElements(accountForm, requireDirty);

Expand All @@ -211,8 +217,8 @@ function AccountEditController(
}

function handleAccountCreateState() {
submit.classe = submit.number.substr(0,1);
submit.classe = submit.number.substr(0, 1);

return Accounts.create(submit)
.then(handleAccountCreateResult)
.catch(handleModalError);
Expand Down Expand Up @@ -282,7 +288,9 @@ function AccountEditController(
}

function getTypeTitle(typeId) {
if (!typeStore) { return null; }
if (!typeStore) {
return null;
}
return typeStore.get(typeId).translation_key;
}

Expand Down Expand Up @@ -314,4 +322,4 @@ function AccountEditController(
function handleModalError(error) {
vm.fetchError = error;
}
}
}

0 comments on commit d386f37

Please sign in to comment.