$form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
if ($form->{currency} ne $form->{defaultcurrency});
+ # advance payment allows only one tax
+ if ($form->{type} eq 'invoice_for_advance_payment') {
+ my @current_taxaccounts = (split(/ /, $form->{taxaccounts}));
+ $form->error($locale->text('Cannot post invoice for advance payment with more than one tax'))
+ if (scalar @current_taxaccounts > 1);
+ }
for my $i (1 .. $form->{paidaccounts}) {
if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
# (order) -> invoice for adv. payment 1 -> invoice for adv. payment 2 -> invoice for adv. payment 3 -> final invoice
#
# we are currently in the last invoice for adv. payment (3 in this example)
- my $invoice_obj = SL::DB::Invoice->load_cached($form->{id});
- my $links = $invoice_obj->linked_records(direction => 'from', from => ['Invoice'], recursive => 1);
- my @related_invoices = grep {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$links;
-
- push @related_invoices, $invoice_obj;
+ my $related_invoices = IS->_get_invoices_for_advance_payment($form->{id});
delete @{ $form }{qw(printed emailed queued invnumber invdate exchangerate forex deliverydate datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno locked)};
remove_emptied_rows(1);
my $i = 0;
- foreach my $ri (@related_invoices) {
+ foreach my $ri (@$related_invoices) {
foreach my $item (@{$ri->items_sorted}) {
$i++;
$form->{"id_$i"} = $item->parts_id;