<commit_before>(function() {

    'use strict';

    /**
     * @ngdoc service
     * @name requisition-validation.requisitionValidator
     *
     * @description
     * Responsible for validating requisitions, lineItems and their fields.
     */
    angular
        .module('requisition-validation')
        .factory('requisitionValidator', requisitionValidator);

    requisitionValidator.$inject = [
        'validationFactory', 'calculationFactory', 'TEMPLATE_COLUMNS', 'COLUMN_SOURCES',
        'messageService'
    ];

    function requisitionValidator(validationFactory, calculationFactory, TEMPLATE_COLUMNS,
                                  COLUMN_SOURCES, messageService) {

        var counterpart = {
            stockOnHand: TEMPLATE_COLUMNS.TOTAL_CONSUMED_QUANTITY,
            totalConsumedQuantity: TEMPLATE_COLUMNS.STOCK_ON_HAND
        };

        var validator = {
            validateRequisition: validateRequisition,
            validateLineItem: validateLineItem,
            validateLineItemField: validateLineItemField,
            isLineItemValid: isLineItemValid
        };
        return validator;

        /**
         * @ngdoc function
         * @name validateRequisition
         * @methodOf requisition-validation.requisitionValidator
         *
         * @description
         * Validates the given requisitions.
         *
         * @param  {Object} requisition the requisition to be validated
         * @return {Boolean}            true if the requisition is valid, false otherwise
         */
        function validateRequisition(requisition) {
            var valid = true,
                validator = this,
                fullSupplyColumns = requisition.template.getColumns(),
                nonFullSupplyColumns = requisition.template.getColumns(true);

            requisition.$fullSupplyCategories.forEach(function(category) {
              category.lineItems.forEach(function(lineItem) {
                valid = validator.validateLineItem(lineItem, fullSupplyColumns) && valid;
              });
            });

            requisition.$nonFullSupplyCategories.forEach(function(category) {
              category.lineItems.forEach(function(lineItem) {
                valid = validator.validateLineItem(lineItem, nonFullSupplyColumns) && valid;
              });
            });

            return valid;
        }

        /**
         * @ngdoc method
         * @name validateLineItem
         * @methodOf requisition-validation.requisitionValidator
         *
         * @description
         * Validates the given line item.
         *
         * @param  {Object} lineItem the line item to be validated
         * @param  {Object} columns  the list of columns to validate the line item for
         * @return {Boolean}         true if the line item is valid, false otherwise
         */
        function validateLineItem(lineItem, columns, requisition) {
            var valid = true,
                validator = this;

            columns.forEach(function(column) {
                valid = validator.validateLineItemField(lineItem, column, columns, requisition) && valid;
            });<commit_msg>OLMIS-1700: Fixed issue with requisition submision<commit_after>(function() {

    'use strict';

    /**
     * @ngdoc service
     * @name requisition-validation.requisitionValidator
     *
     * @description
     * Responsible for validating requisitions, lineItems and their fields.
     */
    angular
        .module('requisition-validation')
        .factory('requisitionValidator', requisitionValidator);

    requisitionValidator.$inject = [
        'validationFactory', 'calculationFactory', 'TEMPLATE_COLUMNS', 'COLUMN_SOURCES',
        'messageService'
    ];

    function requisitionValidator(validationFactory, calculationFactory, TEMPLATE_COLUMNS,
                                  COLUMN_SOURCES, messageService) {

        var counterpart = {
            stockOnHand: TEMPLATE_COLUMNS.TOTAL_CONSUMED_QUANTITY,
            totalConsumedQuantity: TEMPLATE_COLUMNS.STOCK_ON_HAND
        };

        var validator = {
            validateRequisition: validateRequisition,
            validateLineItem: validateLineItem,
            validateLineItemField: validateLineItemField,
            isLineItemValid: isLineItemValid
        };
        return validator;

        /**
         * @ngdoc function
         * @name validateRequisition
         * @methodOf requisition-validation.requisitionValidator
         *
         * @description
         * Validates the given requisitions.
         *
         * @param  {Object} requisition the requisition to be validated
         * @return {Boolean}            true if the requisition is valid, false otherwise
         */
        function validateRequisition(requisition) {
            var valid = true,
                validator = this,
                fullSupplyColumns = requisition.template.getColumns(),
                nonFullSupplyColumns = requisition.template.getColumns(true);

            requisition.$fullSupplyCategories.forEach(function(category) {
              category.lineItems.forEach(function(lineItem) {
                valid = validator.validateLineItem(lineItem, fullSupplyColumns, requisition) && valid;
              });
            });

            requisition.$nonFullSupplyCategories.forEach(function(category) {
              category.lineItems.forEach(function(lineItem) {
                valid = validator.validateLineItem(lineItem, nonFullSupplyColumns, requisition) && valid;
              });
            });

            return valid;
        }

        /**
         * @ngdoc method
         * @name validateLineItem
         * @methodOf requisition-validation.requisitionValidator
         *
         * @description
         * Validates the given line item.
         *
         * @param  {Object} lineItem the line item to be validated
         * @param  {Object} columns  the list of columns to validate the line item for
         * @return {Boolean}         true if the line item is valid, false otherwise
         */
        function validateLineItem(lineItem, columns, requisition) {
            var valid = true,
                validator = this;

            columns.forEach(function(column) {
                valid = validator.validateLineItemField(lineItem, column, columns, requisition) && valid;
            });
{'fraction_non_alphanumeric': 0.07910846021032805, 'fraction_numerical': 0.0006278449223041908, 'mean_word_length': 2.0531863919501676, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2371866', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1526, 'n_words': 337}