Dear Christ, I need your advice, Chart information : select id , accno , description from chart where id in (10045,10007,10024,10025,10033,10004); id | accno | description -------+-------+---------------------------- 10033 | 4020 | Sales / Hardware 10045 | 5020 | COGS / Hardware 10004 | 1200 | Accounts Receivables 10007 | 1520 | Inventory / Computer Parts 10024 | 2310 | PST (5%) 10025 | 2320 | GST (5%) (6 rows) When I have many invoices from many Ap for the same item. ================================================================================================================================================= select id , invnumber from ap where id in ('303040','303041','303042'); id | invnumber --------+----------- 303040 | 1010 303041 | 1011 303042 | 1012 (3 rows) select id , parts_id , trans_id , qty , allocated from invoice where parts_id =303044; id | parts_id | trans_id | qty | allocated -------+----------+----------+-----+----------- 76634 | 303044 | 303047 | -1 | 0 76633 | 303044 | 303046 | -1 | 0 76632 | 303044 | 303045 | -1 | 0 (3 rows) =============================================================================================================================================== if I sold them in one AR invoice, id | parts_id | trans_id | qty | allocated -------+----------+----------+-----+----------- 76632 | 303044 | 303045 | -1 | 1 76633 | 303044 | 303046 | -1 | 1 76634 | 303044 | 303047 | -1 | 1 76637 | 303044 | 303051 | 3 | -3 (4 rows) select id , invnumber from ar where id = 303051; id | invnumber --------+----------- 303051 | 11374 (1 row) I will have that in acc_trans: select * from acc_trans where trans_id = 303051; trans_id | chart_id | transdate | source | cleared | fx_transaction | project_id | memo | invoice_id | amount | entry_id ----------+----------+------------+--------+---------+----------------+------------+------+------------+--------+---------- 303051 | 10024 | 2009-11-30 | | f | f | | | | 3 | 132403 303051 | 10025 | 2009-11-30 | | f | f | | | | 3 | 132402 303051 | 10004 | 2009-11-30 | | f | f | | | | -66 | 132401 303051 | 10045 | 2009-11-30 | | f | f | | | 76634 | -5 | 132400 303051 | 10045 | 2009-11-30 | | f | f | | | 76633 | -5 | 132399 303051 | 10045 | 2009-11-30 | | f | f | | | 76632 | -5 | 132398 303051 | 10007 | 2009-11-30 | | f | f | | | 76637 | 5 | 132397 303051 | 10007 | 2009-11-30 | | f | f | | | 76633 | 5 | 132396 303051 | 10007 | 2009-11-30 | | f | f | | | 76632 | 5 | 132395 303051 | 10033 | 2009-11-30 | | f | f | | | | 60 | 132394 (10 rows) The program add the invoice id as you see inventory_accno_id and expensive_accno_id = id of invoice that belong to AP. except, When entry_id = 132397 , the program add the invoice id that belong to Ar. From monitoring the code I found those 2 lines in IS.pm, $ndx = $#{ @{ $form->{acc_trans}{lineitems} } }; # add invoice_id $form->{acc_trans}{lineitems}[$ndx]->{invoice_id} = $invoice_id; The program do that for every line, so in COGS function, if the item came from one invoice that is mean : expenses_accno_id will has invoice id that belong to AP and inventory_accno_id will has invoice id for this item that belong to AR. but If the item came from many ap invoices, That is mean one from the lines will have the ar invoice and the rest will have the invoice id that belong to AP. I don't know depend on what the project do that. as you see on this line : # add invoice_id $form->{acc_trans}{lineitems}[$ndx]->{invoice_id} = $invoice_id; I will going to fix it, if I am wrong please tell me . Best wishes, Shaekir, Get a great deal on Windows 7 and see how it works the way you want. See the Windows 7 offers now. Windows Live: Keep your friends up to date with what you do online. Get a great deal on Windows 7 and see how it works the way you want. See the Windows 7 offers now. |