'use strict';

var BalanceSheetCtrl = ['$scope', '$location', 'dateFilter', 'info', function ($scope, $location, dateFilter, 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);
    };
    $('#txtStartDate').focus();
}];

BalanceSheetCtrl.resolve = {
    info: ['$route', 'BalanceSheet', function ($route, BalanceSheet) {
        var date = $route.current.params.date;

        if (typeof date === 'undefined') {
            return BalanceSheet.get({}).$promise;
        } else {
            return BalanceSheet.get({date:date}).$promise;
        }
    }]
};