Menu

#1273 Some vendor invoices can't be opened, error

1.4
closed-fixed
None
5
2014-11-03
2014-10-29
John Locke
No

This happens in both 1.3, and 1.4. Most vendor and customer invoices open fine. However, after updating to the tip of 1.3 and 1.4, when I attempt to open any vendor invoice from a particular vendor, I get an error.

Steps:

  1. Go to AP -> Search (1.4) or AP -> Reports -> Transactions (1.3).
  2. Enter vendor name, and check "Closed" box to pull up vendor history.
  3. In resulting list, click invoice number to open.

For any of this particular vendor's invoices, I get this error (1.4):

SELECT i.id as invoice_id,
coalesce(i.vendor_sku, p.partnumber)
as partnumber,
i.description, i.qty,
i.fxsellprice, i.sellprice, i.precision,
i.parts_id AS id, i.unit, p.bin,
i.deliverydate,
i.serialnumber,
i.discount, i.notes, pg.partsgroup,
p.partsgroup_id, p.partnumber AS sku,
p.weight, p.onhand, p.inventory_accno_id,
p.income_accno_id, p.expense_accno_id,
t.description AS partsgrouptranslation
FROM invoice i
JOIN parts p ON (i.parts_id = p.id)
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
LEFT JOIN translation t
ON (t.trans_id = p.partsgroup_id
AND t.language_code = ?)
WHERE i.trans_id = ?
ORDER BY i.id
called with 3 bind variables when 2 are needed at LedgerSMB/IR.pm line 1174
'

dbversion: 1.4.5, company: ...

... or 1.3:

Error!

SELECT i.id as invoice_id,
coalesce(i.vendor_sku, p.partnumber)
as partnumber,
i.description, i.qty,
i.fxsellprice, i.sellprice, i.precision,
i.parts_id AS id, i.unit, p.bin,
i.deliverydate,
pr.projectnumber, i.project_id,
i.serialnumber,
i.discount, i.notes, pg.partsgroup,
p.partsgroup_id, p.partnumber AS sku,
p.weight, p.onhand, p.inventory_accno_id,
p.income_accno_id, p.expense_accno_id,
t.description AS partsgrouptranslation
FROM invoice i
JOIN parts p ON (i.parts_id = p.id)
LEFT JOIN project pr ON (i.project_id = pr.id)
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
LEFT JOIN translation t
ON (t.trans_id = p.partsgroup_id
AND t.language_code = ?)
WHERE i.trans_id = ?
ORDER BY i.id
called with 3 bind variables when 2 are needed

Discussion

  • John Locke

    John Locke - 2014-10-29

    This is a regression caused by the fix for #1260.

    On my 1.3 instance, checking out LedgerSMB/IR.pm from the previous commit fixes the issue.

     
  • John Locke

    John Locke - 2014-10-29

    I see in the 1.4 instance, the query being prepared has two lines removed, one of which contains a placeholder. So removing the parameter from the database call appears to fix the issue:

    diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm
    index 3e241f9..5c12f08 100644
    --- a/LedgerSMB/IR.pm
    +++ b/LedgerSMB/IR.pm
    @@ -1171,7 +1171,7 @@ sub retrieve_invoice {
                                WHERE i.trans_id = ?
                             ORDER BY i.id|;
             $sth = $dbh->prepare($query);
    
    -        $sth->execute( $form->{vendor_id}, $form->{language_code}, $form->{id} )
    +        $sth->execute( $form->{language_code}, $form->{id} )
               || $form->dberror($query);
    
             my $bu_sth = $dbh->prepare(
    

    (edit: fixing formatting)

     

    Last edit: John Locke 2014-10-29
  • John Locke

    John Locke - 2014-10-29

    ... and here's the corresponding patch for 1.3:

    ~~~~~~~~~~~
    diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm
    index 9ae8c26..530628a 100644
    --- a/LedgerSMB/IR.pm
    +++ b/LedgerSMB/IR.pm
    @@ -1282,7 +1282,7 @@ sub retrieve_invoice {
    WHERE i.trans_id = ?
    ORDER BY i.id|;
    $sth = $dbh->prepare($query);

    • $sth->execute( $form->{vendor_id}, $form->{language_code}, $form->{id} )
    • $sth->execute( $form->{language_code}, $form->{id} )
      || $form->dberror($query);
       # exchangerate defaults
      

      ~~~~~~~~~~~~

    Istvan, Chris, can you review and let me know if this is the appropriate fix?

     
  • Chris Travers

    Chris Travers - 2014-11-03
    • status: open --> closed-fixed
    • assigned_to: John Locke
     
  • Chris Travers

    Chris Travers - 2014-11-03

    I recall these patches being applied.

     
MongoDB Logo MongoDB