@@ -, +, @@ --- C4/Acquisition.pm | 82 +++++++++++++ acqui/payment.pl | 84 +++++++++++++ acqui/payments.pl | 110 +++++++++++++++++ installer/data/mysql/kohastructure.sql | 13 ++ installer/data/mysql/updatedatabase.pl | 13 ++ .../prog/en/includes/acquisitions-toolbar.inc | 1 + .../prog/en/modules/acqui/booksellers.tt | 1 + .../intranet-tmpl/prog/en/modules/acqui/payment.tt | 105 ++++++++++++++++ .../prog/en/modules/acqui/payments.tt | 128 ++++++++++++++++++++ 9 files changed, 537 insertions(+), 0 deletions(-) create mode 100755 acqui/payment.pl create mode 100755 acqui/payments.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/payment.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/payments.tt --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -56,6 +56,9 @@ BEGIN { &SearchOrder &GetHistory &GetRecentAcqui &ModReceiveOrder &ModOrderBiblioitemNumber &GetCancelledOrders + &GetPayments + &GetPendingpayments + &AddPayments &NewOrderItem &ModOrderItem &ModItemOrder @@ -158,6 +161,85 @@ sub GetBasket { return ( $basket ); } + +=head3 GetPayments + + $aqpayment = &GetPayments($bookseller,$order, $code, $chequeno); + +get all payments informations in aqpayments for a given vendor + + +=cut + +sub GetPayments { + my ($bookseller,$code, $chequeno) = @_; + my $dbh = C4::Context->dbh; + my @query_params = (); + my $strsth =" + SELECT aqpayments.booksellerinvoicenumber, aqpayments.chequeno,aqpayments.chequedate, aqpayments.notes FROM aqpayments LEFT JOIN aqorders ON aqpayments.booksellerinvoicenumber = aqorders.booksellerinvoicenumber LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno WHERE aqbasket.booksellerid = ? + "; + push @query_params, $bookseller; + + if ( defined $code ) { + $strsth .= " AND aqpayments.booksellerinvoicenumber LIKE ? "; + push @query_params, "$code%"; + } + + if ( defined $chequeno ) { + $strsth .= " AND aqpayments.chequeno LIKE ? "; + push @query_params, "$chequeno%"; + } + + $strsth .= "GROUP BY aqpayments.booksellerinvoicenumber "; + + my $sth = $dbh->prepare($strsth); + + $sth->execute( @query_params ); + my $results = $sth->fetchall_arrayref({}); + $sth->finish; + return @$results; +} + +=head3 GetPendingpayments + + $aqpendingpayment = &GetPendingpayments($supplierid); + +get all pending payments informations in aqpayments for a given vendor + +=cut + +sub GetPendingpayments { + my ($supplierid) = @_; + my $dbh = C4::Context->dbh; + my $strsth = " + SELECT DISTINCT(aqorders.booksellerinvoicenumber) AS booksellerinvoicenumber, aqorders.datereceived FROM aqorders LEFT JOIN aqbasket ON aqorders.basketno= aqbasket.basketno LEFT JOIN aqpayments ON aqorders.booksellerinvoicenumber = aqpayments.booksellerinvoicenumber + WHERE aqbasket.booksellerid=? and aqorders.booksellerinvoicenumber IS NOT NULL AND aqpayments.booksellerinvoicenumber IS NULL"; + my @query_params = ( $supplierid ); + my $sth = $dbh->prepare($strsth); + $sth->execute( @query_params ); + my $results = $sth->fetchall_arrayref({}); + $sth->finish; + return $results; +} + +=head3 AddPayments + + $aqaddpayment = &GetPendingpayments($booksellerinvoicenumber,$chequeno,$chequedate,$notes); + +save all the payments in aqpayments table for a given vendor + +=cut + +sub AddPayments { + my ( $booksellerinvoicenumber, $chequeno,$chequedate,$notes) = @_; + my $dbh = C4::Context->dbh; + my $query = qq| + INSERT INTO aqpayments + (booksellerinvoicenumber,chequeno,chequedate,notes) + VALUES (?,?,?,?) |; + my $sth = $dbh->prepare($query); + $sth->execute( $booksellerinvoicenumber,$chequeno,$chequedate,$notes); +} #------------------------------------------------------------# =head3 NewBasket --- a/acqui/payment.pl +++ a/acqui/payment.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl + +#script to Payment Capture against vendor +#written by amit.gupta@osslabs.biz 09/06/2012 + +# Copyright 2012 Nucsoft Osslabs +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +=head1 NAME + +payments.pl + +This script is used to capture payments against vendor. + +=cut + +use strict; +use warnings; +use CGI; +use C4::Auth; +use C4::Output; + +use C4::Dates qw/format_date/; +use C4::Acquisition; +use C4::Bookseller qw/ GetBookSellerFromId /; + +my $input = CGI->new; +my $booksellerid = $input->param('booksellerid'); +my $startfrom = $input->param('startfrom'); +my $code = $input->param('filter'); +my $chequeno = $input->param('chequeno'); + + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => 'acqui/payment.tmpl', + query => $input, + type => 'intranet', + authnotrequired => 0, + flagsrequired => { acquisition => 'order_receive' }, + debug => 1, + } +); + +my $bookseller = GetBookSellerFromId($booksellerid); +my @payments = GetPayments( $booksellerid, $code, $chequeno); +my $count_payments = @payments; +my @loop_received = (); + +for (my $i = 0 ; $i < $count_payments ; $i++) { + my %line; + %line = %{ $payments[$i] }; + $line{booksellerid} = $booksellerid; + $line{chequedate} = format_date($line{chequedate}); + push @loop_received, \%line; + +} + +if ($count_payments) { + $template->param( searchresults => \@loop_received, count => $count_payments, ); +} +$template->param( + chequeno => $chequeno, + name => $bookseller->{'name'}, + datereceived_today => C4::Dates->new()->output(), + booksellerid => $booksellerid, +); + +output_html_with_http_headers $input, $cookie, $template->output; + + --- a/acqui/payments.pl +++ a/acqui/payments.pl @@ -0,0 +1,110 @@ +#!/usr/bin/perl + +#script to Payment Capture against vendor +#written by amit.gupta@osslabs.biz 09/06/2012 + +# Copyright 2012 Nucsoft Osslabs +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +=head1 NAME + +payments.pl + +This script is used to capture payments against vendor. + +=cut + +use strict; +use warnings; +use C4::Auth; +use C4::Acquisition; +use C4::Bookseller qw/ GetBookSellerFromId /; +use CGI; +use C4::Output; +use C4::Dates qw/format_date format_date_in_iso/; + + +my $input=new CGI; +my $booksellerid=$input->param('booksellerid'); +my $bookseller=GetBookSellerFromId($booksellerid); +my $chequeno=$input->param('chequeno') || ''; +my $notes=$input->param('notes') || ''; +my $op = $input->param('op'); + +my $datereceived = ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) : C4::Dates->new($input->param('datereceived'), 'iso') ; +$datereceived = C4::Dates->new() unless $datereceived; + +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "acqui/payments.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {acquisition => 'order_receive'}, + debug => 1, +}); + +my @parcelitems = GetPayments($booksellerid); +my $countlines = scalar @parcelitems; +my @loop_received = (); + +for (my $i = 0 ; $i < $countlines ; $i++) { + my %line; + %line = %{ $parcelitems[$i] }; + $line{booksellerid} = $booksellerid; + $line{chequedate} = format_date($line{chequedate}); + push @loop_received, \%line; + +} + +my $pendingpayments = GetPendingpayments($booksellerid); +my $countpendings = scalar @$pendingpayments; + + +my @loop_orders = (); +for (my $i = 0 ; $i < $countpendings ; $i++) { + my %line; + %line = %{$pendingpayments->[$i]}; + $line{datereceived} = format_date($line{datereceived}); + push @loop_orders, \%line; +} + + +if ($op eq "saveall"){ + my @booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber'); + my $chequedate = $input->param('date'); + foreach my $invoiceno(@booksellerinvoicenumber){ + next unless $invoiceno; + AddPayments( $invoiceno, $chequeno,$chequedate,$notes); + } + my $date = format_date($chequedate); + print $input->redirect("payments.pl?booksellerid=$booksellerid&op=new¬es=$notes&chequeno=$chequeno&datereceived=$date"); +} + + +$template->param( + chequeno => $chequeno, + notes => $notes, + datereceived => $datereceived->output('iso'), + formatteddatereceived => $datereceived->output(), + booksellerid => $booksellerid, + name => $bookseller->{'name'}, + loop_received => \@loop_received, + loop_orders => \@loop_orders, + +); +output_html_with_http_headers $input, $cookie, $template->output; + --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -2846,6 +2846,19 @@ CREATE TABLE `quotes` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `aqpayments` +-- + +DROP TABLE IF EXISTS aqpayments; +CREATE TABLE `aqpayments` ( + `booksellerinvoicenumber` mediumtext, + `chequeno` varchar(80) default NULL, + `chequedate` date default NULL, + `notes` varchar(80) default NULL, + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -5343,6 +5343,19 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion ="3.09.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("CREATE TABLE `aqpayments` ( + `booksellerinvoicenumber` mediumtext, + `chequeno` varchar(80) default NULL, + `chequedate` date default NULL, + `notes` varchar(80) default NULL, + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + print "Upgrade to $DBversion done (New table structure for aqpayments)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc @@ -26,6 +26,7 @@ { text: _("New basket"), url: "/cgi-bin/koha/acqui/basketheader.pl?booksellerid=[% booksellerid %]&op=add_form"}, { text: _("Baskets"), url: "/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid %]"}, { text: _("Basket groups"), url: "/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid %]"}, + { text: _("Payment"), url: "/cgi-bin/koha/acqui/payment.pl?booksellerid=[% booksellerid %]"}, [% END %] { text: _("Receive shipments"), url: "/cgi-bin/koha/acqui/parcels.pl?booksellerid=[% booksellerid %]" }, [% IF ( basketno ) %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt @@ -81,6 +81,7 @@ $(document).ready(function() { [% END %] [% END %] +
[% IF ( supplier.loop_basket.size ) %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/payment.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/payment.tt @@ -0,0 +1,105 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Acquisitions › Payments Details for vendor [% name %] +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'calendar.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'acquisitions-search.inc' %] + + + +[% IF ( count ) %]
[% ELSE %]
[% END %] + +
+
+
+ +

Payments Details for vendor [% name %]

+ +[% IF ( count ) %] + +
+ + + + + + + + + +[% FOREACH searchresult IN searchresults %] +[% UNLESS ( loop.odd ) %] + + [% ELSE %] + + [% END %] + + + + +[% END %] +
Transaction DateInvoice numberChq No./DD No.
[% searchresult.chequedate %][% searchresult.booksellerinvoicenumber %][% searchresult.chequeno %]
+
+[% END %] +
+
+
+ Payment Details +
  1. + + + + +
  2. +
  3. + + +
  4. +
  5. + + Show Calendar + +
    [% INCLUDE 'date-format.inc' %]
  6. +
+
+
Cancel
+
+
+
+
+
+[% IF ( count ) %]
+
+

Filter

+
    +
  1. +
  2. +
  3. +

  4. +
  5. +
+
Clear
+
+
[% END %] +
+
+[% INCLUDE 'intranet-bottom.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/payments.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/payments.tt @@ -0,0 +1,128 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Acquisitions › [% IF ( date ) %] + Receipt summary for [% name %] [% IF ( chequeno ) %]invoice [% chequeno %][% END %] on [% formatteddatereceived %][% ELSE %]Receive orders from [% name %][% END %] +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'greybox.inc' %] + + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'acquisitions-search.inc' %] + + + +
+
+
+
+ +
+

Chq No./DD No: [% chequeno %] Received by: [% loggedinusername %] Transaction Date: [% formatteddatereceived %]

+
+ +
+

Already Paid

+ [% IF ( loop_received ) %] +
+ + + + + + + + + + + [% FOREACH loop_receive IN loop_received %] + [% UNLESS ( loop.odd ) %] + + [% ELSE %] + + [% END %] + + + + + [% END %] + +
Invoice NumberChq No./DD No Transaction DateNotes
[% loop_receive.booksellerinvoicenumber %] + [% loop_receive.chequeno %][% loop_receive.chequedate %][% loop_receive.notes %]
+
+ [% ELSE %]There are no received payments.[% END %] +
+ +
+ +
+ +
+
+ +
+
+
+[% INCLUDE 'acquisitions-menu.inc' %] +
+
+[% INCLUDE 'intranet-bottom.inc' %] + --