[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code for populating database



2011/11/12 Philippe Clérié <..hidden..>:
> On Saturday, 12 November 2011 09:18:00 Chris Travers wrote:
>> 2011/11/11 Philippe Clérié <..hidden..>:
>> > I'm sure someone has faced the problem of loading a brand new
>> > installation with existing data. Is there some sample code somewhere
>> > which shows how it's done? Particularly customer/AR data...
>> >
>> > The code in doc/samples seems to be a bit old and I'm not sure how
>> > relevant it is now.
>>
>> The customer section is a bit old but the ar/acc_trans/invoice
>> structure hasn't changed much.
>>
>> However, if you could give me a little more info as to what exactly
>> you are talking about that would be helpful.  Is this an ongoing
>> import need?  A one-time migration thing?  Something else?  If nothing
>> else I can point you to relevant tables and stored procedures in the
>> db docs.
>>
>> Best Wishes,
>> Chris Travers
>
> Thanks, Chris.
>
> This is going to be a one-time migration for a customer who prints out
> monthly invoices for a recurring service. I would like to transfer from
> their current system basic customer data, current balances and, if possible,
> the recurring invoices.
>
> I was thinking that it would be prudent to try doing that via the code
> rather than directly accessing the raw tables, hopefully, to allow the
> system to point to any missing and necessary data.

Ok.  For the customer information, you have basically two options.
You can populate the tables directly, or you can call the procedural
interface.  If you are populating the tables directly, the tables
involved are entity, entity_credit_account, company, location,
eca_to_location, eca_to_contact. You can use the 1.2-1.3.sql here as
sample code.

You can also use the following stored procedures to accomplish the
same thing (for documentation location, see below):

company_save
eca__save_location
eca__save_contact
eca__save_bank_account

Services need to go in the parts table.  There is no procedural
interface yet for this.

For invoices, you would need to populate the following tables:
ar  (populates transactions via triggers)
acc_trans
invoice

For recurring information please see tables beginning with "recurring"

These areas have no procedural interface yet, but this will be coming
in future versions.

For database documentation see doc/database/ledgersmb.html located in
your ledgersmb directory.

Best Wishes,
Chris Travers