From f40522d77f0ebf521c0415bdb40e4679839e3f0e Mon Sep 17 00:00:00 2001 From: Chris Travers Date: Wed, 22 Oct 2014 18:15:52 -0700 Subject: [PATCH 1/6] Fixed simialr bug to 1259 for invoices --- Changelog | 1 + LedgerSMB/IS.pm | 2 +- LedgerSMB/OE.pm | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 8c037bde3b..1b8917043d 100644 --- a/Changelog +++ b/Changelog @@ -5,6 +5,7 @@ Supported Presently Changelog for 1.3.46 * Fixing bug 1257, ordnumber shows all orders open/closd (Chris T) * Fixed bug 1259, id from new_shipto overwrites form-id (Pongracz I) +* Fixed related bug to 1259 on invoices (Chris T) Chris T is Chris Travers Pongracz I is Pongracz Istvan diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm index 4285750efc..a1195587ef 100644 --- a/LedgerSMB/IS.pm +++ b/LedgerSMB/IS.pm @@ -2141,7 +2141,7 @@ sub retrieve_invoice { $ref = $sth->fetchrow_hashref(NAME_lc); $ref->{locationid} = $ref->{id}; delete $ref->{id}; - for ( keys %$ref ) { $form->{$_} = $ref->{$_} } + for ( keys %$ref ) { $form->{$_} = $ref->{$_} unless $_ eq 'id' }; $sth->finish; # retrieve individual items diff --git a/LedgerSMB/OE.pm b/LedgerSMB/OE.pm index fafd1701ce..8dbcc09915 100644 --- a/LedgerSMB/OE.pm +++ b/LedgerSMB/OE.pm @@ -874,7 +874,7 @@ sub retrieve { $sth->execute( $form->{id} ) || $form->dberror($query); $ref = $sth->fetchrow_hashref('NAME_lc'); - for ( keys %$ref ) { $form->{$_} = $ref->{$_} unless ( $_ == "id") } + for ( keys %$ref ) { $form->{$_} = $ref->{$_} unless ( $_ eq "id") } $sth->finish; # get printed, emailed and queued From 5f1ce9f0b7cd6239ca19034d35b7a9fefd43b693 Mon Sep 17 00:00:00 2001 From: Chris Travers Date: Thu, 23 Oct 2014 07:30:09 -0700 Subject: [PATCH 2/6] Removing a sql query with invalid syntax --- LedgerSMB/IC.pm | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/LedgerSMB/IC.pm b/LedgerSMB/IC.pm index cbfb84a198..6adcdc4583 100644 --- a/LedgerSMB/IC.pm +++ b/LedgerSMB/IC.pm @@ -1953,47 +1953,6 @@ sub create_links { ( $form->{currencies} ) = $dbh->selectrow_array($query); } - else { - - # Dieter: FIXME left joins not working - $query = qq| - SELECT (SELECT value FROM defaults - WHERE setting_key = 'weightunit') - AS weightunit, current_date AS priceupdate, - (SELECT value FROM defaults - WHERE setting_key = 'curr') AS currencies, - a1.accno AS inventory_accno, - a1.description AS inventory_description, - a2.accno AS income_accno, - a2.description AS income_description, - a3.accno AS expense_accno, - a3.description AS expense_description - FROM account a1, account a2, account a3 - WHERE a1.id IN (SELECT value::int FROM defaults - WHERE setting_key = 'inventory_accno_id') - AND a2.id IN (SELECT value::int FROM defaults - WHERE setting_key = 'income_accno_id') - AND a3.id IN (SELECT value::int FROM defaults - WHERE setting_key - = 'expense_accno_id')|; - $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - - $ref = $sth->fetchrow_hashref(NAME_lc); - for (qw(weightunit priceupdate currencies)) { - $form->{$_} = $ref->{$_}; - } - - # setup accno hash, {amount} is used in create_links - for (qw(inventory income expense)) { - $form->{amount}{"IC_$_"} = { - accno => $ref->{"${_}_accno"}, - description => $ref->{"${_}_description"} - }; - } - - $sth->finish; - } $dbh->commit; From 5744ef87b0a97a0fefca920957792b4a0ac88114 Mon Sep 17 00:00:00 2001 From: Chris Travers Date: Thu, 23 Oct 2014 07:30:39 -0700 Subject: [PATCH 3/6] Changelog entry --- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index 1b8917043d..42162ed061 100644 --- a/Changelog +++ b/Changelog @@ -6,6 +6,7 @@ Changelog for 1.3.46 * Fixing bug 1257, ordnumber shows all orders open/closd (Chris T) * Fixed bug 1259, id from new_shipto overwrites form-id (Pongracz I) * Fixed related bug to 1259 on invoices (Chris T) +* Some log quieting fixes. (Chris T) Chris T is Chris Travers Pongracz I is Pongracz Istvan From 8bb553811f5b2f94f99cb5d4fac7fd5d0ff0c593 Mon Sep 17 00:00:00 2001 From: Chris Travers Date: Fri, 24 Oct 2014 16:49:53 -0700 Subject: [PATCH 4/6] 1.3-specific fix for 1262 --- scripts/payment.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/payment.pl b/scripts/payment.pl index 5733c7fc58..4758eb4115 100644 --- a/scripts/payment.pl +++ b/scripts/payment.pl @@ -1330,6 +1330,9 @@ sub post_payment { # Now we split the account selected options, using the namespace the if statement # provides for us. $request->{"overpayment_account_$i"} =~ /^(\d+)--*/; + $request->{"overpayment_account_$i"} = $request->parse_amount( + amount => $request->{"overpayment_account_$i"} + ); my $id = $1; $request->{"overpayment_cash_account_$i"} =~ /^(\d+)--*/; my $cashid = $1; From a6350857a40054a0fbea634b8c3fc14a6a6ae556 Mon Sep 17 00:00:00 2001 From: Chris Travers Date: Fri, 24 Oct 2014 16:50:23 -0700 Subject: [PATCH 5/6] Changelog update for 1262 fix --- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index 42162ed061..f8bfa1d173 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,7 @@ Changelog for 1.3.46 * Fixed bug 1259, id from new_shipto overwrites form-id (Pongracz I) * Fixed related bug to 1259 on invoices (Chris T) * Some log quieting fixes. (Chris T) +* Fixed bug 1262, cannot post overpayment with formatted numbers (Chris T) Chris T is Chris Travers Pongracz I is Pongracz Istvan From 1238424308c2dc1dbc822ad4900776aaf593c096 Mon Sep 17 00:00:00 2001 From: Chris Travers Date: Fri, 24 Oct 2014 19:27:22 -0700 Subject: [PATCH 6/6] Fixing bug 1260 --- Changelog | 1 + LedgerSMB/IR.pm | 13 ++++++------- sql/Pg-database.sql | 1 + sql/modules/Fixes.sql | 13 +++++++++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index f8bfa1d173..1a1f8f339f 100644 --- a/Changelog +++ b/Changelog @@ -8,6 +8,7 @@ Changelog for 1.3.46 * Fixed related bug to 1259 on invoices (Chris T) * Some log quieting fixes. (Chris T) * Fixed bug 1262, cannot post overpayment with formatted numbers (Chris T) +* Fixed bug 1260, Multiple vendor skus breaks display of invoice (Chris T) Chris T is Chris Travers Pongracz I is Pongracz Istvan diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm index fd4f0783dd..9ae8c263c0 100644 --- a/LedgerSMB/IR.pm +++ b/LedgerSMB/IR.pm @@ -326,7 +326,8 @@ sub post_invoice { project_id = ?, serialnumber = ?, precision = ?, - notes = ? + notes = ?, + vendor_sku = ? WHERE id = ?|; $sth = $dbh->prepare($query); $sth->execute( @@ -336,7 +337,8 @@ sub post_invoice { $form->{"discount_$i"}, $allocated, $form->{"unit_$i"}, $form->{"deliverydate_$i"}, $project_id, $form->{"serialnumber_$i"}, - $form->{"precision_$i"}, $form->{"notes_$i"}, + $form->{"precision_$i"}, $form->{"notes_$i"}, + $form->{"partnumber_$i"}, $invoice_id ) || $form->dberror($query); @@ -1257,9 +1259,8 @@ sub retrieve_invoice { # retrieve individual items $query = qq| SELECT i.id as invoice_id, - coalesce( - CASE WHEN pv.partnumber <> '' THEN pv.partnumber - ELSE NULL END, p.partnumber) as partnumber, + 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, @@ -1274,8 +1275,6 @@ sub retrieve_invoice { FROM invoice i JOIN parts p ON (i.parts_id = p.id) LEFT JOIN project pr ON (i.project_id = pr.id) - LEFT JOIN partsvendor pv ON (p.id = pv.parts_id - AND pv.credit_id = ?) LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id) LEFT JOIN translation t ON (t.trans_id = p.partsgroup_id diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql index 48aad855c6..b5ecc91fa3 100644 --- a/sql/Pg-database.sql +++ b/sql/Pg-database.sql @@ -1214,6 +1214,7 @@ CREATE TABLE invoice ( project_id int, deliverydate date, serialnumber text, + vendor_sku text, notes text ); diff --git a/sql/modules/Fixes.sql b/sql/modules/Fixes.sql index 6eb3f518d7..d60fd097c4 100644 --- a/sql/modules/Fixes.sql +++ b/sql/modules/Fixes.sql @@ -699,3 +699,16 @@ ALTER TABLE BATCH ADD FOREIGN KEY (locked_by) references session (session_id) ON DELETE SET NULL; COMMIT; + +BEGIN; +ALTER TABLE invoice ADD vendor_sku text; +UPDATE invoice SET vendor_sku = (select min(partnumber) from partsvendor + where parts_id = invoice.parts_id + AND credit_id = ( + select entity_credit_account + from ap + where ap.id = invoice.trans_id + ) + ) + WHERE trans_id in (select id from ap); +COMMIT;