[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2251] trunk



Revision: 2251
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2251&view=rev
Author:   einhverfr
Date:     2008-08-12 16:39:00 +0000 (Tue, 12 Aug 2008)

Log Message:
-----------
Undoing svn commit rev 2250

Revision Links:
--------------
    http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2250&view=rev

Modified Paths:
--------------
    trunk/LedgerSMB/CA.pm
    trunk/LedgerSMB/DBObject/Company.pm
    trunk/UI/payments/payments_detail.html
    trunk/scripts/payment.pl
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Payment.sql

Modified: trunk/LedgerSMB/CA.pm
===================================================================
--- trunk/LedgerSMB/CA.pm	2008-08-12 16:37:02 UTC (rev 2250)
+++ trunk/LedgerSMB/CA.pm	2008-08-12 16:39:00 UTC (rev 2251)
@@ -403,6 +403,9 @@
 			$dpt_where
 			       AND ($approved OR (a.approved AND ac.approved))
 			$project|;
+        if ($d_id) {
+            push @queryargs, $d_id;
+        }
         push @queryargs, $id;
         if ($fdate) {
             push @queryargs, $fdate;
@@ -434,6 +437,9 @@
 			$dpt_where
 			$project|;
 
+        if ($d_id) {
+            push @queryargs, $d_id;
+        }
         push @queryargs, $id;
         if ($fdate) {
             push @queryargs, $fdate;
@@ -465,6 +471,9 @@
 			$dpt_where
 			$project |;
 
+        if ($d_id) {
+            push @queryargs, $d_id;
+        }
         push @queryargs, $id;
         if ($fdate) {
             push @queryargs, $fdate;

Modified: trunk/LedgerSMB/DBObject/Company.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Company.pm	2008-08-12 16:37:02 UTC (rev 2250)
+++ trunk/LedgerSMB/DBObject/Company.pm	2008-08-12 16:39:00 UTC (rev 2251)
@@ -88,17 +88,9 @@
 
 sub save_location {
     my $self = shift @_;
-
     $self->{country_id} = $self->{country_code};
+    $self->exec_method(funcname => 'company__location_save');
 
-    if($self->{credit_id}){
-        $self->exec_method(funcname => 'eca__location_save');
-    } else {
-        my ($ref) = $self->exec_method(funcname => 'company__location_save');
-        my @vals = values %$ref;
-        $self->{location_id} = $vals[0];
-    }
-
     $self->{dbh}->commit;
 }
 
@@ -162,15 +154,13 @@
     @{$self->{contact_class_list}} = 
          $self->exec_method(funcname => 'entity_list_contact_class');
 
+    @{$self->{credit_list}} = 
+         $self->exec_method(funcname => 'entity__list_credit');
 }
 
 sub save_contact {
     my ($self) = @_;
-    if ($self->{credit_id}){
-        $self->exec_method(funcname => 'eca__save_contact');
-    } else {
-        $self->exec_method(funcname => 'company__save_contact');
-    }
+    $self->exec_method(funcname => 'company__save_contact');
     $self->{dbh}->commit;
 }
 
@@ -182,11 +172,7 @@
 
 sub save_notes {
     my $self = shift @_;
-    if ($self->{credit_id} && $self->{note_class} eq '3'){
-        $self->exec_method(funcname => 'eca__save_notes');
-    } else {
-        $self->exec_method(funcname => 'entity__save_notes');
-    }
+    $self->exec_method(funcname => 'entity__save_notes');
     $self->{dbh}->commit;
 }
 
@@ -212,65 +198,19 @@
     $self->merge($ref);
     $self->{threshold} = $self->format_amount(amount => $self->{threshold});
 
-    @{$self->{credit_list}} = 
-         $self->exec_method(funcname => 'entity__list_credit');
-
-    for (@{$self->{credit_list}}){
-	print STDERR "credit_id: $_->{credit_id}\n";
-        if (($_->{credit_id} eq $self->{credit_id}) 
-                   or ($_->{meta_number} eq $self->{meta_number})){
-		$self->merge($_);
-                last;
-        }
-    }
     $self->{name} = $self->{legal_name};
-    if ($self->{credit_id} and $self->{meta_number}){
-        $self->get_credit_id;
-    }
 
-    if ($self->{credit_id}){
-        @{$self->{locations}} = $self->exec_method(
-		funcname => 'eca__list_locations');
-        @{$self->{contacts}} = $self->exec_method(
-		funcname => 'eca__list_contacts');
-        @{$self->{notes}} = $self->exec_method(
-		funcname => 'eca__list_notes');
-        
-    }
-    else {
-        @{$self->{locations}} = $self->exec_method(
+    @{$self->{locations}} = $self->exec_method(
 		funcname => 'company__list_locations');
-        @{$self->{contacts}} = $self->exec_method(
+
+    @{$self->{contacts}} = $self->exec_method(
 		funcname => 'company__list_contacts');
-        @{$self->{notes}} = $self->exec_method(
-		funcname => 'company__list_notes');
 
-    }
-
-    if ($self->{location_id}){
-        for (@{$self->{locations}}){
-            if ($_->{id} = $self->{location_id}){
-                my $old_id = $self->{id};
-                $self->merge($_);
-                $self->{id} = $old_id;
-                last;
-            }
-        }
-    }
-
-    if ($self->{contact_id}){
-        for (@{$self->{contacts}}){
-            if ($_->{id} = $self->{contact_id}){
-                my $old_id = $self->{id};
-                $self->merge($_);
-                $self->{id} = $old_id;
-                last;
-            }
-        }
-    }
-
     @{$self->{bank_account}} = $self->exec_method(
 		funcname => 'company__list_bank_account');
+
+    @{$self->{notes}} = $self->exec_method(
+		funcname => 'company__list_notes');
 };
 
 1;

Modified: trunk/UI/payments/payments_detail.html
===================================================================
--- trunk/UI/payments/payments_detail.html	2008-08-12 16:37:02 UTC (rev 2250)
+++ trunk/UI/payments/payments_detail.html	2008-08-12 16:39:00 UTC (rev 2251)
@@ -198,8 +198,7 @@
 		ELSE ; 'name_has_no_vouchers' ; 
 		END
 		?>"><?lsmb r.contact_name ?></span></td>
-	<td class="invoice"><?lsmb INCLUDE format_money number=r.total_due ?> 
-		<?lsmb currency ?></td>
+	<td class="invoice"><?lsmb r.total_due ?> <?lsmb currency ?></td>
         <td class="payment" class="details_select">
 		<?lsmb INCLUDE input element_data = {
 		name = "paid_$r.contact_id"
@@ -294,10 +293,12 @@
 			value = icount
 		} ?>
 		<?lsmb IF !r.unselected;
-			IF (${"paid_$r.contact_id"} == 'some');
+			IF (${"paid_$r.contact_id"} == 'all');
+				grand_total = grand_total + r.total_due;
+			ELSIF (${"paid_$r.contact_id"} == 'some');
 				grand_total = grand_total + contact_total;
 			ELSE;
-				grand_total = grand_total + r.total_due;
+				contact_total = 'error';
 			END; # IF (paid...)
 		END # IF !r.unselected) ?>
 		<tr class="subtotal">

Modified: trunk/scripts/payment.pl
===================================================================
--- trunk/scripts/payment.pl	2008-08-12 16:37:02 UTC (rev 2250)
+++ trunk/scripts/payment.pl	2008-08-12 16:39:00 UTC (rev 2251)
@@ -307,6 +307,7 @@
             }
 
             for my $inv (1 .. $inv_count){
+		print STDERR "Invoice $inv of " .$payment->{"invoice_count_$id"} . "\n";
                 my $invhash = {};
                 my $inv_id = $payment->{"invoice_${id}_$inv"};
                 for (qw(invnumber invdate)){

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2008-08-12 16:37:02 UTC (rev 2250)
+++ trunk/sql/Pg-database.sql	2008-08-12 16:39:00 UTC (rev 2251)
@@ -1,7 +1,11 @@
 begin;
 CREATE SEQUENCE id;
--- As of 1.3 there is no central db anymore. --CT
+-- Central DB structure
+-- This is the central database stuff which is used across all datasets
+-- in the ledger-smb.conf it is called 'ledgersmb' by default, but obviously
+-- can be named anything.
 
+
 -- BEGIN new entity management
 CREATE TABLE entity_class (
   id serial primary key,
@@ -18,8 +22,7 @@
   name text check (name ~ '[[:alnum:]_]'),
   entity_class integer references entity_class(id) not null ,
   created date not null default current_date,
-  control_code text,
-  PRIMARY KEY(control_code, entity_class));
+  PRIMARY KEY(name,entity_class));
   
 COMMENT ON TABLE entity IS $$ The primary entity table to map to all contacts $$;
 COMMENT ON COLUMN entity.name IS $$ This is the common name of an entity. If it was a person it may be Joshua Drake, a company Acme Corp. You may also choose to use a domain such as commandprompt.com $$;
@@ -160,24 +163,6 @@
   company_id integer not null references company(id) ON DELETE CASCADE,
   PRIMARY KEY(location_id,company_id));
 
-COMMENT ON TABLE company_to_location IS
-$$ This table is used for locations generic to companies.  For contract-bound
-addresses, use eca_to_location instead $$;
-
-CREATE TABLE eca_to_location (
-  location_id integer references location(id) not null,
-  location_class integer not null references location_class(id),
-  credit_id integer not null references entity_credit_account(id) 
-	ON DELETE CASCADE,
-  PRIMARY KEY(location_id,credit_id));
-
-CREATE UNIQUE INDEX eca_to_location_billing_u ON eca_to_location(credit_id)
-	WHERE location_class = 1;
-
-COMMENT ON TABLE eca_to_location IS
-$$ This table is used for locations bound to contracts.  For generic contact
-addresses, use company_to_location instead $$;
-
 CREATE TABLE salutation (
  id serial unique,
  salutation text primary key);
@@ -290,23 +275,10 @@
 
 COMMENT ON TABLE company_to_contact IS $$ To keep track of the relationship between multiple contact methods and a single company $$;
   
-CREATE TABLE eca_to_contact (
-  credit_id integer not null references entity_credit_account(id) 
-	ON DELETE CASCADE,
-  contact_class_id integer references contact_class(id) not null,
-  contact text check(contact ~ '[[:alnum:]_]') not null,
-  description text,
-  PRIMARY KEY (credit_id, contact_class_id,  contact));  
-
-COMMENT ON TABLE eca_to_contact IS $$ To keep track of the relationship between multiple contact methods and a single vendor or customer account. For generic 
-contacts, use company_to_contact or person_to_contact instead.$$;
-  
 -- Begin rocking notes interface
--- Begin rocking notes interface
 CREATE TABLE note_class(id serial primary key, class text not null check (class ~ '[[:alnum:]_]'));
 INSERT INTO note_class(id,class) VALUES (1,'Entity');
 INSERT INTO note_class(id,class) VALUES (2,'Invoice');
-INSERT INTO note_class(id,class) VALUES (3,'Entity Credit Account');
 CREATE UNIQUE INDEX note_class_idx ON note_class(lower(class));
 
 CREATE TABLE note (id serial primary key, note_class integer not null references note_class(id), 
@@ -325,13 +297,6 @@
 CREATE UNIQUE INDEX invoice_note_class_idx ON note_class(lower(class));
 CREATE INDEX invoice_note_vectors_idx ON invoice_note USING gist(vector);
 
-CREATE TABLE eca_note() 
-	INHERITS (note);
-ALTER TABLE eca_note ADD CHECK (note_class = 3);
-ALTER TABLE eca_note ADD FOREIGN KEY (ref_key) 
-	REFERENCES entity_credit_account(id) 
-	ON DELETE CASCADE;
-
 -- END entity   
 
 --
@@ -2542,7 +2507,7 @@
 198	module	vouchers.pl	553
 199	module	vouchers.pl	559
 199	action	create_batch	560
-199	batch_type	ap	561
+199	batch_type	payable	561
 201	module	vouchers.pl	562
 201	action	create_batch	563
 203	module	vouchers.pl	565

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2008-08-12 16:37:02 UTC (rev 2250)
+++ trunk/sql/modules/Payment.sql	2008-08-12 16:39:00 UTC (rev 2251)
@@ -187,12 +187,7 @@
 	FOR payment_item IN
 		  SELECT c.id AS contact_id, e.name AS contact_name,
 		         c.meta_number AS account_number,
-		              sum (coalesce(p.due, 0) -
-		              CASE WHEN c.discount_terms 
-		                        > extract('days' FROM age(a.transdate))
-		                   THEN 0
-		                   ELSE (coalesce(p.due, 0)) * coalesce(c.discount, 0) / 100
-		              END) AS total_due,
+		         sum(p.due) AS total_due, 
 		         compound_array(ARRAY[[
 		              a.id::text, a.invnumber, a.transdate::text, 
 		              a.amount::text, (a.amount - p.due)::text,


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.