#'
# FIXME - Okay, so what does this function do, really?
-sub manualinvoice{
- my ($borrowernumber,$itemnum,$desc,$type,$amount,$user)=@_;
- my $dbh = C4::Context->dbh;
- my $notifyid=0;
- my $insert;
- $itemnum=~ s/ //g;
- my $accountno=getnextacctno($borrowernumber);
- my $amountleft=$amount;
-
- if ($type eq 'CS' || $type eq 'CB' || $type eq 'CW'
- || $type eq 'CF' || $type eq 'CL'){
- my $amount2=$amount*-1; # FIXME - $amount2 = -$amount
- $amountleft=fixcredit($borrowernumber,$amount2,$itemnum,$type,$user);
- }
- if ($type eq 'N'){
- $desc.="New Card";
- }
- if ($type eq 'F'){
- $desc.="Fine";
- }
- if ($type eq 'A'){
- $desc.="Account Management fee";
- }
- if ($type eq 'M'){
- $desc.="Sundry";
- }
-
- if ($type eq 'L' && $desc eq ''){
-
- $desc="Lost Item";
- }
- if ($type eq 'REF'){
- $desc.="Cash Refund";
- $amountleft=refund('',$borrowernumber,$amount);
- }
- if(($type eq 'L') or ($type eq 'F') or ($type eq 'A') or ($type eq 'N') or ($type eq 'M') ){
- $notifyid=1;
- }
-
- if ($itemnum ne ''){
- $desc.=" ".$itemnum;
- my $sth=$dbh->prepare("INSERT INTO accountlines
+sub manualinvoice {
+ my ( $borrowernumber, $itemnum, $desc, $type, $amount, $user ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $notifyid = 0;
+ my $insert;
+ $itemnum =~ s/ //g;
+ my $accountno = getnextacctno($borrowernumber);
+ my $amountleft = $amount;
+
+ if ( $type eq 'CS'
+ || $type eq 'CB'
+ || $type eq 'CW'
+ || $type eq 'CF'
+ || $type eq 'CL' )
+ {
+ my $amount2 = $amount * -1; # FIXME - $amount2 = -$amount
+ $amountleft =
+ fixcredit( $borrowernumber, $amount2, $itemnum, $type, $user );
+ }
+ if ( $type eq 'N' ) {
+ $desc .= "New Card";
+ }
+ if ( $type eq 'F' ) {
+ $desc .= "Fine";
+ }
+ if ( $type eq 'A' ) {
+ $desc .= "Account Management fee";
+ }
+ if ( $type eq 'M' ) {
+ $desc .= "Sundry";
+ }
+
+ if ( $type eq 'L' && $desc eq '' ) {
+
+ $desc = "Lost Item";
+ }
+ if ( $type eq 'REF' ) {
+ $desc .= "Cash Refund";
+ $amountleft = refund( '', $borrowernumber, $amount );
+ }
+ if ( ( $type eq 'L' )
+ or ( $type eq 'F' )
+ or ( $type eq 'A' )
+ or ( $type eq 'N' )
+ or ( $type eq 'M' ) )
+ {
+ $notifyid = 1;
+ }
+
+ if ( $itemnum ne '' ) {
+ $desc .= " " . $itemnum;
+ my $sth = $dbh->prepare(
+ "INSERT INTO accountlines
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id)
- VALUES (?, ?, now(), ?,?, ?,?,?,?)"
- );
-
- # $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $data->{'itemnumber'});
- $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
- $amountleft, $itemnum, $notifyid );
- }
- else {
- my $sth = $dbh->prepare(
- "INSERT INTO accountlines
+ VALUES (?, ?, now(), ?,?, ?,?,?,?)");
+ $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid) || return $sth->errstr;
+ } else {
+ my $sth=$dbh->prepare("INSERT INTO accountlines
(borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id)
- VALUES (?, ?, now(), ?, ?, ?, ?,?)");
- $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft,$notifyid);
- }
+ VALUES (?, ?, now(), ?, ?, ?, ?,?)"
+ );
+ $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
+ $amountleft, $notifyid );
+ }
}
=head2 fixcredit