Commit b3bd73bf authored by Jérome Perrin's avatar Jérome Perrin

Update PCG to Version 2025

This was done by manually converting 
https://www.anc.gouv.fr/files/anc/files/1_Normes_fran%C3%A7aises/Plans%20comptables/Plan-de-comptes-PCG-2025.pdf to csv and importing it with CategoryTool_viewImportGapFileDialog

[PCG2025.csv](/uploads/afb7eb0b386359f98dd5538bb24e81f3/PCG2025.csv)

See merge request nexedi/erp5!2038
parents 9be120e4 2fbbaa6a
Pipeline #38923 failed with stage
in 0 seconds
import csv
def recursiveDocumentList(obj):
ret = []
ret.append(obj.getPath())
......@@ -5,64 +7,12 @@ def recursiveDocumentList(obj):
ret.extend(recursiveDocumentList(i))
return ret
def splitCsvLine(str_line):
unclean_list = []
pieces_of_line = str_line.split(',')
p_stack = ''
for p in pieces_of_line:
p_stack += p
if p_stack.count('"')%2 == 0:
unclean_list.append(p_stack)
p_stack = ''
clean_list = []
for item in unclean_list:
clean_item = item
if clean_item.find('"') != -1:
if len(clean_item) <= 2:
clean_item = ''
else:
clean_item = clean_item[1:]
clean_item = clean_item[:-1]
clean_item = clean_item.replace('""', '"')
else:
if len(clean_item) > 0:
if clean_item.find('.') != -1:
clean_item = float(clean_item)
else:
clean_item = int(clean_item)
else:
clean_item = None
clean_list.append(clean_item)
return clean_list
def getSubCategory(parent, category_id):
try:
return parent[category_id]
except KeyError:
return parent.newContent(id=category_id)
csv_file_line_list = import_file.readlines()
csv_line_list = []
for csv_line in csv_file_line_list:
csv_line_list.append( string.replace(csv_line, '\n', '').decode(encoding).encode('utf-8') )
object_list = []
csv_property_list = splitCsvLine(csv_line_list[0])
for csv_line in csv_line_list[2:]:
property_dict = {}
csv_data_list = splitCsvLine(csv_line)
data_n = 0
for property_ in csv_property_list:
property_dict[property_] = csv_data_list[data_n]
data_n += 1
object_list.append(property_dict)
root = context.getPortalObject().portal_categories
for path in gap_root_path.split('/'):
......@@ -71,7 +21,7 @@ for path in gap_root_path.split('/'):
existing_path_list = recursiveDocumentList(root)
existing_path_list.remove(root.getPath())
for property_dict in object_list:
for property_dict in list(csv.DictReader(import_file)):
description = property_dict.get('Description', None) or ''
gap = property_dict.get('Gap', None) or ''
title = property_dict.get('Title', None) or ''
......
......@@ -67,8 +67,7 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Plan comptable général\n
Version consolidée du règlement ANC 2014-03 (Version au 1er janvier 2017)</string> </value>
<value> <string>Plan comptable général - Règlement ANC 2014-03 (Version 2025)</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......@@ -80,7 +79,7 @@ Version consolidée du règlement ANC 2014-03 (Version au 1er janvier 2017)</str
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Plan Comptable Général (Version au 1er janvier 2017)</string> </value>
<value> <string>Plan Comptable Général (Version au 1er janvier 2025)</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -87,7 +87,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Classe 1 : Comptes de capitaux</string> </value>
<value> <string>CLASSE 1 : COMPTES DE CAPITAUX</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -65,7 +65,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Primes liées au capital social</string> </value>
<value> <string>Primes liées au capital</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Ecarts de réévaluation</string> </value>
<value> <string>Écarts de réévaluation</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>1051</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>1051</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Réserve spéciale de réévaluation</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>1052</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>1052</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Ecart de réévaluation libre</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>1053</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>1053</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> <