50 |
50 |
use SL::DB::RecordTemplate;
|
51 |
51 |
use SL::DB::Tax;
|
52 |
52 |
use SL::Helper::Flash qw(flash);
|
|
53 |
use SL::Locale::String qw(t8);
|
53 |
54 |
use SL::ReportGenerator;
|
54 |
55 |
|
55 |
56 |
require "bin/mozilla/common.pl";
|
... | ... | |
392 |
393 |
my $follow_up_vc = $form->{customer_id} ? SL::DB::Customer->load_cached($form->{customer_id})->name : '';
|
393 |
394 |
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)";
|
394 |
395 |
|
395 |
|
$::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.File.js", "kivi.RecordTemplate.js");
|
|
396 |
$::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.File.js", "kivi.RecordTemplate.js", "kivi.AR.js");
|
396 |
397 |
|
397 |
398 |
my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
|
398 |
399 |
my $first_taxchart;
|
... | ... | |
502 |
503 |
],
|
503 |
504 |
);
|
504 |
505 |
|
|
506 |
setup_ar_form_header_action_bar();
|
|
507 |
|
505 |
508 |
$form->header;
|
506 |
509 |
print $::form->parse_html_template('ar/form_header', {
|
507 |
510 |
paid_missing => $::form->{invtotal} - $::form->{totalpaid},
|
... | ... | |
539 |
542 |
}
|
540 |
543 |
}
|
541 |
544 |
|
542 |
|
my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
|
543 |
|
my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
|
544 |
|
|
545 |
|
$form->{is_closed} = $transdate <= $closedto;
|
546 |
|
|
547 |
|
# ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it
|
548 |
|
$form->{show_storno_button} =
|
549 |
|
$form->{id} &&
|
550 |
|
!IS->has_storno(\%myconfig, $form, 'ar') &&
|
551 |
|
!IS->is_storno(\%myconfig, $form, 'ar') &&
|
552 |
|
($form->{totalpaid} == 0 || $form->{totalpaid} eq "");
|
553 |
|
|
554 |
|
$form->{show_mark_as_paid_button} = $form->{id} && $::instance_conf->get_ar_show_mark_as_paid();
|
555 |
|
|
556 |
545 |
print $::form->parse_html_template('ar/form_footer');
|
557 |
546 |
|
558 |
547 |
$main::lxdebug->leave_sub();
|
... | ... | |
562 |
551 |
$::auth->assert('ar_transactions');
|
563 |
552 |
|
564 |
553 |
SL::DB::Invoice->new(id => $::form->{id})->load->mark_as_paid;
|
565 |
|
|
566 |
554 |
$::form->redirect($::locale->text("Marked as paid"));
|
567 |
555 |
}
|
568 |
556 |
|
... | ... | |
836 |
824 |
my $form = $main::form;
|
837 |
825 |
my %myconfig = %main::myconfig;
|
838 |
826 |
|
839 |
|
map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
|
|
827 |
map { delete $form->{$_} } qw(printed emailed queued invnumber deliverydate id datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
|
840 |
828 |
$form->{paidaccounts} = 1;
|
841 |
829 |
$form->{rowcount}--;
|
842 |
|
$form->{invdate} = $form->current_date(\%myconfig);
|
843 |
|
&update;
|
844 |
830 |
|
845 |
|
$main::lxdebug->leave_sub();
|
846 |
|
}
|
847 |
|
|
848 |
|
sub delete {
|
849 |
|
$main::lxdebug->enter_sub();
|
850 |
|
|
851 |
|
$main::auth->assert('ar_transactions');
|
852 |
|
|
853 |
|
my $form = $main::form;
|
854 |
|
my $locale = $main::locale;
|
|
831 |
my $today = DateTime->today_local;
|
|
832 |
$form->{transdate} = $today->to_kivitendo;
|
|
833 |
$form->{duedate} = $form->{transdate};
|
855 |
834 |
|
856 |
|
$form->{title} = $locale->text('Confirm!');
|
857 |
|
|
858 |
|
$form->header;
|
859 |
|
|
860 |
|
delete $form->{header};
|
861 |
|
|
862 |
|
print qq|
|
863 |
|
<form method=post action=$form->{script}>
|
864 |
|
|;
|
865 |
|
|
866 |
|
foreach my $key (keys %$form) {
|
867 |
|
next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
|
868 |
|
$form->{$key} =~ s/\"/"/g;
|
869 |
|
print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
|
|
835 |
if ($form->{customer_id}) {
|
|
836 |
my $payment_terms = SL::DB::Customer->load_cached($form->{customer_id})->payment;
|
|
837 |
$form->{duedate} = $payment_terms->calc_date(reference_date => $today)->to_kivitendo if $payment_terms;
|
870 |
838 |
}
|
871 |
839 |
|
872 |
|
print qq|
|
873 |
|
<h2 class=confirm>$form->{title}</h2>
|
874 |
|
|
875 |
|
<h4>|
|
876 |
|
. $locale->text('Are you sure you want to delete Transaction')
|
877 |
|
. qq| $form->{invnumber}</h4>
|
878 |
|
|
879 |
|
<input name=action class=submit type=submit value="|
|
880 |
|
. $locale->text('Yes') . qq|">
|
881 |
|
</form>
|
882 |
|
|;
|
|
840 |
&update;
|
883 |
841 |
|
884 |
842 |
$main::lxdebug->leave_sub();
|
885 |
843 |
}
|
886 |
844 |
|
887 |
|
sub yes {
|
888 |
|
$main::lxdebug->enter_sub();
|
889 |
|
|
890 |
|
$main::auth->assert('ar_transactions');
|
|
845 |
sub delete {
|
|
846 |
$::auth->assert('ar_transactions');
|
891 |
847 |
|
892 |
848 |
my $form = $main::form;
|
893 |
849 |
my %myconfig = %main::myconfig;
|
... | ... | |
905 |
861 |
$form->redirect($locale->text('Transaction deleted!'));
|
906 |
862 |
}
|
907 |
863 |
$form->error($locale->text('Cannot delete transaction!'));
|
908 |
|
|
909 |
|
$main::lxdebug->leave_sub();
|
910 |
864 |
}
|
911 |
865 |
|
912 |
866 |
sub setup_ar_search_action_bar {
|
... | ... | |
1283 |
1237 |
$main::lxdebug->leave_sub();
|
1284 |
1238 |
}
|
1285 |
1239 |
|
|
1240 |
sub setup_ar_form_header_action_bar {
|
|
1241 |
my $transdate = $::form->datetonum($::form->{transdate}, \%::myconfig);
|
|
1242 |
my $closedto = $::form->datetonum($::form->{closedto}, \%::myconfig);
|
|
1243 |
my $is_closed = $transdate <= $closedto;
|
|
1244 |
|
|
1245 |
my $change_never = $::instance_conf->get_ar_changeable == 0;
|
|
1246 |
my $change_on_same_day_only = $::instance_conf->get_ar_changeable == 2 && ($::form->current_date(\%::myconfig) ne $::form->{gldate});
|
|
1247 |
|
|
1248 |
my $is_storno = IS->is_storno(\%::myconfig, $::form, 'ar', $::form->{id});
|
|
1249 |
my $has_storno = IS->has_storno(\%::myconfig, $::form, 'ar');
|
|
1250 |
|
|
1251 |
for my $bar ($::request->layout->get('actionbar')) {
|
|
1252 |
$bar->add(
|
|
1253 |
action => [
|
|
1254 |
t8('Update'),
|
|
1255 |
submit => [ '#form', { action => "update" } ],
|
|
1256 |
id => 'update_button',
|
|
1257 |
accesskey => 'enter',
|
|
1258 |
],
|
|
1259 |
|
|
1260 |
combobox => [
|
|
1261 |
action => [
|
|
1262 |
t8('Post'),
|
|
1263 |
submit => [ '#form', { action => "post" } ],
|
|
1264 |
checks => [ 'kivi.AR.check_fields_before_posting' ],
|
|
1265 |
disabled => $is_closed ? t8('The billing period has already been locked.')
|
|
1266 |
: $is_storno ? t8('A canceled invoice cannot be posted.')
|
|
1267 |
: ($::form->{id} && $change_never) ? t8('Changing invoices has been disabled in the configuration.')
|
|
1268 |
: ($::form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
|
|
1269 |
: undef,
|
|
1270 |
],
|
|
1271 |
action => [
|
|
1272 |
t8('Post Payment'),
|
|
1273 |
submit => [ '#form', { action => "post_payment" } ],
|
|
1274 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
|
|
1275 |
],
|
|
1276 |
action => [ t8('Mark as paid'),
|
|
1277 |
submit => [ '#form', { action => "mark_as_paid" } ],
|
|
1278 |
confirm => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
|
|
1279 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
|
|
1280 |
only_if => $::instance_conf->get_is_show_mark_as_paid,
|
|
1281 |
],
|
|
1282 |
], # end of combobox "Post"
|
|
1283 |
|
|
1284 |
combobox => [
|
|
1285 |
action => [ t8('Storno'),
|
|
1286 |
submit => [ '#form', { action => "storno" } ],
|
|
1287 |
checks => [ 'kivi.AR.check_fields_before_posting' ],
|
|
1288 |
confirm => t8('Do you really want to cancel this invoice?'),
|
|
1289 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.')
|
|
1290 |
: $has_storno ? t8('This invoice has been canceled already.')
|
|
1291 |
: $is_storno ? t8('Reversal invoices cannot be canceled.')
|
|
1292 |
: $::form->{totalpaid} ? t8('Invoices with payments cannot be canceled.')
|
|
1293 |
: undef,
|
|
1294 |
],
|
|
1295 |
action => [ t8('Delete'),
|
|
1296 |
submit => [ '#form', { action => "delete" } ],
|
|
1297 |
confirm => t8('Do you really want to delete this object?'),
|
|
1298 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.')
|
|
1299 |
: $change_never ? t8('Changing invoices has been disabled in the configuration.')
|
|
1300 |
: $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
|
|
1301 |
: $is_closed ? t8('The billing period has already been locked.')
|
|
1302 |
: undef,
|
|
1303 |
],
|
|
1304 |
], # end of combobox "Storno"
|
|
1305 |
|
|
1306 |
'separator',
|
|
1307 |
|
|
1308 |
combobox => [
|
|
1309 |
action => [ t8('Workflow') ],
|
|
1310 |
action => [
|
|
1311 |
t8('Use As New'),
|
|
1312 |
submit => [ '#form', { action => "use_as_new" } ],
|
|
1313 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
|
|
1314 |
],
|
|
1315 |
], # end of combobox "Workflow"
|
|
1316 |
|
|
1317 |
combobox => [
|
|
1318 |
action => [ t8('more') ],
|
|
1319 |
action => [
|
|
1320 |
t8('History'),
|
|
1321 |
call => [ 'set_history_window', $::form->{id} * 1, 'glid' ],
|
|
1322 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
|
|
1323 |
],
|
|
1324 |
action => [
|
|
1325 |
t8('Follow-Up'),
|
|
1326 |
call => [ 'follow_up_window' ],
|
|
1327 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
|
|
1328 |
],
|
|
1329 |
action => [
|
|
1330 |
t8('Record templates'),
|
|
1331 |
call => [ 'kivi.RecordTemplate.popup', 'ar_transaction' ],
|
|
1332 |
],
|
|
1333 |
action => [
|
|
1334 |
t8('Drafts'),
|
|
1335 |
call => [ 'kivi.Draft.popup', 'ar', 'invoice', $::form->{draft_id}, $::form->{draft_description} ],
|
|
1336 |
disabled => $::form->{id} ? t8('This invoice has already been posted.')
|
|
1337 |
: $is_closed ? t8('The billing period has already been locked.')
|
|
1338 |
: undef,
|
|
1339 |
],
|
|
1340 |
], # end of combobox "more"
|
|
1341 |
);
|
|
1342 |
}
|
|
1343 |
}
|
|
1344 |
|
1286 |
1345 |
1;
|
ActionBar: Verwendung bei Debitorenbuchungen