+ # Sanity checks for invoices for advance payment and final invoices
+ my $advance_payment_clearing_chart;
+ if (any { $_ eq $form->{type} } qw(invoice_for_advance_payment final_invoice)) {
+ $advance_payment_clearing_chart = SL::DB::Chart->new(id => $::instance_conf->get_advance_payment_clearing_chart_id)->load;
+ die "No Clearing Chart for Advance Payment" unless ref $advance_payment_clearing_chart eq 'SL::DB::Chart';
+
+ my @current_taxaccounts = (split(/ /, $form->{taxaccounts}));
+ die 'Wrong call: Cannot post invoice for advance payment or final invoice with more than one tax' if (scalar @current_taxaccounts > 1);
+
+ my @trans_ids = keys %{ $form->{amount} };
+ if (scalar @trans_ids > 1) {
+ require Data::Dumper;
+ die "Invalid state for advance payment more than one trans_id " . Dumper($form->{amount});
+ }
+ }
+