Skip to content

Commit

Permalink
fix(inventory): account select validation
Browse files Browse the repository at this point in the history
This commit fixes the validation on the `bhAccountSelect`s for inventory
group accounts.  Only the sales account is required.  If it is left
blank, a validation message is shown.
  • Loading branch information
jniles committed Dec 5, 2017
1 parent 18d811b commit 2daca84
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ PORT=8080
DB_HOST='localhost'
DB_USER='bhima'
DB_PASS='HISCongo2013'
DB_NAME='bhima_test'
DB_NAME='bhima-empty-v1'

# session variables
SESS_SECRET='XopEn BlowFISH'

DEBUG=db
DEBUG=app

# Amazon S3 Creds
S3_ACCESS_KEY_ID=""
Expand Down
69 changes: 34 additions & 35 deletions client/src/modules/inventory/configuration/groups/groups.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
angular.module('bhima.controllers')
.controller('InventoryGroupsController', InventoryGroupsController);
.controller('InventoryGroupsController', InventoryGroupsController);

// dependencies injection
InventoryGroupsController.$inject = [
'$translate', 'InventoryGroupService', 'AccountService',
'NotifyService', 'ModalService', 'Store'
'NotifyService', 'ModalService', 'Store',
];

/**
* Inventory Group Controller ]
* This controller is responsible for handling inventory group module
*/
function InventoryGroupsController($translate, InventoryGroup, Account, Notify, Modal, Store) {
var vm = this, AccountStore;
var vm = this;
var AccountStore;

/** global variables */
vm.created = false;
Expand All @@ -26,18 +27,24 @@ function InventoryGroupsController($translate, InventoryGroup, Account, Notify,
// startup
startup();

function handler(err) {
if (err) {
Notify.handleError(err);
}
}

/** add inventory group */
function addInventoryGroup() {
var request = { action : 'add' };

Modal.openInventoryGroupActions(request)
.then(function (res) {
if (res.uuid) {
Notify.success('FORM.INFO.CREATE_SUCCESS');
}
})
.then(startup)
.catch(Notify.handleError);
.then(function (res) {
if (res.uuid) {
Notify.success('FORM.INFO.CREATE_SUCCESS');
}
})
.then(startup)
.catch(handler);
}

/** edit inventory group */
Expand All @@ -49,37 +56,31 @@ function InventoryGroupsController($translate, InventoryGroup, Account, Notify,
Notify.success('FORM.INFO.UPDATE_SUCCESS');
})
.then(startup)
.catch(function (err) {
if (err) {
Notify.handleError(err);
}
});
.catch(handler);
}

/** delete inventory group */
function deleteInventoryGroup(id) {
Modal.confirm('FORM.DIALOGS.CONFIRM_DELETE')
.then(function (bool) {
// if the user clicked cancel, reset the view and return
if (!bool) {
.then(function (bool) {
// if the user clicked cancel, reset the view and return
if (!bool) {
vm.view = 'default';
return;
}
// if we get there, the user wants to delete
InventoryGroup.remove(id)
.then(function () {
Notify.success('FORM.INFO.DELETE_SUCCESS');
startup();
return;
})
.catch(Notify.handleError);
});
}
// if we get there, the user wants to delete
InventoryGroup.remove(id)
.then(function () {
Notify.success('FORM.INFO.DELETE_SUCCESS');
startup();
return;
})
.catch(Notify.handleError);
});
}


/** init the module */
function startup() {

// initializes inventory group list with associate accounts
Account.read()
.then(handleAccountList)
Expand All @@ -101,11 +102,11 @@ function InventoryGroupsController($translate, InventoryGroup, Account, Notify,
AccountStore.get(group.stock_account).number : '';

// sales account
group.saleAccountNumber = AccountStore.get(group.sales_account) ?
group.saleAccountNumber = AccountStore.get(group.sales_account) ?
AccountStore.get(group.sales_account).number : '';

// charge account
group.cogsAccountNumber = AccountStore.get(group.cogs_account) ?
group.cogsAccountNumber = AccountStore.get(group.cogs_account) ?
AccountStore.get(group.cogs_account).number : '';
});

Expand All @@ -114,10 +115,8 @@ function InventoryGroupsController($translate, InventoryGroup, Account, Notify,
return list;
}

function readInventoryGroup(){
function readInventoryGroup() {
return InventoryGroup.read(null, { include_members : 1 });
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
name="sales_account"
id="sales_account"
account-id="$ctrl.session.sales_account"
validation-trigger="ActionForm.$submitted"
exclude-title-accounts="true"
on-select-callback="$ctrl.onSelectSalesAccount(account)">
(<span translate>FORM.LABELS.SALE</span>)
Expand All @@ -52,6 +53,7 @@
id="stock_account"
account-id="$ctrl.session.stock_account"
exclude-title-accounts="true"
required="false"
on-select-callback="$ctrl.onSelectStockAccount(account)">
(<span translate>FORM.LABELS.STOCK</span>)
<bh-clear on-clear="$ctrl.session.stock_account = null;"></bh-clear>
Expand All @@ -62,6 +64,7 @@
id="cogs_account"
account-id="$ctrl.session.cogs_account"
exclude-title-accounts="true"
required="false"
on-select-callback="$ctrl.onSelectCOGSAccount(account)">
(<span translate>FORM.LABELS.CHARGE</span>)
<bh-clear on-clear="$ctrl.session.cogs_account = null;"></bh-clear>
Expand Down
Empty file modified sh/build-init-database.sh
100644 → 100755
Empty file.

0 comments on commit 2daca84

Please sign in to comment.