View | Details | Raw Unified | Return to bug 5713
Collapse All | Expand All

(-)a/C4/Accounts.pm (-22 / +35 lines)
Lines 169-195 sub makepayment { Link Here
169
    my $data = $sth->fetchrow_hashref;
169
    my $data = $sth->fetchrow_hashref;
170
    $sth->finish;
170
    $sth->finish;
171
171
172
    $sth = $dbh->prepare("UPDATE accountlines
172
    if($data->{'accounttype'} eq "Pay"){
173
			        SET amountoutstanding = 0
173
        my $udp = 		
174
			      WHERE borrowernumber = ?
174
            $dbh->prepare(
175
				AND accountno = ?");
175
                "UPDATE accountlines
176
    $sth->execute($borrowernumber, $accountno);
176
                    SET amountoutstanding = 0, description = 'Payment,thanks'
177
177
                    WHERE borrowernumber = ?
178
    #  print $updquery;
178
                    AND accountno = ?
179
#    $dbh->do( "
179
                "
180
#        INSERT INTO     accountoffsets
180
            );
181
#                        (borrowernumber, accountno, offsetaccount,
181
        $udp->execute($borrowernumber, $accountno );
182
#                         offsetamount)
182
        $udp->finish;
183
#        VALUES          ($borrowernumber, $accountno, $nextaccntno, $newamtos)
183
    }else{
184
#        " );
184
        my $udp = 		
185
185
            $dbh->prepare(
186
    # create new line
186
                "UPDATE accountlines
187
    my $payment = 0 - $amount;
187
                    SET amountoutstanding = 0
188
    $sth = $dbh->prepare("INSERT INTO accountlines
188
                    WHERE borrowernumber = ?
189
					 (borrowernumber, accountno, date, amount,
189
                    AND accountno = ?
190
					  description, accounttype, amountoutstanding)
190
                "
191
				  VALUES (?,?,now(),?,?,'Pay',0)");
191
            );
192
    $sth->execute($borrowernumber, $nextaccntno, $payment, "Payment,thanks - $user");
192
        $udp->execute($borrowernumber, $accountno );
193
        $udp->finish;
194
195
         # create new line
196
        my $payment = 0 - $amount;
197
        
198
        my $ins = 
199
            $dbh->prepare( 
200
                "INSERT 
201
                    INTO accountlines (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding)
202
                    VALUES ( ?, ?, now(), ?, 'Payment,thanks', 'Pay', 0)"
203
            );
204
        $ins->execute($borrowernumber, $nextaccntno, $payment);
205
        $ins->finish;
206
    }
193
207
194
    # FIXME - The second argument to &UpdateStats is supposed to be the
208
    # FIXME - The second argument to &UpdateStats is supposed to be the
195
    # branch code.
209
    # branch code.
196
- 

Return to bug 5713