app/classes/commodity.js
// Assign the measure components to the measures - also check for Meursing
Assign the measure components to the measures - also check for Meursing
Assign the measure components to the measures - also check for Meursing
assign_measure_components(req) {
        this.measure_components.forEach(mc => {
            this.measures.forEach(m => {
                if (mc.measure_id == m.id) {
                    var a = 1;
                    if (mc.is_meursing) {
                        m.has_meursing = true;
                        this.has_meursing = true;
                    }
                    m.measure_components.push(mc);
                }
            });
        });
        if (this.has_meursing) {
            var data = require('../data/meursing_duties.json');
            var jp = require('jsonpath');
            var query_string = '$.duties[?(@.geographical_area_id == "1011" && @.additional_code_id == "' + this.meursing_code + '")]'
            var result = jp.query(data, query_string);
            req.session.data["meursing-duties"] = result;
            if (result.length == 0) {
                this.measures.forEach(m => {
                    m.measure_components.forEach(mc => {
                        mc.duty_string_with_meursing = "";
                    });
                });
            } else {
                this.measures.forEach(m => {
                    m.measure_components.forEach(mc => {
                        if (mc.is_meursing) {
                            mc.set_meursing_overlay(result);
                        }
                    });
                });
            }
        }
        this.measures.forEach(m => {
            m.combine_duties();
        });
    }
assign_measure_components ( req ) { this . measure_components . forEach ( mc => { this . measures . forEach ( m => { if ( mc . measure_id == m . id ) { var a = 1 ; if ( mc . is_meursing ) { m . has_meursing = true ; this . has_meursing = true ; } m . measure_components . push ( mc ) ; } } ) ; } ) ; if ( this . has_meursing ) { var data = require ( '../data/meursing_duties.json' ) ; var jp = require ( 'jsonpath' ) ; var query_string = '$.duties[?(@.geographical_area_id == "1011" && @.additional_code_id == "' + this . meursing_code + '")]' var result = jp . query ( data , query_string ) ; req . session . data [ "meursing-duties" ] = result ; if ( result . length == 0 ) { this . measures . forEach ( m => { m . measure_components . forEach ( mc => { mc . duty_string_with_meursing = "" ; } ) ; } ) ; } else { this . measures . forEach ( m => { m . measure_components . forEach ( mc => { if ( mc . is_meursing ) { mc . set_meursing_overlay ( result ) ; } } ) ; } ) ; } } this . measures . forEach ( m => { m . combine_duties ( ) ; } ) ; }
Assign the measure components to the measures - also check for Meursing
Assign the measure components to the measures - also check for Meursing
// Set the Meursing duties for each component