[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2504] trunk
- Subject: SF.net SVN: ledger-smb:[2504] trunk
- From: ..hidden..
- Date: Mon, 16 Mar 2009 20:22:38 +0000
Revision: 2504
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2504&view=rev
Author: einhverfr
Date: 2009-03-16 20:22:38 +0000 (Mon, 16 Mar 2009)
Log Message:
-----------
Some of David Mora's payment enhancements (single payment interface only, not batch payment interface), Sadash's fixes for shipto info
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Payment.pm
trunk/LedgerSMB/Setting.pm
trunk/UI/Contact/contact.html
trunk/bin/admin.pl
trunk/bin/arap.pl
trunk/bin/io.pl
trunk/bin/ir.pl
trunk/bin/is.pl
trunk/bin/oe.pl
trunk/scripts/payment.pl
trunk/sql/modules/chart.sql
Modified: trunk/LedgerSMB/DBObject/Payment.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Payment.pm 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/LedgerSMB/DBObject/Payment.pm 2009-03-16 20:22:38 UTC (rev 2504)
@@ -125,7 +125,6 @@
@{$self->{entity_accounts}} =
$self->exec_method(funcname => 'payment_get_entity_accounts');
return @{$self->{entity_accounts}};
-
}
@@ -333,8 +332,10 @@
return @{$self->{openCurrencies}};
}
+
=over
+
=item list_accounting
This method lists all accounts that match the role specified in account_class property and
@@ -599,4 +600,32 @@
@{$self->{line_info}} = $self->exec_method(funcname => 'payment_gather_line_info');
}
+
+=item get_open_overpayment_entities
+
+This method retrieves all the entities with the specified
+account_class which have unused overpayments
+
+=cut
+
+sub get_open_overpayment_entities {
+my ($self) = @_;
..hidden..>{open_overpayment_entities}} = $self->exec_method(funcname => 'payment_get_open_overpayment_entities');
+return @{$self->{open_overpayment_entities}};
+}
+
+sub get_unused_overpayments {
+my ($self) = @_;
..hidden..>{unused_overpayment}} = $self->exec_method(funcname => 'payment_get_unused_overpayment');
+return @{$self->{unused_overpayment}};
+}
+
+sub get_availible_overpayment_amount {
+my ($self) = @_;
..hidden..>{availible_overpayment_amount}} = $self->exec_method(funcname => 'payment_get_availible_overpayment_amount');
+return @{$self->{availible_overpayment_amount}};
+}
+
+
+
1;
Modified: trunk/LedgerSMB/Setting.pm
===================================================================
--- trunk/LedgerSMB/Setting.pm 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/LedgerSMB/Setting.pm 2009-03-16 20:22:38 UTC (rev 2504)
@@ -159,3 +159,10 @@
$var;
}
+sub get_currencies {
+ my $self = shift;
+ $self->{settig__get_currencies} = $self->exec_method(funcname => 'setting__get_currencies');
+ # @{$self->{currencies}} = $self->_parse_array($ref->{setting__get_currencies});
+ return @{$self->{currencies}};
+}
+
Modified: trunk/UI/Contact/contact.html
===================================================================
--- trunk/UI/Contact/contact.html 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/UI/Contact/contact.html 2009-03-16 20:22:38 UTC (rev 2504)
@@ -418,6 +418,15 @@
value_attr = "id"
} ?>
</td>
+ <td> <?lsmb INCLUDE select element_data = {
+ name = "discount_account_id"
+ default_values = [discount_account_id]
+ options = discount_acc_list
+ label = text('Discount')
+ text_attr = "text"
+ value_attr = "id"
+ } ?>
+ </td>
</tr>
<tr id="business-threshold-row">
<td> <?lsmb INCLUDE select element_data = {
Modified: trunk/bin/admin.pl
===================================================================
--- trunk/bin/admin.pl 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/bin/admin.pl 2009-03-16 20:22:38 UTC (rev 2504)
@@ -77,8 +77,6 @@
. $locale->text('No Database Drivers available!') )
unless ( LedgerSMB::User->dbdrivers );
- $root = LedgerSMB::User->new('admin');
-
&adminlogin;
}
@@ -201,7 +199,7 @@
qq|<button type="submit" class="submit" name="action" value="delete">|
. $locale->text('Delete')
. qq|</button>
- <input type="hidden" name="edit" value="1" />|;
+ <input type="hidden" name="edit" value="1" />|;
}
print qq|
@@ -220,6 +218,7 @@
sub list_users {
# use the central database handle
+
my $dbh = ${LedgerSMB::Sysconfig::GLOBALDBH};
my $fetchMembers = $dbh->selectall_arrayref(
Modified: trunk/bin/arap.pl
===================================================================
--- trunk/bin/arap.pl 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/bin/arap.pl 2009-03-16 20:22:38 UTC (rev 2504)
@@ -1036,10 +1036,16 @@
}
-sub continue { &{ $form->{nextsub} } }
+
+
+sub continue {&{ $form->{nextsub} }; }
+sub continuenew {$form->{rowcount}--; &setlocation_id; &{ $form->{nextsub} }; }
+sub updatenew {&createlocations;}
sub gl_transaction { &add }
sub ar_transaction { &add_transaction(ar) }
sub ap_transaction { &add_transaction(ap) }
sub sales_invoice_ { &add_transaction(is) }
sub vendor_invoice_ { &add_transaction(ir) }
+
+
Modified: trunk/bin/io.pl
===================================================================
--- trunk/bin/io.pl 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/bin/io.pl 2009-03-16 20:22:38 UTC (rev 2504)
@@ -39,7 +39,6 @@
#######################################################################
use Error qw(:try);
-
use LedgerSMB::Tax;
use LedgerSMB::Template;
use LedgerSMB::Sysconfig;
@@ -786,12 +785,15 @@
# if we have a display_form
if ( $form->{display_form} ) {
- &{"$form->{display_form}"};
+
+ &{"$form->{display_form}"};
exit;
}
+
+
&form_header;
-
+
$numrows = ++$form->{rowcount};
$subroutine = "display_row";
@@ -824,12 +826,19 @@
}
# create rows
+
&{$subroutine}($numrows) if $numrows;
+ $form->hide_form(qw|locationid|);
+
&form_footer;
}
+
+
+
+
sub check_form {
my @a = ();
@@ -1814,8 +1823,11 @@
}
+
+
sub ship_to {
+
$title = $form->{title};
$form->{title} = $locale->text('Ship to');
@@ -1827,10 +1839,12 @@
$form->parse_amount( \%myconfig, $form->{"paid_$_"} );
}
- # get details for name
- &{"$form->{vc}_details"};
+
+ &{"$form->{vc}_details"};
- $number =
+ &list_locations_contacts();
+
+ $number =
( $form->{vc} eq 'customer' )
? $locale->text('Customer Number')
: $locale->text('Vendor Number');
@@ -1838,120 +1852,381 @@
$nextsub =
( $form->{display_form} ) ? $form->{display_form} : "display_form";
- $form->{rowcount}--;
+
$form->header;
+
print qq|
-<body>
+ <body>
-<form method=post action=$form->{script}>
+<form name="form" method=post action=$form->{script}>
-<table width=100%>
- <tr>
- <td>
- <table>
- <tr class=listheading>
- <th class=listheading colspan=2 width=50%>|
- . $locale->text('Billing Address')
- . qq|</th>
- <th class=listheading width=50%>|
- . $locale->text('Shipping Address')
- . qq|</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <th align=right nowrap>$number</th>
- <td>$form->{"$form->{vc}number"}</td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
- <td>$form->{name}</td>
- <td><input name=shiptoname size=35 maxlength=64 value="$form->{shiptoname}"></td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('Address') . qq|</th>
- <td>$form->{address1}</td>
- <td><input name=shiptoaddress1 size=35 maxlength=32 value="$form->{shiptoaddress1}"></td>
- </tr>
- <tr>
- <th></th>
- <td>$form->{address2}</td>
- <td><input name=shiptoaddress2 size=35 maxlength=32 value="$form->{shiptoaddress2}"></td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('City') . qq|</th>
- <td>$form->{city}</td>
- <td><input name=shiptocity size=35 maxlength=32 value="$form->{shiptocity}"></td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('State/Province') . qq|</th>
- <td>$form->{state}</td>
- <td><input name=shiptostate size=35 maxlength=32 value="$form->{shiptostate}"></td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('Zip/Postal Code') . qq|</th>
- <td>$form->{zipcode}</td>
- <td><input name=shiptozipcode size=10 maxlength=10 value="$form->{shiptozipcode}"></td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('Country') . qq|</th>
- <td>$form->{country}</td>
- <td><input name=shiptocountry size=35 maxlength=32 value="$form->{shiptocountry}"></td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
- <td>$form->{contact}</td>
- <td><input name=shiptocontact size=35 maxlength=64 value="$form->{shiptocontact}"></td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
- <td>$form->{"$form->{vc}phone"}</td>
- <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
- <td>$form->{"$form->{vc}fax"}</td>
- <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
- <td>$form->{email}</td>
- <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
- </tr>
- </table>
- </td>
- </tr>
+<table width=100% cellspacing="0" cellpadding="0" border="0">
+ <tr>
+ <td>
+ <table>
+ <tr >
+ <th >
+ $form->{vc} Number:<td>$form->{"$form->{vc}number"}</td>
+ </th>
+ <th> </th>
+ <th>
+ $form->{vc} Name:<td>$form->{name}</td>
+ </th>
+ </tr>
+ </table>
+
+
+ <table cellspacing="0" cellpadding="0" border="0">
+ <tr>
+ <td valign="top">
+ <table width=70% >
+
+ <tr class=listheading> |
+ . qq|<th class=listheading width=1% >
+ |
+ . $locale->text(' ')
+ . qq|</th>
+ <th class=listheading width=5%>|
+ . $locale->text('Add line1')
+ . qq|</th>
+ <th class=listheading width=5%>|
+ . $locale->text('Add line2')
+ . qq|</th>
+ <th class=listheading width=1% >
+ |
+ . $locale->text('Add line3 ')
+ . qq|</th>
+ <th class=listheading width=5%>|
+ . $locale->text('city')
+ . qq|</th>
+ <th class=listheading width=5%>|
+ . $locale->text('State')
+ . qq|</th>
+ <th class=listheading width=5%>|
+ . $locale->text('Zip Code')
+ . qq|</th>
+ <th class=listheading width=5%>|
+ . $locale->text('Country')
+ . qq|
+ </tr>
+ |;
+
+ my $i;
+
+ for($i=1;$i<=$form->{totallocations};$i++)
+ {
+
+ print qq|
+ <tr>
+
+ <td><input type=radio name=shiptoradio value="$i" ondblclick="return uncheckRadio(this);"></td>
+ <input name=shiptolocationid_$i type="hidden" value="$form->{"shiptolocationid_$i"}" readonly>
+ <td><input name=shiptoaddress1_$i size=12 maxlength=64 id="ad1_$i" value="$form->{"shiptoaddress1_$i"}" readonly></td>
+ <td><input name=shiptoaddress2_$i size=12 maxlength=64 id="ad2_$i" value="$form->{"shiptoaddress2_$i"}" readonly></td>
+ <td><input name=shiptoaddress3_$i size=12 maxlength=64 id="ad2_$i" value="$form->{"shiptoaddress3_$i"}" readonly></td>
+ <td><input name=shiptocity_$i size=8 maxlength=32 id="ci_$i" value="$form->{"shiptocity_$i"}" readonly></td>
+ <td><input name=shiptostate_$i size=10 maxlength=32 id="st_$i" value="$form->{"shiptostate_$i"}" readonly></td>
+ <td><input name=shiptozipcode_$i size=8 maxlength=10 id="zi_$i" value="$form->{"shiptozipcode_$i"}" readonly></td>
+ <td><input name=shiptocountry_$i size=5 maxlength=32 id="co_$i" value="$form->{"shiptocountry_$i"}" readonly></td>
+
+ <tr>
+
+ |;
+
+ }
+ my $deletelocations=$i;
+
+
+ print qq|<input type=hidden name=nextsub value=$nextsub>|;
+
+ # delete shipto
+ for (qw(action nextsub)) { delete $form->{$_} }
+
+ $form->{title} = $title;
+
+
+ print qq|
+
+ </table>
+
+ </td>
+ <td background="new_images/line.gif"><IMG SRC="new_images/line.gif" WIDTH="2px"/> </td>
+ <td valign="top" >
+ <table width=30%>
+ <tr class=listheading>
+ <th> </th>
+ <th class=listheading width="20%">|
+ . $locale->text('Type')
+ . qq|</th>
+ <th class=listheading width="35%">|
+ . $locale->text('Contact')
+ . qq|</th>
+ <th class="listheading" width="35%">|
+ . $locale->text('Description')
+ . qq|</th>
+ </tr>
+ <tr></tr>
+ |;
+
+ for($i=1;$i<=$form->{totalcontacts};$i++)
+ {
+ print qq|
+ <tr>
+ <td> </td>
+ <td><input name=shiptotype_$i size=5 maxlength=100 value="$form->{"shiptotype_$i"}" readonly></td>
+ <td><input name=shiptocontact_$i size=11 maxlength=100 value="$form->{"shiptocontact_$i"}" readonly></td>
+ <td><input name=shiptodescription_$i size=12 maxlength=100 value="$form->{"shiptodescription_$i"}" readonly></td>
+ </tr> |;
+
+ }
+ my $deletecontacts=$i;
+
+ print qq|
+ </table>
+ </td>
+ </tr>
+
+ </table>
+ |;
+
+ my $country=&construct_countrys_types("country");
+
+ my $contacttype=&construct_countrys_types("type");
+
+
+ for(my $k=1;$k<$deletecontacts;$k++)
+ {
+ for (qq| type_$k contact_$k description_$k |)
+ {
+ delete $form->{"shipto$_"};
+ }
+
+ }
+
+ delete $form->{shiptoradiocontact};
+ delete $form->{shiptoradio};
+
+ for (qq| address1_new address2_new address3_new city_new state_new zipcode_new country_new type_new contact_new description_new|)
+ {
+ delete $form->{"shipto$_"};
+ }
+
+
+
+ for(my $k=1;$k<$deletelocations;$k++)
+ {
+ for (qq| locationid_$k address1_$k address2_$k address3_$k city_$k state_$k zipcode_$k country_$k|)
+ {
+ delete $form->{"shipto$_"};
+ }
+
+ }
+
+ $form->hide_form;
+ print qq|
+
+ <hr valign="type" size=1 noshade >
+
+ <table valign="top">
+ <tr>
+ Others
+ </tr>
+ </tr>
+ <td><input type=radio name=shiptoradio value="new" ondblclick="return uncheckRadio(this);"></td>
+ <td><input name=shiptoaddress1_new size=12 maxlength=64 value="$form->{shiptoaddress1_new}" ></td>
+ <td><input name=shiptoaddress2_new size=12 maxlength=64 value="$form->{shiptoaddress2_new}" ></td>
+ <td><input name=shiptoaddress3_new size=12 maxlength=64 value="$form->{shiptoaddress3_new}" ></td>
+ <td><input name=shiptocity_new size=8 maxlength=32 value="$form->{shiptocity_new}" ></td>
+ <td><input name=shiptostate_new size=10 maxlength=32 value="$form->{shiptostate_new}" ></td>
+ <td><input name=shiptozipcode_new size=8 maxlength=10 value="$form->{shiptozipcode_new}" ></td>
+ <td><select name="shiptocountry_new">$country</select></td>
+
+ <td background="new_images/line.gif"><IMG SRC="new_images/line.gif" WIDTH="0px"/></td>
+ <td><input type=radio name=shiptoradiocontact value="1" ondblclick="uncheckRadiocontact(this);" ></td>
+ <td><select name="shiptotype_new">$contacttype</select></td>
+ <td><input name=shiptocontact_new size=10 maxlength=100 value="$form->{shiptocontact_new}" ></td>
+ <td><input name=shiptodescription_new size=10 maxlength=100 value="$form->{shiptodescription_new}" ></td>
+
+ </tr>
+
+
+ </table>
+ </td>
+ </tr>
+
</table>
-<input type=hidden name=nextsub value=$nextsub>
+<br>
+
|;
- # delete shipto
- for (qw(action nextsub)) { delete $form->{$_} }
- for (
- qw(name address1 address2 city state zipcode country contact phone fax email)
- )
- {
- delete $form->{"shipto$_"};
- }
- $form->{title} = $title;
- $form->hide_form;
+
+print qq|
- print qq|
+<button class="submit" type="submit" name="action" value="continuenew">|
+. $locale->text('Continue')
+. qq|
+</button>
+<button class="submit" type="submit" name="action" value="updatenew">|
+. $locale->text('Update')
+. qq|
+</button>
-<hr size=3 noshade>
-
-<br>
-<button class="submit" type="submit" name="action" value="continue">|
- . $locale->text('Continue')
- . qq|</button>
</form>
</body>
+
</html>
|;
}
+
+
+=pod
+
+Author...Sadashiva
+
+The list of functions would create the new location / uses existing locations , and sets the $form->{locationid}.
+
+list_locations_contacts() would extracts all locations and sets into form parameter...
+
+$form->{id} used to extract all locations and contacts(eca_to_location and eca_to_contact) and location
+
+construct_countrys_types return the drop down list of the country/contact_class ; value= country_id/contract_class_id and display text= country name/contract class
+
+createlocations called by update action... calling eca__location_save and eca__save_contact
+
+setlocation_id called by continue action... just setting $form->{locationid} this is the final location id which is returned by shipto service
+
+
+
+=cut
+
+
+
+sub list_locations_contacts
+{
+
+
+ IS->list_locations_contacts( \%myconfig, \%$form );
+
+
+}
+
+
+
+sub construct_countrys_types
+{
+
+ my $retvalue="";
+
+ if($_[0] eq "country")
+ {
+
+ $retvalue=IS->construct_countrys(\%$form);
+
+ }
+ elsif($_[0] eq "type")
+ {
+
+ $retvalue=IS->construct_types(\%$form);
+
+ }
+ return($retvalue);
+
+}
+
+
+
+
+
+sub createlocations
+{
+
+ my $loc_id_index=$form->{"shiptoradio"};
+
+ my $index="locationid_".$loc_id_index;
+
+ my $loc_id=$form->{$index};
+
+
+ if($form->{shiptoradio} eq "new")
+ {
+
+ # required to create the new locations
+
+ &validatelocation;
+
+ IS->createlocation($form);
+
+
+ }
+
+ if($form->{shiptoradiocontact}==1)
+ {
+ &validatecontact;
+ IS->createcontact($form);
+
+
+ }
+
+ &ship_to;
+
+
+
+}
+
+
+sub validatelocation
+{
+
+ my @Newlocation=("shiptoaddress1_new","shiptoaddress2_new","shiptoaddress3_new","shiptocity_new","shiptostate_new","shiptozipcode_new","shiptocountry_new");
+ foreach(@Newlocation)
+ {
+ $form->error( " Don not keep field empty $_") unless($form->{"$_"});
+ }
+
+
+}
+
+
+sub validatecontact
+{
+
+ my @Newcontact=("shiptotype_new","shiptodescription_new","shiptocontact_new");
+ foreach(@Newcontact)
+ {
+ $form->error( " Don not keep field empty $_") unless($form->{"$_"});
+ }
+
+
+}
+
+
+
+sub setlocation_id
+{
+
+ if(!$form->{"shiptoradio"})
+ {
+ $form->error("Please select the location");
+ }
+ if($form->{"shiptoradio"} eq "new")
+ {
+ $form->error("Please dont select from others");
+ }
+
+
+
+ my $loc_id_index=$form->{"shiptoradio"};
+
+ my $index="locationid_".$loc_id_index;
+
+ $form->{"locationid"}=$form->{$index};
+
+
+}
Modified: trunk/bin/ir.pl
===================================================================
--- trunk/bin/ir.pl 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/bin/ir.pl 2009-03-16 20:22:38 UTC (rev 2504)
@@ -274,6 +274,7 @@
sub form_header {
+
# set option selected
for (qw(AP currency)) {
$form->{"select$_"} =~ s/ selected//;
@@ -1142,3 +1143,9 @@
&edit(); # it was already IN edit for this to be reached.
}
}
+
+
+sub
+
+
+
Modified: trunk/bin/is.pl
===================================================================
--- trunk/bin/is.pl 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/bin/is.pl 2009-03-16 20:22:38 UTC (rev 2504)
@@ -847,7 +847,8 @@
$form->{terms} * 1 )
: $form->{duedate};
$form->{oldtransdate} = $form->{transdate};
- &rebuild_vc( customer, AR, $form->{transdate}, 1 ) if !$newname;
+
+ &rebuild_vc( customer, AR, $form->{transdate}, 1 ) if !$newname;
if ( $form->{currency} ne $form->{defaultcurrency} ) {
delete $form->{exchangerate};
@@ -855,7 +856,7 @@
if (
$form->{forex} = (
$exchangerate = $form->check_exchangerate(
- \%myconfig, $form->{currency},
+ \%myconfig,$form->{currency},
$form->{transdate}, 'buy'
)
)
Modified: trunk/bin/oe.pl
===================================================================
--- trunk/bin/oe.pl 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/bin/oe.pl 2009-03-16 20:22:38 UTC (rev 2504)
@@ -236,8 +236,8 @@
if ( $form->{id} ) {
- for (
- qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptoaddress1 shiptoaddress2 shiptocity shiptostate shiptozipcode shiptocountry shiptocontact)
+ for(
+ qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptoaddress1 shiptoaddress2 shiptocity shiptostate shiptozipcode shiptocountry shiptocontact)
)
{
$form->{$_} = $form->quote( $form->{$_} );
@@ -349,6 +349,8 @@
sub form_header {
+
+
$checkedopen = ( $form->{closed} ) ? "" : "checked";
$checkedclosed = ( $form->{closed} ) ? "checked" : "";
@@ -2110,6 +2112,7 @@
sub save {
+
if ( $form->{type} =~ /_order$/ ) {
$msg = $locale->text('Order Date missing!');
}
@@ -2120,9 +2123,11 @@
$form->isblank( "transdate", $msg );
$msg = ucfirst $form->{vc};
+
$form->isblank( $form->{vc}, $locale->text( $msg . " missing!" ) );
# $locale->text('Customer missing!');
+
# $locale->text('Vendor missing!');
$form->isblank( "exchangerate", $locale->text('Exchange rate missing!') )
@@ -2130,6 +2135,7 @@
&validate_items;
+
# if the name changed get new values
if ( &check_name( $form->{vc} ) ) {
&update;
@@ -2179,6 +2185,8 @@
}
}
+
+
if ( OE->save( \%myconfig, \%$form ) ) {
$form->redirect( $locale->text('Order saved!') );
}
Modified: trunk/scripts/payment.pl
===================================================================
--- trunk/scripts/payment.pl 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/scripts/payment.pl 2009-03-16 20:22:38 UTC (rev 2504)
@@ -1138,5 +1138,130 @@
&print_payment($Payment);
}
+
+=pod
+
+=item use_overpayment
+
+This item will do the trick to use the overpayment information stored inside the payments,
+it should be powerful enough to link overpayment from one customer to other customers.
+
+=back
+
+=cut
+
+sub use_overpayment {
+my ($request) = @_;
+my $locale = $request->{_locale};
+my $Payment = LedgerSMB::DBObject::Payment->new({'base' => $request});
+my @entities;
+
+#We will use $ui to handle all the data needed by the User Interface
+my $ui = { stylesheet => $request->{_user}->{stylesheet}};
+$ui->{accountclass} = {name => 'account_class', value => $request->{account_class}};
+#We want to get all the customer/vendor with unused overpayment
+my @data = $Payment->get_open_overpayment_entities();
+for my $ref (0 .. $#data) {
+ push @entities, { value => $data[$ref]->{id},
+ name => $data[$ref]->{name}};
+ }
+$ui->{entities} = ..hidden..;
+$ui->{action} = {name => 'action', value => 'use_overpayment2', text => $locale->text('Continue')};
+my $template = LedgerSMB::Template->new(
+ user => $request->{_user},
+ locale => $request->{_locale},
+ path => 'UI/payments',
+ template => 'use_overpayment1',
+ format => 'HTML' );
+eval {$template->render($ui) };
+if ($@) { $request->error("$@"); } # PRINT ERRORS ON THE UI
+}
+
+
+=pod
+
+=item use_overpayment2
+
+This sub runs to allow the user to specify the invoices in which an overpayment should be used
+
+=back
+
+=cut
+
+
+sub use_overpayment2 {
+my ($request) = @_;
+my $locale = $request->{_locale};
+my $Payment = LedgerSMB::DBObject::Payment->new({'base' => $request});
+my @array_options;
+my @vc_options;
+my @overpayments;
+my $exchangerate;
+my @selected_checkboxes;
+my $availible_subtotal = 0;
+my $touse_subtotal = 0;
+my @hiddens;
+
+
+# First we need to insert some hidden information
+
+push @hiddens, { id => 'entity_credit_id',
+ name => 'entity_credit_id',
+ type => 'hidden',
+ value => $request->{entity_credit_id}};
+push @hiddens, { id => 'account_class',
+ name => 'account_class',
+ type => 'hidden',
+ value => $request->{account_class} };
+push @hiddens, { id => 'login',
+ name => 'login',
+ type => 'hidden',
+ value => $request->{login} };
+
+
+# need to get all the availible overpayments
..hidden.. = $Payment->get_availible_overpayment_amount();
+for my $ref (0 .. $#array_options) {
+ push @overpayments, { id => $array_options[$ref]->{payment_id},
+ accno => $array_options[$ref]->{accno},
+ description => $array_options[$ref]->{description},
+ amount => "$array_options[$ref]->{movements}",
+ availible => "$array_options[$ref]->{availible}",
+ touse => $array_options[$ref]->{'ovp_'."$array_options[$ref]->{payment_id}"}
+ };
+ $availible_subtotal += "$array_options[$ref]->{availible}";
+ $touse_subtotal += $array_options[$ref]->{'ovp_'."$array_options[$ref]->{payment_id}"};
+}
+
+
+# We start with our data selection called ui
+
+my $ui = { overpayments => ..hidden..,
+ availible_subtotal => $availible_subtotal,
+ touse_subtotal => $touse_subtotal,
+ stylesheet => $request->{_user}->{stylesheet},
+ header => { text => $locale->text('Use overpayment/prepayment')},
+ };
+
+
+# Lastly we include the hiddens on the UI
+
+$ui->{hiddens} = ..hidden..;
+
+my $template = LedgerSMB::Template->new(
+ user => $request->{_user},
+ locale => $request->{_locale},
+ path => 'UI/payments',
+ template => 'use_overpayment2',
+ format => 'HTML' );
+eval {$template->render($ui) };
+if ($@) { $request->error("$@"); } # PRINT ERRORS ON THE UI
+
+}# End SUB
+
+
+
+
+
eval { do "scripts/custom/payment.pl"};
1;
Modified: trunk/sql/modules/chart.sql
===================================================================
--- trunk/sql/modules/chart.sql 2009-03-16 20:14:13 UTC (rev 2503)
+++ trunk/sql/modules/chart.sql 2009-03-16 20:22:38 UTC (rev 2504)
@@ -84,3 +84,28 @@
COMMENT ON FUNCTION chart_list_cash(in_account_class int) IS
$$ This function returns the overpayment accounts acording with in_account_class which must be 1 or 2 $$;
+
+CREATE OR REPLACE FUNCTION chart_list_discount(in_account_class int)
+RETURNS SETOF chart AS
+$$
+DECLARE resultrow record;
+ link_string text;
+BEGIN
+ IF in_account_class = 1 THEN
+ link_string := '%AP_discount%';
+ ELSE
+ link_string := '%AR_discount%';
+ END IF;
+
+ FOR resultrow IN
+ SELECT * FROM chart
+ WHERE link LIKE link_string
+ ORDER BY accno
+ LOOP
+ return next resultrow;
+ END LOOP;
+END;
+$$ language plpgsql;
+
+COMMENT ON FUNCTION chart_list_discount(in_account_class int) IS
+$$ This function returns the discount accounts acording with in_account_class which must be 1 or 2 $$;
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.