Topic: Import Transactions Multi Item Sales

When using Import Transactions last sales invoice number gets updated and then subsequently used by manual Direct Sales invoice. This causes a problem at times if Import is run, then few Direct Sales Invoices created manually, then another Import is run. Since FA has advanced sales invoice numbers second Import may try to import same references.

Is there any way to either not update last used sales invoice number when running Import Transaction or ignore reference column from Import Transactions and let FA generate Sales Invoice number when importing (as if it was a manual Direct Sales invoice)? The latter is preferred.

2 (edited by Braath Waate 05/01/2019 07:23:39 pm)

Re: Import Transactions Multi Item Sales

What FA version are you using?   In my fork, if reference number is left blank in the csv file, import_transactions generates the reference number automatically.

Re: Import Transactions Multi Item Sales

Thanks Braath
FA 2.3.24
Import Transactions 2.3.24-1

How do you deal with multi line invoices if reference is left blank?

Re: Import Transactions Multi Item Sales

Well I guess that won't work, will it?  Successive lines need some kind of continuation symbol for the reference field.  I updated my fork to use '+'.   However, this code is 2.4 based and might not work in 2.3.

Re: Import Transactions Multi Item Sales

I am thinking to still use reference from CSV file to detect a new document, store it on some memo (external reference) field on sales invoice, but always get a new sales invoice number for each new sales invoice being imported.
May be add a Boolean switch to Import Transactions to indicate whether to use invoice number from CSV or generate new.
What do you think?

Re: Import Transactions Multi Item Sales

That would be one way of doing it.  I guess I prefer the way I coded it though, because no extra boolean switch is needed.

Re: Import Transactions Multi Item Sales

I see what you have done:
- blank reference "" means get new number,
- non "+" reference means use this value as reference
- "+" reference means second, third, n-th lines of the same document
In other words - you only specify document number on the first line.

This way you can mix automatic numbers and given references in the same file, right?

Re: Import Transactions Multi Item Sales

Yes, thats the idea.

Re: Import Transactions Multi Item Sales

Noticed your version has been merged in to FA24Extensions library. Tried multi line sales invoice import with blank references - came across couple of issues there:

1. $Refs->get_next($type) seems to return the same document number until transaction is committed;
2. block of code to get the number document number is too late (lines 274-277 in import_transactions.php), by the time process reaches it, document has already been created. Thinking it should be soon after line 202, after list function is called but before $reference is tested in line 208;
3. $_SESSION['Items']->write(0); (line 212 in import_transactions.php) eventually calls function add_sales_order(&$order), which tries to insert sales order, but sales_type and prep_amount variables are not set in $order object, so fails there as well

Question:
Is there a way to get several new document numbers in the middle of transaction before commit?

Thank you.

Re: Import Transactions Multi Item Sales

@Denis

I made a new version with support for blank/+ references in multiline sales orders which address #1 and #2.  I didn't run into #3.