+sub _get_invoices_for_advance_payment {
+ my ($self, $id) = @_;
+
+ return [] if !$id;
+
+ my $invoice_obj = SL::DB::Invoice->new(id => $id*1)->load;
+ 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 if "invoice_for_advance_payment" eq $invoice_obj->type;
+
+ return \@related_invoices;
+}
+
+