Factures fournisseurs ... filepath creation

Good Morning everybody.
I’m new to dolibarr and working for the import of my access database. a structure of contacts, joined invoices, documents … nearly equal organized like DB.
I’m putting every dataset – equal if adress, contact, document or invoice with VBA-Code via ODBC directly into the dolibarr instance … and this works quite good …
but i get struggeling with the iinvoices of the fournisseurs.
.
If I take the example of the document database, the dataset is relying via the fk_soc - id to the societe-rowid.
then the php script finds in the path of /dolibarr/documents/societe/socid/text1.pdf the files and displayes them joined to the dataset “societe” … everything is fine.

Now … I want to do the same with factures-fournisseurs.
I write my code, I put the file into the path where it logically should be (yes, there is a “fournisseur/facture/” between ) and logically the path should be like
/documents/fournisseur/facture/socid/ref/123-invoice.pdf

but… it is not.
Im struggeling with that for a week.
If I do a manual upload, the (same) fournisseurs-facture goes to
sometimes
/documents/fournisseurs/facture/0/socid/ (i I have this in my database hasardly … then everything is fine …)
or
/documents/fournisseurs/facture/5/socid/

or
/documents/fournisseurs/facture/8/socid/

Please, can you tell me, how the destination-Path is “calculated” ?
And … in the database after every manual upload there seems to be hash-values in the table — how are they calculated so tha t i can continue to import my invoices as pdf files ?

:confused:
kind regards
rob