'use strict';

var NetTransactionsController = ['$scope', '$location', 'asDateFilter', 'netTransactions', function ($scope, $location, asDate, netTransactions) {
    $scope.info = netTransactions;
    $scope.show = function () {
        var startDate = asDate($scope.info.StartDate),
            finishDate = asDate($scope.info.FinishDate);
        $location.path('/NetTransactions').search({StartDate: startDate, FinishDate: finishDate});
    };
    $scope.foDate = true;
}];

NetTransactionsController.resolve = {
    netTransactions: ['$route', 'NetTransactions', function ($route, NetTransactions) {
        var startDate = $route.current.params.StartDate,
            finishDate = $route.current.params.FinishDate;

        if (angular.isUndefined(startDate) || angular.isUndefined(finishDate)) {
            return NetTransactions.get({}).$promise;
        } else {
            return NetTransactions.get({StartDate: startDate, FinishDate: finishDate}).$promise;
        }
    }]
};