Discussões
Community Articles: What Topic Should We Cover Next? Your idea could be our next feature—drop your suggestion now and spark the next big discussion!
SuiteScript 2.x Atualizar modelo de reconhecimento de receita no documento fiscal
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();
Rotulado:
0
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!