[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4248] branches/1.3
- Subject: SF.net SVN: ledger-smb:[4248] branches/1.3
- From: ..hidden..
- Date: Thu, 29 Dec 2011 12:32:16 +0000
Revision: 4248
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4248&view=rev
Author: tshvr
Date: 2011-12-29 12:32:16 +0000 (Thu, 29 Dec 2011)
Log Message:
-----------
also link to ir/is from payment
Modified Paths:
--------------
branches/1.3/LedgerSMB/DBObject/Customer.pm
branches/1.3/LedgerSMB/DBObject/Vendor.pm
branches/1.3/scripts/payment.pl
branches/1.3/sql/modules/Payment.sql
Modified: branches/1.3/LedgerSMB/DBObject/Customer.pm
===================================================================
--- branches/1.3/LedgerSMB/DBObject/Customer.pm 2011-12-28 17:11:18 UTC (rev 4247)
+++ branches/1.3/LedgerSMB/DBObject/Customer.pm 2011-12-29 12:32:16 UTC (rev 4248)
@@ -28,7 +28,7 @@
use base qw(LedgerSMB::DBObject::Company);
use strict;
-my $ENTITY_CLASS = 2;
+our $ENTITY_CLASS = 2;
sub set_entity_class {
Modified: branches/1.3/LedgerSMB/DBObject/Vendor.pm
===================================================================
--- branches/1.3/LedgerSMB/DBObject/Vendor.pm 2011-12-28 17:11:18 UTC (rev 4247)
+++ branches/1.3/LedgerSMB/DBObject/Vendor.pm 2011-12-29 12:32:16 UTC (rev 4248)
@@ -29,7 +29,7 @@
use base qw(LedgerSMB::DBObject::Company);
use strict;
-my $ENTITY_CLASS = 1;
+our $ENTITY_CLASS = 1;
sub set_entity_class {
my $self = shift @_;
Modified: branches/1.3/scripts/payment.pl
===================================================================
--- branches/1.3/scripts/payment.pl 2011-12-28 17:11:18 UTC (rev 4247)
+++ branches/1.3/scripts/payment.pl 2011-12-29 12:32:16 UTC (rev 4248)
@@ -51,6 +51,8 @@
use LedgerSMB::Sysconfig;
use LedgerSMB::DBObject::Payment;
use LedgerSMB::DBObject::Date;
+use LedgerSMB::DBObject::Customer;
+use LedgerSMB::DBObject::Vendor;
use LedgerSMB::CancelFurtherProcessing;
use Error::Simple;
use Error;
@@ -975,9 +977,38 @@
}
#print STDERR localtime()." payment.pl array=".Data::Dumper::Dumper($array_options[$ref])."\n";
my $paid_formatted=$Payment->format_amount(amount=>($array_options[$ref]->{amount} - $array_options[$ref]->{due} - $array_options[$ref]->{discount}));
-#Now its time to build the link to the invoice :)
-my $uri = $Payment->{account_class} == 1 ? 'ap' : 'ar';
-$uri .= '.pl?action=edit&id='.$array_options[$ref]->{invoice_id}.'&path=bin/mozilla&login='.$request->{login};
+ #Now its time to build the link to the invoice :)
+ my $uri_module;
+ #TODO move following code to sub getModuleForUri() ?
+ if($Payment->{account_class} == $LedgerSMB::DBObject::Vendor::ENTITY_CLASS)
+ {
+ if($array_options[$ref]->{invoice})
+ {
+ $uri_module='ir';
+ }
+ else
+ {
+ $uri_module='ap';
+ }
+ }#account_class 1
+ elsif($Payment->{account_class} == $LedgerSMB::DBObject::Customer::ENTITY_CLASS)
+ {
+ if($array_options[$ref]->{invoice})
+ {
+ $uri_module='is';
+ }
+ else
+ {
+ $uri_module='ar';
+ }
+ }#account_class 2
+ else
+ {
+ #TODO
+ $uri_module='??';
+ }
+#my $uri = $Payment->{account_class} == 1 ? 'ap' : 'ar';
+ my $uri =$uri_module.'.pl?action=edit&id='.$array_options[$ref]->{invoice_id}.'&path=bin/mozilla&login='.$request->{login};
push @invoice_data, { invoice => { number => $array_options[$ref]->{invnumber},
id => $array_options[$ref]->{invoice_id},
Modified: branches/1.3/sql/modules/Payment.sql
===================================================================
--- branches/1.3/sql/modules/Payment.sql 2011-12-28 17:11:18 UTC (rev 4247)
+++ branches/1.3/sql/modules/Payment.sql 2011-12-29 12:32:16 UTC (rev 4248)
@@ -125,6 +125,7 @@
CREATE TYPE payment_invoice AS (
invoice_id int,
invnumber text,
+ invoice bool,
invoice_date date,
amount numeric,
amount_fx numeric,
@@ -149,7 +150,7 @@
DECLARE payment_inv payment_invoice;
BEGIN
FOR payment_inv IN
- SELECT a.id AS invoice_id, a.invnumber AS invnumber,
+ SELECT a.id AS invoice_id, a.invnumber AS invnumber,a.invoice AS invoice,
a.transdate AS invoice_date, a.amount AS amount,
a.amount/
(CASE WHEN a.curr = (SELECT * from defaults_get_defaultcurrency())
@@ -198,13 +199,13 @@
END) AS exchangerate
--TODO HV prepare drop entity_id from ap,ar
--FROM (SELECT id, invnumber, transdate, amount, entity_id,
- FROM (SELECT id, invnumber, transdate, amount,
+ FROM (SELECT id, invnumber, invoice, transdate, amount,
1 as invoice_class, paid, curr,
entity_credit_account, department_id, approved
FROM ap
UNION
--SELECT id, invnumber, transdate, amount, entity_id,
- SELECT id, invnumber, transdate, amount,
+ SELECT id, invnumber, invoice, transdate, amount,
2 AS invoice_class, paid, curr,
entity_credit_account, department_id, approved
FROM ar
@@ -239,7 +240,7 @@
OR in_department_id IS NULL)
AND due <> 0
AND a.approved = true
- GROUP BY a.invnumber, a.transdate, a.amount, amount_fx, discount, discount_fx, ac.due, a.id, c.discount_terms, ex.buy, ex.sell, a.curr
+ GROUP BY a.invnumber, a.transdate, a.amount, amount_fx, discount, discount_fx, ac.due, a.id, c.discount_terms, ex.buy, ex.sell, a.curr, a.invoice
LOOP
RETURN NEXT payment_inv;
END LOOP;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.