'use strict';

var TrialBalanceCtrl = ['$scope', '$location', 'dateFilter', 'trial_balance', function ($scope, $location, dateFilter, trial_balance) {
    $scope.info = trial_balance;

    $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);
    };
    $('#txtDate').focus();
}];
TrialBalanceCtrl.resolve = {
    trial_balance: ['$route', 'TrialBalance', function ($route, TrialBalance) {
        var date = $route.current.params.date;

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