Skip to content

Commit

Permalink
Merge pull request #43 from ledgersmb/1.3
Browse files Browse the repository at this point in the history
1.3 - sync from central
  • Loading branch information
pongraczi committed Oct 25, 2014
2 parents 848aec4 + b738f7d commit f6095b8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 50 deletions.
4 changes: 4 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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)
* 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
Expand Down
41 changes: 0 additions & 41 deletions LedgerSMB/IC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 6 additions & 7 deletions LedgerSMB/IR.pm
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ sub post_invoice {
project_id = ?,
serialnumber = ?,
precision = ?,
notes = ?
notes = ?,
vendor_sku = ?
WHERE id = ?|;
$sth = $dbh->prepare($query);
$sth->execute(
Expand All @@ -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);

Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion LedgerSMB/IS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion LedgerSMB/OE.pm
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,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
Expand Down
3 changes: 3 additions & 0 deletions scripts/payment.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions sql/Pg-database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,7 @@ CREATE TABLE invoice (
project_id int,
deliverydate date,
serialnumber text,
vendor_sku text,
notes text
);

Expand Down
13 changes: 13 additions & 0 deletions sql/modules/Fixes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit f6095b8

Please sign in to comment.