Segue meu model :
type
[Entity]
[Table('PREVENDA')]
[Inheritance(TInheritanceStrategy.SingleTable)]
[Id('FChave', TIdGenerator.None)]
TPrevenda=class
private
[Column('CHAVE', [TColumnProp.Required])]
FChave: Integer;
[Column('ATIVO', [])]
FAtivo: Integer;
[Column('CHAVEEMPRESA', [TColumnProp.Required])]
FChaveEmpresa: Integer;
[Column('NUMEROPV', [], 10)]
FNumeropv: string;
[Column('DATAPV', [])]
FDatapv: TDateTime;
[ManyValuedAssociation([], CascadeTypeAll)]
[ForeignJoinColumn('ChavePrevenda', [])]
FItens: TList<TItensprevendaBRS>;
[ManyValuedAssociation([], CascadeTypeAll)]
[ForeignJoinColumn('ChaveDocDestino', [TColumnProp.NoUpdate])]
FAgrupadas: TList<TPrevenda>;
FTemItens: Boolean;
FListaAgrup: TList<String>;
FStatus: Integer;
procedure setAgrupadas(const Value: TList<TPrevenda>);
function getAgrupadas: TList<TPrevenda>;
public
property Chave: Integer read FChave write FChave;
property Ativo: Integer read FAtivo write FAtivo;
property ChaveEmpresa: Integer read FChaveEmpresa write FChaveEmpresa;
property Numeropv: string read FNumeropv write FNumeropv;
property Datapv: TDateTime read FDatapv write FDatapv;
property Itens: TList read FItens write FItens;
property Agrupadas: TList read getAgrupadas write setAgrupadas;
type
[Entity]
[Sequence('GEN_ITENSPREVENDA_ID')]
[Id('FChave', TIdGenerator.None)]
[Table('ITENSPREVENDA')]
TItensprevendaBRS=class
private
[Column('CHAVE', [TColumnProp.Required])]
FChave: Integer;
[Column('ATIVO', [])]
FAtivo: Integer;
[Column('CHAVEEMPRESA', [TColumnProp.Required])]
FChaveEmpresa: Integer;
[Column('QTDE', [], 18, 6)]
FQtde: Double;
[Column('VLRUNIT', [], 18, 6)]
FVlrunit: Double;
public
property Chave: Integer read FChave write FChave;
property Ativo: Integer read FAtivo write FAtivo;
property ChaveEmpresa: Integer read FChaveEmpresa write FChaveEmpresa;
property Qtde: Double read FQtde write FQtde;
property Vlrunit: Double read FVlrunit write FVlrunit;
type
[Entity]
[DiscriminatorValue('PrevendaBRS')]
TPrevendaBRS=class(TPrevenda)
private
FStatus: Integer;
public
[Transient]
property Status: Integer read FStatus write FStatus;
class function GetComanda(_ALista: TList<TPrevendaBRS>): TPrevendaBRS;
end;
implementation
function TPrevenda.getAgrupadas: TList;
var
APrevenda: TPrevenda;
begin
if not Assigned(FAgrupadas) then
Exit(nil);
Result := TList.Create;
for APrevenda in FAgrupadas do begin
if (APrevenda.Tipodocdestino = 0) and (APrevenda.ChaveEmpresa = ChaveEmpresa) then
Result.Add(APrevenda)
else
Continue;
end;
end;
procedure TPrevenda.setAgrupadas(const Value: TList);
var
APrevenda: TPrevenda;
begin
FAgrupadas := TList.Create;
for APrevenda in Value do begin
if (APrevenda.Tipodocdestino = 0) and (APrevenda.ChaveEmpresa = ChaveEmpresa) then
FAgrupadas.Add(APrevenda)
else
Continue;
end;
end;
No meu json retorna o erro sempre que tem uma lista de 'Agrupadas' , que no caso seria um tlist do tipo TPrevenda , será que modelei errado esse tipo de objeto?
está retornando o seguinte :
{"record":{"$type":"model.BRS.TPrevendaBRS","$id":1,"FChavevendedor":null,"FVlracrescimo":null,"FHora":"09:15:55.000","FChaveopertitulos":null,"FBrstaxaentregador":0,"FBrstaxacouvert":0,"FChaveEmpresa":1,"FObs":"","FTiposenhadesconto":0,"FChaveplanoconta":null,"FBrscredito":0,"FBrsqtdepessoas":1,"FFinalizado":"S","FPessoa":null,"FChavecfopprod":0,"FTotalpv":53.98,"FCcf":null,"FBrsgorjetagarcomvlr":0,"FDatahoraentregue":null,"FBrsqtdepessoasremanesc":1,"FDatapv":"2022-01-13","FDescvlrprod":0,"FNomecliente":"","FChavectabancaria":null,"FEntrega":0,"FDatahoraultconsumacao":"2022-01-13 09:15:55.000","FSenhaImpressao":0,"FAtivo":1,"FFatura":null,"FCodigorest":"8888000105","FTipodocdestino":0,"FBrstipopedido":0,"FChaveformapgto":0,"FLocalmesa":"","FAgrupadas":[{"$type":"model.BRS.TPrevenda","$id":2,"FChavevendedor":0,"FVlracrescimo":null,"FHora":"13:47:14.000","FChaveopertitulos":null,"FBrstaxaentregador":0,"FBrstaxacouvert":0,"FChaveEmpresa":1,"FObs":"","FTiposenhadesconto":0,"FChaveplanoconta":null,"FBrscredito":0,"FBrsqtdepessoas":1,"FFinalizado":"S","FPessoa":null,"FChavecfopprod":0,"FTotalpv":13.98,"FCcf":null,"FBrsgorjetagarcomvlr":0,"FDatahoraentregue":null,"FBrsqtdepessoasremanesc":1,"FDatapv":"2019-09-12","FDescvlrprod":0,"FNomecliente":"","FChavectabancaria":null,"FEntrega":0,"FDatahoraultconsumacao":"2019-09-12 13:57:26.000","FSenhaImpressao":0,"FAtivo":1,"FFatura":null,"FCodigorest":"8888000007","FTipodocdestino":3,"FBrstipopedido":0,"FChaveformapgto":0,"FLocalmesa":"","FAgrupadas":[],"FChavecfopoperfiscais":0,"FTotalproduto":13.98,"FCoo":null,"FBrsgorjetagarcomperc":0,"FDatahoraentregando":null,"FBrsconfimpressa":"N","FNumeropv":"","FDescporcprod":0,"FChaveusuarioautordesconto":0,"FChavecentrocusto":null,"FChavebrsentregador":0,"FBrstemrecompensa":"N","FFormapgto":null,"FChave":27075,"FChavecondpgto":null,"FNl":125119,"FTipo":2,"FBrstaxaentrega":0,"FTrocopara":0,"FChaveusuariogerou":23,"FItens":[{"$type":"model.BRS.TItensprevendaBRS","$id":3,"FQtde":1,"FDescvlr":0,"FVlrtotal":6.99,"FChaveusuarioautordesc":0,"FNummesacontatransf":"","FIndice":1,"FOrigemlanc":1,"FRecompensa":0,"FChavetabelapreco":1,"Comp":[],"FChave":85839,"FVlrunit":6.99,"FVlrunitcomdesc":6.99,"FNl":125119,"FVlrunittabela":6.99,"FChaveloteprod":0,"FDataitempv":"2019-09-12","FImpressoauto":1,"FChaveitemrecompensa":0,"FIdentificadorMobBRS":"","FAtivo":1,"FVlrunitoriginal":6.99,"FChavetributacao":1,"FChaveclassfiscal":1191,"FVlrvendaminimo":0,"FChavevendedor":101,"FHoraitempv":"13:47:14.000","FObsImpressao":"IMP. AUT.: 12/09/2019 13:34:21, TERMINAL: DESKTOP-KVUJGI9, IMP.: BALCAO","FTipoproduto":0,"Produto":{"$type":"model.BRS.TProdutoComProdutoVenda","$id":4,"Ativo":1,"Codigo":"009989","Status":0,"DescrComplp":"ESPRESSO MACHIATTO","ChaveFamilia":0,"DataHoraAlt":"2021-12-13 17:33:41.000","PesoBruto":0,"ChaveClassFiscal":1191,"CodigoFabrica":"","ProdutoVenda":null,"Chave":5150,"Chaveempresa":1,"Tipo":0,"Descricao":"ESPRESSO MACHIATTO","Chaveclasse":2,"ChaveSubGrupo":45,"ChaveUnidade":1,"Obs":"","CodBarras":"","ProdFavorito":"N","GrupoFiscal":null},"FChaveEmpresa":1,"FDescporc":0,"FVlrsubtotal":6.99,"FTiposenhadesc":0,"FChaveorigemtransf":0,"FAliqcomisfat":0,"FDescrcomplement":"","FSituacaopreparo":0,"FTransferido":"N"},{"$type":"model.BRS.TItensprevendaBRS","$id":5,"FQtde":1,"FDescvlr":0,"FVlrtotal":6.99,"FChaveusuarioautordesc":0,"FNummesacontatransf":"","FIndice":2,"FOrigemlanc":1,"FRecompensa":0,"FChavetabelapreco":1,"Comp":[],"FChave":85841,"FVlrunit":6.99,"FVlrunitcomdesc":6.99,"FNl":125119,"FVlrunittabela":6.99,"FChaveloteprod":0,"FDataitempv":"2019-09-12","FImpressoauto":1,"FChaveitemrecompensa":0,"FIdentificadorMobBRS":"","FAtivo":1,"FVlrunitoriginal":6.99,"FChavetributacao":1,"FChaveclassfiscal":1191,"FVlrvendaminimo":0,"FChavevendedor":101,"FHoraitempv":"13:57:26.000","FObsImpressao":"IMP. AUT.: 12/09/2019 13:44:31, TERMINAL: DESKTOP-KVUJGI9, IMP.: BALCAO","FTipoproduto":0,"Produto":{"$ref":4},"FChaveEmpresa":1,"FDescporc":0,"FVlrsubtotal":6.99,"FTiposenhadesc":0,"FChaveorigemtransf":0,"FAliqcomisfat":0,"FDescrcomplement":"","FSituacaopreparo":0,"FTransferido":"N"}]}],"FChavecfopoperfiscais":0,"FTotalproduto":53.98,"FCoo":null,"FBrsgorjetagarcomperc":0,"FDatahoraentregando":null,"FBrsconfimpressa":"N","FNumeropv":"","FDescporcprod":0,"FChaveusuarioautordesconto":0,"FChavecentrocusto":null,"FChavebrsentregador":0,"FBrstemrecompensa":"N","FFormapgto":null,"FChave":89687,"FChavecondpgto":null,"FNl":402963,"FTipo":2,"FBrstaxaentrega":0,"FTrocopara":0,"FChaveusuariogerou":2,"FItens":[{"$type":"model.BRS.TItensprevendaBRS","$id":6,"FQtde":1,"FDescvlr":0,"FVlrtotal":26.99,"FChaveusuarioautordesc":0,"FNummesacontatransf":"","FIndice":1,"FOrigemlanc":0,"FRecompensa":0,"FChavetabelapreco":1,"Comp":[],"FChave":305547,"FVlrunit":26.99,"FVlrunitcomdesc":26.99,"FNl":402963,"FVlrunittabela":26.99,"FChaveloteprod":0,"FDataitempv":"2022-01-13","FImpressoauto":0,"FChaveitemrecompensa":0,"FIdentificadorMobBRS":"","FAtivo":1,"FVlrunitoriginal":26.99,"FChavetributacao":14,"FChaveclassfiscal":1112,"FVlrvendaminimo":0,"FChavevendedor":10,"FHoraitempv":"09:15:55.000","FObsImpressao":"","FTipoproduto":0,"Produto":{"$type":"model.BRS.TProdutoComProdutoVenda","$id":7,"Ativo":1,"Codigo":"000159","Status":0,"DescrComplp":"PAO MACAXEIRA TRAD","ChaveFamilia":0,"DataHoraAlt":"2021-06-12 13:02:17.000","PesoBruto":1,"ChaveClassFiscal":1112,"CodigoFabrica":"","ProdutoVenda":[{"$type":"model.ProdutoVenda.TProdutovenda","$id":8,"Chave":154,"Ativo":1,"Chaveempresa":1,"PrecoVenda":26.99,"ChavetabelaPreco":1,"PrecoVendaMinimo":0,"DataHoraAlt":"2018-11-14 15:00:43.000"}],"Chave":154,"Chaveempresa":1,"Tipo":0,"Descricao":"PAO MACAXEIRA TRAD","Chaveclasse":0,"ChaveSubGrupo":46,"ChaveUnidade":3,"Obs":"","CodBarras":"","ProdFavorito":"N","GrupoFiscal":{"$type":"model.GenericProd.TGrupoFiscalBRS","$id":9,"Chave":25,"Ativo":1,"ChaveEmpresa":1,"IPI":0,"Codigo":"000025","VlrIpiTrib":0,"ChaveTributacao":14}},"FChaveEmpresa":1,"FDescporc":0,"FVlrsubtotal":26.99,"FTiposenhadesc":0,"FChaveorigemtransf":0,"FAliqcomisfat":0,"FDescrcomplement":"","FSituacaopreparo":0,"FTransferido":"N"},{"$type":"model.BRS.TItensprevendaBRS","$id":10,"FQtde":1,"FDescvlr":0,"FVlrtotal":26.99,"FChaveusuarioautordesc":0,"FNummesacontatransf":"8888000106","FIndice":2,"FOrigemlanc":0,"FRecompensa":0,"FChavetabelapreco":1,"Comp":[],"FChave":305549,"FVlrunit":26.99,"FVlrunitcomdesc":26.99,"FNl":402963,"FVlrunittabela":26.99,"FChaveloteprod":0,"FDataitempv":"2022-01-13","FImpressoauto":0,"FChaveitemrecompensa":0,"FIdentificadorMobBRS":"","FAtivo":1,"FVlrunitoriginal":26.99,"FChavetributacao":14,"FChaveclassfiscal":1112,"FVlrvendaminimo":0,"FChavevendedor":10,"FHoraitempv":"09:16:13.000","FObsImpressao":"","FTipoproduto":0,"Produto":{"$ref":7},"FChaveEmpresa":1,"FDescporc":0,"FVlrsubtotal":26.99,"FTiposenhadesc":0,"FChaveorigemtransf":305548,"FAliqcomisfat":0,"FDescrcomplement":"","FSituacaopreparo":0,"FTransferido":"N"}]}}