'use strict';

function TrialBalanceCtrl($scope, $routeParams, $location, trial_balance) {
    $scope.info = trial_balance;

    $scope.show = function () {
        $location.path('/TrialBalance/' + $scope.info.Date);
    };
    $('#txtDate').focus();
}
TrialBalanceCtrl.resolve = {
    trial_balance:function ($q, $route, TrialBalance) {
        var deferred = $q.defer();

        var date = $route.current.params.date;

        var successCb = function (result) {
            deferred.resolve(result);
        };

        if (typeof date === 'undefined') {
            TrialBalance.get({}, successCb);
        } else {
            TrialBalance.get({date:date}, successCb);
        }
        return deferred.promise;
    }
};