sub pay {
my ( $self, $params ) = @_;
- my $amount = $params->{amount};
- my $description = $params->{description};
- my $note = $params->{note} || q{};
- my $library_id = $params->{library_id};
- my $lines = $params->{lines};
- my $type = $params->{type} || 'payment';
- my $payment_type = $params->{payment_type} || undef;
- my $account_type = $params->{account_type};
- my $offset_type = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
+ my $amount = $params->{amount};
+ my $description = $params->{description};
+ my $note = $params->{note} || q{};
+ my $library_id = $params->{library_id};
+ my $lines = $params->{lines};
+ my $type = $params->{type} || 'payment';
+ my $payment_type = $params->{payment_type} || undef;
+ my $account_type = $params->{account_type};
+ my $offset_type = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
+ my $cash_register = $params->{cash_register};
my $userenv = C4::Context->userenv;
my $manager_id = $userenv ? $userenv->{number} : 0;
my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
+ Koha::Exceptions::Account::RegisterRequired->throw()
+ if ( C4::Context->preference("UseCashRegisters")
+ && !defined($cash_register)
+ && ( $interface ne 'opac' ) );
my @fines_paid; # List of account lines paid on with this payment
manager_id => $manager_id,
interface => $interface,
branchcode => $library_id,
+ register_id => $cash_register,
note => $note,
}
)->store();
my ( $self, $params ) = @_;
# amount is passed as a positive value, but we store credit as negative values
- my $amount = $params->{amount} * -1;
- my $description = $params->{description} // q{};
- my $note = $params->{note} // q{};
- my $user_id = $params->{user_id};
- my $interface = $params->{interface};
- my $library_id = $params->{library_id};
- my $payment_type = $params->{payment_type};
- my $type = $params->{type} || 'payment';
- my $item_id = $params->{item_id};
+ my $amount = $params->{amount} * -1;
+ my $description = $params->{description} // q{};
+ my $note = $params->{note} // q{};
+ my $user_id = $params->{user_id};
+ my $interface = $params->{interface};
+ my $library_id = $params->{library_id};
+ my $cash_register = $params->{cash_register};
+ my $payment_type = $params->{payment_type};
+ my $type = $params->{type} || 'payment';
+ my $item_id = $params->{item_id};
unless ( $interface ) {
Koha::Exceptions::MissingParameter->throw(
);
}
+ Koha::Exceptions::Account::RegisterRequired->throw()
+ if ( C4::Context->preference("UseCashRegisters")
+ && !defined($cash_register)
+ && ( $payment_type eq 'CASH' ) );
+
my $schema = Koha::Database->new->schema;
my $account_type = $Koha::Account::account_type_credit->{$type};
manager_id => $user_id,
interface => $interface,
branchcode => $library_id,
+ register_id => $cash_register,
itemnumber => $item_id,
}
)->store();
</select>
</li>
[% END %]
+ [% IF Koha.Preference('UseCashRegisters') %]
+ <li>
+ <label for="cash_register">Cash register: </label>
+ <select name="cash_register" id="cash_register">
+ [% FOREACH register IN registers %]
+ [% IF register.id == registerid %]
+ <option value="[% register.id %]" selected="selected">[% register.name | html %]</option>
+ [% ELSE %]
+ <option value="[% register.id %]">[% register.name | html %]</option>
+ [% END %]
+ [% END %]
+ </select>
+ </li>
+ [% END %]
</ol>
</fieldset>
<label>Change to give: </label>
<span id="change">0.00</span>
</li>
+
[% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
[% IF payment_types %]
<li>
</select>
</li>
[% END %]
+
+ [% IF Koha.Preference('UseCashRegisters') %]
+ <li>
+ <label for="cash_register">Cash register: </label>
+ <select name="cash_register" id="cash_register">
+ [% FOREACH register IN registers %]
+ [% IF register.id == registerid %]
+ <option value="[% register.id %]" selected="selected">[% register.name | html %]</option>
+ [% ELSE %]
+ <option value="[% register.id %]">[% register.name | html %]</option>
+ [% END %]
+ [% END %]
+ </select>
+ </li>
+ [% END %]
+
<li>
<label for="selected_accts_notes">Note: </label>
<textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea>
use C4::Accounts;
use C4::Koha;
+use Koha::Cash::Registers;
use Koha::Patrons;
use Koha::Patron::Categories;
use Koha::AuthorisedValues;
my $payment_type = scalar $input->param('payment_type');
my $accountlines_id;
+my $registerid = $input->param('registerid');
+if ( !$registerid ) {
+ $registerid = Koha::Cash::Registers->find(
+ { branch => $library_id, branch_default => 1 },
+ )->id;
+}
+my $registers = Koha::Cash::Registers->search(
+ { branch => $library_id, archived => 0 },
+ { order_by => { '-asc' => 'name' } }
+);
+$template->param(
+ registerid => $registerid,
+ registers => $registers,
+);
+
if ( $pay_individual || $writeoff_individual ) {
if ($pay_individual) {
$template->param( pay_individual => 1 );
note => $payment_note,
interface => C4::Context->interface,
payment_type => $payment_type,
+ cash_register => $registerid
}
);
print $input->redirect(
note => $note,
interface => C4::Context->interface,
payment_type => $payment_type,
+ cash_register => $registerid
}
);
}
library_id => $library_id,
note => $note,
payment_type => $payment_type,
- interface => C4::Context->interface
+ interface => C4::Context->interface,
+ payment_type => $payment_type,
+ cash_register => $registerid
}
);
}