Feature: Credit Service Charge with adjustable service points

Refactor: Renamed column, table, and uses of Cost Center to Cost Centre
Refactor: Renamed costcenter to cost_centre
This commit is contained in:
tanshu committed 2015-02-12 17:42:46 +05:30
1 parent fdcedb262c
commit 6a815692bd
58 files changed
+843 -526

No files matched your search

+6 -6
View File
@@ -18,7 +18,7 @@ var AccountListController = ['$scope', '$location', '$routeParams', 'Tokenizer',
't': {'Col': 'Type', 'Comparator': 'text'},
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
'r': {'Col': 'IsReconcilable', 'Comparator': 'boolean'},
'c': {'Col': 'CostCenter', 'Comparator': 'text'}
'c': {'Col': 'CostCentre', 'Comparator': 'text'}
},
def: 'n',
sorter: {
@@ -26,7 +26,7 @@ var AccountListController = ['$scope', '$location', '$routeParams', 'Tokenizer',
't': 'Type',
'a': 'IsActive',
'r': 'IsReconcilable',
'c': 'CostCenter'
'c': 'CostCentre'
}
};
$scope.filterAccounts = _.debounce(function (q) {
@@ -76,11 +76,11 @@ AccountListController.resolve = {
}]
};
var AccountController = ['$scope', '$location', '$modal', 'account', 'accountTypes', 'costCenters', function ($scope, $location, $modal, account, accountTypes, costCenters) {
var AccountController = ['$scope', '$location', '$modal', 'account', 'accountTypes', 'costCentres', function ($scope, $location, $modal, account, accountTypes, costCentres) {
$scope.account = account;
$scope.accountTypes = accountTypes;
$scope.costCenters = costCenters;
$scope.costCentres = costCentres;
$scope.save = function () {
$scope.account.$save(function () {
@@ -131,7 +131,7 @@ AccountController.resolve = {
accountTypes: ['AccountType', function (AccountType) {
return AccountType.query({}).$promise;
}],
costCenters: ['CostCenter', function (CostCenter) {
return CostCenter.query({}).$promise;
costCentres: ['CostCentre', function (CostCentre) {
return CostCentre.query({}).$promise;
}]
};
+29 -6
View File
@@ -85,9 +85,9 @@ overlordService.factory('ProductLedger', ['$resource', function ($resource) {
return $resource('/api/ProductLedger/:id');
}]);
overlordService.factory('CostCenter', ['$resource', function ($resource) {
return $resource('/api/CostCenter/:id',
{id: '@CostCenterID'}, {
overlordService.factory('CostCentre', ['$resource', function ($resource) {
return $resource('/api/CostCentre/:id',
{id: '@CostCentreID'}, {
query: {method: 'GET', params: {list: true}, isArray: true}
});
}]);
@@ -139,9 +139,9 @@ overlordService.factory('ProductGroup', ['$resource', function ($resource) {
});
}]);
overlordService.factory('CostCenter', ['$resource', function ($resource) {
return $resource('/api/CostCenter/:id',
{id: '@CostCenterID'}, {
overlordService.factory('CostCentre', ['$resource', function ($resource) {
return $resource('/api/CostCentre/:id',
{id: '@CostCentreID'}, {
query: {method: 'GET', params: {list: true}, isArray: true}
});
}]);
@@ -270,6 +270,29 @@ overlordService.factory('Tokenizer', ['$filter', function ($filter) {
return obj.toLowerCase().indexOf(text) > -1;
}
},
'date': function (obj, text) {
var reGoodDate = /^((0?[1-9]|[12][0-9]|3[01])[- /.](0?[1-9]|1[012]|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[- /.](19|20)?[0-9]{2})*$/i,
asDateObject = function (input) {
if (angular.isDate(input)) {
return input;
}
},
op = opLength(text),
ob = op ? asDateObject(obj) : '',
tex = op ? asDateObject(text.substr(op).trim()) : '';
if (op) {
return operators[text.substr(0, op)](ob, tex);
} else {
return obj.toString().indexOf(text) > -1;
}
if (text.indexOf('!') === 0) {
return obj.toLowerCase().indexOf(text.substr(1)) <= -1;
} else {
return obj.toLowerCase().indexOf(text) > -1;
}
},
'boolean': function (obj, text) {
return obj === isTrue(text);
},
-41
View File
@@ -1,41 +0,0 @@
'use strict';
var CostCenterListController = ['$scope', 'costCenters', function ($scope, costCenters) {
$scope.info = costCenters;
}];
CostCenterListController.resolve = {
costCenters: ['CostCenter', function (CostCenter) {
return CostCenter.query({}).$promise;
}]
};
var CostCenterController = ['$scope', '$routeParams', '$location', 'costCenter', function ($scope, $routeParams, $location, costCenter) {
$scope.costCenter = costCenter;
$scope.save = function () {
$scope.costCenter.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/CostCenters')
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.delete = function () {
$scope.costCenter.$delete(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/CostCenters')
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.foName = true;
}];
CostCenterController.resolve = {
costCenter: ['$route', 'CostCenter', function ($route, CostCenter) {
var id = $route.current.params.id;
return CostCenter.get({id: id}).$promise;
}]
};
+41
View File
@@ -0,0 +1,41 @@
'use strict';
var CostCentreListController = ['$scope', 'costCentres', function ($scope, costCentres) {
$scope.info = costCentres;
}];
CostCentreListController.resolve = {
costCentres: ['CostCentre', function (CostCentre) {
return CostCentre.query({}).$promise;
}]
};
var CostCentreController = ['$scope', '$routeParams', '$location', 'costCentre', function ($scope, $routeParams, $location, costCentre) {
$scope.costCentre = costCentre;
$scope.save = function () {
$scope.costCentre.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/CostCentres')
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.delete = function () {
$scope.costCentre.$delete(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/CostCentres')
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.foName = true;
}];
CostCentreController.resolve = {
costCentre: ['$route', 'CostCentre', function ($route, CostCentre) {
var id = $route.current.params.id;
return CostCentre.get({id: id}).$promise;
}]
};
@@ -17,25 +17,6 @@ var EmployeeFunctionsController = ['$scope', '$http', 'asDateFilter', function (
});
};
$scope.creditServiceCharge = function () {
if (!angular.isDate($scope.sc.Month)) {
return;
}
var ServiceChargeMonth = asDate($scope.sc.Month);
if (!angular.isDate($scope.sc.CreditDate)) {
return;
}
var CreditDate = asDate($scope.sc.CreditDate);
return $http.
post('/api/CreditServiceCharge', {Month: ServiceChargeMonth, CreditDate: CreditDate}).
success(function (data) {
$scope.toasts.push({Type: 'Success', Message: data.message});
}).
error(function (errorMessage) {
$scope.toasts.push({Type: 'Danger', Message: errorMessage});
});
};
$scope.attendanceRecordUrl = function () {
if (!$scope.record.StartDate || !$scope.record.FinishDate) {
return;
+6 -6
View File
@@ -19,7 +19,7 @@ var EmployeeListController = ['$scope', '$location', '$routeParams', 'Tokenizer'
's': {'Col': 'Salary', 'Comparator': 'numeric'},
'a': {'Col': 'IsActive', 'Comparator': 'boolean'},
'des': {'Col': 'Designation', 'Comparator': 'text'},
'dep': {'Col': 'CostCenter', 'Comparator': 'text'}
'dep': {'Col': 'CostCentre', 'Comparator': 'text'}
},
def: 'n',
sorter: {
@@ -28,7 +28,7 @@ var EmployeeListController = ['$scope', '$location', '$routeParams', 'Tokenizer'
's': 'Salary',
'a': 'IsActive',
'des': 'Designation',
'dep': 'CostCenter'
'dep': 'CostCentre'
}
};
$scope.filterEmployees = _.debounce(function (q) {
@@ -79,10 +79,10 @@ EmployeeListController.resolve = {
}]
};
var EmployeeController = ['$scope', '$routeParams', '$location', 'asDateFilter', '$modal', 'employee', 'costCenters', function ($scope, $routeParams, $location, asDate, $modal, employee, costCenters) {
var EmployeeController = ['$scope', '$routeParams', '$location', 'asDateFilter', '$modal', 'employee', 'costCentres', function ($scope, $routeParams, $location, asDate, $modal, employee, costCentres) {
$scope.employee = employee;
$scope.costCenters = costCenters;
$scope.costCentres = costCentres;
$scope.save = function () {
$scope.employee.JoiningDate = asDate($scope.employee.JoiningDate);
@@ -132,7 +132,7 @@ EmployeeController.resolve = {
var id = $route.current.params.id;
return Employee.get({id: id}).$promise;
}],
costCenters: ['CostCenter', function (CostCenter) {
return CostCenter.query({}).$promise;
costCentres: ['CostCentre', function (CostCentre) {
return CostCentre.query({}).$promise;
}]
};
+5 -5
View File
@@ -1,8 +1,8 @@
'use strict';
var IssueController = ['$scope', '$routeParams', '$location', 'asDateFilter', 'voucher', 'costCenters', 'smallGrid', 'IssueGrid', 'Voucher', '$modal', 'Batch', function ($scope, $routeParams, $location, asDate, voucher, costCenters, smallGrid, IssueGrid, Voucher, $modal, Batch) {
var IssueController = ['$scope', '$routeParams', '$location', 'asDateFilter', 'voucher', 'costCentres', 'smallGrid', 'IssueGrid', 'Voucher', '$modal', 'Batch', function ($scope, $routeParams, $location, asDate, voucher, costCentres, smallGrid, IssueGrid, Voucher, $modal, Batch) {
$scope.voucher = voucher;
$scope.costCenters = costCenters;
$scope.costCentres = costCentres;
$scope.smallGrid = smallGrid;
if (angular.isUndefined($routeParams.Source) && angular.isUndefined($routeParams.Destination) && angular.isUndefined($routeParams.id)) {
@@ -81,7 +81,7 @@ var IssueController = ['$scope', '$routeParams', '$location', 'asDateFilter', 'v
function getDebitCredit(journals, type) {
for (var i = 0, l = journals.length; i < l; i++) {
if (journals[i].Debit === type) {
return journals[i].CostCenter.CostCenterID;
return journals[i].CostCentre.CostCentreID;
}
}
}
@@ -279,8 +279,8 @@ IssueController.resolve = {
return [];
}
}],
costCenters: ['CostCenter', function (CostCenter) {
return CostCenter.query({}).$promise;
costCentres: ['CostCentre', function (CostCentre) {
return CostCentre.query({}).$promise;
}]
};
+6 -3
View File
@@ -28,6 +28,9 @@ var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filte
when('/SalaryDeduction', {templateUrl: '/partial/salary-deduction.html', controller: SalaryDeductionController, resolve: SalaryDeductionController.resolve}).
when('/SalaryDeduction/:id', {templateUrl: '/partial/salary-deduction.html', controller: SalaryDeductionController, resolve: SalaryDeductionController.resolve}).
when('/ServiceCharge', {templateUrl: '/partial/employee-service-charge.html', controller: ServiceChargeController, resolve: ServiceChargeController.resolve}).
when('/ServiceCharge/:id', {templateUrl: '/partial/employee-service-charge.html', controller: ServiceChargeController, resolve: ServiceChargeController.resolve}).
when('/Ledger', {templateUrl: '/partial/ledger.html', controller: LedgerController, resolve: LedgerController.resolve}).
when('/Ledger/:id', {templateUrl: '/partial/ledger.html', controller: LedgerController, resolve: LedgerController.resolve}).
@@ -75,9 +78,9 @@ var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filte
when('/Employee', {templateUrl: '/partial/employee-detail.html', controller: EmployeeController, resolve: EmployeeController.resolve}).
when('/Employee/:id', {templateUrl: '/partial/employee-detail.html', controller: EmployeeController, resolve: EmployeeController.resolve}).
when('/CostCenters', {templateUrl: '/partial/cost-center-list.html', controller: CostCenterListController, resolve: CostCenterListController.resolve}).
when('/CostCenter', {templateUrl: '/partial/cost-center-detail.html', controller: CostCenterController, resolve: CostCenterController.resolve}).
when('/CostCenter/:id', {templateUrl: '/partial/cost-center-detail.html', controller: CostCenterController, resolve: CostCenterController.resolve}).
when('/CostCentres', {templateUrl: '/partial/cost-centre-list.html', controller: CostCentreListController, resolve: CostCentreListController.resolve}).
when('/CostCentre', {templateUrl: '/partial/cost-centre-detail.html', controller: CostCentreController, resolve: CostCentreController.resolve}).
when('/CostCentre/:id', {templateUrl: '/partial/cost-centre-detail.html', controller: CostCentreController, resolve: CostCentreController.resolve}).
when('/Products', {templateUrl: '/partial/product-list.html', controller: ProductListController, resolve: ProductListController.resolve, reloadOnSearch:false}).
when('/Product', {templateUrl: '/partial/product-detail.html', controller: ProductController, resolve: ProductController.resolve}).
+114
View File
@@ -0,0 +1,114 @@
'use strict';
var ServiceChargeController = ['$scope', '$location', '$routeParams', 'numberFilter', 'asDateFilter', '$modal', 'voucher', function ($scope, $location, $routeParams, numberFilter, asDate, $modal, voucher) {
$scope.voucher = voucher;
$scope.TotalPoints = function (){
return _($scope.voucher.ServiceCharges).map(function (item) {
return item.DaysWorked * Number(item.Points);
}).reduce(function (sum, item) {
return sum + item;
});
};
$scope.PointValue = function () {
return Math.round($scope.voucher.ServiceCharge * 100 / $scope.TotalPoints()) / 100;
};
$scope.less = function (employee) {
if (employee.Points >= 1) {
employee.Points -= 1;
}
};
$scope.more = function (employee) {
employee.Points += 1;
};
$scope.$watch('voucher.Date', function (newDate, oldDate) {
var nDate = asDate(newDate),
oDate = asDate(oldDate);
if (nDate !== oDate && !angular.isUndefined(nDate)) {
if (angular.isUndefined($routeParams.id)) {
return voucher.$get({type: 'Service Charge', Date: nDate}).$promise;
}
}
}, true);
$scope.employeeAmount = function (employee) {
return Number(employee.Points) * employee.DaysWorked * $scope.PointValue();
}
$scope.preventAlteration = function (voucher) {
if (angular.isUndefined($scope.perms)) {
return false;
} else if (angular.isUndefined(voucher.VoucherID)) {
return !$scope.perms['Service Charge'];
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
return true;
} else if (voucher.User.UserID !== $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
return true;
} else {
return false;
}
};
$scope.save = function () {
$scope.voucher.Date = asDate($scope.voucher.Date);
$scope.voucher.$save({type: 'Service Charge'}, function (u) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/ServiceCharge/' + u.VoucherID);
}, function (data) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.delete = function () {
$scope.voucher.$delete(function () {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/ServiceCharge').replace();
}, function (data) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.post = function () {
$scope.voucher.$post(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.confirm = function () {
var modalInstance = $modal.open({
backdrop: true,
templateUrl: '/template/modal/confirm.html',
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
$scope.title = "Delete Voucher";
$scope.body = "Are you sure? This cannot be undone.";
$scope.isDelete = true;
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}]
});
modalInstance.result.then(function () {
$scope.delete();
});
};
}];
ServiceChargeController.resolve = {
voucher: ['$route', 'Voucher', function ($route, Voucher) {
var id = $route.current.params.id;
if (angular.isUndefined(id)) {
return Voucher.get({type: 'Service Charge'}).$promise;
} else {
return Voucher.get({id: id}).$promise;
}
}]
};