[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2344] trunk
- Subject: SF.net SVN: ledger-smb:[2344] trunk
- From: ..hidden..
- Date: Mon, 29 Sep 2008 23:38:25 +0000
Revision: 2344
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2344&view=rev
Author: einhverfr
Date: 2008-09-29 23:38:19 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
Correcting payment bug: contact total shows 0 when Some radio button is selected
Also moved the bulk post function to use a temp table to try to get performance gains (if this doesn't work, we will have to go to the one stored proc per invoice approach which I would rather not do).
Modified Paths:
--------------
trunk/scripts/payment.pl
trunk/sql/modules/Payment.sql
Modified: trunk/scripts/payment.pl
===================================================================
--- trunk/scripts/payment.pl 2008-09-26 01:38:47 UTC (rev 2343)
+++ trunk/scripts/payment.pl 2008-09-29 23:38:19 UTC (rev 2344)
@@ -368,11 +368,10 @@
for my $invoice (@{$_->{invoices}}){
if (($payment->{action} ne 'update_payments')
or (defined $payment->{"id_$_->{contact_id}"})){
-
if ($payment->{"paid_$_->{contact_id}"} eq 'some'){
my $i_id = $invoice->[0];
$contact_total
- += $payment->{"paid_$_->{contact_id}_$i_id"};
+ += $payment->{"payment_$i_id"};
}
}
$invoice->[3] = $payment->format_amount(amount => $invoice->[3],
@@ -383,8 +382,8 @@
money => 1);
$invoice->[6] = $payment->format_amount(amount => $invoice->[6],
money => 1);
- if (!$payment->{action} ne 'update_payments'){
- my $fld = "payment_" . $invoice->[0];
+ my $fld = "payment_" . $invoice->[0];
+ if (!defined $payment->{"$fld"} ){
$payment->{"$fld"} = $invoice->[6];
}
}
Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql 2008-09-26 01:38:47 UTC (rev 2343)
+++ trunk/sql/modules/Payment.sql 2008-09-29 23:38:19 UTC (rev 2344)
@@ -420,6 +420,8 @@
t_voucher_id := currval('voucher_id_seq');
END IF;
+ CREATE TEMPORARY TABLE bulk_payments_in (id int, amount numeric);
+
select id into t_ar_ap_id from chart where accno = in_ar_ap_accno;
select id into t_cash_id from chart where accno = in_cash_accno;
@@ -427,39 +429,54 @@
array_lower(in_transactions, 1) ..
array_upper(in_transactions, 1)
LOOP
+ EXECUTE $E$
+ INSERT INTO bulk_payments_in(id, amount)
+ VALUES ($E$ || quote_literal(in_transactions[out_count][1])
+ || $E$, $E$ ||
+ quote_literal(in_transactions[out_count][2])
+ || $E$)$E$;
+ END LOOP;
+ EXECUTE $E$
INSERT INTO acc_trans
- (trans_id, chart_id, amount, approved, voucher_id,
- transdate, source)
- VALUES
- (in_transactions[out_count][1],
- case when in_account_class = 1 THEN t_cash_id
- WHEN in_account_class = 2 THEN t_ar_ap_id
- ELSE -1 END,
+ (trans_id, chart_id, amount, approved, voucher_id, transdate,
+ source)
+ SELECT id,
+ case when $E$ || quote_literal(in_account_class) || $E$ = 1
+ THEN $E$ || t_cash_id || $E$
+ WHEN $E$ || quote_literal(in_account_class) || $E$ = 2
+ THEN $E$ || t_ar_ap_id || $E$
+ ELSE -1 END,
+ amount,
+ CASE
+ WHEN $E$|| t_voucher_id || $E$ IS NULL THEN true
+ ELSE false END,
+ $E$ || t_voucher_id || $E$, $E$|| quote_literal(in_payment_date)
+ ||$E$ , $E$ ||COALESCE(quote_literal(in_source), 'NULL') ||$E$
+ FROM bulk_payments_in $E$;
- in_transactions[out_count][2],
-
- CASE WHEN t_voucher_id IS NULL THEN true
- ELSE false END,
- t_voucher_id, in_payment_date, in_source);
-
+ EXECUTE $E$
INSERT INTO acc_trans
- (trans_id, chart_id, amount, approved, voucher_id,
- transdate, source)
- VALUES
- (in_transactions[out_count][1],
- case when in_account_class = 1 THEN t_ar_ap_id
- WHEN in_account_class = 2 THEN t_cash_id
- ELSE -1 END,
+ (trans_id, chart_id, amount, approved, voucher_id, transdate,
+ source)
+ SELECT id,
+ case when $E$ || quote_literal(in_account_class) || $E$ = 1
+ THEN $E$ || t_ar_ap_id || $E$
+ WHEN $E$ || quote_literal(in_account_class) || $E$ = 2
+ THEN $E$ || t_cash_id || $E$
+ ELSE -1 END,
+ amount * -1,
+ CASE
+ WHEN $E$|| t_voucher_id || $E$ IS NULL THEN true
+ ELSE false END,
+ $E$ || t_voucher_id || $E$, $E$|| quote_literal(in_payment_date)
+ ||$E$ , $E$ ||COALESCE(quote_literal(in_source), 'null') ||$E$
+ FROM bulk_payments_in $E$;
- in_transactions[out_count][2]* -1,
-
- CASE WHEN t_voucher_id IS NULL THEN true
- ELSE false END,
- t_voucher_id, in_payment_date, in_source);
+ EXECUTE $E$
UPDATE ap
- set paid = paid +in_transactions[out_count][2]
- where id =in_transactions[out_count][1];
- END LOOP;
+ set paid = paid + (select amount from bulk_payments_in b
+ where b.id = ap.id)
+ where id in (select id from bulk_payments_in) $E$;
perform unlock_all();
return out_count;
END;
@@ -472,8 +489,7 @@
IS
$$ Note that in_transactions is a two-dimensional numeric array. Of each
sub-array, the first element is the (integer) transaction id, and the second
-is the amount for that transaction. If the total of the amounts do not add up
-to in_total, then an error is generated. $$;
+is the amount for that transaction. $$;
--
-- WE NEED A PAYMENT TABLE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.