Skip to content
GitLab
Explore
Sign in
Commits on Source (3)
First attempt to fix the chart of account
· 8d5411a9
Luca Cristaldi
authored
Sep 20, 2019
8d5411a9
First working version
· eb470208
Luca Cristaldi
authored
Sep 20, 2019
eb470208
update xml file
· 7115d988
Luca Cristaldi
authored
Oct 13, 2019
7115d988
Expand all
Show whitespace changes
Inline
Side-by-side
AccountTemplate.csv
View file @
7115d988
id,name,code,
kind,type,deferral
,reconcile,party_required,general_ledger_balance,parent
16,Mittelab,,
view,
mittelab_aps,,,,,
40,RENDICONTO DI GESTIONE,,
view,,,,,,16
84,STATO PATRIMONIALE,,
view,
,,,,
,
16
41,ONERI,,
view,,
,,,,40
76,PROVENTI,,
view,,,,,,40
17,ATTIVITÀ,,
view,,,,,,84
35,PASSIVITÀ,,
view,,
,,,,84
18,CREDITI VERSO ASSOCIATI PER VERSAMENTO QUOTE,01/00/00/00,
receivable,
crediti_verso_soci_quote,True,True,True,
,
17
28,DISPONIBILITÀ LIQUIDE,03/00/00/00,
view,,,,,,17
29,Depositi bancari e postali,03/10/00/00,
other,
disponibilita_liquide,True,
True,
False,,28
30,Assegni,03/20/00/00,
other,
disponibilita_liquide,True,
True,
False,,28
31,Denaro e valori in cassa,03/30/00/00,
other,
disponibilita_liquide,True,
True,
False,,28
19,IMMOBILIZZAZIONI,05/00/00/00,
view,
,,,,
,
17
20,Immobilizzazioni immateriali,05/10/00/00,
view,
,,,,
,
19
21,Costi di impianto e di ampliamento,05/10/10/00,
expense,
immobilizzazioni,True,
True,
False,,20
22,Diritti di brevetto industriale e diritti di utilizzazione delle opere dell’ingegno,05/10/20/00,
expense,
immobilizzazioni,True,
True,
False,,20
23,Immobilizzazioni materiali,05/20/00/00,
view,
,,,,
,
19
24,Impianti e attrezzature,05/20/10/00,
expense,
immobilizzazioni,True,
True,
False,,23
25,Altri beni,05/20/20/00,
expense,
immobilizzazioni,True,
True,
False,,23
26,Immobilizzazioni finanziarie,05/30/00/00,
view,
,,,,
,
19
27,Partecipazioni in imprese diverse,05/30/10/00,
stock,
immobilizzazioni,True,
True,
False,,26
32,CREDITI,07/00/00/00,
view,,
,,,,17
33,Verso soci,07/10/00/00,
receivable,
crediti,True,True,True,
,
32
34,Verso altri,07/20/00/00,
receivable,
crediti,True,True,True,
,
32
36,PATRIMONIO NETTO,31/00/00/00,
view,,
,,,,35
37,DEBITI,33/00/00/00,
view,,
,,,,35
38,Verso fornitori,33/10/00/00,
payable,
debiti,True,True,True,
,
37
39,Altri debiti,33/20/00/00,
payable,
debiti,True,True,True,
,
37
87,Verso soci per rimborso spese,33/30/00/00,
payable,
debiti,True,True,True,
,
37
42,Oneri da attività tipiche,71/00/00/00,
view,,
,,,,41
43,Godimento beni di terzi,71/10/00/00,
view,,
,,,,42
52,Infrastruttura esterna,71/10/10/00,
view,,
,,,,43
47,Dominio,71/10/10/10,
expense,oneri,False
,True,False,,52
48,Canone Server,71/10/10/20,
expense,oneri,False
,True,False,,52
46,Oneri diversi di gestione,71/20/00/00,
view,,
,,,,42
53,Amministrazione,71/20/10/00,
view,,
,,,,46
49,Assicurazione RCT,71/20/10/10,
expense,oneri,False
,True,False,,53
50,Oneri bancari,71/20/10/20,
expense,oneri,False
,True,False,,53
54,Media,71/20/20/00,
view,,
,,,,46
58,Pubblicità online,71/20/20/10,
expense,oneri,False
,True,False,,54
59,Materiale pubblicitario,71/20/20/20,
expense,oneri,False
,True,False,,54
55,Eventi e corsi,71/20/30/00,
view,,
,,,,46
61,Contributo relatori ospiti,71/20/30/10,
expense,oneri,False
,True,False,,55
60,Rinfreschi,71/20/30/20,
expense,oneri,False
,True,False,,55
56,Materiale di consumo,71/20/40/00,
view,,
,,,,46
62,Consumabili elettrici,71/20/40/10,
expense,oneri,False
,True,False,,56
63,Consumabili informatici,71/20/40/20,
expense,oneri,False
,True,False,,56
64,Cosumabili meccanici,71/20/40/30,
expense,oneri,False
,True,False,,56
65,Cancelleria,71/20/40/40,
expense,oneri,False
,True,False,,56
66,Altro materiale di consumo,71/20/40/50,
expense,oneri,False
,True,False,,56
57,Trasferte,71/20/50/00,
view,,
,,,,46
67,Viaggio,71/20/50/10,
expense,oneri,False
,True,False,,57
68,Parcheggio,71/20/50/20,
expense,oneri,False
,True,False,,57
72,Ammortamenti,71/30/00/00,
view,,
,,,,42
69,Beni immateriali,71/30/10/00,
expense,oneri,False
,True,False,,72
73,Beni materiali,71/30/20/00,
expense,oneri,False
,True,False,,72
77,Proventi da attività tipiche,91/00/00/00,
view,,,,,,76
79,Da contributi su progetti,91/10/00/00,
revenue,
proventi,
False,
True,False,,77
80,Da contributi enti pubblici,91/20/00/00,
revenue,
proventi,
False,
True,False,,77
81,Erogazioni liberali degli associati,91/30/00/00,
revenue,
proventi,
False,
True,False,,77
82,Erogazioni liberali da non soci,91/40/00/00,
revenue,
proventi,
False,
True,False,,77
86,Quote associative versate,91/50/00/00,
revenue,
proventi,
False,
True,False,,77
88,Affitto immobili,71/10/20/00,
expense,oneri,False
,True,False,,43
89,Noleggio,71/10/30/00,
expense,oneri,False
,True,False,,43
90,Fondo ammortamento,35/00/00/00,
view,
,,,,
,
35
91,Fondo impianti e attrezzature,35/10/00/00,
other,
fondo_ammortamento,True,
True,
False,,90
92,Fondo altri beni,35/20/00/00,
other,
fondo_ammortamento,True,
True,
False,,90
93,Fondo costi impianto e di ampiamento,35/30/00/00,
other,
fondo_ammortamento,True,
True,
False,,90
id,name,code,
type
,reconcile,party_required,general_ledger_balance,parent
,closed
16,Mittelab,,mittelab_aps,,,,,
True
40,RENDICONTO DI GESTIONE,,
rendiconto_di_gestione,,,,16,True
84,STATO PATRIMONIALE,,
stato_patrimoniale
,,,,16
,True
41,ONERI,,
oneri
,,,,40
,True
76,PROVENTI,,
proventi,,,,40,True
17,ATTIVITÀ,,
attivita,,,,84,True
35,PASSIVITÀ,,
passivita
,,,,84
,True
18,CREDITI VERSO ASSOCIATI PER VERSAMENTO QUOTE,01/00/00/00,crediti_verso_soci_quote,True,True,True,17
,
28,DISPONIBILITÀ LIQUIDE,03/00/00/00,
disponibilita_liquide,,,,17,True
29,Depositi bancari e postali,03/10/00/00,disponibilita_liquide,True,False,
True
,28
,
30,Assegni,03/20/00/00,disponibilita_liquide,True,False,
True
,28
,
31,Denaro e valori in cassa,03/30/00/00,disponibilita_liquide,True,False,
True
,28
,
19,IMMOBILIZZAZIONI,05/00/00/00,
immobilizzazioni
,,,,17
,True
20,Immobilizzazioni immateriali,05/10/00/00,
immobilizzazioni
,,,,19
,True
21,Costi di impianto e di ampliamento,05/10/10/00,immobilizzazioni,True,False,
True
,20
,
22,Diritti di brevetto industriale e diritti di utilizzazione delle opere dell’ingegno,05/10/20/00,immobilizzazioni,True,False,
True
,20
,
23,Immobilizzazioni materiali,05/20/00/00,
immobilizzazioni
,,,,19
,True
24,Impianti e attrezzature,05/20/10/00,immobilizzazioni,True,False,
True
,23
,
25,Altri beni,05/20/20/00,immobilizzazioni,True,False,
True
,23
,
26,Immobilizzazioni finanziarie,05/30/00/00,
immobilizzazioni
,,,,19
,True
27,Partecipazioni in imprese diverse,05/30/10/00,immobilizzazioni,True,False,
True
,26
,
32,CREDITI,07/00/00/00,
crediti
,,,,17
,True
33,Verso soci,07/10/00/00,crediti,True,True,True,32
,
34,Verso altri,07/20/00/00,crediti,True,True,True,32
,
36,PATRIMONIO NETTO,31/00/00/00,,,,,35
,True
37,DEBITI,33/00/00/00,,,,,35
,True
38,Verso fornitori,33/10/00/00,debiti,True,True,True,37
,
39,Altri debiti,33/20/00/00,debiti,True,True,True,37
,
87,Verso soci per rimborso spese,33/30/00/00,debiti,True,True,True,37
,
42,Oneri da attività tipiche,71/00/00/00,
oneri
,,,,41
,True
43,Godimento beni di terzi,71/10/00/00,
oneri
,,,,42
,True
52,Infrastruttura esterna,71/10/10/00,
oneri
,,,,43
,True
47,Dominio,71/10/10/10,
oneri
,True,False,
True
,52
,
48,Canone Server,71/10/10/20,
oneri
,True,False,
True
,52
,
46,Oneri diversi di gestione,71/20/00/00,
oneri
,,,,42
,True
53,Amministrazione,71/20/10/00,
oneri
,,,,46
,True
49,Assicurazione RCT,71/20/10/10,
oneri
,True,False,
True
,53
,
50,Oneri bancari,71/20/10/20,
oneri
,True,False,
True
,53
,
54,Media,71/20/20/00,
oneri
,,,,46
,True
58,Pubblicità online,71/20/20/10,
oneri
,True,False,
True
,54
,
59,Materiale pubblicitario,71/20/20/20,
oneri
,True,False,
True
,54
,
55,Eventi e corsi,71/20/30/00,
oneri
,,,,46
,True
61,Contributo relatori ospiti,71/20/30/10,
oneri
,True,False,
True
,55
,
60,Rinfreschi,71/20/30/20,
oneri
,True,False,
True
,55
,
56,Materiale di consumo,71/20/40/00,
oneri
,,,,46
,True
62,Consumabili elettrici,71/20/40/10,
oneri
,True,False,
True
,56
,
63,Consumabili informatici,71/20/40/20,
oneri
,True,False,
True
,56
,
64,Cosumabili meccanici,71/20/40/30,
oneri
,True,False,
True
,56
,
65,Cancelleria,71/20/40/40,
oneri
,True,False,
True
,56
,
66,Altro materiale di consumo,71/20/40/50,
oneri
,True,False,
True
,56
,
57,Trasferte,71/20/50/00,
oneri
,,,,46
,True
67,Viaggio,71/20/50/10,
oneri
,True,False,
True
,57
,
68,Parcheggio,71/20/50/20,
oneri
,True,False,
True
,57
,
72,Ammortamenti,71/30/00/00,
oneri
,,,,42
,True
69,Beni immateriali,71/30/10/00,
oneri
,True,False,
True
,72
,
73,Beni materiali,71/30/20/00,
oneri
,True,False,
True
,72
,
77,Proventi da attività tipiche,91/00/00/00,
proventi,,,,76,True
79,Da contributi su progetti,91/10/00/00,proventi,True,False,
True
,77
,
80,Da contributi enti pubblici,91/20/00/00,proventi,True,False,
True
,77
,
81,Erogazioni liberali degli associati,91/30/00/00,proventi,True,False,
True
,77
,
82,Erogazioni liberali da non soci,91/40/00/00,proventi,True,False,
True
,77
,
86,Quote associative versate,91/50/00/00,proventi,True,False,
True
,77
,
88,Affitto immobili,71/10/20/00,
oneri
,True,False,
True
,43
,
89,Noleggio,71/10/30/00,
oneri
,True,False,
True
,43
,
90,Fondo ammortamento,35/00/00/00,
fondo_ammortamento
,,,,35
,True
91,Fondo impianti e attrezzature,35/10/00/00,fondo_ammortamento,True,False,
True
,90
,
92,Fondo altri beni,35/20/00/00,fondo_ammortamento,True,False,
True
,90
,
93,Fondo costi impianto e di ampiamento,35/30/00/00,fondo_ammortamento,True,False,
True
,90
,
AccountType.csv
View file @
7115d988
id,name,
sequence,
statement,assets,receivable,
stock,
payable,revenue,expense,parent
mittelab_aps,Mittelab APS,
10,None
,,,,,,,
rendiconto_di_gestione,RENDICONTO DI GESTIONE,
20,Non
e,,,,,,,mittelab_aps
oneri,ONERI,
30,
income,,,,,,,rendiconto_di_gestione
proventi,PROVENTI,
40,
income,,,,,,,rendiconto_di_gestione
stato_patrimoniale,STATO PATRIMONIALE,
50,Non
e,,,,,,,mittelab_aps
attivita,ATTIVITÀ,
60,Non
e,,,,,,,stato_patrimoniale
crediti_verso_soci_quote,CREDITI VERSO ASSOCIATI PER VERSAMENTO QUOTE,
70,
balance,,,,,,,attivita
disponibilita_liquide,DISPONIBILITÀ LIQUIDE,
80,
balance,,,,,,,attivita
immobilizzazioni,IMMOBILIZZAZIONI,
90,
balance,,,,,,,attivita
crediti,CREDITI,
100,
balance,,,,,,,attivita
passivita,PASSIVITÀ,
110,
balance,,,,,,,stato_patrimoniale
debiti,DEBITI,
120,
balance,,,,,,,passivita
fondo_ammortamento,FODO AMMORTAMENTO,
130,
balance,,,,,,,passivita
patrimonio_netto,PATRIMONIO NETTO,
140,
income,,,,,,,passivita
id,name,statement,assets,
stock,
receivable,payable,revenue,expense,parent
mittelab_aps,Mittelab APS,,,,,,,,
rendiconto_di_gestione,RENDICONTO DI GESTIONE,
incom
e,,,,,,,mittelab_aps
oneri,ONERI,income,,,,,,
True
,rendiconto_di_gestione
proventi,PROVENTI,income,,,,,
True
,,rendiconto_di_gestione
stato_patrimoniale,STATO PATRIMONIALE,
balanc
e,,,,,,,mittelab_aps
attivita,ATTIVITÀ,
balanc
e,,,,,,,stato_patrimoniale
crediti_verso_soci_quote,CREDITI VERSO ASSOCIATI PER VERSAMENTO QUOTE,balance,,,
True
,,,,attivita
disponibilita_liquide,DISPONIBILITÀ LIQUIDE,balance,
True
,,,,,,attivita
immobilizzazioni,IMMOBILIZZAZIONI,balance,,
True
,,,,,attivita
crediti,CREDITI,balance,,,
True
,,,,attivita
passivita,PASSIVITÀ,balance,,,,,,,stato_patrimoniale
debiti,DEBITI,balance,,,,
True
,,,passivita
fondo_ammortamento,FODO AMMORTAMENTO,balance,,
True
,,,,,passivita
patrimonio_netto,PATRIMONIO NETTO,income,,,,,,,passivita
account_mittelab_aps.xml
View file @
7115d988
This diff is collapsed.
Click to expand it.
csv2chartAccount.py
View file @
7115d988
...
...
@@ -4,7 +4,8 @@ import csv
import
xml.dom.minidom
as
xmd
import
xml.etree.ElementTree
as
ET
from
argparse
import
ArgumentParser
,
FileType
import
itertools
from
abc
import
ABC
def
pretty_print
(
xmlstring
):
"""
...
...
@@ -13,111 +14,89 @@ def pretty_print(xmlstring):
return
'
/n
'
.
join
(
line
for
line
in
xmd
.
parseString
(
xmlstring
).
toprettyxml
(
indent
=
"
"
).
split
(
'
/n
'
))
def
appendAccountTemplate
(
structure
,
id
,
name
,
code
=
''
,
kind
=
'
view
'
,
type
=
''
,
deferral
=
'
True
'
,
reconcile
=
'
False
'
,
party_required
=
'
False
'
,
parent
=
''
):
"""
Appends an account template to `structure`.
"""
record
=
ET
.
Element
(
'
record
'
,
id
=
id
,
model
=
'
account.account.template
'
)
class
BaseTemplate
(
ABC
):
model
=
None
n
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
name
'
)
n
.
text
=
name
def
createRecord
(
self
,
id
,
parent
=
None
,
fields
=
{}):
record
=
ET
.
Element
(
'
record
'
,
id
=
id
,
model
=
self
.
model
)
if
code
:
c
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
code
'
)
c
.
text
=
code
k
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
kind
'
)
k
.
text
=
kind
if
type
:
t
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
type
'
,
ref
=
type
)
if
kind
!=
'
view
'
:
d
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
deferral
'
,
eval
=
deferral
)
r
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
reconcile
'
,
eval
=
reconcile
)
pr
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
party_required
'
,
eval
=
party_required
)
for
field
in
fields
:
text
=
field
.
pop
(
'
text
'
,
None
)
p
=
ET
.
SubElement
(
record
,
'
field
'
,
**
field
)
if
text
:
p
.
text
=
text
if
parent
:
p
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
parent
'
,
ref
=
parent
)
return
record
def
createTemplate
(
self
,
**
kvars
):
fields
=
[]
id
=
kvars
.
pop
(
'
id
'
)
parent
=
kvars
.
pop
(
'
parent
'
,
None
)
name
=
kvars
.
pop
(
'
name
'
,
None
)
statement
=
kvars
.
pop
(
'
statement
'
,
None
)
code
=
kvars
.
pop
(
'
code
'
,
None
)
type
=
kvars
.
pop
(
'
type
'
,
None
)
if
code
:
fields
.
append
({
'
name
'
:
'
code
'
,
'
text
'
:
code
})
if
type
:
fields
.
append
({
'
name
'
:
'
type
'
,
'
ref
'
:
type
})
if
parent
:
fields
.
append
({
'
name
'
:
'
parent
'
,
'
ref
'
:
parent
})
if
name
:
fields
.
append
({
'
name
'
:
'
name
'
,
'
text
'
:
name
})
if
statement
:
fields
.
append
({
'
name
'
:
'
statement
'
,
'
text
'
:
statement
})
fields
.
extend
([{
'
name
'
:
key
,
'
eval
'
:
kvars
[
key
]}
for
key
in
kvars
.
keys
()])
return
self
.
createRecord
(
id
,
parent
,
fields
)
structure
.
append
(
record
)
def
appendAccountType
(
structure
,
id
,
name
,
sequence
=
''
,
income_statement
=
'
False
'
,
balance_sheet
=
'
False
'
,
display_balance
=
'
credit-debit
'
,
parent
=
''
):
"""
Appends an account type template to `structure`
"""
record
=
ET
.
Element
(
'
record
'
,
id
=
id
,
model
=
'
account.account.type.template
'
)
n
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
name
'
)
n
.
text
=
name
if
sequence
:
c
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
sequence
'
,
eval
=
sequence
)
i
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
income_statement
'
,
eval
=
income_statement
)
b
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
balance_sheet
'
,
eval
=
balance_sheet
)
class
AccountTypeTemplate
(
BaseTemplate
):
model
=
'
account.account.type.template
'
d
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
display_balance
'
)
d
.
text
=
display_balance
d
ef
__init__
(
self
):
self
.
sequence
=
itertools
.
count
(
10
,
10
)
if
parent
:
p
=
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
parent
'
,
ref
=
parent
)
def
createRecord
(
self
,
id
,
parent
=
None
,
fields
=
{}):
record
=
super
().
createRecord
(
id
,
parent
,
fields
)
ET
.
SubElement
(
record
,
'
field
'
,
name
=
'
sequence
'
,
eval
=
str
(
next
(
self
.
sequence
)))
return
record
structure
.
append
(
record
)
class
AccountTemplate
(
BaseTemplate
):
model
=
'
account.account.template
'
def
createXML
(
type_file
=
''
,
account_file
=
''
):
def
createXML
(
type_file
,
account_file
):
"""
Take the path to the csv files and create a xml structure.
If both file path are present it will concatenate.
"""
tryton
=
ET
.
Element
(
'
tryton
'
)
data
=
ET
.
SubElement
(
tryton
,
'
data
'
)
if
not
(
type_file
or
account_file
):
raise
AttributeError
(
'
Pass atleast one path to a csv file
'
)
acctype
=
AccountTypeTemplate
()
acctempl
=
AccountTemplate
()
if
type_file
:
csv_reader
=
csv
.
DictReader
(
type_file
)
data
.
append
(
ET
.
Comment
(
'
=== Account Type Template ===
'
))
for
row
in
csv_reader
:
try
:
appendAccountType
(
data
,
**
row
)
except
TypeError
as
err
:
raise
TypeError
(
'
{0}
\n
'
\
'
Collumn in the Type table must be named:
\n
'
\
'
- id
\n
'
\
'
- name
\n
'
\
'
- sequence
\n
'
\
'
- income_statement
\n
'
\
'
- balance_sheet
\n
'
\
'
- display_balance
\n
'
\
'
- parent
'
.
format
(
err
))
nonNullDict
=
{
k
:
v
for
k
,
v
in
row
.
items
()
if
v
}
data
.
append
(
acctype
.
createTemplate
(
**
nonNullDict
))
if
account_file
:
csv_reader
=
csv
.
DictReader
(
account_file
)
data
.
append
(
ET
.
Comment
(
'
=== Account Template ===
'
))
for
row
in
csv_reader
:
try
:
appendAccountTemplate
(
data
,
**
row
)
except
TypeError
as
err
:
raise
TypeError
(
'
{0}
\n
'
\
'
Collumn in the Account table must be named:
\n
'
\
'
- id
\n
'
\
'
- name
\n
'
\
'
- code
\n
'
\
'
- kind
\n
'
\
'
- type
\n
'
\
'
- deferral
\n
'
\
'
- reconcile
\n
'
\
'
- party_required
'
\
'
- parent
'
.
format
(
err
))
nonNullDict
=
{
k
:
v
for
k
,
v
in
row
.
items
()
if
v
}
data
.
append
(
acctempl
.
createTemplate
(
**
nonNullDict
))
return
tryton
def
main
():
parser
=
ArgumentParser
()
parser
.
add_argument
(
'
--type-template
'
,
type
=
FileType
())
...
...
@@ -131,6 +110,13 @@ def main():
outstring
=
pretty_print
(
ET
.
tostring
(
trytonxml
,
encoding
=
'
UTF-8
'
,
method
=
'
xml
'
))
args
.
output
.
write
(
outstring
)
def
main2
():
x
=
ET
.
Element
(
'
test
'
)
e
=
AccountTypeTemplate
(
x
)
e
.
addTemplate
(
"
10
"
,
"
peni
"
,
None
,
statement
=
"
balance
"
,
asset
=
"
True
"
,
receivable
=
"
True
"
)
print
(
ET
.
tostring
(
e
.
xml
))
if
__name__
==
"
__main__
"
:
#main2()
main
()
tryton.cfg
View file @
7115d988
[tryton]
version
=
5.
0
.0
version
=
5.
2
.0
depends:
account
ir
...
...