{"id":21333,"date":"2022-04-11T13:56:08","date_gmt":"2022-04-11T11:56:08","guid":{"rendered":"https:\/\/help.openbee.com\/open-bee-scan-capture\/knowledge-base\/how-to-guides\/scripts-in-capture\/case-studies\/index\/index-due-date-45-days-end-of-month\/"},"modified":"2026-05-13T09:36:49","modified_gmt":"2026-05-13T07:36:49","slug":"index-due-date-45-days-end-of-month","status":"publish","type":"page","link":"https:\/\/help.openbee.com\/en\/open-bee-scan-capture\/knowledge-base\/how-to-guides\/scripts-in-capture\/case-studies\/index\/index-due-date-45-days-end-of-month\/","title":{"rendered":"Index: Due date 45 days end of month"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"Index:Dated'&#xE9;ch&#xE9;ance45joursfindemois-Principe:\">Principle:<\/h2>\n\n<p>Calculation of the due date (the scripted index) from the date of the document to which 45 days are added. The end of the month thus calculated is then kept.<\/p>\n\n<h2 class=\"wp-block-heading\" id=\"Index:Dated'&#xE9;ch&#xE9;ance45joursfindemois-Exemples:\">Examples:  <\/h2>\n\n<ul class=\"wp-block-list\"><li>01\/01\/2017 =&gt; 28\/02\/2017<\/li><li>20\/07\/2017 =&gt; 30\/09\/2017<\/li><li>20\/12\/2017 =&gt; 28\/02\/2018<\/li><\/ul>\n\n<h2 class=\"wp-block-heading\" id=\"Index:Dated'&#xE9;ch&#xE9;ance45joursfindemois-Script:\">Script:<\/h2>\n\n<pre class=\"wp-block-code\"><code>\/**\n * @param pParameters : Informations du document (les index dans lesquels on va chercher la date)\n * @param nbDaysToAdd : nombre de jours \u00e0 ajouter \u00e0 la date pour calculer la date d\u2019\u00e9ch\u00e9ance \n * @param idDateIndex : ide de l'index date utilis\u00e9 comme base pour le calcul\n * @return DueDate au format \"dd\/MM\/yyyy\"\n *\/\nvar getDueDateEndOfMonth = function(pParameters, nbDaysToAdd, idDateIndex){\n\t\n\tvar dateGeneralIndex = getTextFromIndexInfo(getFirstIndexFromID(pParameters,idDateIndex));\n\tvar splitDate = dateGeneralIndex.split(\"\/\");\n\tvar expectedDate=new Date(parseInt(splitDate&#91;2]),parseInt(splitDate&#91;1])-1,parseInt(splitDate&#91;0])+nbDaysToAdd);\n\tvar endOfMonthDueDate=new Date(expectedDate.getFullYear(),expectedDate.getMonth()+1,0);\n\tvar months = endOfMonthDueDate.getMonth() + 1;\n\tvar dayOn2Digits = endOfMonthDueDate.getDate() &lt; 10 ? \"0\" + endOfMonthDueDate.getDate() : endOfMonthDueDate.getDate();\n\tvar monthOn2Digits = months &lt; 10 ? \"0\" + months : months;\n\treturn dayOn2Digits + \"\/\" + monthOn2Digits + \"\/\" + endOfMonthDueDate.getFullYear();\n};\nreturn getDueDateEndOfMonth(pParameters, 45, idDateIndex);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Principle: Calculation of the due date (the scripted index) from the date of the document to which 45 days are added. The end of the month thus calculated is then kept. Examples: 01\/01\/2017 =&gt; 28\/02\/2017 20\/07\/2017 =&gt; 30\/09\/2017 20\/12\/2017 =&gt; 28\/02\/2018 Script:<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":21276,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"templates\/ob-help-products.php","meta":{"footnotes":""},"class_list":["post-21333","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/comments?post=21333"}],"version-history":[{"count":1,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21333\/revisions"}],"predecessor-version":[{"id":21337,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21333\/revisions\/21337"}],"up":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21276"}],"wp:attachment":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/media?parent=21333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}