<commit_before>(function () {
  'use strict';

  // Generals controller
  angular
    .module('generals')
    .controller('GeneralsController', GeneralsController);

  GeneralsController.$inject = ['$scope', '$state', '$window', 'Authentication', 'generalResolve'];

  function GeneralsController ($scope, $state, $window, Authentication, general) {
    var vm = this;

    vm.authentication = Authentication;
    vm.general = general;
    vm.error = null;
    vm.form = {};
    vm.remove = remove;
    vm.save = save;
    vm.saveToApprove = function(isValid){
      if (!isValid) {
        $scope.$broadcast('show-errors-check-validity', 'vm.form.generalForm');
        return false;
      }
      vm.general.status = 'waiting for approve';
      vm.save(true);
    }

    vm.approved = function(){
      
      vm.general.status = 'approved';
      vm.save(true);
    }

    vm.rejected = function(){
      
      vm.general.status = 'rejected';
      vm.save(true);
    }

    // Remove existing General
    function remove() {
      if ($window.confirm('Are you sure you want to delete?')) {
        vm.general.$remove($state.go('generals.list'));
      }
    }

    // Save General
    function save(isValid) {
      if (!isValid) {
        $scope.$broadcast('show-errors-check-validity', 'vm.form.generalForm');
        return false;
      }

      // TODO: move create/update logic to service
      if (vm.general._id) {
        vm.general.$update(successCallback, errorCallback);<commit_msg>fdfds<commit_after>(function () {
  'use strict';

  // Generals controller
  angular
    .module('generals')
    .controller('GeneralsController', GeneralsController);

  GeneralsController.$inject = ['$scope', '$state', '$window', 'Authentication', 'generalResolve'];

  function GeneralsController($scope, $state, $window, Authentication, general) {
    var vm = this;




    vm.authentication = Authentication;
    vm.general = general;
    if (vm.general.trnsdate) {
      vm.general.trnsdate = new Date(vm.general.trnsdate);
    }
    if (vm.general.estexpense.apprvdate) {
      vm.general.estexpense.apprvdate = new Date(vm.general.estexpense.apprvdate);
    }
    vm.error = null;
    vm.form = {};
    vm.remove = remove;
    vm.save = save;
    vm.saveToApprove = function (isValid) {
      if (!isValid) {
        $scope.$broadcast('show-errors-check-validity', 'vm.form.generalForm');
        return false;
      }
      vm.general.status = 'waiting for approve';
      vm.save(true);
    }

    vm.approved = function () {

      vm.general.status = 'approved';
      vm.save(true);
    }

    vm.rejected = function () {

      vm.general.status = 'rejected';
      vm.save(true);
    }

    // Remove existing General
    function remove() {
      if ($window.confirm('Are you sure you want to delete?')) {
        vm.general.$remove($state.go('generals.list'));
      }
    }

    // Save General
    function save(isValid) {
      if (!isValid) {
        $scope.$broadcast('show-errors-check-validity', 'vm.form.generalForm');
        return false;
      }

      // TODO: move create/update logic to service
      if (vm.general._id) {
        vm.general.$update(successCallback, errorCallback);
{'fraction_non_alphanumeric': 0.1477909147479776, 'fraction_numerical': 0.0, 'mean_word_length': 2.5643015521064303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6125713', 'n_tokens_mistral': 989, 'n_tokens_neox': 969, 'n_words': 195}