When creating an Invoice with lines to be transformed from one or more orders, I know that the BSO.Commercial method Sales.AddedTransformedLine works correctly and makes the transformation due to the management of the quantities as well as other rules.
However, if you want to update the user fields in the Invoice lines to be created, the same ones, although apparently well filled, both before and after the Document update method, as I was able to confirm after querying the debugged object in the Visual Studio Watch, are never updated in the database. The pseudo-code used is the following:
GcpBEDocumentoVenda fatura = new GcpBEDocumentoVenda();
//atribuir dados do cabeçalho
fatura.set_Tipodoc("FA")
etc...
BSO.Comercial.Vendas.PreencheDadosRelacionados(fatura);
//percorrer encomendas de origem a transformar
foreach (encomenda...)
{
//percorrer linhas de cada encomenda
foreach (linha in encomenda...)
{
//CÓDIGO REAL:
BSO.Comercial.Vendas.AdicionaLinhaTransformada
(
fatura
, encomenda.TipoDoc
, encomenda.NumDoc
, linha.NumLinhaNossaEncomenda
, strSerieEnc: encomenda.Serie
, QuantSatisf: linha.QtFaturar
);
//obter última linha inserida
GcpBELinhaDocumentoVenda linhaDocumentoVenda = fatura.get_Linhas()[fatura.get_Linhas().NumItens];
//actualizar os CDUs
linhaDocumentoVenda.get_CamposUtil().get_Item("CDU_Teste1").Valor = "Teste1";
linhaDocumentoVenda.get_CamposUtil().get_Item("CDU_Teste2").Valor = "Teste2";
etc...
}
}
//gravar documento
string avisos = "";
BSO.Comercial.Vendas.Actualiza(fatura, avisos);
I hope it's noticeable. It works everything as expected except the user fields. Anything you're doing less well? Thank you in advance.