Skip to content

Commit

Permalink
perf(modal): rewrtting lot configurtion configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
DedrickEnc committed Oct 19, 2017
1 parent 31db14a commit a610210
Show file tree
Hide file tree
Showing 13 changed files with 344 additions and 343 deletions.
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ SESS_SECRET='XopEn BlowFISH'
SESS_RESAVE=0
SESS_UNSET='destroy'

LOG_LEVEL='warn'
# LOG_LEVEL='debug'
# LOG_LEVEL='warn'
LOG_LEVEL='debug'

UPLOAD_DIR='client/upload'

Expand Down
4 changes: 0 additions & 4 deletions client/src/modules/stock/StockForm.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,10 @@ function StockFormService(StockItem, Store, AppCache, Session, $timeout) {
*/
StockForm.prototype.addItems = function addItems(n) {
var elt;
// var idx;
// var self = this;

// will repeat will n > 0
while (n--) {
elt = new StockItem();
// idx = this.store.data.length;
// elt.index = idx ? idx + 1 : idx;
elt.index = this.store.data.length;
this.store.post(elt);
}
Expand Down
44 changes: 14 additions & 30 deletions client/src/modules/stock/StockItem.service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('bhima.services')
.service('StockItemService', StockItemService);
.service('StockItemService', StockItemService);

StockItemService.$inject = [];

Expand All @@ -11,36 +11,20 @@ function StockItemService() {
* @constructor StockItem
*/
function StockItem() {
var self = this;

// index
self.index = 0;

// inventory
self.inventory_uuid = null;
self.code = null;
self.text = null;

// lot
self.lot_uuid = null;
self.label = null;
self.quantity = 0;
self.available = 0;
self.unit_price = 0;
self.amount = 0;
self.expiration_date = null;

// lots
self.lots = [];

// validation
self.validation = function () {
self.no_missing = self.inventory_uuid && self.lot_uuid &&
self.quantity && self.expiration_date &&
self.quantity <= self.available;
};
this.inventory_uuid = null;
this.code = null;
this.label = null;
this.quantity = 0;
this.unit_cost = 0;
this.expiration_date = new Date();
this.lots = [];
this.isValid = false;

this.validate();
}

self.validation();
StockItem.prototype.validate = function validate() {
this.isValid = this.inventory_uuid && this.lots.length > 0 && this.code;
}

return StockItem;
Expand Down
Loading

0 comments on commit a610210

Please sign in to comment.