Discussões

New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.

SuiteScript 2.x Atualizar modelo de reconhecimento de receita no documento fiscal

editado Jun 2, 2025 2:48PM Dentro Contabilidade/ERP

Aplica-se a:  NetSuite 2023.1

Cenário: Cliente deseja atualizar o modelo de Reconhecimento de receita na Fatura por meio do SuiteScript 2.x.


Solução:

Consulte o script de Evento de usuário abaixo implantado em uma Fatura, acionado em Após a função enviar:

 

/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */

define(['N/record', 'N/format'],

function(rec, format) {

    function update(context) {
	var invoiceID = context.newRecord.id;
	var invoice = rec.load({
		type: rec.Type.INVOICE,
		id: invoiceID
	});

	var intLine = invoice.getLineCount('item');

	for (var j=1; j<=intLine; j++){

		invoice.setSublistValue({	// Lists > Accounting > Revenue Recognition Schedules
			sublistId: 'item',
			fieldId: 'revrecschedule',
			line: j,
			value: 'xxx'
		});

		invoice.setSublistValue({
			sublistId: 'item',
			fieldId: 'amortizationtype',
			line: j,
			value: 'STANDARD'		//  standard or variable
		});

		invoice.setSublistValue({
			sublistId: 'item',
			fieldId: 'amortizationperiod',
			line: j,
			value: 2
		});

		invoice.setSublistValue({
			sublistId: 'item',
			fieldId: 'revrecstartdate',
			line: j,
			value: format.parse({value: '11/30/2019', type: format.Type.DATE})
		});

		invoice.setSublistValue({
			sublistId: 'item',
			fieldId: 'revrecenddate',
			line: j,
			value: format.parse({value: '11/30/2020', type: format.Type.DATE})
		});

		// You can hardcode the value or have a custom field of type date and set the value of that field on end and start date

	}

	invoice.save();

   

Olá, bem-vind@!

Faça login

Para ver todos os detalhes, faça o login.

Cadastre-se

Não tem uma conta? Clique aqui para começar!

Ranking

Gênio da Comunidade

1º Trimestre (Jan-Mar 2026)

Líderes desta semana

Líderes deste mês

Líderes de todos os tempos