{"id":2705,"date":"2017-08-21T15:16:39","date_gmt":"2017-08-21T15:16:39","guid":{"rendered":"https:\/\/answers.gurussolutions.com\/answers\/how-to-scriptmatically-generate-the-next-invoice-from-a-netsuite-sales-order-with-a-billing-schedule-2\/"},"modified":"2026-07-28T18:25:09","modified_gmt":"2026-07-28T18:25:09","slug":"comment-generer-par-script-la-prochaine-facture-a-partir-dune-commande-client-netsuite-avec-un-echeancier-de-facturation","status":"publish","type":"qa_entry","link":"https:\/\/answers.gurussolutions.com\/fr\/answers\/comment-generer-par-script-la-prochaine-facture-a-partir-dune-commande-client-netsuite-avec-un-echeancier-de-facturation\/","title":{"rendered":"Comment g\u00e9n\u00e9rer par script la prochaine facture \u00e0 partir d\u2019une commande client NetSuite avec un \u00e9ch\u00e9ancier de facturation"},"content":{"rendered":"","protected":false},"template":"","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","ga_subtitle":"Automatisez la g\u00e9n\u00e9ration de la prochaine facture ou de la prochaine vente au comptant \u00e0 partir d\u2019une commande client NetSuite \u00e0 l\u2019aide de SuiteScript 2.x, en tirant parti de son calendrier de facturation.","ga_short_answer":"Pour g\u00e9n\u00e9rer la prochaine facture ou vente au comptant \u00e0 partir d\u2019une commande client comportant un \u00e9ch\u00e9ancier de facturation, utilisez SuiteScript 2.x pour charger la commande client, r\u00e9cup\u00e9rer la date \u00ab nextbill \u00bb, transformer la commande client en type de transaction souhait\u00e9, d\u00e9finir le champ \u00ab billdate \u00bb sur l\u2019enregistrement transform\u00e9, puis l\u2019enregistrer.","ga_scenario":"Les utilisateurs de NetSuite ont souvent besoin de g\u00e9n\u00e9rer par programmation la prochaine facture ou la prochaine vente au comptant pour les commandes client associ\u00e9es \u00e0 un calendrier de facturation. Ce processus garantit que les \u00e9v\u00e9nements de facturation suivants sont d\u00e9clench\u00e9s et enregistr\u00e9s avec pr\u00e9cision, pr\u00e9servant ainsi l\u2019int\u00e9grit\u00e9 des flux de revenus r\u00e9currents.","ga_solution":"Pour g\u00e9n\u00e9rer par programmation la prochaine facture ou vente au comptant \u00e0 partir d\u2019une commande client dot\u00e9e d\u2019un calendrier de facturation actif, vous pouvez utiliser SuiteScript 2.x afin de transformer l\u2019enregistrement de la commande client. La cl\u00e9 consiste \u00e0 r\u00e9cup\u00e9rer la date `nextbill` de la commande client d\u2019origine et \u00e0 l\u2019appliquer en tant que `billdate` au cours du processus de transformation. Le code SuiteScript 2.x suivant illustre ce processus :\n```\njavascript\n\/\/ Assume salesOrderId is the internal ID of the sales order\nvar salesOrderRecord = record.load({\n    type: record.Type.SALES_ORDER,\n    id: salesOrderId,\n    isDynamic: false\n});\n\nvar nextBillDateValue = salesOrderRecord.getValue({ fieldId: 'nextbill' });\n\nvar transformedRecord = record.transform({\n    fromType: record.Type.SALES_ORDER,\n    fromId: salesOrderId,\n    toType: record.Type.CASH_SALE, \/\/ Use record.Type.INVOICE for an Invoice\n    isDynamic: false\n});\n\nif (nextBillDateValue) {\n    transformedRecord.setValue({\n        fieldId: 'billdate',\n        value: nextBillDateValue\n    });\n}\n\ntransformedRecord.save();\n```\nPoints \u00e0 prendre en compte pour la mise en \u0153uvre :\n*   Ce script part du principe qu\u2019un calendrier de facturation est d\u00e9fini sur la commande client. Mettez en place une validation pour vous assurer qu\u2019un calendrier de facturation existe avant de tenter la transformation.\n*   Le param\u00e8tre `toType` dans `record.transform` peut \u00eatre d\u00e9fini sur `record.Type.INVOICE` pour une facture ou sur `record.Type.CASH_SALE` pour une vente au comptant, en fonction du type de transaction requis.","ga_source_author":"","ga_source_author_email":"","ga_date_original":"2017-08-21T17:16:39+02:00","ga_date_verified":"2026-07-05","ga_source_subject":"Can we genereate the next invoice on a sales order with a billing schedule?","ga_ans_id":"ANS-0966","ga_publish_decision":"publish_with_edits","ga_staleness_risk":"high","ga_review_priority":"spot_check","ga_tier2_verdict":"partially_outdated","ga_tier2_concerns":"The `nlapiTransformRecord` function is a SuiteScript 1.0 API and has been superseded by `record.transform` in SuiteScript 2.x.; The `nlapiSubmitRecord` function is a SuiteScript 1.0 API and has been superseded by `record.save` in SuiteScript 2.x.; The claim that 'nextbilldate' is 'not documented as a direct field' might be outdated or nuanced, as SuiteScript 2.0 examples show accessing a 'nextbill' field directly on the sales order record using `oSalesOrder.getValue({ fieldId: 'nextbill' })`.","ga_final_category":"SuiteScript Development","footnotes":""},"ga_category":[108,23,108],"ga_audience":[10],"ga_difficulty":[92],"class_list":["post-2705","qa_entry","type-qa_entry","status-publish","hentry","ga_category-developpement-suitescript","ga_category-suitescript-development","ga_audience-developer-suitescript","ga_difficulty-niveau-intermediaire"],"taxonomy_info":{"ga_category":[{"value":108,"label":"D\u00e9veloppement SuiteScript"},{"value":23,"label":"SuiteScript Development"},{"value":108,"label":"D\u00e9veloppement SuiteScript"}],"ga_audience":[{"value":10,"label":"Developer\/SuiteScript"}],"ga_difficulty":[{"value":92,"label":"Niveau interm\u00e9diaire"}]},"featured_image_src_large":[],"author_info":[],"comment_info":"","_links":{"self":[{"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/qa_entry\/2705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/qa_entry"}],"about":[{"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/types\/qa_entry"}],"version-history":[{"count":1,"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/qa_entry\/2705\/revisions"}],"predecessor-version":[{"id":4625,"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/qa_entry\/2705\/revisions\/4625"}],"wp:attachment":[{"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/media?parent=2705"}],"wp:term":[{"taxonomy":"ga_category","embeddable":true,"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/ga_category?post=2705"},{"taxonomy":"ga_audience","embeddable":true,"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/ga_audience?post=2705"},{"taxonomy":"ga_difficulty","embeddable":true,"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/ga_difficulty?post=2705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}