'use strict';

var BalanceSheetCtrl = ['$scope', '$location', 'asDateFilter', 'info', function ($scope, $location, asDate, info) {
    $scope.info = info;
    $scope.show = function () {
        var date = asDate($scope.info.Date);
        $location.path('/BalanceSheet/' + date);
    };
    $('#txtStartDate').focus();
}];

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

        if (angular.isUndefined(date)) {
            return BalanceSheet.get({}).$promise;
        } else {
            return BalanceSheet.get({date: date}).$promise;
        }
    }]
};