{"size": 865, "ext": "js", "max_stars_repo_path": "client/app/features/main/dashboard/taxes/sellerDetails/sellerDetails.resolve.js", "max_stars_repo_name": "zperk0/preo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/app/features/main/dashboard/taxes/sellerDetails/sellerDetails.resolve.js", "max_issues_repo_name": "zperk0/preo", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/app/features/main/dashboard/taxes/sellerDetails/sellerDetails.resolve.js", "max_forks_repo_name": "zperk0/preo", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.9032258065, "max_line_length": 100, "alphanum_fraction": 0.6358381503}

export default function taxSettingsResolve($q, TaxesService, StateService, Spinner, authenticated) {
  'ngInject';

  const deferred = $q.defer();
  const LOADER_KEY = 'tax-settings-fetch';

  Spinner.show(LOADER_KEY);

  TaxesService.getTaxSettings(true)
    .then((taxSettings) => {
      deferred.resolve(taxSettings);
    }).catch((err) => {
      // Add new Tax Settings
      if (angular.isObject(err) && err.status && err.status == 404) {
        const taxSettings = new Preoday.TaxSettings({
          channelId: StateService.channel && StateService.channel.id,
          venueId: StateService.venue && StateService.venue.id
        });
        // Resolve as new Tax Settings
        return deferred.resolve(taxSettings);
      }
      deferred.reject(err);
    })
    .finally(() => {
      Spinner.hide(LOADER_KEY);
    });

  return deferred.promise;
}
