Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Changed validation to work on inventory received screen
Browse files Browse the repository at this point in the history
Fixes #139
  • Loading branch information
jkleinsc committed Jul 14, 2015
1 parent 31ce852 commit 66b4005
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions app/models/inventory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import AbstractModel from "hospitalrun/models/abstract";

var validateIfNewItem = {
if: function validateNewItem(object) {
var skipSavePurchase = object.get('skipSavePurchase');
//Only validate on new items and only if we are saving a purchase.
return (!skipSavePurchase && object.get('isNew'));
}
};
export default AbstractModel.extend({
purchases: DS.hasMany('inv-purchase'),
locations: DS.hasMany('inv-location'),
Expand All @@ -26,31 +32,21 @@ export default AbstractModel.extend({
presence: true,
},
purchaseCost: {
numericality: {
if: function(object) {
//Only validate on new items
return (object.get('isNew'));
}
}
numericality: validateIfNewItem
},
name: {
presence: true,
},
quantity: {
numericality: true
numericality: validateIfNewItem
},
price: {
numericality: {
allowBlank: true
}
},
originalQuantity: {
presence: {
if: function(object) {
//Only validate on new items
return (object.get('isNew'));
}
}
presence: validateIfNewItem
},
reorderPoint: {
numericality: {
Expand All @@ -61,12 +57,7 @@ export default AbstractModel.extend({
presence: true,
},
vendor: {
presence: {
if: function(object) {
//Only validate on new items
return (object.get('isNew'));
}
}
presence: validateIfNewItem
}
},

Expand Down

0 comments on commit 66b4005

Please sign in to comment.