#1 2014-04-06 05:14:51

Roberiopraciano
Member
Registered: 2013-01-25
Posts: 8

I want use mormot in my erp in Brazil help me please

good night , great job with the mormot , I have some questions:

I'm starting a restructuring of my erp and would like to make it 3 layers , so I started testing our DataSnap friend, but it does not seem very stable , so thank my countryman Roberto who tested DataSnap and mormot met your project , since then I have disclosed to all my fellow developers in Brazil but :

although WalterAlex have posted some videos and providing some examples , and you have spoken to think of the object and not in the database adopting mormot 'm almost definitely in my project , I hope you help me with some questions :

I have a Bank ( postgresql ) to the tables :

TB_UNIT
ID : integer ( auto generate controlled by postgresql ) primary key
Description : Varchar ( 50 )

TB_STOCK
ID : integer ( auto generate controlled by postgresql ) primary key
Description : Varchar ( 50 )

TB_PRODUCT
ID : integer ( auto generate controlled by postgresql ) primary key
Description : Varchar ( 50 )
ID_STOCK ( FOREIGN KEY FOR ID IN TB_STOCK )
ID_UNIT ( FOREIGN KEY FOR ID IN TB_UNIT )
VALUE_SALE (CURRENCY )
VALUE_COST (CURRENCY )

imagine you have a class :

Tunit = class ( TSQLRecord )

property id integer ;
property description : rawutf8 ;


Tstock = class ( TSQLRecord )
property id integer ;
property description : rawutf8 ;



TProducts = class ( TSQLRecord )
property id integer ;
property description : rawutf8 ;
id_stock property : integer ;
id_unit property : integer ;
valuesale property : currency ;
valuecost property : currency ;
_unit property Description : rawutf8 ; ( transient )
_stock property Description : rawutf8 ; ( transient )

grid because the product has the records aperecer thus:

Id | description | Product Id Stock | Unit Id | Value of sale | Value Cost | Drive Description | Description of stock

sample row on the client

1 | Egg | 1 | 1 | $ 3.5 | $ 1.4 | Box | Kitchen

I would like to know where can I start this?

another thing : you already work with objects lazy ?

and finally :


  how do I bring to an application and its items in a single query to the server mormot ? , and how do i update them one by one ? ?

Offline

#2 2014-04-06 08:10:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: I want use mormot in my erp in Brazil help me please

Please download the latest version of the SAD 1.18 pdf.
You have every information you need in it, including sample code.

1. Since your classes inherit from TSQLRecord, there is already a "property id: integer" field - no need to define it.

2. To access foreign key, use a property with the target class as type.

type
  TProduct = class ( TSQLRecord )
  private
    Fvaluecost: currency;
    Fvaluesale: currency;
    Fdescription: RawUtf8;
    Fid_stock: TStock;
    Fid_unit: TUnit;
  published
    property description: RawUtf8 read Fdescription write Fdescription;
    property id_stock: TStock read Fid_stock write Fid_stock;
    property id_unit: TUnit read Fid_unit write Fid_unit;
    property valuesale: currency read Fvaluesale write Fvaluesale;
    property valuecost: currency read Fvaluecost write Fvaluecost;
  end;

Note that id_stock is not a true instance (there is no direct loading).
You have to load it explicitly via function TSQLRest.Retrieve(aPublishedRecord, aValue: TSQLRecord): boolean;

Offline

#3 2014-04-06 14:45:54

Roberiopraciano
Member
Registered: 2013-01-25
Posts: 8

Re: I want use mormot in my erp in Brazil help me please

ok I understand , I can not use  (id ) in the class definition because mormot manage this for me right? , but I can view it on the client in a grid ? ?, but Id is Autoincremet in database??? (postgres sample)

Using DataSnap can make objects aligned as follows one inside the other , any tips on how to do this in mormot? , I'm reading the extensive documentation but paradgma is another and I'm still learning , following example:

type: " ProdutoVO.TProdutoVO "
ID: 1
-fields : {
FID : 1
FGTIN : " 7896019606226 "
FNOME : " 01 PRODUCT OF THE GROUP SUBGROUP 01 01 "
FID_UNIDADE_PRODUTO 1
FID_ALMOXARIFADO 1
FID_GRUPO_TRIBUTARIO 1
FID_TRIBUT_ICMS_CUSTOM_CAB 1
FID_MARCA_PRODUTO 1
FID_SUB_GRUPO 1
FCODIGO_INTERNO : " 622 "
FNCM : " 17049010 "
FDESCRICAO : " 01 PRODUCT OF THE GROUP SUBGROUP 01 01 "
FDESCRICAO_PDV : "PRODUCT OF SUBGROUP 01 01 "
FVALOR_COMPRA : 4
FVALOR_VENDA 6
FPRECO_VENDA_MINIMO : 0
FPRECO_SUGERIDO : 0
FCUSTO_MEDIO_LIQUIDO : 0
FPRECO_LUCRO_ZERO : 0
FPRECO_LUCRO_MINIMO : 0
FPRECO_LUCRO_MAXIMO : 0
FMARKUP : 0
FQUANTIDADE_ESTOQUE : 0
FQUANTIDADE_ESTOQUE_ANTERIOR : 0
FESTOQUE_MINIMO 10
FESTOQUE_MAXIMO : 200
FESTOQUE_IDEAL : 100
FEXCLUIDO : " "
FINATIVO : " N "
FDATA_CADASTRO : 41367
FFOTO_PRODUTO : " "
FEX_TIPI : " "
FCODIGO_LST : " "
FCLASSE_ABC : "A"
FIAT : " T "
FIPPT : " T "
FTIPO_ITEM_SPED " 00"
FPESO : 0
FPORCENTO_COMISSAO : 0
FPONTO_PEDIDO : 0
FLOTE_ECONOMICO_COMPRA : 0
FALIQUOTA_ICMS_PAF 17
FALIQUOTA_ISSQN_PAF : 0
FTOTALIZADOR_PARCIAL : " 01T1700 "
FCODIGO_BALANCA : 0
FDATA_ALTERACAO : 41367
FVALIDADE : 0
Ftype : " V "
FTributIcmsCustomCabDescricao : " 15 % GST CUSTOM "
FUnidadeProdutoSigla : "UN "
FAlmoxarifadoNome : " test"
FTributGrupoTributarioDescricao : "PRODUCT SUBJECT TO OWN MANUFACTURE ICMS ST "
FProdutoMarcaNome : " test"
FProdutoSubGrupoNome : " SUB-GROUP 01 GROUP 01 "
FProdutoGrupoNome : " GROUP 01 "
FImagem : " "
FTipoImagem : " "
- FTributIcmsCustomCabVO : {
type: " TributIcmsCustomCabVO.TTributIcmsCustomCabVO "
ID: 2
-fields : {
FID : 1
FID_EMPRESA 1
FDESCRICAO : " 15 % GST CUSTOM "
FORIGEM_MERCADORIA : " "
FListaTributIcmsCustomDetVO : null
}
}
- FUnidadeProdutoVO : {
type: " UnidadeProdutoVO.TUnidadeProdutoVO "
id: 3
-fields : {
FID : 1
FSIGLA : "UN "
FDESCRICAO : " UNIT "
FPODE_FRACIONAR " S"
}
}
- FAlmoxarifadoVO : {
type: " AlmoxarifadoVO.TAlmoxarifadoVO "
ID: 4
-fields : {
FID : 1
FID_EMPRESA 1
FNOME : " test"
FEmpresaRazaoSocial : " "
FEmpresaVO : null
}
}
- FGrupoTributarioVO : {
type: " TributGrupoTributarioVO.TTributGrupoTributarioVO "
id: 5
-fields : {
FID : 1
FID_EMPRESA 1
FDESCRICAO : "PRODUCT SUBJECT TO OWN MANUFACTURE ICMS ST "
FORIGEM_MERCADORIA " 0 "
FOBSERVACAO : " 1 own manufacturing products ( subject to ICMS ST ) . "
}
}
- FProdutoMarcaVO : {
type: " ProdutoMarcaVO.TProdutoMarcaVO "
ID: 6
-fields : {
FID : 1
FNOME : " test"
FDESCRICAO : " "
}
}
- FProdutoSubGrupoVO : {
type: " ProdutoSubGrupoVO.TProdutoSubGrupoVO "
ID: 7
-fields : {
FID : 1
FID_GRUPO 1
FNOME : " SUB-GROUP 01 GROUP 01 "
FDESCRICAO : " SUB-GROUP 01 GROUP 01 "
FProdutoGrupoNome : " "
- FProdutoGrupoVO : {
type: " ProdutoGrupoVO.TProdutoGrupoVO "
ID: 8
-fields : {
FID : 1
FNOME : " GROUP 01 "
FDESCRICAO : " GROUP 01 "
}
}
}
}
}
}

Offline

#4 2014-04-09 19:35:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: I want use mormot in my erp in Brazil help me please

We just added new TSQLRecord.CreateJoined() and CreateAndFillPrepareJoined() constructors, to auto-initialize and load nested TSQLRecord properties.
See http://synopse.info/fossil/info/6fe2dd5218
and updated documentation (SAD 1.18 pdf).

Once retrieved, you can easily export the TSQLRecord instance back as JSON, with nested objects, e.g. via ObjectToJSON().

Offline

#5 2014-04-13 18:32:53

Roberiopraciano
Member
Registered: 2013-01-25
Posts: 8

Re: I want use mormot in my erp in Brazil help me please

I currently have a small erp which has 386 classes with DataSnap server and client, all classes inherit from a class type jsonvo created by me, which implement functions Marchal and json serialization, so that serialization method is slow DataSnap and lasting memory leak. Finally I would take all my classes, however all use the id field as integer and primary key, is to use my classes that inherit from jsonvo and make jsonvo inherit from sqlrecord, but how has the class sqlrecord ignore my property id? So I can convert my application quickly without having to change my existing classes thanks for the great product

Offline

#6 2014-04-19 06:50:35

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: I want use mormot in my erp in Brazil help me please

The JOIN will be done with this ID property.
This is a well documented limitation of our ORM.

What you can do is not to use the ORM, but the JSON serialization embedded with mORMot.
See ObjectToJSON() function, and please read the corresponding paragraphs about object serialization in the SAD 1.18 pdf document.

Offline

#7 2014-04-25 03:51:20

Roberiopraciano
Member
Registered: 2013-01-25
Posts: 8

Re: I want use mormot in my erp in Brazil help me please

But I would like to use any mormot both the ORM as the HTTP Server.

Sorry for my English poorly but still have questions to ask:

I currently have no way to use my class with the explicit Id field?

At least let him in class with some tag for mormot not handle, just show up?

Offline

#8 2014-04-25 08:58:47

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: I want use mormot in my erp in Brazil help me please

Why not just:
- Let jsonvo inherit from TSQLRecord
- Remove the ID field from jsonvo (since it is already in TSQLRecord)
- Fix/remove the constructor/destructor/unneeded methods from jsonvo

Then you would be able to use the RESTful ORM directly.

Offline

Board footer

Powered by FluxBB