Chore: Major variable renaming from python style underscores to camel case.

Chore: Replace undefined checks with angular.isUndefined
This commit is contained in:
Amritanshu committed 2014-06-06 16:09:32 +05:30
1 parent 358b235d8f
commit f667481d71
50 files changed
+481 -563

No files matched your search

+2 -2
View File
@@ -20,7 +20,7 @@
<div class="col-md-10">
<select id="ddlType" class="form-control" ng-model="account.Type"
ng-options="l.AccountTypeID as l.Name for l in account_types"> </select>
ng-options="l.AccountTypeID as l.Name for l in accountTypes"> </select>
</div>
</div>
@@ -41,7 +41,7 @@
<div class="col-md-10">
<select id="ddlCostCenter" class="form-control" ng-model="account.CostCenter.CostCenterID"
ng-options="l.CostCenterID as l.Name for l in cost_centers"> </select>
ng-options="l.CostCenterID as l.Name for l in costCenters"> </select>
</div>
</div>
+1 -1
View File
@@ -39,7 +39,7 @@
<td>{{item.Department}}</td>
<td>
<select class="form-control" ng-model="item.AttendanceTypeID"
ng-options="i.AttendanceTypeID as i.Name for i in attendance_types"></select>
ng-options="i.AttendanceTypeID as i.Name for i in attendanceTypes"></select>
</td>
<td class="no-bg">{{item.Prints}}
<span ng-show="item.Hours.length > 0"
@@ -5,7 +5,7 @@
<label for="txtName" class="col-md-2 control-label">Name</label>
<div class="col-md-10">
<input type="text" id="txtName" class="form-control" ng-model="cost_center.Name"/>
<input type="text" id="txtName" class="form-control" ng-model="costCenter.Name"/>
</div>
</div>
<div class="form-group">
@@ -54,7 +54,7 @@
<td>{{item.Date}}</td>
<td>
<select name="box" class="form-control" ng-model="item.AttendanceTypeID"
ng-options="i.AttendanceTypeID as i.Name for i in attendance_types"> </select>
ng-options="i.AttendanceTypeID as i.Name for i in attendanceTypes"> </select>
</td>
<td class="no-bg">{{item.Prints}} <span ng-show="item.Hours.length > 0"
+1 -1
View File
@@ -50,7 +50,7 @@
<div class="col-md-10">
<select id="ddlCostCenter" class="form-control" ng-model="employee.CostCenter.CostCenterID"
ng-options="l.CostCenterID as l.Name for l in cost_centers"> </select>
ng-options="l.CostCenterID as l.Name for l in costCenters"> </select>
</div>
</div>
+2 -2
View File
@@ -30,12 +30,12 @@
</div>
<div class="col-md-3" ng-repeat="journal in voucher.Journals | journalDebit:-1">
<select id="ddlSourceCostCenter" class="form-control" ng-model="journal.CostCenter.CostCenterID"
ng-options="l.CostCenterID as l.Name for l in cost_centers"> </select>
ng-options="l.CostCenterID as l.Name for l in costCenters"> </select>
</div>
<div class="col-md-5" ng-repeat="journal in voucher.Journals | journalDebit:1">
<div class="input-group">
<select id="ddlDestinationCostCenter" class="form-control" ng-model="journal.CostCenter.CostCenterID"
ng-options="l.CostCenterID as l.Name for l in cost_centers"> </select>
ng-options="l.CostCenterID as l.Name for l in costCenters"> </select>
<span class="input-group-addon">₹</span>
<input type="text" class="form-control" placeholder="Amount" value="{{journal.Amount | number:2}}"/>
</div>
+1 -1
View File
@@ -63,7 +63,7 @@
<div class="col-md-10">
<select id="ddlType" class="form-control" ng-model="product.ProductGroup.ProductGroupID"
ng-options="l.ProductGroupID as l.Name for l in product_groups"> </select>
ng-options="l.ProductGroupID as l.Name for l in productGroups"> </select>
</div>
</div>
@@ -5,7 +5,7 @@
<label for="txtName" class="col-md-2 control-label">Name</label>
<div class="col-md-10">
<input type="text" id="txtName" class="form-control" ng-model="product_group.Name"/>
<input type="text" id="txtName" class="form-control" ng-model="productGroup.Name"/>
</div>
</div>
<div class="form-group">
+3 -3
View File
@@ -15,7 +15,7 @@
<th class="text-right">Code</th>
<th>Name</th>
<th class="text-right">Price</th>
<th ng-if="show_extended" class="text-right">Yield</th>
<th ng-if="showExtended" class="text-right">Yield</th>
<th>Type</th>
<th>Is Active?</th>
</tr>
@@ -23,9 +23,9 @@
<tbody>
<tr ng-repeat="item in products">
<td class="text-right">{{item.Code}}</td>
<td><a href="{{item.Url}}">{{item.Name}} ({{show_extended ? item.Fraction + ' ' + item.FractionUnits + ' = 1 ' : ''}}{{item.Units}})</a></td>
<td><a href="{{item.Url}}">{{item.Name}} ({{showExtended ? item.Fraction + ' ' + item.FractionUnits + ' = 1 ' : ''}}{{item.Units}})</a></td>
<td class="text-right">{{item.Price | currency}}</td>
<td ng-if="show_extended" class="text-right">{{item.ProductYield * 100 | number:2}}%</td>
<td ng-if="showExtended" class="text-right">{{item.ProductYield * 100 | number:2}}%</td>
<td>{{item.ProductGroup}}</td>
<td>{{item.IsActive}}</td>
</tr>
+2 -2
View File
@@ -20,7 +20,7 @@
</div>
</div>
<div class="col-md-2">
<p class="form-control-static">{{cost_price | currency}} / {{cost_price * 100 / recipe.SalePrice | number:2 }}%</p>
<p class="form-control-static">{{costPrice | currency}} / {{costPrice * 100 / recipe.SalePrice | number:2 }}%</p>
</div>
</div>
<div class="form-group">
@@ -47,7 +47,7 @@
</div>
<div class="col-md-4" ng-hide="recipe.IsSemi">
<select id="ddlType" class="form-control" ng-model="recipe.ProductGroup.ProductGroupID"
ng-options="l.ProductGroupID as l.Name for l in product_groups"> </select>
ng-options="l.ProductGroupID as l.Name for l in productGroups"> </select>
</div>
</div>
<div class="form-group">
+10 -10
View File
@@ -13,20 +13,20 @@
<div class="form-group">
<div class="col-md-offset-2 col-md-2">
<select class="form-control" ng-model="product_type_selected">
<select class="form-control" ng-model="productTypeSelected">
<option value="semi">Semi Products</option>
<option value="menu">Menu Items</option>
<option value="all">All</option>
</select>
</div>
<div class="col-md-3">
<select class="form-control" ng-model="show_latest">
<select class="form-control" ng-model="showLatest">
<option value="latest">Only Latest Recipes</option>
<option value="all">All Recipes</option>
</select>
</div>
<div class="col-md-3">
<select class="form-control" ng-model="show_summary">
<select class="form-control" ng-model="showSummary">
<option value="no">Brief</option>
<option value="yes">With Recipes</option>
</select>
@@ -36,25 +36,25 @@
<thead>
<tr>
<th>Name</th>
<th ng-if="show_summary === 'no'">Date</th>
<th ng-if="showSummary === 'no'">Date</th>
<th class="text-right">Sale Price</th>
<th class="text-right">Original Cost</th>
<th class="text-right" ng-if="show_summary === 'no'">Current Cost</th>
<th class="text-right" ng-if="showSummary === 'no'">Current Cost</th>
<th class="text-right">Original Costing</th>
<th class="text-right" ng-if="show_summary === 'no'">Current Costing</th>
<th class="text-right" ng-if="showSummary === 'no'">Current Costing</th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="item in display">
<td><a ng-if="item.IsLatest" href="{{item.Url}}">{{item.Name}} ({{item.Units}})</a></td>
<td ng-if="show_summary === 'no'">{{item.Date}}</td>
<td ng-if="showSummary === 'no'">{{item.Date}}</td>
<td class="text-right">{{item.IsSemi ? '' : (item.SalePrice | currency)}}</td>
<td class="text-right">{{item.CostPrice | currency}}</td>
<td class="text-right" ng-if="show_summary === 'no'">{{item.CurrentCostPrice | currency}}</td>
<td class="text-right" ng-if="showSummary === 'no'">{{item.CurrentCostPrice | currency}}</td>
<td class="text-right">{{item.IsSemi ? '' : (item.Costing | percent)}}</td>
<td class="text-right" ng-if="show_summary === 'no'">{{item.IsSemi ? '' : (item.CurrentCosting | percent)}}</td>
<td class="text-right" ng-if="showSummary === 'no'">{{item.IsSemi ? '' : (item.CurrentCosting | percent)}}</td>
</tr>
<tr ng-repeat-end ng-if="show_summary === 'yes'">
<tr ng-repeat-end ng-if="showSummary === 'yes'">
<td colspan="7">
<table class="table table-condensed table-striped">
<thead>
+6 -6
View File
@@ -14,13 +14,13 @@ var AccountListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'acco
$scope.searchInfo = {
comparator: {
'def': 'n',
'n': {'Col': 'Name', 'Comparator': 'text'},
't': {'Col': 'Type', 'Comparator': 'text'},
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
'r': {'Col': 'IsReconcilable', 'Comparator': 'boolean'},
'c': {'Col': 'CostCenter', 'Comparator': 'text'}
},
def: 'n',
sorter: {
'n': 'Name',
't': 'Type',
@@ -51,11 +51,11 @@ AccountListCtrl.resolve = {
}]
};
var AccountCtrl = ['$scope', '$location', '$modal', 'account', 'account_types', 'cost_centers', function ($scope, $location, $modal, account, account_types, cost_centers) {
var AccountCtrl = ['$scope', '$location', '$modal', 'account', 'accountTypes', 'costCenters', function ($scope, $location, $modal, account, accountTypes, costCenters) {
$scope.account = account;
$scope.account_types = account_types;
$scope.cost_centers = cost_centers;
$scope.accountTypes = accountTypes;
$scope.costCenters = costCenters;
$scope.save = function () {
$scope.account.$save(function (u, putResponseHeaders) {
@@ -103,10 +103,10 @@ AccountCtrl.resolve = {
var id = $route.current.params.id;
return Account.get({id: id}).$promise;
}],
account_types: ['AccountType', function (AccountType) {
accountTypes: ['AccountType', function (AccountType) {
return AccountType.query({}).$promise;
}],
cost_centers: ['CostCenter', function (CostCenter) {
costCenters: ['CostCenter', function (CostCenter) {
return CostCenter.query({}).$promise;
}]
};
+1 -1
View File
@@ -94,7 +94,7 @@ overlord_directive.directive('chosen', ['$parse', function ($parse) {
createFunction = attrs['createFunction'],
options = {};
if (typeof createFunction !== 'undefined') {
if (angular.isUndefined(createFunction)) {
options['create_option'] = function (data) {
var fn = $parse(attrs['createFunction'] + '("' + data + '")');
scope.$apply(function () {
+8 -2
View File
@@ -35,7 +35,7 @@ overlord_filter.filter('save_button', function () {
overlord_filter.filter('journalDebit', function () {
return function (input, debit) {
var list = [];
if (typeof input !== 'undefined') {
if (angular.isUndefined(input)) {
for (var i = 0, l = input.length; i < l; i++) {
if (input[i].Debit === debit) {
list.push(input[i]);
@@ -83,7 +83,7 @@ overlord_filter.filter('localTime', function () {
}
return function (input) {
if (typeof input === 'undefined') {
if (angular.isUndefined(input)) {
return '';
}
var d = input.match(/(\w+)/g);
@@ -106,6 +106,12 @@ overlord_filter.filter('percent', ['numberFilter', function (numberFilter) {
};
}]);
overlord_filter.filter('asDate', ['dateFilter', function (dateFilter) {
return function (input) {
return angular.isDate(input) ? dateFilter(input, 'dd-MMM-yyyy') : input
};
}]);
overlord_filter.filter('clr', function () {
return function (input) {
if (input === '\u20B9\u00A00.00' || input === '0.00') {
+100 -36
View File
@@ -252,35 +252,77 @@ overlord_service.service('EventSource', function () {
}, false);
};
this.source.addEventListener('error', function (e) {
if (e.readyState == EventSource.CLOSED) {
if (e.readyState === EventSource.CLOSED) {
this.status = 'Error';
}
}, false);
this.ErrorCallback = function (callback) {
this.source.addEventListener('error', callback, false);
}
};
this.EventCallback = function (event, callback) {
this.source.addEventListener(event, callback, false);
}
};
this.Close = function () {
if (this.status === 'Open') {
this.source.close();
this.status = 'Closed'
}
this.status = 'Closed';
}
};
});
overlord_service.factory('Tokenizer', ['$filter', function ($filter) {
var parseFilterString = function (q, searchInfo) {
var re = /((([^ ]+):\s*('[^':]+'|"[^":]+"|[^ ]+))|[^ ]+[^: '"]*)/g,
comparator = searchInfo.comparator,
sorter = searchInfo.sorter,
defaultKey = comparator[comparator.def],
// '[^']+'|"[^"]+"|[^ ]+ == Match a space delimited string or quoted string. ms for short
// ((ms\s*:\s*ms)|ms) == Match string : Match string OR Match string
var re = /((('[^']+'|"[^"]+"|[^\s]+)\s*:\s*('[^']+'|"[^"]+"|[^\s]+))|('[^']+'|"[^"]+"|[^\s]+))/g,
comparator = searchInfo.comparator || {},
sorter = searchInfo.sorter || {},
flagger = searchInfo.flags || {},
defaultKey = searchInfo.def,
matches = [],
sorting = [],
flags = {};
flags = {},
operators = {
'<': function (a, b) {
return a < b;
},
'>': function (a, b) {
return a > b;
},
'<=': function (a, b) {
return a <= b;
},
'>=': function (a, b) {
return a >= b;
},
'==': function (a, b) {
return a == b;
},
'!=': function (a, b) {
return a != b;
}
},
comparators = {
'text': function (obj, text) {
return obj.toLowerCase().indexOf(text) > -1;
},
'boolean': function (obj, text) {
return obj === isTrue(text);
},
'numeric': function (obj, text) {
var op = opLength(text);
if (op) {
return operators[text.substr(0, op)](obj, Number(text.substr(op).trim()));
} else {
return obj.toString().indexOf(text) > -1;
}
},
'true': function (obj, text) {
return true;
}
};
function isTrue(value) {
@@ -289,39 +331,61 @@ overlord_service.factory('Tokenizer', ['$filter', function ($filter) {
});
}
function is(ch, chars) {
return chars.indexOf(ch) !== -1;
}
function pushObject(comparator, value) {
return {'Col': comparator.Col, 'Comparator': comparators[comparator.Comparator], 'Value': value};
}
var comparators = {
'text': function (obj, text) {
return obj.toLowerCase().indexOf(text) > -1;
},
'boolean': function (obj, text) {
return obj === isTrue(text);
},
'true': function (obj, text) {
return true;
}
};
var m = q.match(re);
_.forEach(m, function (item) {
item = item.trim();
function toArray(matches) {
return _.reduce(matches, function (accumulator, item) {
var key,
value;
if (item.indexOf(':') === -1) {
if ((item.length > 1) && (item.charAt(0) === '+' || item.charAt(0) === '-') && (item.substr(1) in sorter)) {
sorting.push(item.charAt(0) + sorter[item.substr(1).toLowerCase()]);
} else if (item.length >= 1 && item.charAt(0) !== '+' && item.charAt(0) !== '-') {
matches.push(pushObject(defaultKey, item));
}
key = '';
value = item;
} else {
var key = item.substr(0, item.indexOf(':')).toLowerCase();
var value = item.substr(item.indexOf(':') + 1, item.length).trim().toLowerCase();
if (value.indexOf("'") !== -1 || value.indexOf('"') !== -1) {
value = value.substring(1, value.length - 1).trim();
key = item.substr(0, item.indexOf(':')).trim();
value = item.substr(item.indexOf(':') + 1, item.length).trim();
}
if (key !== '' && value !== '' && key in comparator) {
if (key.indexOf("'") !== -1 || key.indexOf('"') !== -1) {
key = key.substring(1, key.length - 1).trim();
}
if (value.indexOf("'") !== -1 || value.indexOf('"') !== -1) {
value = key.substring(1, value.length - 1).trim();
}
if (value !== '') {
accumulator.push({Key: key, Value: value});
}
return accumulator;
}, []);
}
function opLength(operator) {
var i,
ops = ['<=', '<', '>=', '>', '==', '!='];
for (i = 0; i < ops.length; i++) {
if (operator.indexOf(ops[i]) == 0) {
return ops[i].length;
}
}
return 0;
}
_(q.match(re))
_.forEach(toArray(q.match(re)), function (item) {
var key = item.Key,
value = item.Value;
if (key === '' && value.length > 1 && is(value.charAt(0), '+-') && value.substr(1) in sorter) {
sorting.push(value.charAt(0) + sorter[value.substr(1).toLowerCase()]);
} else {
key = key || defaultKey;
if (key in comparator) {
matches.push(pushObject(comparator[key], value));
} else if (key !== '' && !angular.isUndefined(searchInfo.flags) && key in searchInfo.flags) {
} else if (key in flagger) {
flags[key] = value;
}
}
@@ -389,7 +453,7 @@ overlord_service.factory("ReaderPromise", ["$q", function ($q) {
};
}]);
overlord_service.factory("UploadedImageResizer", ["$q", "ReaderPromise", function ($q, ReaderPromise) {
overlord_service.factory("uploadedImageResizer", ["$q", "ReaderPromise", function ($q, ReaderPromise) {
function ResizeImage(file, MAX_WIDTH, MAX_HEIGHT) {
var image = file,
canvas = document.createElement('canvas'),
+6 -10
View File
@@ -1,18 +1,14 @@
'use strict';
var AttendanceCtrl = ['$scope', '$location', 'dateFilter', 'Attendance', 'attendance_types', 'info', function ($scope, $location, dateFilter, Attendance, attendance_types, info) {
$scope.attendance_types = attendance_types;
var AttendanceCtrl = ['$scope', '$location', 'asDateFilter', 'Attendance', 'attendanceTypes', 'info', function ($scope, $location, asDate, Attendance, attendanceTypes, info) {
$scope.attendanceTypes = attendanceTypes;
$scope.info = info;
$scope.show = function () {
if (angular.isDate($scope.info.Date)) {
$scope.info.Date = dateFilter($scope.info.Date, 'dd-MMM-yyyy');
}
$scope.info.Date = asDate($scope.info.Date);
$location.path('/Attendance/' + $scope.info.Date);
};
$scope.save = function () {
if (angular.isDate($scope.info.Date)) {
$scope.info.Date = dateFilter($scope.info.Date, 'dd-MMM-yyyy');
}
$scope.info.Date = asDate($scope.info.Date);
return $scope.info.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: u.Code});
}, function (data, status) {
@@ -50,13 +46,13 @@ var AttendanceSubCtrl = ['$scope', function ($scope) {
AttendanceCtrl.resolve = {
info: ['$route', 'Attendance', function ($route, Attendance) {
var date = $route.current.params.date;
if (typeof date === 'undefined') {
if (angular.isUndefined(date)) {
return Attendance.get({}).$promise;
} else {
return Attendance.get({date: date}).$promise;
}
}],
attendance_types: ['AttendanceTypes', function (AttendanceTypes) {
attendanceTypes: ['AttendanceTypes', function (AttendanceTypes) {
return AttendanceTypes.query({}).$promise;
}]
};
+4 -6
View File
@@ -1,12 +1,10 @@
'use strict';
var BalanceSheetCtrl = ['$scope', '$location', 'dateFilter', 'info', function ($scope, $location, dateFilter, info) {
var BalanceSheetCtrl = ['$scope', '$location', 'asDateFilter', 'info', function ($scope, $location, asDate, info) {
$scope.info = info;
$scope.show = function () {
if (angular.isDate($scope.info.Date)) {
$scope.info.Date = dateFilter($scope.info.Date, 'dd-MMM-yyyy');
}
$location.path('/BalanceSheet/' + $scope.info.Date);
var date = asDate($scope.info.Date);
$location.path('/BalanceSheet/' + date);
};
$('#txtStartDate').focus();
}];
@@ -15,7 +13,7 @@ BalanceSheetCtrl.resolve = {
info: ['$route', 'BalanceSheet', function ($route, BalanceSheet) {
var date = $route.current.params.date;
if (typeof date === 'undefined') {
if (angular.isUndefined(date)) {
return BalanceSheet.get({}).$promise;
} else {
return BalanceSheet.get({date: date}).$promise;
+12 -16
View File
@@ -1,30 +1,26 @@
'use strict';
var CashFlowCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'cash_flow', function ($scope, $routeParams, $location, dateFilter, cash_flow) {
$scope.info = cash_flow;
var CashFlowCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'cashFlow', function ($scope, $routeParams, $location, asDate, cashFlow) {
$scope.info = cashFlow;
$scope.show = function () {
if (angular.isDate($scope.info.StartDate)) {
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.info.FinishDate)) {
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
}
$location.path('/CashFlow').search({StartDate:$scope.info.StartDate, FinishDate:$scope.info.FinishDate});
var startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
$location.path('/CashFlow').search({StartDate: startDate, FinishDate: finishDate});
};
$('#txtStartDate').focus();
}];
CashFlowCtrl.resolve = {
cash_flow:['$route', 'CashFlow', function ($route, CashFlow) {
cashFlow: ['$route', 'CashFlow', function ($route, CashFlow) {
var id = $route.current.params.id,
start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
if (angular.isUndefined(startDate) || angular.isUndefined(finishDate)) {
return CashFlow.get({}).$promise;
} else if (typeof id === 'undefined') {
return CashFlow.get({StartDate:start_date, FinishDate:finish_date}).$promise;
} else if (angular.isUndefined(id)) {
return CashFlow.get({StartDate: startDate, FinishDate: finishDate}).$promise;
} else {
return CashFlow.get({id:id, StartDate:start_date, FinishDate:finish_date}).$promise;
return CashFlow.get({id: id, StartDate: startDate, FinishDate: finishDate}).$promise;
}
}]
};
+4 -6
View File
@@ -1,12 +1,10 @@
'use strict';
var ClosingStockCtrl = ['$scope', '$location', 'dateFilter', 'info', function ($scope, $location, dateFilter, info) {
var ClosingStockCtrl = ['$scope', '$location', 'asDateFilter', 'info', function ($scope, $location, asDate, info) {
$scope.info = info;
$scope.show = function () {
if (angular.isDate($scope.info.Date)) {
$scope.info.Date = dateFilter($scope.info.Date, 'dd-MMM-yyyy');
}
$location.path('/ClosingStock/' + $scope.info.Date);
var date = asDate($scope.info.Date);
$location.path('/ClosingStock/' + date);
};
$('#txtDate').focus();
}];
@@ -15,7 +13,7 @@ ClosingStockCtrl.resolve = {
info: ['$route', 'ClosingStock', function ($route, ClosingStock) {
var date = $route.current.params.date;
if (typeof date === 'undefined') {
if (angular.isUndefined(date)) {
return ClosingStock.get({}).$promise;
} else {
return ClosingStock.get({date: date}).$promise;
+8 -9
View File
@@ -1,20 +1,20 @@
'use strict';
var CostCenterListCtrl = ['$scope', 'cost_centers', function ($scope, cost_centers) {
$scope.info = cost_centers;
var CostCenterListCtrl = ['$scope', 'costCenters', function ($scope, costCenters) {
$scope.info = costCenters;
}];
CostCenterListCtrl.resolve = {
cost_centers: ['CostCenter', function (CostCenter) {
costCenters: ['CostCenter', function (CostCenter) {
return CostCenter.query({}).$promise;
}]
};
var CostCenterCtrl = ['$scope', '$routeParams', '$location', 'cost_center', function ($scope, $routeParams, $location, cost_center) {
$scope.cost_center = cost_center;
var CostCenterCtrl = ['$scope', '$routeParams', '$location', 'costCenter', function ($scope, $routeParams, $location, costCenter) {
$scope.costCenter = costCenter;
$scope.save = function () {
$scope.cost_center.$save(function (u, putResponseHeaders) {
$scope.costCenter.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/CostCenters')
}, function (data, status) {
@@ -23,7 +23,7 @@ var CostCenterCtrl = ['$scope', '$routeParams', '$location', 'cost_center', func
};
$scope.delete = function () {
$scope.cost_center.$delete(function (u, putResponseHeaders) {
$scope.costCenter.$delete(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/CostCenters')
}, function (data, status) {
@@ -34,9 +34,8 @@ var CostCenterCtrl = ['$scope', '$routeParams', '$location', 'cost_center', func
}];
CostCenterCtrl.resolve = {
cost_center: ['$route', 'CostCenter', function ($route, CostCenter) {
costCenter: ['$route', 'CostCenter', function ($route, CostCenter) {
var id = $route.current.params.id;
return CostCenter.get({id: id}).$promise;
}]
};
+8 -12
View File
@@ -1,27 +1,23 @@
'use strict';
var DaybookCtrl = ['$scope', '$location', 'dateFilter', 'info', function ($scope, $location, dateFilter, info) {
var DaybookCtrl = ['$scope', '$location', 'asDateFilter', 'info', function ($scope, $location, asDate, info) {
$scope.info = info;
$scope.show = function () {
if (angular.isDate($scope.info.StartDate)) {
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.info.FinishDate)) {
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
}
$location.path('/Daybook').search({StartDate:$scope.info.StartDate, FinishDate:$scope.info.FinishDate});
var startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
$location.path('/Daybook').search({StartDate: startDate, FinishDate: finishDate});
};
$('#txtStartDate').focus();
}];
DaybookCtrl.resolve = {
info: ['$route', 'Daybook', function ($route, Daybook) {
var start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
var startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
if (angular.isUndefined(startDate) || angular.isUndefined(finishDate)) {
return Daybook.get({}).$promise;
} else {
return Daybook.get({StartDate:start_date, FinishDate:finish_date}).$promise;
return Daybook.get({StartDate: startDate, FinishDate: finishDate}).$promise;
}
}]
};
+12 -18
View File
@@ -1,25 +1,19 @@
'use strict';
var EmployeeAttendanceCtrl = ['$scope', '$location', '$routeParams', 'dateFilter', 'EmployeeAttendance', 'attendance_types', 'info', 'Employee', function ($scope, $location, $routeParams, dateFilter, EmployeeAttendance, attendance_types, info, Employee) {
$scope.attendance_types = attendance_types;
var EmployeeAttendanceCtrl = ['$scope', '$location', '$routeParams', 'asDateFilter', 'EmployeeAttendance', 'attendanceTypes', 'info', 'Employee', function ($scope, $location, $routeParams, asDate, EmployeeAttendance, attendanceTypes, info, Employee) {
$scope.attendanceTypes = attendanceTypes;
$scope.info = info;
$scope.show = function () {
var id = $scope.info.Employee.LedgerID;
if (angular.isDate($scope.info.StartDate)) {
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.info.FinishDate)) {
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
}
var start_date = $scope.info.StartDate;
var finish_date = $scope.info.FinishDate;
if (id == $routeParams.id && start_date == $routeParams.StartDate && finish_date == $routeParams.FinishDate) {
EmployeeAttendance.get({id: id, StartDate: start_date, FinishDate: finish_date}, function (data) {
var startDate = asDate($scope.info.StartDate);
var finishDate = asDate($scope.info.FinishDate);
if (id === $routeParams.id && startDate === $routeParams.StartDate && finishDate === $routeParams.FinishDate) {
EmployeeAttendance.get({id: id, StartDate: startDate, FinishDate: finishDate}, function (data) {
$scope.info = data;
});
}
else {
$location.path('/EmployeeAttendance/' + $scope.info.Employee.LedgerID).search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
$location.path('/EmployeeAttendance/' + id).search({StartDate: startDate, FinishDate: finishDate});
}
};
@@ -64,16 +58,16 @@ var EmployeeAttendanceSubCtrl = ['$scope', function ($scope) {
EmployeeAttendanceCtrl.resolve = {
info: ['$route', 'EmployeeAttendance', function ($route, EmployeeAttendance) {
var id = $route.current.params.id,
start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
return EmployeeAttendance.get({}).$promise;
} else {
return EmployeeAttendance.get({id: id, StartDate: start_date, FinishDate: finish_date}).$promise;
return EmployeeAttendance.get({id: id, StartDate: startDate, FinishDate: finishDate}).$promise;
}
}],
attendance_types: ['AttendanceTypes', function (AttendanceTypes) {
attendanceTypes: ['AttendanceTypes', function (AttendanceTypes) {
return AttendanceTypes.query({}).$promise;
}]
};
+6 -6
View File
@@ -1,14 +1,14 @@
'use strict';
var EmployeeFunctionsCtrl = ['$scope', '$http', 'dateFilter', function ($scope, $http, dateFilter) {
var EmployeeFunctionsCtrl = ['$scope', '$http', 'asDateFilter', function ($scope, $http, asDate) {
$scope.record = {};
$scope.creditSalary = function () {
if (!angular.isDate($scope.salaryMonth)) {
return;
}
var salary_month = dateFilter($scope.salaryMonth, 'dd-MMM-yyyy');
var SalaryMonth = asDate($scope.salaryMonth);
return $http.
post('/api/CreditSalary', {Month: salary_month}).
post('/api/CreditSalary', {Month: SalaryMonth}).
success(function (data) {
$scope.toasts.push({Type: 'Success', Message: data.message});
}).
@@ -21,10 +21,10 @@ var EmployeeFunctionsCtrl = ['$scope', '$http', 'dateFilter', function ($scope,
if (!$scope.record.StartDate || !$scope.record.FinishDate) {
return;
}
var start_date = angular.isDate($scope.record.StartDate) ? dateFilter($scope.record.StartDate, 'dd-MMM-yyyy') : $scope.record.StartDate;
var finish_date = angular.isDate($scope.record.FinishDate) ? dateFilter($scope.record.FinishDate, 'dd-MMM-yyyy') : $scope.record.FinishDate;
var startDate = asDate($scope.record.StartDate);
var finishDate = asDate($scope.record.FinishDate);
var url = '/AttendanceReport?StartDate=' + start_date + "&FinishDate=" + finish_date;
var url = '/AttendanceReport?StartDate=' + startDate + "&FinishDate=" + finishDate;
return url;
};
$scope.setFile = function (element) {
+32 -64
View File
@@ -1,6 +1,6 @@
'use strict';
var EmployeeListCtrl = ['$scope', '$location', '$routeParams', 'employees', function ($scope, $location, $routeParams, employees) {
var EmployeeListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'employees', function ($scope, $location, $routeParams, Tokenizer, employees) {
$scope.search = $routeParams.q || '';
$scope.info = employees;
var re = /((([^ ]+):\s*('[^':]+'|"[^":]+"|[^ ]+))|[^ ]+[^: '"]*)/g;
@@ -16,6 +16,29 @@ var EmployeeListCtrl = ['$scope', '$location', '$routeParams', 'employees', func
$scope.filterEmployees(newValue);
}, true);
$scope.$on('$destroy', function () {
Tokenizer.doFilter.cache = {};
});
$scope.searchInfo = {
comparator: {
'n': {'Col': 'Name', 'Comparator': 'text'},
'c': {'Col': 'Code', 'Comparator': 'numeric'},
's': {'Col': 'Salary', 'Comparator': 'numeric'},
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
'des': {'Col': 'Designation', 'Comparator': 'text'},
'dep': {'Col': 'CostCenter', 'Comparator': 'text'}
},
def: 'n',
sorter: {
'n': 'Name',
'c': 'Code',
's': 'Salary',
'a': 'IsActive',
'des': 'Designation',
'dep': 'CostCenter'
}
};
$scope.filterEmployees = _.debounce(function (q) {
if (q !== $scope._search) {
$scope._search = q;
@@ -25,62 +48,12 @@ var EmployeeListCtrl = ['$scope', '$location', '$routeParams', 'employees', func
$location.path('/Employees').search({'q': q}).replace();
}
$scope.$apply(function () {
$scope.employees = $scope.doFilter(q);
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo);
$scope.employees = Tokenizer.doFilter(q, $scope.info, matches);
});
}
}, 350);
$scope.doFilter = _.memoize(function (q) {
var matches = [], i, len;
if (angular.isUndefined(q) || q === '') {
return $scope.info;
}
var m = q.match(re);
_.forEach(m, function (item) {
item = item.toLowerCase();
if (item.indexOf(':') === -1) {
matches.push({'key': 'n', 'value': item});
} else {
var key = item.substr(0, item.indexOf(':')).toLowerCase();
var value = item.substr(item.indexOf(':') + 1, item.length).trim().toLowerCase();
if (value.indexOf("'") === 0 || value.indexOf('"') === 0) {
value = value.substring(1, value.length - 2);
}
if (key !== '' && value !== '' && _.any(['w', 'dep', 'des', 'c'], function (item) {
return item === key;
})) {
matches.push({'key': key, 'value': value});
}
}
});
return _.filter($scope.info, function (item) {
len = matches.length;
for (i = 0; i < len; i++) {
var match = matches[i];
if (match.key === 'n') {
if (item.Name.toLowerCase().indexOf(match.value) === -1) {
return false;
}
} else if (match.key === 'w') {
if (item.IsActive !== $scope.isTrue(match.value)) {
return false;
}
} else if (match.key === 'dep') {
if (item.CostCenter.toLowerCase().indexOf(match.value) === -1) {
return false;
}
} else if (match.key === 'des') {
if (item.Designation.toLowerCase().indexOf(match.value) === -1) {
return false;
}
} else if (match.key === 'c') {
if (item.Code.toString().indexOf(match.value) === -1) {
return false;
}
}
}
return true;
});
});
}];
EmployeeListCtrl.resolve = {
@@ -89,18 +62,14 @@ EmployeeListCtrl.resolve = {
}]
};
var EmployeeCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', '$modal', 'employee', 'cost_centers', function ($scope, $routeParams, $location, dateFilter, $modal, employee, cost_centers) {
var EmployeeCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', '$modal', 'employee', 'costCenters', function ($scope, $routeParams, $location, asDate, $modal, employee, costCenters) {
$scope.employee = employee;
$scope.cost_centers = cost_centers;
$scope.costCenters = costCenters;
$scope.save = function () {
if (angular.isDate($scope.employee.JoiningDate)) {
$scope.employee.JoiningDate = dateFilter($scope.employee.JoiningDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.employee.LeavingDate)) {
$scope.employee.LeavingDate = dateFilter($scope.employee.LeavingDate, 'dd-MMM-yyyy');
}
$scope.employee.JoiningDate = asDate($scope.employee.JoiningDate);
$scope.employee.LeavingDate = asDate($scope.employee.LeavingDate);
$scope.employee.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: u.Code});
$location.path('/Employees');
@@ -145,10 +114,9 @@ var EmployeeCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', '$modal
EmployeeCtrl.resolve = {
employee: ['$route', 'Employee', function ($route, Employee) {
var id = $route.current.params.id;
return Employee.get({id: id}).$promise;
}],
cost_centers: ['CostCenter', function (CostCenter) {
costCenters: ['CostCenter', function (CostCenter) {
return CostCenter.query({}).$promise;
}]
};
+5 -4
View File
@@ -1,6 +1,6 @@
'use strict';
var HomeCtrl = ['$scope', '$location', '$http', 'dateFilter', 'messages', 'dashboard', 'Message', function ($scope, $location, $http, dateFilter, messages, dashboard, Message) {
var HomeCtrl = ['$scope', '$location', '$http', 'asDateFilter', 'messages', 'dashboard', 'Message', function ($scope, $location, $http, asDate, messages, dashboard, Message) {
$scope.chosen = messages.Type;
$scope.dashboard = dashboard;
$scope.info = messages.Threads;
@@ -20,9 +20,9 @@ var HomeCtrl = ['$scope', '$location', '$http', 'dateFilter', 'messages', 'dashb
});
};
$scope.getDashboard = function () {
var start_date = angular.isDate($scope.dashboard.StartDate) ? dateFilter($scope.dashboard.StartDate, 'dd-MMM-yyyy') : $scope.dashboard.StartDate;
var finish_date = angular.isDate($scope.dashboard.FinishDate) ? dateFilter($scope.dashboard.FinishDate, 'dd-MMM-yyyy') : $scope.dashboard.FinishDate;
return $http({ method: 'GET', url: '/api/Dashboard', params: {s: start_date, f: finish_date}}).then(function (data, status, headers, config) {
var startDate = asDate($scope.dashboard.StartDate),
finishDate = asDate($scope.dashboard.FinishDate);
return $http({ method: 'GET', url: '/api/Dashboard', params: {s: startDate, f: finishDate}}).then(function (data, status, headers, config) {
$scope.dashboard = data.data;
formatData();
});
@@ -102,6 +102,7 @@ var HomeCtrl = ['$scope', '$location', '$http', 'dateFilter', 'messages', 'dashb
};
}
}
formatData();
}];
HomeCtrl.resolve = {
+25 -32
View File
@@ -1,11 +1,11 @@
'use strict';
var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher', 'cost_centers', 'issue_grid', 'IssueGrid', 'Voucher', '$modal', 'Batch', function ($scope, $routeParams, $location, dateFilter, voucher, cost_centers, issue_grid, IssueGrid, Voucher, $modal, Batch) {
var IssueCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'voucher', 'costCenters', 'smallGrid', 'IssueGrid', 'Voucher', '$modal', 'Batch', function ($scope, $routeParams, $location, asDate, voucher, costCenters, smallGrid, IssueGrid, Voucher, $modal, Batch) {
$scope.voucher = voucher;
$scope.cost_centers = cost_centers;
$scope.smallGrid = issue_grid;
$scope.costCenters = costCenters;
$scope.smallGrid = smallGrid;
if (typeof $routeParams.Source === 'undefined' && typeof $routeParams.Destination === 'undefined' && typeof $routeParams.id === 'undefined') {
if (angular.isUndefined($routeParams.Source) && angular.isUndefined($routeParams.Destination) && angular.isUndefined($routeParams.id)) {
var date = $scope.voucher.Date;
var source = getDebitCredit($scope.voucher.Journals, -1);
var destination = getDebitCredit($scope.voucher.Journals, 1);
@@ -27,7 +27,7 @@ var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher',
return;
}
if (typeof oldInventory !== 'undefined' &&
if (!angular.isUndefined(oldInventory) &&
oldInventory.Batch.BatchID === $scope.batch.BatchID &&
(!consumption || oldInventory.Quantity + quantity <= $scope.batch.QuantityRemaining)) {
oldInventory.Quantity += quantity;
@@ -36,7 +36,7 @@ var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher',
$('#txtBatch').focus();
}
if (typeof oldInventory === 'undefined' && (!consumption || quantity <= $scope.batch.QuantityRemaining)) {
if (angular.isUndefined(oldInventory) && (!consumption || quantity <= $scope.batch.QuantityRemaining)) {
this.voucher.Inventories.push(
{
Product: $scope.batch.Product,
@@ -58,12 +58,12 @@ var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher',
};
$scope.$watch('voucher.Date', function (newDate, oldDate) {
var nDate = angular.isDate(newDate) ? dateFilter(newDate, 'dd-MMM-yyyy') : newDate,
oDate = angular.isDate(oldDate) ? dateFilter(oldDate, 'dd-MMM-yyyy') : oldDate;
var nDate = asDate(newDate),
oDate = asDate(oldDate);
if (nDate !== oDate && typeof nDate !== 'undefined') {
if (typeof $routeParams.Source !== 'undefined' && typeof $routeParams.Destination !== 'undefined' && typeof $routeParams.id !== 'undefined') {
if (nDate !== oDate && !angular.isUndefined(nDate)) {
if (!angular.isUndefined($routeParams.Source) && !angular.isUndefined($routeParams.Destination) && !angular.isUndefined($routeParams.id)) {
$location.path('/Issue/' + nDate).search({Source: $routeParams.Source, Destination: $routeParams.Destination});
} else {
$scope.smallGrid = IssueGrid.query({date: nDate, Source: $routeParams.Source, Destination: $routeParams.Destination});
@@ -80,16 +80,16 @@ var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher',
}
$scope.$watch('voucher.Journals', function (newJournals, oldJournals) {
if (typeof newJournals === 'undefined' || angular.equals(newJournals, oldJournals)) {
if (angular.isUndefined(newJournals) || angular.equals(newJournals, oldJournals)) {
return;
}
if (typeof oldJournals !== 'undefined') {
if (!angular.isUndefined(oldJournals)) {
if (getDebitCredit(oldJournals, -1) === getDebitCredit(newJournals, -1) && getDebitCredit(oldJournals, 1) === getDebitCredit(newJournals, 1)) {
return;
}
}
if (typeof $routeParams.Source !== 'undefined' && typeof $routeParams.Destination !== 'undefined' && typeof $routeParams.id !== 'undefined') {
if (!angular.isUndefined($routeParams.Source) && !angular.isUndefined($routeParams.Destination) && !angular.isUndefined($routeParams.id)) {
$location.path('/Issue/' + $scope.voucher.Date).search({Source: getDebitCredit(newJournals, -1), Destination: getDebitCredit(newJournals, 1)});
} else {
$scope.smallGrid = IssueGrid.query({date: $scope.voucher.Date, Source: getDebitCredit(newJournals, -1), Destination: getDebitCredit(newJournals, 1)});
@@ -97,7 +97,7 @@ var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher',
}, true);
$scope.$watch('voucher.Inventories', function (newInventories, oldInventories) {
if (typeof newInventories === 'undefined' || typeof oldInventories === 'undefined') {
if (angular.isUndefined(newInventories) || angular.isUndefined(oldInventories)) {
return;
}
var amount = 0;
@@ -117,7 +117,7 @@ var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher',
};
$scope.preventAlteration = function (voucher) {
if (typeof voucher.VoucherID === 'undefined') {
if (angular.isUndefined(voucher.VoucherID)) {
return !$scope.perms['Issue'];
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
return true;
@@ -137,9 +137,7 @@ var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher',
};
$scope.save = function () {
if (angular.isDate($scope.voucher.Date)) {
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
}
$scope.voucher.Date = asDate($scope.voucher.Date);
$scope.voucher.$save({type: 'Issue'}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$scope.redirectOnSave(u);
@@ -160,7 +158,7 @@ var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher',
});
};
$scope.redirectOnSave = function (voucher) {
if (typeof $routeParams.Source !== 'undefined' && typeof $routeParams.Destination !== 'undefined' && typeof $routeParams.id !== 'undefined') {
if (!angular.isUndefined($routeParams.Source) && !angular.isUndefined($routeParams.Destination) && !angular.isUndefined($routeParams.id)) {
Voucher.get({type: 'Issue', Date: $routeParams.id, Source: $routeParams.Source, Destination: $routeParams.Destination}, function (u, putResponseHeaders) {
$scope.voucher = u;
});
@@ -188,7 +186,7 @@ var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher',
modalInstance.result.then(function (updated) {
if (updated.Product.ProductID !== $scope.selectedInventory.Batch.Product.ProductID) {
var oldInventory = getOld(updated.Batch.Product.ProductID, $scope.voucher.Inventories);
if (typeof oldInventory !== 'undefined') {
if (!angular.isUndefined(oldInventory)) {
delete $scope.selectedInventory;
return false;
}
@@ -223,12 +221,7 @@ var IssueCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'voucher',
};
$scope.batches = function ($viewValue) {
var params = {term: $viewValue, count: 20};
if (angular.isDate($scope.voucher.Date)) {
params.date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
} else {
params.date = $scope.voucher.Date;
}
var params = {term: $viewValue, count: 20, date: asDate($scope.voucher.Date)};
return Batch.autocomplete(params).$promise;
};
}];
@@ -239,28 +232,28 @@ IssueCtrl.resolve = {
source = $route.current.params.Source,
destination = $route.current.params.Destination;
if (typeof source !== 'undefined' && typeof destination !== 'undefined' && typeof id !== 'undefined') {
if (!angular.isUndefined(source) && !angular.isUndefined(destination) && !angular.isUndefined(id)) {
return Voucher.get({type: 'Issue', Date: id, Source: source, Destination: destination}).$promise;
} else if (typeof source === 'undefined' && typeof destination === 'undefined' && typeof id !== 'undefined') {
} else if (angular.isUndefined(source) && angular.isUndefined(destination) && !angular.isUndefined(id)) {
return Voucher.get({id: id}).$promise;
} else {
return Voucher.get({type: 'Issue'}).$promise;
}
}],
issue_grid: ['$route', 'IssueGrid', function ($route, IssueGrid) {
smallGrid: ['$route', 'IssueGrid', function ($route, IssueGrid) {
var id = $route.current.params.id,
source = $route.current.params.Source,
destination = $route.current.params.Destination;
if (typeof source !== 'undefined' && typeof destination !== 'undefined' && typeof id !== 'undefined') {
if (!angular.isUndefined(source) && !angular.isUndefined(destination) && !angular.isUndefined(id)) {
return IssueGrid.query({date: id, Source: source, Destination: destination}).$promise;
} else if (typeof source === 'undefined' && typeof destination === 'undefined' && typeof id !== 'undefined') {
} else if (angular.isUndefined(source) && angular.isUndefined(destination) && !angular.isUndefined(id)) {
return IssueGrid.query({date: id}).$promise;
} else {
return [];
}
}],
cost_centers: ['CostCenter', function (CostCenter) {
costCenters: ['CostCenter', function (CostCenter) {
return CostCenter.query({}).$promise;
}]
};
+9 -19
View File
@@ -1,6 +1,6 @@
'use strict';
var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImageResizer', 'voucher', 'Account', function ($scope, $location, dateFilter, $modal, UploadedImageResizer, voucher, Account) {
var JournalCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'uploadedImageResizer', 'voucher', 'Account', function ($scope, $location, asDate, $modal, uploadedImageResizer, voucher, Account) {
$('#txtAccount').focus();
$scope.voucher = voucher;
@@ -12,7 +12,7 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
}
$scope.$on("fileSelected", function (event, args) {
UploadedImageResizer(args, $scope.voucher.Files);
uploadedImageResizer(args, $scope.voucher.Files);
});
@@ -39,7 +39,7 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
return;
}
var oldJournal = getOld($scope.account.LedgerID, this.voucher.Journals);
if (typeof oldJournal !== 'undefined') {
if (!angular.isUndefined(oldJournal)) {
var amount = (oldJournal.Debit * oldJournal.Amount) + (parseInt($scope.debit) * Number($scope.amount));
if (amount < 0) {
oldJournal.Debit = -1;
@@ -61,7 +61,7 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
this.voucher.Journals.splice(index, 1);
};
$scope.$watch('voucher.Journals', function (journals, oldValue) {
$scope.$watch('voucher.Journals', function (journals) {
if (!angular.isArray(journals)) {
return;
}
@@ -72,9 +72,9 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
}, true);
$scope.preventAlteration = function (voucher) {
if (typeof $scope.perms === 'undefined') {
if (angular.isUndefined($scope.perms)) {
return false;
} else if (typeof voucher.VoucherID === 'undefined') {
} else if (angular.isUndefined(voucher.VoucherID)) {
return !$scope.perms['Journal'];
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
return true;
@@ -85,18 +85,8 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
}
};
$scope.get = function (voucherid) {
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.save = function () {
if (angular.isDate($scope.voucher.Date)) {
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
}
$scope.voucher.Date = asDate($scope.voucher.Date);
return $scope.voucher.$save({type: 'Journal'}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/Journal/' + u.VoucherID);
@@ -137,7 +127,7 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
modalInstance.result.then(function (updated) {
if (updated.Ledger.LedgerID !== $scope.selectedJournal.Ledger.LedgerID) {
var oldJournal = getOld(updated.Ledger.LedgerID, $scope.voucher.Journals);
if (typeof oldJournal !== 'undefined') {
if (!angular.isUndefined(oldJournal)) {
delete $scope.selectedJournal;
return false;
}
@@ -179,7 +169,7 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
JournalCtrl.resolve = {
voucher: ['$route', 'Voucher', function ($route, Voucher) {
var id = $route.current.params.id;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
return Voucher.get({type: 'Journal'}).$promise;
} else {
return Voucher.get({id: id}).$promise;
+18 -15
View File
@@ -1,18 +1,19 @@
'use strict';
var LedgerCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'ledger', 'Ledger', 'Account', function ($scope, $routeParams, $location, dateFilter, ledger, Ledger, Account) {
var LedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'ledger', 'Ledger', 'Account', function ($scope, $routeParams, $location, asDate, ledger, Ledger, Account) {
$scope.info = ledger;
$scope.hidden = [];
$scope.show = function () {
var id = $scope.info.Ledger.LedgerID;
var start_date = angular.isDate($scope.info.StartDate) ? dateFilter($scope.info.StartDate, 'dd-MMM-yyyy') : $scope.info.StartDate;
var finish_date = angular.isDate($scope.info.FinishDate) ? dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy') : $scope.info.FinishDate;
if (id === $routeParams.id && start_date === $routeParams.StartDate && finish_date === $routeParams.FinishDate) {
Ledger.get({id: id, StartDate: start_date, FinishDate: finish_date}, function (data) {
var id = $scope.info.Ledger.LedgerID,
startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
if (id === $routeParams.id && startDate === $routeParams.StartDate && finishDate === $routeParams.FinishDate) {
Ledger.get({id: id, StartDate: startDate, FinishDate: finishDate}, function (data) {
$scope.doFilter.cache = {};
$scope.info = data;
});
} else {
$location.path('/Ledger/' + id).search('StartDate', start_date).search('FinishDate', finish_date);
$location.path('/Ledger/' + id).search('StartDate', startDate).search('FinishDate', finishDate);
}
};
@@ -35,10 +36,10 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'ledger',
};
$scope.$watch('hidden', function () {
$scope.display = doFilter($scope.info, $scope.hidden);
$scope.display = $scope.doFilter($scope.info, $scope.hidden);
}, true);
var doFilter = function (input, hidden) {
$scope.doFilter = _.memoize(function (input, hidden) {
var ledger = angular.copy(input),
data = ledger.Body,
footer = ledger.Footer,
@@ -68,7 +69,9 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'ledger',
footer.Credit = credit;
footer.Running = running;
return {Body: data, Footer: footer};
};
}, function (input, hidden) {
return hidden.sort().join(' ');
});
$scope.shortcuts = {
'up': function (e) {
@@ -81,7 +84,7 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'ledger',
}
},
'down': function (e) {
if ($scope.selected < $scope.info.Body.length - 1) {
if ($scope.selected < $scope.display.Body.length - 1) {
$scope.$apply(function () {
$scope.selected = $scope.selected += 1;
});
@@ -125,13 +128,13 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'ledger',
LedgerCtrl.resolve = {
ledger: ['$route', 'Ledger', function ($route, Ledger) {
var id = $route.current.params.id,
start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
return Ledger.get({}).$promise;
} else {
return Ledger.get({id: id, StartDate: start_date, FinishDate: finish_date}).$promise;
return Ledger.get({id: id, StartDate: startDate, FinishDate: finishDate}).$promise;
}
}]
};
+5 -4
View File
@@ -3,10 +3,11 @@
var LoginCtrl = ['$scope', '$http', '$location', '$routeParams', '$cookieStore', function ($scope, $http, $location, $routeParams, $cookieStore) {
$scope.showOTP = false;
$scope.submit = function () {
var data;
if ($scope.showOTP) {
var data = {username: $scope.username, password: $scope.password, otp: $scope.otp, ClientName: $scope.name};
data = {username: $scope.username, password: $scope.password, otp: $scope.otp, ClientName: $scope.name};
} else {
var data = {username: $scope.username, password: $scope.password};
data = {username: $scope.username, password: $scope.password};
}
@@ -14,7 +15,7 @@ var LoginCtrl = ['$scope', '$http', '$location', '$routeParams', '$cookieStore',
post('/api/login', data).
success(function () {
var came_from = $routeParams.came_from;
if (typeof came_from === 'undefined' || came_from === "" || came_from === "/login" || came_from === "/logout") {
if (angular.isUndefined(came_from) || came_from === "" || came_from === "/login" || came_from === "/logout") {
came_from = "/";
}
$location.path(came_from).search({});
@@ -36,7 +37,7 @@ var LogoutCtrl = ['$scope', '$http', '$location', function ($scope, $http, $loca
post('/logout').
success(function () {
$scope.toasts.push({Type: 'Success', Message: 'Logged out'});
$location.path('/')
$location.path('/');
}).
error(function (errorMessage) {
$scope.toasts.push({Type: 'Danger', Message: errorMessage});
+2 -4
View File
@@ -1,6 +1,6 @@
'use strict';
var MessageCtrl = ['$scope', '$location', 'dateFilter', 'message', 'tags', 'users', 'priorities', function ($scope, $location, dateFilter, message, tags, users, priorities) {
var MessageCtrl = ['$scope', '$location', 'asDateFilter', 'message', 'tags', 'users', 'priorities', function ($scope, $location, asDate, message, tags, users, priorities) {
$scope.message = message;
$scope.priorities = priorities
$scope.tags = tags;
@@ -23,9 +23,7 @@ var MessageCtrl = ['$scope', '$location', 'dateFilter', 'message', 'tags', 'user
return;
}
for (var i = 0, l = $scope.message.Posts.length; i < l; i++) {
if (angular.isDate($scope.message.Posts[i].Date)) {
$scope.message.Posts[i].Date = dateFilter($scope.message.Posts[i].Date, 'dd-MMM-yyyy');
}
$scope.message.Posts[i].Date = asDate($scope.message.Posts[i].Date);
}
$scope.message.$save(function (u, putResponseHeaders) {
+8 -12
View File
@@ -1,28 +1,24 @@
'use strict';
var NetTransactionsCtrl = ['$scope', '$location', 'dateFilter', 'net_transactions', function ($scope, $location, dateFilter, net_transactions) {
var NetTransactionsCtrl = ['$scope', '$location', 'asDateFilter', 'net_transactions', function ($scope, $location, asDate, net_transactions) {
$scope.info = net_transactions;
$scope.show = function () {
if (angular.isDate($scope.info.StartDate)) {
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.info.FinishDate)) {
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
}
$location.path('/NetTransactions').search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
var startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
$location.path('/NetTransactions').search({StartDate: startDate, FinishDate: finishDate});
};
$('#txtStartDate').focus();
}];
NetTransactionsCtrl.resolve = {
net_transactions: ['$route', 'NetTransactions', function ($route, NetTransactions) {
var start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
var startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
if (angular.isUndefined(startDate) || angular.isUndefined(finishDate)) {
return NetTransactions.get({}).$promise;
} else {
return NetTransactions.get({StartDate: start_date, FinishDate: finish_date}).$promise;
return NetTransactions.get({StartDate: startDate, FinishDate: finishDate}).$promise;
}
}]
};
+1 -1
View File
@@ -140,7 +140,7 @@ overlord.controller('BaseCtrl', ['$rootScope', '$scope', 'Auth', '$location', '$
$location.path('/');
} else {
var came_from = $routeParams.came_from;
if (typeof came_from === 'undefined' && $location.path() !== '/login') {
if (angular.isUndefined(came_from) && $location.path() !== '/login') {
came_from = $location.path();
}
$location.path('/login').search({came_from: came_from});
+8 -18
View File
@@ -1,6 +1,6 @@
'use strict';
var PaymentCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImageResizer', 'voucher', 'ledgers', 'Account', function ($scope, $location, dateFilter, $modal, UploadedImageResizer, voucher, ledgers, Account) {
var PaymentCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'uploadedImageResizer', 'voucher', 'ledgers', 'Account', function ($scope, $location, asDate, $modal, uploadedImageResizer, voucher, ledgers, Account) {
$('#txtAccount').focus();
$scope.voucher = voucher;
@@ -12,7 +12,7 @@ var PaymentCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
}
$scope.$on("fileSelected", function (event, args) {
UploadedImageResizer(args, $scope.voucher.Files);
uploadedImageResizer(args, $scope.voucher.Files);
});
@@ -39,7 +39,7 @@ var PaymentCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
return;
}
var oldJournal = getOld($scope.account.LedgerID, this.voucher.Journals);
if (typeof oldJournal === 'undefined') {
if (angular.isUndefined(oldJournal)) {
this.voucher.Journals.push({Debit: 1, Amount: Number($scope.amount), Ledger: $scope.account});
} else {
if (oldJournal.Debit === 1) {
@@ -73,9 +73,9 @@ var PaymentCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
}, true);
$scope.preventAlteration = function (voucher) {
if (typeof $scope.perms === 'undefined') {
if (angular.isUndefined($scope.perms)) {
return false;
} else if (typeof voucher.VoucherID === 'undefined') {
} else if (angular.isUndefined(voucher.VoucherID)) {
return !$scope.perms['Payment'];
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
return true;
@@ -86,18 +86,8 @@ var PaymentCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
}
};
$scope.get = function (voucherid) {
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.save = function () {
if (angular.isDate($scope.voucher.Date)) {
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
}
$scope.voucher.Date = asDate($scope.voucher.Date);
return $scope.voucher.$save({type: 'Payment'}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/Payment/' + u.VoucherID);
@@ -138,7 +128,7 @@ var PaymentCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
modalInstance.result.then(function (updated) {
if (updated.Ledger.LedgerID !== $scope.selectedJournal.Ledger.LedgerID) {
var oldJournal = getOld(updated.Ledger.LedgerID, $scope.voucher.Journals);
if (typeof oldJournal !== 'undefined') {
if (!angular.isUndefined(oldJournal)) {
delete $scope.selectedJournal;
return false;
}
@@ -181,7 +171,7 @@ PaymentCtrl.resolve = {
var id = $route.current.params.id,
account = $route.current.params.a;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
var options = {type: 'Payment'};
if (!angular.isUndefined(account)) {
options.a = account;
+8 -8
View File
@@ -1,20 +1,20 @@
'use strict';
var ProductGroupListCtrl = ['$scope', 'product_groups', function ($scope, product_groups) {
$scope.info = product_groups;
var ProductGroupListCtrl = ['$scope', 'productGroups', function ($scope, productGroups) {
$scope.info = productGroups;
}];
ProductGroupListCtrl.resolve = {
product_groups: ['ProductGroup', function (ProductGroup) {
productGroups: ['ProductGroup', function (ProductGroup) {
return ProductGroup.query({}).$promise;
}]
};
var ProductGroupCtrl = ['$scope', '$location', 'product_group', function ($scope, $location, product_group) {
$scope.product_group = product_group;
var ProductGroupCtrl = ['$scope', '$location', 'productGroup', function ($scope, $location, productGroup) {
$scope.productGroup = productGroup;
$scope.save = function () {
$scope.product_group.$save(function (u, putResponseHeaders) {
$scope.productGroup.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/ProductGroups')
}, function (data, status) {
@@ -23,7 +23,7 @@ var ProductGroupCtrl = ['$scope', '$location', 'product_group', function ($scope
};
$scope.delete = function () {
$scope.product_group.$delete(function (u, putResponseHeaders) {
$scope.productGroup.$delete(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/ProductGroups')
}, function (data, status) {
@@ -34,7 +34,7 @@ var ProductGroupCtrl = ['$scope', '$location', 'product_group', function ($scope
}];
ProductGroupCtrl.resolve = {
product_group: ['$route', 'ProductGroup', function ($route, ProductGroup) {
productGroup: ['$route', 'ProductGroup', function ($route, ProductGroup) {
var id = $route.current.params.id;
return ProductGroup.get({id: id}).$promise;
}]
+11 -12
View File
@@ -1,18 +1,17 @@
'use strict';
var ProductLedgerCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'product_ledger', 'ProductLedger', 'Product', function ($scope, $routeParams, $location, dateFilter, product_ledger, ProductLedger, Product) {
var ProductLedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'product_ledger', 'ProductLedger', 'Product', function ($scope, $routeParams, $location, asDate, product_ledger, ProductLedger, Product) {
$scope.info = product_ledger;
$scope.show = function () {
var id = $scope.info.Product.ProductID;
var start_date = angular.isDate($scope.info.StartDate) ? dateFilter($scope.info.StartDate, 'dd-MMM-yyyy') : $scope.info.StartDate;
var finish_date = angular.isDate($scope.info.FinishDate) ? dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy') : $scope.info.FinishDate;
if (id === $routeParams.id && start_date === $routeParams.StartDate && finish_date === $routeParams.FinishDate) {
ProductLedger.get({id: id, StartDate: start_date, FinishDate: finish_date}, function (data) {
var id = $scope.info.Product.ProductID,
startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
if (id === $routeParams.id && startDate === $routeParams.StartDate && finishDate === $routeParams.FinishDate) {
ProductLedger.get({id: id, StartDate: startDate, FinishDate: finishDate}, function (data) {
$scope.info = data;
});
} else {
$location.path('/ProductLedger/' + $scope.info.Product.ProductID).search('StartDate', start_date).search('FinishDate', finish_date);
$location.path('/ProductLedger/' + $scope.info.Product.ProductID).search('StartDate', startDate).search('FinishDate', finishDate);
}
};
$scope.downloadTable = function () {
@@ -31,13 +30,13 @@ var ProductLedgerCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'p
ProductLedgerCtrl.resolve = {
product_ledger: ['$route', 'ProductLedger', function ($route, ProductLedger) {
var id = $route.current.params.id,
start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
return ProductLedger.get({}).$promise;
} else {
return ProductLedger.get({id: id, StartDate: start_date, FinishDate: finish_date}).$promise;
return ProductLedger.get({id: id, StartDate: startDate, FinishDate: finishDate}).$promise;
}
}]
};
+6 -6
View File
@@ -2,7 +2,7 @@
var ProductListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'products', function ($scope, $location, $routeParams, Tokenizer, products) {
$scope.search = $routeParams.q || '';
$scope.show_extended = false;
$scope.showExtended = false;
$scope.info = products;
$scope.$watch('search', function (newValue, oldValue) {
@@ -15,12 +15,12 @@ var ProductListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'prod
$scope.searchInfo = {
comparator: {
'def': 'n',
'n': {'Col': 'Name', 'Comparator': 'text'},
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
'u': {'Col': 'Units', 'Comparator': 'text'},
't': {'Col': 'ProductGroup', 'Comparator': 'text'}
},
def: 'n',
sorter: {
'c': 'Code',
'n': 'Name',
@@ -47,7 +47,7 @@ var ProductListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'prod
}
$scope.$apply(function () {
var matches = Tokenizer.parseFilterString(q, $scope.searchInfo);
$scope.show_extended = 'e' in matches.f;
$scope.showExtended = 'e' in matches.f;
$scope.products = Tokenizer.doFilter(q, $scope.info, matches);
});
@@ -61,9 +61,9 @@ ProductListCtrl.resolve = {
}]
};
var ProductCtrl = ['$scope', '$location', '$window', '$modal', 'product', 'product_groups', function ($scope, $location, $window, $modal, product, product_groups) {
var ProductCtrl = ['$scope', '$location', '$window', '$modal', 'product', 'product_groups', function ($scope, $location, $window, $modal, product, productGroups) {
$scope.product = product;
$scope.product_groups = product_groups;
$scope.productGroups = productGroups;
$scope.save = function () {
$scope.product.$save(function (u, putResponseHeaders) {
@@ -113,7 +113,7 @@ ProductCtrl.resolve = {
return Product.get({id: id}).$promise;
}],
product_groups: ['ProductGroup', function (ProductGroup) {
productGroups: ['ProductGroup', function (ProductGroup) {
return ProductGroup.query({}).$promise;
}]
};
+8 -12
View File
@@ -1,28 +1,24 @@
'use strict';
var ProfitLossCtrl = ['$scope', '$location', 'dateFilter', 'profit_loss', function ($scope, $location, dateFilter, profit_loss) {
var ProfitLossCtrl = ['$scope', '$location', 'asDateFilter', 'profit_loss', function ($scope, $location, asDate, profit_loss) {
$scope.info = profit_loss;
$scope.show = function () {
if (angular.isDate($scope.info.StartDate)) {
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.info.FinishDate)) {
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
}
$location.path('/ProfitLoss').search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
var startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
$location.path('/ProfitLoss').search({StartDate: startDate, FinishDate: finishDate});
};
$('#txtStartDate').focus();
}];
ProfitLossCtrl.resolve = {
profit_loss: ['$route', 'ProfitLoss', function ($route, ProfitLoss) {
var start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
var startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
if (angular.isUndefined(startDate) || angular.isUndefined(finishDate)) {
return ProfitLoss.get({}).$promise;
} else {
return ProfitLoss.get({StartDate: start_date, FinishDate: finish_date}).$promise;
return ProfitLoss.get({StartDate: startDate, FinishDate: finishDate}).$promise;
}
}]
};
+10 -14
View File
@@ -1,29 +1,25 @@
'use strict';
var PurchaseEntriesCtrl = ['$scope', '$location', 'dateFilter', 'purchase_entries', function ($scope, $location, dateFilter, purchase_entries) {
$scope.info = purchase_entries;
var PurchaseEntriesCtrl = ['$scope', '$location', 'asDateFilter', 'purchaseEntries', function ($scope, $location, asDate, purchaseEntries) {
$scope.info = purchaseEntries;
$scope.show = function () {
if (angular.isDate($scope.info.StartDate)) {
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.info.FinishDate)) {
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
}
$location.path('/PurchaseEntries').search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
var startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
$location.path('/PurchaseEntries').search({StartDate: startDate, FinishDate: finishDate});
};
$('#txtStartDate').focus();
}];
PurchaseEntriesCtrl.resolve = {
purchase_entries: ['$route', 'PurchaseEntries', function ($route, PurchaseEntries) {
var start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
purchaseEntries: ['$route', 'PurchaseEntries', function ($route, PurchaseEntries) {
var startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
if (angular.isUndefined(startDate) || angular.isUndefined(finishDate)) {
return PurchaseEntries.get({}).$promise;
} else {
return PurchaseEntries.get({StartDate: start_date, FinishDate: finish_date}).$promise;
return PurchaseEntries.get({StartDate: startDate, FinishDate: finishDate}).$promise;
}
}]
};
+11 -27
View File
@@ -1,6 +1,6 @@
'use strict';
var PurchaseReturnCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImageResizer', 'voucher', 'Account', 'Batch', function ($scope, $location, dateFilter, $modal, UploadedImageResizer, voucher, Account, Batch) {
var PurchaseReturnCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'uploadedImageResizer', 'voucher', 'Account', 'Batch', function ($scope, $location, asDate, $modal, uploadedImageResizer, voucher, Account, Batch) {
$scope.voucher = voucher;
$scope.rate = 0;
function getOld(productID, inventories) {
@@ -10,7 +10,7 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'Upload
}
$scope.$on("fileSelected", function (event, args) {
UploadedImageResizer(args, $scope.voucher.Files);
uploadedImageResizer(args, $scope.voucher.Files);
});
@@ -40,7 +40,7 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'Upload
return;
}
if (typeof oldInventory === 'undefined' && quantity <= $scope.batch.QuantityRemaining) {
if (angular.isUndefined(oldInventory) && quantity <= $scope.batch.QuantityRemaining) {
this.voucher.Inventories.push(
{
Product: $scope.batch.Product,
@@ -64,12 +64,12 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'Upload
$scope.$watch('voucher.Inventories', function (inventories, oldValue) {
var amount = 0;
if (typeof inventories !== 'undefined') {
if (!angular.isUndefined(inventories)) {
for (var i = 0, l = inventories.length; i < l; i++) {
amount += Number(inventories[i].Amount);
}
}
if (typeof $scope.voucher.Journals !== 'undefined') {
if (!angular.isUndefined($scope.voucher.Journals)) {
for (var i = 0, l = $scope.voucher.Journals.length; i < l; i++) {
if ($scope.voucher.Journals[i].Debit === 1) {
$scope.voucher.Journals[i].Amount = amount;
@@ -80,9 +80,9 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'Upload
}, true);
$scope.preventAlteration = function (voucher) {
if (typeof $scope.perms === 'undefined') {
if (angular.isUndefined($scope.perms)) {
return false;
} else if (typeof voucher.VoucherID === 'undefined') {
} else if (angular.isUndefined(voucher.VoucherID)) {
return !$scope.perms['Purchase Return'];
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
return true;
@@ -93,18 +93,8 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'Upload
}
};
$scope.get = function (voucherid) {
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.save = function () {
if (angular.isDate($scope.voucher.Date)) {
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
}
$scope.voucher.Date = asDate($scope.voucher.Date);
return $scope.voucher.$save({type: 'Purchase Return'}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/Return/' + u.VoucherID);
@@ -145,7 +135,7 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'Upload
modalInstance.result.then(function (updated) {
if (updated.Product.ProductID !== $scope.selectedInventory.Batch.Product.ProductID) {
var oldInventory = getOld(updated.Batch.Product.ProductID, $scope.voucher.Inventories);
if (typeof oldInventory !== 'undefined') {
if (!angular.isUndefined(oldInventory)) {
delete $scope.selectedInventory;
return false;
}
@@ -182,13 +172,7 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'Upload
return Account.autocomplete({term: $viewValue, count: 20, a: true}).$promise;
};
$scope.batches = function ($viewValue) {
var params = {term: $viewValue, count: 20};
if (angular.isDate($scope.voucher.Date)) {
params.date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
} else {
params.date = $scope.voucher.Date;
}
var params = {term: $viewValue, count: 20, date: asDate($scope.voucher.Date)};
return Batch.autocomplete(params).$promise;
};
}];
@@ -196,7 +180,7 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'Upload
PurchaseReturnCtrl.resolve = {
voucher: ['$route', 'Voucher', function ($route, Voucher) {
var id = $route.current.params.id;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
return Voucher.get({type: 'Purchase Return'}).$promise;
} else {
return Voucher.get({id: id}).$promise;
+14 -23
View File
@@ -1,6 +1,6 @@
'use strict';
var PurchaseCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImageResizer', 'voucher', 'Account', 'Product', function ($scope, $location, dateFilter, $modal, UploadedImageResizer, voucher, Account, Product) {
var PurchaseCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'uploadedImageResizer', 'voucher', 'Account', 'Product', function ($scope, $location, asDate, $modal, uploadedImageResizer, voucher, Account, Product) {
$scope.voucher = voucher;
function getOld(productID, inventories) {
return _.find(inventories, function (inventory) {
@@ -9,7 +9,7 @@ var PurchaseCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImag
}
$scope.$on("fileSelected", function (event, args) {
UploadedImageResizer(args, $scope.voucher.Files);
uploadedImageResizer(args, $scope.voucher.Files);
});
@@ -42,7 +42,7 @@ var PurchaseCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImag
return;
}
if (typeof oldInventory === 'undefined') {
if (angular.isUndefined(oldInventory)) {
this.voucher.Inventories.push(
{
Product: $scope.product,
@@ -65,14 +65,15 @@ var PurchaseCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImag
};
$scope.$watch('voucher.Inventories', function (inventories, oldValue) {
var amount = 0;
if (typeof inventories !== 'undefined') {
for (var i = 0, l = inventories.length; i < l; i++) {
var amount = 0,
i, l;
if (!angular.isUndefined(inventories)) {
for (i = 0, l = inventories.length; i < l; i++) {
amount += Number(inventories[i].Amount);
}
}
if (typeof $scope.voucher.Journals !== 'undefined') {
for (var i = 0, l = $scope.voucher.Journals.length; i < l; i++) {
if (!angular.isUndefined($scope.voucher.Journals)) {
for (i = 0, l = $scope.voucher.Journals.length; i < l; i++) {
if ($scope.voucher.Journals[i].Debit === -1) {
$scope.voucher.Journals[i].Amount = amount;
break;
@@ -82,9 +83,9 @@ var PurchaseCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImag
}, true);
$scope.preventAlteration = function (voucher) {
if (typeof $scope.perms === 'undefined') {
if (angular.isUndefined($scope.perms)) {
return false;
} else if (typeof voucher.VoucherID === 'undefined') {
} else if (angular.isUndefined(voucher.VoucherID)) {
return !$scope.perms['Purchase'];
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
return true;
@@ -95,18 +96,8 @@ var PurchaseCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImag
}
};
$scope.get = function (voucherid) {
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.save = function () {
if (angular.isDate($scope.voucher.Date)) {
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
}
$scope.voucher.Date = asDate($scope.voucher.Date);
return $scope.voucher.$save({type: 'Purchase'}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/Purchase/' + u.VoucherID);
@@ -147,7 +138,7 @@ var PurchaseCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImag
modalInstance.result.then(function (updated) {
if (updated.Product.ProductID !== $scope.selectedInventory.Product.ProductID) {
var oldInventory = getOld(updated.Product.ProductID, $scope.voucher.Inventories);
if (typeof oldInventory !== 'undefined') {
if (!angular.isUndefined(oldInventory)) {
delete $scope.selectedInventory;
return false;
}
@@ -193,7 +184,7 @@ PurchaseCtrl.resolve = {
voucher: ['$route', 'Voucher', function ($route, Voucher) {
var id = $route.current.params.id;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
return Voucher.get({type: 'Purchase'}).$promise;
} else {
return Voucher.get({id: id}).$promise;
+8 -12
View File
@@ -1,26 +1,22 @@
'use strict';
var PurchasesCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'purchases', function ($scope, $routeParams, $location, dateFilter, purchases) {
var PurchasesCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'purchases', function ($scope, $routeParams, $location, asDate, purchases) {
$scope.info = purchases;
$scope.show = function () {
if (angular.isDate($scope.info.StartDate)) {
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.info.FinishDate)) {
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
}
$location.path('/Purchases').search({s:$scope.info.StartDate, f:$scope.info.FinishDate});
var startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
$location.path('/Purchases').search({s: startDate, f: finishDate});
};
}];
PurchasesCtrl.resolve = {
purchases: ['$route', 'Purchases', function ($route, Purchases) {
var start_date = $route.current.params.s,
finish_date = $route.current.params.f;
var startDate = $route.current.params.s,
finishDate = $route.current.params.f;
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
if (angular.isUndefined(startDate) || angular.isUndefined(finishDate)) {
return Purchases.get({}).$promise;
} else {
return Purchases.get({s:start_date, f:finish_date}).$promise;
return Purchases.get({s: startDate, f: finishDate}).$promise;
}
}]
};
+12 -16
View File
@@ -1,31 +1,27 @@
'use strict';
var RawMaterialCostCtrl = ['$scope', '$location', 'dateFilter', 'raw_material_cost', function ($scope, $location, dateFilter, raw_material_cost) {
$scope.info = raw_material_cost;
var RawMaterialCostCtrl = ['$scope', '$location', 'asDateFilter', 'rawMaterialCost', function ($scope, $location, asDate, rawMaterialCost) {
$scope.info = rawMaterialCost;
$scope.show = function () {
if (angular.isDate($scope.info.StartDate)) {
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.info.FinishDate)) {
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
}
$location.path('/RawMaterialCost').search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
var startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
$location.path('/RawMaterialCost').search({StartDate: startDate, FinishDate: finishDate});
};
$('#txtStartDate').focus();
}];
RawMaterialCostCtrl.resolve = {
raw_material_cost: ['$route', 'RawMaterialCost', function ($route, RawMaterialCost) {
rawMaterialCost: ['$route', 'RawMaterialCost', function ($route, RawMaterialCost) {
var id = $route.current.params.id,
start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
if (angular.isUndefined(startDate) || angular.isUndefined(finishDate)) {
return RawMaterialCost.get({}).$promise;
} else if (typeof id === 'undefined') {
return RawMaterialCost.get({StartDate: start_date, FinishDate: finish_date}).$promise;
} else if (angular.isUndefined(id)) {
return RawMaterialCost.get({StartDate: startDate, FinishDate: finishDate}).$promise;
} else {
return RawMaterialCost.get({id: id, StartDate: start_date, FinishDate: finish_date}).$promise;
return RawMaterialCost.get({id: id, StartDate: startDate, FinishDate: finishDate}).$promise;
}
}]
};
+8 -18
View File
@@ -1,6 +1,6 @@
'use strict';
var ReceiptCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', '$modal', 'UploadedImageResizer', 'voucher', 'ledgers', 'Voucher', 'Account', function ($scope, $routeParams, $location, dateFilter, $modal, UploadedImageResizer, voucher, ledgers, Voucher, Account) {
var ReceiptCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', '$modal', 'uploadedImageResizer', 'voucher', 'ledgers', 'Voucher', 'Account', function ($scope, $routeParams, $location, asDate, $modal, uploadedImageResizer, voucher, ledgers, Voucher, Account) {
$('#txtAccount').focus();
$scope.voucher = voucher;
@@ -12,7 +12,7 @@ var ReceiptCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', '$modal'
}
$scope.$on("fileSelected", function (event, args) {
UploadedImageResizer(args, $scope.voucher.Files);
uploadedImageResizer(args, $scope.voucher.Files);
});
@@ -39,7 +39,7 @@ var ReceiptCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', '$modal'
return;
}
var oldJournal = getOld($scope.account.LedgerID, this.voucher.Journals);
if (typeof oldJournal === 'undefined') {
if (angular.isUndefined(oldJournal)) {
this.voucher.Journals.push({Debit: -1, Amount: Number($scope.amount), Ledger: $scope.account});
} else {
if (oldJournal.Debit === -1) {
@@ -73,9 +73,9 @@ var ReceiptCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', '$modal'
}, true);
$scope.preventAlteration = function (voucher) {
if (typeof $scope.perms === 'undefined') {
if (angular.isUndefined($scope.perms)) {
return false;
} else if (typeof voucher.VoucherID === 'undefined') {
} else if (angular.isUndefined(voucher.VoucherID)) {
return !$scope.perms['Receipt'];
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
return true;
@@ -86,18 +86,8 @@ var ReceiptCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', '$modal'
}
};
$scope.get = function (voucherid) {
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.save = function () {
if (angular.isDate($scope.voucher.Date)) {
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
}
$scope.voucher.Date = asDate($scope.voucher.Date);
return $scope.voucher.$save({type: 'Receipt'}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/Receipt/' + u.VoucherID);
@@ -138,7 +128,7 @@ var ReceiptCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', '$modal'
modalInstance.result.then(function (updated) {
if (updated.Ledger.LedgerID !== $scope.selectedJournal.Ledger.LedgerID) {
var oldJournal = getOld(updated.Ledger.LedgerID, $scope.voucher.Journals);
if (typeof oldJournal !== 'undefined') {
if (!angular.isUndefined(oldJournal)) {
delete $scope.selectedJournal;
return false;
}
@@ -181,7 +171,7 @@ ReceiptCtrl.resolve = {
var id = $route.current.params.id,
account = $route.current.params.a;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
var options = {type: 'Receipt'};
if (!angular.isUndefined(account)) {
options.a = account;
+19 -21
View File
@@ -3,29 +3,29 @@
var RecipeListCtrl = ['$scope', 'recipes', function ($scope, recipes) {
$scope.info = recipes;
$scope.display = $scope.info;
$scope.product_type_selected = 'all';
$scope.show_latest = 'latest';
$scope.show_summary = 'no';
$scope.productTypeSelected = 'all';
$scope.showLatest = 'latest';
$scope.showSummary = 'no';
$scope.$watch('product_type_selected', function (value) {
$scope.$watch('productTypeSelected', function (value) {
$scope.display = $scope.doFilter();
}, true);
$scope.$watch('show_latest', function (value) {
$scope.$watch('showLatest', function (value) {
$scope.display = $scope.doFilter();
}, true);
$scope.doFilter = function (q) {
return _.filter($scope.info, function (item) {
if ($scope.product_type_selected === 'menu') {
if ($scope.productTypeSelected === 'menu') {
if (item.IsSemi) {
return false;
}
} else if ($scope.product_type_selected === 'semi') {
} else if ($scope.productTypeSelected === 'semi') {
if (!item.IsSemi) {
return false;
}
}
if ($scope.show_latest === 'latest' && !item.IsLatest) {
if ($scope.showLatest === 'latest' && !item.IsLatest) {
return false;
}
return true;
@@ -39,14 +39,14 @@ RecipeListCtrl.resolve = {
}]
};
var RecipeCtrl = ['$scope', '$location', '$window', '$modal', 'dateFilter', 'Product', 'recipe', 'product_groups', function ($scope, $location, $window, $modal, dateFilter, Product, recipe, product_groups) {
var RecipeCtrl = ['$scope', '$location', '$window', '$modal', 'asDateFilter', 'Product', 'recipe', 'productGroups', function ($scope, $location, $window, $modal, asDate, Product, recipe, productGroups) {
$scope.recipe = recipe;
$scope.original = {};
angular.copy($scope.recipe, $scope.original);
$scope.product_groups = product_groups;
$scope.cost_price = 0;
function getOld(productID, recipe_items) {
return _.find(recipe_items, function (recipe_item) {
$scope.productGroups = productGroups;
$scope.costPrice = 0;
function getOld(productID, recipeItems) {
return _.find(recipeItems, function (recipe_item) {
return recipe_item.Product.ProductID === productID;
});
}
@@ -56,7 +56,7 @@ var RecipeCtrl = ['$scope', '$location', '$window', '$modal', 'dateFilter', 'Pro
return;
}
var oldItem = getOld($scope.product.ProductID, this.recipe.RecipeItems);
if (typeof oldItem === 'undefined') {
if (angular.isUndefined(oldItem)) {
var quantity = Number($scope.quantity);
var price = Number($scope.product.Price);
this.recipe.RecipeItems.push({
@@ -77,20 +77,18 @@ var RecipeCtrl = ['$scope', '$location', '$window', '$modal', 'dateFilter', 'Pro
this.recipe.RecipeItems.splice(index, 1);
};
$scope.$watch('recipe.RecipeItems', function (recipe_items, oldValue) {
if (!angular.isArray(recipe_items)) {
$scope.$watch('recipe.RecipeItems', function (recipeItems, oldValue) {
if (!angular.isArray(recipeItems)) {
return;
}
$scope.cost_price = recipe_items.reduce(function (sum, item, index, array) {
$scope.costPrice = recipeItems.reduce(function (sum, item, index, array) {
var rate = item.Price / (item.Product.Fraction * item.Product.ProductYield)
return sum + (item.Quantity * rate);
}, 0);
}, true);
$scope.save = function () {
if (angular.isDate($scope.recipe.Date)) {
$scope.recipe.Date = dateFilter($scope.recipe.Date, 'dd-MMM-yyyy');
}
$scope.recipe.Date = asDate($scope.recipe.Date);
if (angular.isUndefined($scope.recipe.Date) || $scope.recipe.Date === '') {
$scope.toasts.push({Type: 'Danger', Message: 'Please Choose a date'});
return;
@@ -171,7 +169,7 @@ RecipeCtrl.resolve = {
return Recipe.get({id: id}).$promise;
}],
product_groups: ['ProductGroup', function (ProductGroup) {
productGroups: ['ProductGroup', function (ProductGroup) {
return ProductGroup.query({}).$promise;
}]
};
+18 -20
View File
@@ -1,26 +1,26 @@
'use strict';
var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'reconcile', 'Reconcile', 'Account', function ($scope, $routeParams, $location, dateFilter, reconcile, Reconcile, Account) {
var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'reconcile', 'Reconcile', 'Account', function ($scope, $routeParams, $location, asDate, reconcile, Reconcile, Account) {
$scope.info = reconcile;
$scope.hidden = [];
$scope.show = function () {
var id = $scope.info.Account.LedgerID;
var start_date = angular.isDate($scope.info.StartDate) ? dateFilter($scope.info.StartDate, 'dd-MMM-yyyy') : $scope.info.StartDate;
var finish_date = angular.isDate($scope.info.FinishDate) ? dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy') : $scope.info.FinishDate;
if (id === $routeParams.id && start_date === $routeParams.StartDate && finish_date === $routeParams.FinishDate) {
Reconcile.get({id: id, StartDate: start_date, FinishDate: finish_date}, function (data) {
var id = $scope.info.Account.LedgerID,
startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
if (id === $routeParams.id && startDate === $routeParams.StartDate && finishDate === $routeParams.FinishDate) {
Reconcile.get({id: id, StartDate: startDate, FinishDate: finishDate}, function (data) {
$scope.doFilter.cache = {};
$scope.info = data;
});
} else {
$location.path('/Reconcile/' + id).search('StartDate', start_date).search('FinishDate', finish_date);
$location.path('/Reconcile/' + id).search('StartDate', startDate).search('FinishDate', finishDate);
}
};
$scope.save = function () {
var i, l,
len = $scope.info.Body.length;
for (i = 0, l = len; i < l; i++) {
if (angular.isDate($scope.info.Body[i].ReconcileDate)) {
$scope.info.Body[i].ReconcileDate = dateFilter($scope.info.Body[i].ReconcileDate, 'dd-MMM-yyyy');
}
$scope.info.Body[i].ReconcileDate = asDate($scope.info.Body[i].ReconcileDate);
}
$scope.info.$save({StartDate: $routeParams.StartDate, FinishDate: $routeParams.FinishDate}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
@@ -54,6 +54,8 @@ var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'recon
$scope.$apply(function () {
$scope.selected = $scope.selected -= 1;
});
$("#" + $scope.selected).scrollintoview({duration: 'fast'});
e.preventDefault();
}
},
'down': function () {
@@ -61,19 +63,15 @@ var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'recon
$scope.$apply(function () {
$scope.selected = $scope.selected += 1;
});
$("#" + $scope.selected).scrollintoview({duration: 'fast'});
e.preventDefault();
}
},
'alt+r': function () {
console.log('alt+r');
},
'enter': function () {
var path = $scope.info.Body[$scope.selected].Url.replace(/^(?:\/\/|[^\/]+)*/, "");
$scope.$apply(function () {
$location.path(path).search('StartDate', null).search('FinishDate', null);
});
},
'alt+u': function () {
console.log('alt+u');
}
};
@@ -85,13 +83,13 @@ var ReconcileCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'recon
ReconcileCtrl.resolve = {
reconcile: ['$route', 'Reconcile', function ($route, Reconcile) {
var id = $route.current.params.id,
start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
return Reconcile.get({}).$promise;
} else {
return Reconcile.get({id: id, StartDate: start_date, FinishDate: finish_date}).$promise;
return Reconcile.get({id: id, StartDate: startDate, FinishDate: finishDate}).$promise;
}
}]
};
+14 -16
View File
@@ -1,6 +1,6 @@
'use strict';
var SalaryDeductionCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'voucher', 'Employee', function ($scope, $location, dateFilter, $modal, voucher, Employee) {
var SalaryDeductionCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'voucher', 'Employee', function ($scope, $location, asDate, $modal, voucher, Employee) {
$scope.voucher = voucher;
function getOldItem(ledgerID, items) {
@@ -39,19 +39,19 @@ var SalaryDeductionCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'vouch
function getEsi(grossSalary, daysWorked, daysInMonth) {
var limit = 15000,
employee_rate = 0.0175,
employer_rate = 0.0475,
employee = (grossSalary > limit) ? 0 : Math.ceil(employee_rate * grossSalary * daysWorked / daysInMonth),
employer = (grossSalary > limit) ? 0 : Math.ceil(employer_rate * grossSalary * daysWorked / daysInMonth);
employeeRate = 0.0175,
employerRate = 0.0475,
employee = (grossSalary > limit) ? 0 : Math.ceil(employeeRate * grossSalary * daysWorked / daysInMonth),
employer = (grossSalary > limit) ? 0 : Math.ceil(employerRate * grossSalary * daysWorked / daysInMonth);
return {ee: employee, er: employer, both: employee + employer};
}
function getPf(grossSalary, daysWorked, daysInMonth) {
var limit = 6500,
employee_rate = 0.12,
employer_rate = 0.12 + 0.011 + 0.005 + 0.0001,
employee = (grossSalary > limit) ? 0 : Math.ceil(employee_rate * grossSalary * daysWorked / daysInMonth),
employer = (grossSalary > limit) ? 0 : Math.ceil(employer_rate * grossSalary * daysWorked / daysInMonth);
employeeRate = 0.12,
employerRate = 0.12 + 0.011 + 0.005 + 0.0001,
employee = (grossSalary > limit) ? 0 : Math.ceil(employeeRate * grossSalary * daysWorked / daysInMonth),
employer = (grossSalary > limit) ? 0 : Math.ceil(employerRate * grossSalary * daysWorked / daysInMonth);
return {ee: employee, er: employer, both: employee + employer};
}
@@ -63,7 +63,7 @@ var SalaryDeductionCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'vouch
esi = getEsi(grossSalary, daysWorked, daysInMonth),
pf = getPf(grossSalary, daysWorked, daysInMonth);
if (typeof oldJournal !== 'undefined') {
if (!angular.isUndefined(oldJournal)) {
$scope.toasts.push({Type: 'Danger', Message: 'Employee has already been added!'});
} else {
this.voucher.SalaryDeductions.push({
@@ -88,9 +88,9 @@ var SalaryDeductionCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'vouch
};
$scope.preventAlteration = function (voucher) {
if (typeof $scope.perms === 'undefined') {
if (angular.isUndefined($scope.perms)) {
return false;
} else if (typeof voucher.VoucherID === 'undefined') {
} else if (angular.isUndefined(voucher.VoucherID)) {
return !$scope.perms['Salary Deduction'];
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
return true;
@@ -110,9 +110,7 @@ var SalaryDeductionCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'vouch
};
$scope.save = function () {
if (angular.isDate($scope.voucher.Date)) {
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
}
$scope.voucher.Date = asDate($scope.voucher.Date);
$scope.voucher.$save({type: 'Salary Deduction'}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/SalaryDeduction/' + u.VoucherID);
@@ -169,7 +167,7 @@ SalaryDeductionCtrl.resolve = {
voucher: ['$route', 'Voucher', function ($route, Voucher) {
var id = $route.current.params.id;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
return Voucher.get({type: 'Salary Deduction'}).$promise;
} else {
return Voucher.get({id: id}).$promise;
+6 -8
View File
@@ -1,6 +1,6 @@
'use strict';
var SettingsCtrl = ['$scope', '$http', 'dateFilter', '$modal', 'lockInfo', 'Product', function ($scope, $http, dateFilter, $modal, lockInfo, Product) {
var SettingsCtrl = ['$scope', '$http', 'asDateFilter', '$modal', 'lockInfo', 'Product', function ($scope, $http, asDate, $modal, lockInfo, Product) {
$scope.lockInfo = lockInfo.data;
$scope.rebaseDate = '';
$scope.setLockDate = function () {
@@ -8,7 +8,7 @@ var SettingsCtrl = ['$scope', '$http', 'dateFilter', '$modal', 'lockInfo', 'Prod
if ($scope.lockInfo.Start.Rolling) {
$scope.lockInfo.Start.Days = parseInt($scope.lockInfo.Start.Days, 10);
} else if (angular.isDate($scope.lockInfo.Start.Date)) {
$scope.lockInfo.Start.Date = dateFilter($scope.lockInfo.Start.Date, 'dd-MMM-yyyy');
$scope.lockInfo.Start.Date = asDate($scope.lockInfo.Start.Date);
}
}
@@ -16,7 +16,7 @@ var SettingsCtrl = ['$scope', '$http', 'dateFilter', '$modal', 'lockInfo', 'Prod
if ($scope.lockInfo.Finish.Rolling) {
$scope.lockInfo.Finish.Days = parseInt($scope.lockInfo.Finish.Days, 10);
} else if (angular.isDate($scope.lockInfo.Finish.Date)) {
$scope.lockInfo.Finish.Date = dateFilter($scope.lockInfo.Finish.Date, 'dd-MMM-yyyy');
$scope.lockInfo.Finish.Date = asDate($scope.lockInfo.Finish.Date);
}
}
return $http.post('/api/LockInfo', $scope.lockInfo).
@@ -64,9 +64,7 @@ var SettingsCtrl = ['$scope', '$http', 'dateFilter', '$modal', 'lockInfo', 'Prod
if ($scope.rebaseDate === '') {
return;
}
if (angular.isDate($scope.rebaseDate)) {
$scope.rebaseDate = dateFilter($scope.rebaseDate, 'dd-MMM-yyyy');
}
$scope.rebaseDate = asDate($scope.rebaseDate);
$http({method: 'POST', url: '/api/Rebase/' + $scope.rebaseDate}).
success(function (data) {
$scope.toasts.push({Type: 'Success', Message: 'Data rebased!'});
@@ -109,8 +107,8 @@ var SettingsCtrl = ['$scope', '$http', 'dateFilter', '$modal', 'lockInfo', 'Prod
if (angular.isUndefined($scope.qty) || $scope.qty === '') {
return;
}
var resetDate = angular.isDate($scope.resetDate) ? dateFilter($scope.resetDate, 'dd-MMM-yyyy') : $scope.resetDate;
var stockDate = angular.isDate($scope.stockDate) ? dateFilter($scope.stockDate, 'dd-MMM-yyyy') : $scope.stockDate;
var resetDate = asDate($scope.resetDate);
var stockDate = asDate($scope.stockDate);
var qty = Number($scope.qty);
$http({method: 'POST', url: '/api/ResetStock/' + $scope.product.ProductID, params: {StockDate: stockDate, ResetDate: resetDate, Quantity: qty}}).
success(function (data) {
+10 -14
View File
@@ -1,28 +1,24 @@
'use strict';
var StockMovementCtrl = ['$scope', '$location', 'dateFilter', 'stock_movement', function ($scope, $location, dateFilter, stock_movement) {
$scope.info = stock_movement;
var StockMovementCtrl = ['$scope', '$location', 'asDateFilter', 'stockMovement', function ($scope, $location, asDate, stockMovement) {
$scope.info = stockMovement;
$scope.show = function () {
if (angular.isDate($scope.info.StartDate)) {
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.info.FinishDate)) {
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
}
$location.path('/StockMovement').search({StartDate: $scope.info.StartDate, FinishDate: $scope.info.FinishDate});
var startDate = asDate($scope.info.StartDate),
finishDate = asDate($scope.info.FinishDate);
$location.path('/StockMovement').search({StartDate: startDate, FinishDate: finishDate});
};
$('#txtStartDate').focus();
}];
StockMovementCtrl.resolve = {
stock_movement: ['$route', 'StockMovement', function ($route, StockMovement) {
var start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
stockMovement: ['$route', 'StockMovement', function ($route, StockMovement) {
var startDate = $route.current.params.StartDate,
finishDate = $route.current.params.FinishDate;
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
if (angular.isUndefined(startDate) || angular.isUndefined(finishDate)) {
return StockMovement.get({}).$promise;
} else {
return StockMovement.get({StartDate: start_date, FinishDate: finish_date}).$promise;
return StockMovement.get({StartDate: startDate, FinishDate: finishDate}).$promise;
}
}]
};
+5 -9
View File
@@ -1,21 +1,17 @@
'use strict';
var TrialBalanceCtrl = ['$scope', '$location', 'dateFilter', 'trial_balance', function ($scope, $location, dateFilter, trial_balance) {
$scope.info = trial_balance;
var TrialBalanceCtrl = ['$scope', '$location', 'asDateFilter', 'trialBalance', function ($scope, $location, asDate, trialBalance) {
$scope.info = trialBalance;
$scope.show = function () {
if (angular.isDate($scope.info.Date)) {
$scope.info.Date = dateFilter($scope.info.Date, 'dd-MMM-yyyy');
}
$location.path('/TrialBalance/' + $scope.info.Date);
$location.path('/TrialBalance/' + asDate($scope.info.Date));
};
$('#txtDate').focus();
}];
TrialBalanceCtrl.resolve = {
trial_balance: ['$route', 'TrialBalance', function ($route, TrialBalance) {
trialBalance: ['$route', 'TrialBalance', function ($route, TrialBalance) {
var date = $route.current.params.date;
if (typeof date === 'undefined') {
if (angular.isUndefined(date)) {
return TrialBalance.get({}).$promise;
} else {
return TrialBalance.get({date: date}).$promise;
-1
View File
@@ -36,7 +36,6 @@ var UserCtrl = ['$scope', '$location', 'user', function ($scope, $location, user
UserCtrl.resolve = {
user: ['$route', 'User', function ($route, User) {
var id = $route.current.params.id;
return User.get({id: id}).$promise;
}]
};