• Resolved pexel

    (@pexel)


    Hello, can you help me identify where I’m making a mistake in this code? I’m trying to write a scenario. The code for the scenario is linked below.

    L?NK

    Direct form URL:?FORM URL

    According to this scenario, I’m adapting it, but the result for criterion 1 is not coming out.

    Thank you!

    (function() {
    var kriter1 = '';
    var self = {
    a4Dates: [
    ["01/01/1900", "05/08/1991"],
    ["06/08/1991", "05/08/1994"],
    ["06/08/1994", "05/08/1997"],
    ["06/08/1997", "05/08/2000"],
    ["06/08/2000", "05/08/2003"],
    ["06/08/2003", "30/09/2008"],
    ["01/10/2008", "31/12/2008"],
    ["01/10/2009", "31/12/2009"],
    ["01/01/2010", "31/12/2010"],
    ["01/01/2011", "31/12/2011"],
    ["01/01/2012", "31/12/2012"],
    ["01/01/2013", "31/12/2013"],
    ["01/01/2014", "31/12/2014"],
    ["01/01/2015", "31/12/2100"]
    ],
    a4Rates: [
    [[80, 100, [15, 0, 3600]], [60, 79, [15, 0, 3600]], [40, 59, [15, 0, 3600]]],
    [[80, 100, [15, 0, 3600]], [60, 79, [15, 8, 3680]], [40, 59, [16, 0, 3760]]],
    [[80, 100, [15, 0, 3600]], [60, 79, [16, 4, 3760]], [40, 59, [17, 0, 3920]]],
    [[80, 100, [15, 0, 3600]], [60, 79, [17, 0, 3840]], [40, 59, [18, 0, 4080]]],
    [[80, 100, [15, 0, 3600]], [60, 79, [17, 8, 3920]], [40, 59, [19, 0, 4240]]],
    [[80, 100, [15, 0, 3600]], [60, 79, [18, 0, 4000]], [40, 59, [20, 0, 4400]]],
    [[60, 100, [15, 0, 3700]], [50, 59, [16, 0, 3700]], [40, 49, [18, 0, 4100]]],
    [[60, 100, [15, 0, 3800]], [50, 59, [16, 0, 3800]], [40, 49, [18, 0, 4200]]],
    [[60, 100, [15, 0, 3900]], [50, 59, [16, 0, 3900]], [40, 49, [18, 0, 4300]]],
    [[60, 100, [15, 0, 3960]], [50, 59, [16, 0, 4000]], [40, 49, [18, 0, 4400]]],
    [[60, 100, [15, 0, 3960]], [50, 59, [16, 0, 4100]], [40, 49, [18, 0, 4500]]],
    [[60, 100, [15, 0, 3960]], [50, 59, [16, 0, 4200]], [40, 49, [18, 0, 4600]]],
    [[60, 100, [15, 0, 3960]], [50, 59, [16, 0, 4320]], [40, 49, [18, 0, 4680]]]
    ]
    };


    if (fieldname34 === "A") {

    for (var i = 0; i < self.a4Dates.length; i++) {
    var startdate = moment(DATEOBJ(fieldname32, 'dd/mm/yyyy'), 'DD/MM/YYYY');
    var a4Date = self.a4Dates[i];


    if (moment(a4Date[0], 'DD/MM/YYYY').isSameOrBefore(startdate) && moment(a4Date[1], 'DD/MM/YYYY').isSameOrAfter(startdate)) {

    for (var k = 0; k < self.a4Rates[i].length; k++) {
    var a4Rate = self.a4Rates[i][k];


    if (a4Rate[0] <= fieldname37 && a4Rate[1] >= fieldname37) {
    var a4Score = a4Rate[2];


    kriter1 = a4Score[0] + " y?l " + (a4Score[1] === 0 ? "" : a4Score[1] + " ay") + " sigortal?l?k süresi";


    jQuery('#calculation-kriter1').html(kriter1);
    jQuery('.kriter1-aciklama').html('Sonu? : ');
    jQuery('.kriter1-sonuc').html(kriter1);

    return;
    }
    }
    }
    }
    }
    })();
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @pexel

    You don’t need to use moment, our plugin includes the operations required to transform dates. Also, you can compare dates directly:


    let d = DATEOBJ(fieldname32, 'dd/mm/yyyy');
    let d1 = DATEOBJ(self.a4Dates[i][0], 'mm/dd/yyyy');
    let d2 = DATEOBJ(self.a4Dates[i][1], 'mm/dd/yyyy');

    if(AND(d1<=d, d<=d2)) {
    /** The code here **/
    }

    If you want to use the third-party “moment” library and have doubts about its use, you must contact the “moment” development team.

    Best regards.

    Thread Starter pexel

    (@pexel)

    Thanks to you, I have solved the first stage, even 80% of it. Only this part remains, how can we adapt it?

    var totalMonths = (a4Score[0] * 12) + a4Score[1];  
    var a4diffMonths = (a4diff.getFullYear() * 12) + a4diff.getMonth();
    if (a4diffMonths > totalMonths) {
    kriter3 = "Sigortal?l?k Süresi Tamamlanm??";
    } else {
    var remainingMonths = totalMonths - a4diffMonths;
    var reqyear = Math.floor(remainingMonths / 12);
    var reqmonth = remainingMonths % 12;
    kriter3 = reqyear + " Y?l " + (reqmonth === 0 ? "" : reqmonth + " Ay") + " sigortal?l?k süresi";
    }
    Plugin Author codepeople

    (@codepeople)

    Hello @pexel

    Sorry, but the plugin support does not cover implementing the users’ projects.

    Please contact us directly through the plugin website if you need to hire a development service. Contact Us

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.