Revision a198dfae
Von Bernd Bleßmann vor fast 3 Jahren hinzugefügt
bin/mozilla/is.pl | ||
---|---|---|
38 | 38 |
use SL::MoreCommon qw(restore_form save_form); |
39 | 39 |
use Data::Dumper; |
40 | 40 |
use DateTime; |
41 |
use List::MoreUtils qw(uniq); |
|
41 |
use List::MoreUtils qw(any uniq);
|
|
42 | 42 |
use List::Util qw(max sum); |
43 | 43 |
use List::UtilsBy qw(sort_by); |
44 | 44 |
use English qw(-no_match_vars); |
... | ... | |
309 | 309 |
if ($::instance_conf->get_warn_no_delivery_order_for_invoice && !$form->{id}) { |
310 | 310 |
$warn_unlinked_delivery_order = 1 unless $form->{convert_from_do_ids}; |
311 | 311 |
} |
312 |
|
|
313 |
my $has_further_invoice_for_advance_payment; |
|
314 |
if ($form->{id} && $form->{type} eq "invoice_for_advance_payment") { |
|
315 |
my $invoice_obj = SL::DB::Invoice->load_cached($form->{id}); |
|
316 |
my $lr = $invoice_obj->linked_records(direction => 'to', to => ['Invoice']); |
|
317 |
$has_further_invoice_for_advance_payment = any {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$lr; |
|
318 |
} |
|
319 |
|
|
312 | 320 |
for my $bar ($::request->layout->get('actionbar')) { |
313 | 321 |
$bar->add( |
314 | 322 |
action => [ |
... | ... | |
393 | 401 |
: !$form->{id} ? t8('This invoice has not been posted yet.') |
394 | 402 |
: undef, |
395 | 403 |
], |
404 |
action => [ |
|
405 |
t8('Further Invoice for Advance Payment'), |
|
406 |
submit => [ '#form', { action => "further_invoice_for_advance_payment" } ], |
|
407 |
checks => [ 'kivi.validate_form' ], |
|
408 |
disabled => !$may_edit_create ? t8('You must not change this invoice.') |
|
409 |
: !$form->{id} ? t8('This invoice has not been posted yet.') |
|
410 |
: $has_further_invoice_for_advance_payment ? t8('This invoice has already a further invoice for advanced payment.') |
|
411 |
: undef, |
|
412 |
only_if => $form->{type} eq "invoice_for_advance_payment", |
|
413 |
], |
|
396 | 414 |
action => [ |
397 | 415 |
t8('Credit Note'), |
398 | 416 |
submit => [ '#form', { action => "credit_note" } ], |
... | ... | |
1129 | 1147 |
$main::lxdebug->leave_sub(); |
1130 | 1148 |
} |
1131 | 1149 |
|
1150 |
sub further_invoice_for_advance_payment { |
|
1151 |
my $form = $main::form; |
|
1152 |
my %myconfig = %main::myconfig; |
|
1153 |
|
|
1154 |
$main::auth->assert('invoice_edit'); |
|
1155 |
|
|
1156 |
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)}; |
|
1157 |
$form->{convert_from_ar_ids} = $form->{id}; |
|
1158 |
$form->{id} = ''; |
|
1159 |
$form->{rowcount}--; |
|
1160 |
$form->{paidaccounts} = 1; |
|
1161 |
$form->{invdate} = $form->current_date(\%myconfig); |
|
1162 |
my $terms = get_payment_terms_for_invoice(); |
|
1163 |
$form->{duedate} = $terms ? $terms->calc_date(reference_date => $form->{invdate})->to_kivitendo : $form->{invdate}; |
|
1164 |
$form->{employee_id} = SL::DB::Manager::Employee->current->id; |
|
1165 |
$form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy'); |
|
1166 |
$form->{exchangerate} = $form->{forex} if $form->{forex}; |
|
1167 |
|
|
1168 |
$form->{"converted_from_invoice_id_$_"} = delete $form->{"invoice_id_$_"} for 1 .. $form->{"rowcount"}; |
|
1169 |
|
|
1170 |
&display_form; |
|
1171 |
} |
|
1172 |
|
|
1132 | 1173 |
sub storno { |
1133 | 1174 |
$main::lxdebug->enter_sub(); |
1134 | 1175 |
|
... | ... | |
1258 | 1299 |
|
1259 | 1300 |
&prepare_invoice; |
1260 | 1301 |
|
1261 |
|
|
1262 | 1302 |
&display_form; |
1263 | 1303 |
|
1264 | 1304 |
$main::lxdebug->leave_sub(); |
Auch abrufbar als: Unified diff
Anzahlungs-Rg.: Workflow Anzahlungs-Rg. -> Anzahlungs-Rg.