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

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



Revision: 2601
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2601&view=rev
Author:   einhverfr
Date:     2009-05-14 04:09:53 +0000 (Thu, 14 May 2009)

Log Message:
-----------
Tax form (1099 or equiv) now added doable by customer

Modified Paths:
--------------
    trunk/LedgerSMB/Batch.pm
    trunk/LedgerSMB/DBObject/Company.pm
    trunk/LedgerSMB/DBObject/Customer.pm
    trunk/LedgerSMB/Setting.pm
    trunk/LedgerSMB/User.pm
    trunk/UI/Contact/contact.html
    trunk/bin/am.pl
    trunk/bin/arap.pl
    trunk/common.pl
    trunk/sql/modules/Company.sql

Modified: trunk/LedgerSMB/Batch.pm
===================================================================
--- trunk/LedgerSMB/Batch.pm	2009-05-13 18:01:27 UTC (rev 2600)
+++ trunk/LedgerSMB/Batch.pm	2009-05-14 04:09:53 UTC (rev 2601)
@@ -70,7 +70,7 @@
 sub get_class_id {
     my ($self, $type) = @_;
     @results = $self->call_procedure(
-                                    procname => 'batch_get_class_id', 
+                                     procname => 'batch_get_class_id', 
                                      args     => [$type]
     );
     my $result = pop @results;

Modified: trunk/LedgerSMB/DBObject/Company.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Company.pm	2009-05-13 18:01:27 UTC (rev 2600)
+++ trunk/LedgerSMB/DBObject/Company.pm	2009-05-14 04:09:53 UTC (rev 2601)
@@ -69,11 +69,15 @@
 =cut
 
 sub save_credit {
+
     my $self = shift @_;
     $self->set_entity_class();
     $self->{threshold} = $self->parse_amount(amount => $self->{threshold});
     my ($ref) = $self->exec_method(funcname => 'entity_credit_save');
     $self->{credit_id} = (values %$ref)[0];
+    my $dbh=$self->{dbh};
+    $dbh->do("update entity_credit_account set country_taxform_id=$self->{taxform1_id} where id=$self->{credit_id}") if($self->{taxform1_id});
+    $dbh->commit();
     $self->{threshold} = $self->format_amount(amount => $self->{threshold});
     $self->{dbh}->commit;
 }
@@ -216,6 +220,17 @@
     my $self = shift @_;
 
     $self->set_entity_class();
+
+    if($self->{entity_id})
+    {
+	@{$self->{taxform_list}} = $self->exec_method(funcname => 'list_taxforms');
+
+	foreach my $ref1(@{$self->{taxform_list}})
+	{
+		print STDERR qq| ______ return value $ref1->{id} and $ref1->{country_id},$ref1->{form_name} ________|;	
+	}
+    }
+
     my ($ref) = $self->exec_method(funcname => 'company_retrieve');
     $self->merge($ref);
     $self->{threshold} = $self->format_amount(amount => $self->{threshold});
@@ -224,8 +239,7 @@
          $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}) 
+	if (($_->{credit_id} eq $self->{credit_id}) 
                    or ($_->{meta_number} eq $self->{meta_number})
                    or ($_->{id} eq $self->{credit_id})){
 		$self->merge($_);

Modified: trunk/LedgerSMB/DBObject/Customer.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Customer.pm	2009-05-13 18:01:27 UTC (rev 2600)
+++ trunk/LedgerSMB/DBObject/Customer.pm	2009-05-14 04:09:53 UTC (rev 2601)
@@ -6,8 +6,10 @@
 my $ENTITY_CLASS = 2;
 
 sub set_entity_class {
+    
     my $self = shift @_;
     $self->{entity_class} = $ENTITY_CLASS;
+
 }
     
 1;

Modified: trunk/LedgerSMB/Setting.pm
===================================================================
--- trunk/LedgerSMB/Setting.pm	2009-05-13 18:01:27 UTC (rev 2600)
+++ trunk/LedgerSMB/Setting.pm	2009-05-14 04:09:53 UTC (rev 2601)
@@ -100,7 +100,7 @@
 
             if ( $param =~
 /<\?lsmb (name|business|description|item|partsgroup|phone|custom)/i
-              )
+               )
             {
 
                 my $fld = lc $&;

Modified: trunk/LedgerSMB/User.pm
===================================================================
--- trunk/LedgerSMB/User.pm	2009-05-13 18:01:27 UTC (rev 2600)
+++ trunk/LedgerSMB/User.pm	2009-05-14 04:09:53 UTC (rev 2601)
@@ -112,6 +112,8 @@
           . ';port='
           . $self->{dbport};
 
+	
+
         if ( $self->{username} ) {
             $self->{login} = $login;
         }

Modified: trunk/UI/Contact/contact.html
===================================================================
--- trunk/UI/Contact/contact.html	2009-05-13 18:01:27 UTC (rev 2600)
+++ trunk/UI/Contact/contact.html	2009-05-14 04:09:53 UTC (rev 2601)
@@ -219,7 +219,17 @@
 		name = "name"
 		value = name
 		size = "20"
-	} ?><br/>
+	} ?>
+
+       <?lsmb IF !country_id_t; country_id_t = default_country_t; END -?>
+		<?lsmb INCLUDE select element_data = {
+			text_attr = "name"
+			value_attr = "id"
+			default_values = [country_id_t]
+			options = country_list
+			name = "country_id_t"
+			label = text('Country:') 
+	} ?> <br/>
         <table>
         <tr>
             
@@ -445,6 +455,21 @@
 			class = "numeric"
                } ?>
 	</tr>
+
+	<tr id="taxform-threshold-row">
+	
+	 <td> <?lsmb INCLUDE select element_data = {
+			name = "taxform1_id"
+			options = taxform_list
+			default_values = [ ]
+			text_attr = "form_name"
+			value_attr = "id"
+			label = text('Taxforms:') #'
+			} ?> 
+	  </td>
+
+        </tr>
+
         </table>
 		<?lsmb IF credit_id;
 		INCLUDE button element_data = {

Modified: trunk/bin/am.pl
===================================================================
--- trunk/bin/am.pl	2009-05-13 18:01:27 UTC (rev 2600)
+++ trunk/bin/am.pl	2009-05-14 04:09:53 UTC (rev 2601)
@@ -1095,6 +1095,7 @@
 
 }
 
+
 sub edit_language {
 
     $form->{title} = "Edit";
@@ -2877,5 +2878,36 @@
 
 }
 
+
+
+sub add_taxform {
+
+    $form->{title} = "Add";
+
+    $form->{callback} =
+"$form->{script}?action=add_taxform&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
+      unless $form->{callback};
+
+    $form->info("Add Country Tax forms is Under Construction");
+
+}
+
+
+sub search_taxform {
+
+    $form->{title} = "Edit";
+
+    $form->{callback} =
+"$form->{script}?action=search_taxform&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
+      unless $form->{callback};
+
+    $form->info("Search Country Tax forms is Under Construction");
+
+}
+
+
+
+
+
 sub continue { &{ $form->{nextsub} } }
 

Modified: trunk/bin/arap.pl
===================================================================
--- trunk/bin/arap.pl	2009-05-13 18:01:27 UTC (rev 2600)
+++ trunk/bin/arap.pl	2009-05-14 04:09:53 UTC (rev 2601)
@@ -54,7 +54,7 @@
 
 sub check_name {
     my ($name) = @_;
-
+    
     my ( $new_name, $new_id ) = split /--/, $form->{$name};
     my $rv = 0;
 

Modified: trunk/common.pl
===================================================================
--- trunk/common.pl	2009-05-13 18:01:27 UTC (rev 2600)
+++ trunk/common.pl	2009-05-14 04:09:53 UTC (rev 2601)
@@ -24,6 +24,7 @@
 
 sub redirect {
     use List::Util qw(first);
+
     my ( $script, $argv ) = split( /\?/, $form->{callback} );
 
     my @common_attrs = qw(
@@ -53,6 +54,7 @@
     for (@common_attrs) {
         $form->{$_} = $temphash{$_};
     }
+
     $form->{script} = $script;
 
     if ( !%myconfig ) {    # needed for login
@@ -63,7 +65,9 @@
     }
 
     require "bin/$script";
+
     &{ $form->{action} };
+
 }
 
 1;

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2009-05-13 18:01:27 UTC (rev 2600)
+++ trunk/sql/modules/Company.sql	2009-05-14 04:09:53 UTC (rev 2601)
@@ -245,6 +245,8 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+
+
 CREATE OR REPLACE FUNCTION company_retrieve (in_entity_id int) RETURNS company AS
 $$
 DECLARE t_company company;
@@ -254,6 +256,29 @@
 END;
 $$ language plpgsql;
 
+
+
+CREATE OR REPLACE FUNCTION list_taxforms (in_entity_id int) RETURNS SETOF country_tax_form AS
+$$
+DECLARE t_country_tax_form country_tax_form;
+BEGIN
+
+	FOR t_country_tax_form IN 
+
+		      SELECT country_id as count_id,form_name as taxform_name,id as taxform_id 
+		            FROM country_tax_form where country_id in(SELECT country_id from entity where id=in_entity_id)
+        LOOP
+
+	RETURN NEXT t_country_tax_form;
+	
+	END LOOP;
+
+END;
+$$ language plpgsql;
+
+
+
+
 CREATE TYPE company_billing_info AS (
 legal_name text,
 meta_number text,
@@ -292,7 +317,7 @@
 CREATE OR REPLACE FUNCTION company_save (
     in_id int, in_control_code text, in_entity_class int,
     in_name text, in_tax_id TEXT,
-    in_entity_id int, in_sic_code text
+    in_entity_id int, in_sic_code text,in_country_id_t int
 ) RETURNS INT AS $$
 DECLARE t_entity_id INT;
 	t_company_id INT;
@@ -308,7 +333,6 @@
 
 	IF in_entity_id IS NULL THEN
 		IF in_id IS NULL THEN
-			RAISE NOTICE 'in_id is null';
 			SELECT id INTO t_company_id FROM company
 			WHERE entity_id = (SELECT id FROM entity WHERE 
 				control_code = t_control_code);
@@ -322,17 +346,27 @@
 		t_entity_id := in_entity_id;
 	END IF;
 	IF t_entity_id IS NULL THEN
-		INSERT INTO entity (name, entity_class, control_code)
-		VALUES (in_name, in_entity_class, t_control_code);
+		INSERT INTO entity (name, entity_class, control_code,country_id)
+		VALUES (in_name, in_entity_class, t_control_code,in_country_id_t);
 		t_entity_id := currval('entity_id_seq');
+		END IF;
 	END IF;
 
+	UPDATE entity
+	SET name = in_name,
+            entity_class = in_entity_class,
+	    control_code = t_control_code,
+	    country_id = in_country_id_t
+	WHERE id = t_entity_id;
+
+
 	UPDATE company
 	SET legal_name = in_name,
 		tax_id = in_tax_id,
 		sic_code = in_sic_code
 	WHERE id = t_company_id;
 
+
 	IF NOT FOUND THEN
 		INSERT INTO company(entity_id, legal_name, tax_id, sic_code)
 		VALUES (t_entity_id, in_name, in_tax_id, in_sic_code);
@@ -351,9 +385,10 @@
     in_language varchar(6), in_pricegroup_id int, 
     in_curr char, in_startdate date, in_enddate date, 
     in_threshold NUMERIC,
-    in_ar_ap_account_id int, 
+    in_ar_ap_account_id int,
     in_cash_account_id int
     
+    
 ) returns INT as $$
     
     DECLARE
@@ -389,7 +424,7 @@
                 startdate = in_startdate,
                 enddate = in_enddate,
                 threshold = in_threshold,
-                discount_terms = in_discount_terms
+		discount_terms = in_discount_terms
             where id = in_credit_id;
         
          IF FOUND THEN
@@ -414,6 +449,7 @@
                 threshold,
 		ar_ap_account_id,
                 cash_account_id
+
             )
             VALUES (
                 in_entity_id,
@@ -433,7 +469,7 @@
                 in_discount_terms,
                 in_threshold,
                 in_ar_ap_account_id,
-                in_cash_account_id
+		in_cash_account_id
             );
             RETURN currval('entity_credit_account_id_seq');
        END IF;


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