Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d7d43eb2

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID d7d43eb2e00f0609b452e1bea65d50004f2d77e9
  • Vorgänger 3c005fa1
  • Nachfolger 16fc9cde

ActionBar: Verwendung bei Debitorenbuchungen

Unterschiede anzeigen:

bin/mozilla/ar.pl
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/\"/&quot;/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;
js/kivi.AR.js
1
namespace('kivi.AR', function(ns){
2
  'use strict';
3

  
4
  ns.check_fields_before_posting = function() {
5
    var errors = [];
6

  
7
    if ($('#transdate').val() === '')
8
      errors.push(kivi.t8('Invoice Date missing!'));
9

  
10
    if ($('#duedate').val() === '')
11
      errors.push(kivi.t8('Due Date missing!'));
12

  
13
    if ($('#customer').val() === '')
14
      errors.push(kivi.t8('Customer missing!'));
15

  
16
    if (errors.length === 0)
17
      return true;
18

  
19
    alert(errors.join(' '));
20

  
21
    return false;
22
  };
23
});
js/locale/de.js
29 29
"Create new quotation/order":"Neues Angebot/neuen Auftrag anlegen",
30 30
"Create new qutoation/order":"Neues Angebot/neuen Auftrag anlegen",
31 31
"Create new version":"Neue Version anlegen",
32
"Customer missing!":"Kundenname fehlt!",
32 33
"Database Connection Test":"Test der Datenbankverbindung",
33 34
"Delete":"Löschen",
34 35
"Delete picture":"Bild löschen",
......
46 47
"Do you really want to unimport the selected documents?":"Wollen Sie wirklich diese Dateien an die Quelle zurückgeben?",
47 48
"Do you want to set the account number \"#1\" to \"#2\" and the name \"#3\" to \"#4\"?":"Soll die Kontonummer \"#1\" zu \"#2\" und den Name \"#3\" zu \"#4\" geändert werden?",
48 49
"Download picture":"Bild herunterladen",
50
"Due Date missing!":"Fälligkeitsdatum fehlt!",
49 51
"Edit":"Bearbeiten",
50 52
"Edit article/section assignments":"Zuweisung Artikel/Abschnitte bearbeiten",
51 53
"Edit custom shipto":"Individuelle Lieferadresse bearbeiten",
......
61 63
"History":"Historie",
62 64
"If you switch to a different tab without saving you will lose the data you've entered in the current tab.":"Wenn Sie auf einen anderen Tab wechseln, ohne vorher zu speichern, so gehen die im aktuellen Tab eingegebenen Daten verloren.",
63 65
"Import documents from #1":"Importiere Dateien von Quelle '#1'",
66
"Invoice Date missing!":"Rechnungsdatum fehlt!",
64 67
"Map":"Karte",
65 68
"More than one file selected, please set only one checkbox!":"Mehr als ein Element selektiert, bitte nur eine Box anklicken",
66 69
"No":"Nein",
locale/de/all
1593 1593
  'Invoice with Storno (abbreviation)' => 'R(S)',
1594 1594
  'Invoices'                    => 'Rechnungen',
1595 1595
  'Invoices can only be changed on the day they are posted.' => 'Rechnungen können nur am Buchungstag geändert werden.',
1596
  'Invoices with payments cannot be canceled.' => 'Rechnungen mit Zahlungen können nicht storniert werden.',
1596 1597
  'Invoices, Credit Notes & AR Transactions' => 'Rechnungen, Gutschriften & Debitorenbuchungen',
1597 1598
  'Is Searchable'               => 'Durchsuchbar',
1598 1599
  'Is this a summary account to record' => 'Sammelkonto für',
......
2431 2432
  'Result'                      => 'Ergebnis',
2432 2433
  'Revenue'                     => 'Erlöskonto',
2433 2434
  'Revenue Account'             => 'Erlöskonto',
2435
  'Reversal invoices cannot be canceled.' => 'Stornorechnungen können nicht storniert werden.',
2434 2436
  'Revert to version'           => 'Auf Version zurücksetzen',
2435 2437
  'Review of Aging list'        => 'Altersstrukturliste',
2436 2438
  'Right'                       => 'Rechts',
......
3213 3215
  'This has been changed in this version, therefore please change the "old" bins to some real warehouse bins.' => 'Das wurde in dieser Version umgestellt, bitte ändern Sie die Freitext-Lagerplätze auf vorhandene Lagerplätze.',
3214 3216
  'This has been changed in this version.' => 'Ab dieser Version ist dies nicht mehr so.',
3215 3217
  'This invoice has already been posted.' => 'Die Rechnung wurde bereits gebucht.',
3218
  'This invoice has been canceled already.' => 'Die Rechnung wurde bereits storniert.',
3216 3219
  'This invoice has not been posted yet.' => 'Die Rechnung wurde noch nicht gebucht.',
3217 3220
  'This invoice\'s dunning level: #1' => 'Mahnstufe dieser Rechnung: #1',
3218 3221
  'This is a very critical problem.' => 'Dieses Problem ist sehr schwerwiegend.',
templates/webpages/ar/form_footer.html
10 10
  <input type="hidden" name="callback" value="[% callback | html %]">
11 11
  [% P.hidden_tag('draft_id', draft_id) %]
12 12
  [% P.hidden_tag('draft_description', draft_description) %]
13

  
14
  <br>
15

  
16
  <input class="submit" type="submit" name="action" id="update_button" value="[% 'Update' | $T8 %]">
17

  
18
  [% IF ( show_storno_button ) %]
19
    <input class="submit" type="submit" name="action" value="[% 'Storno' | $T8 %]">
20
  [% END %]
21

  
22
  [% IF ( id ) %]
23
    [% IF ( radier ) %]
24
      <input class="submit" type="submit" name="action" value="[% 'Post' | $T8 %]">
25
      <input class="submit" type="submit" name="action" value="[% 'Delete' | $T8 %]">
26
    [% END %]
27

  
28
    [% IF ( !is_closed ) %]
29
      <input class="submit" type="submit" name="action" value="[% 'Use As New' | $T8 %]">
30
    [% END %]
31

  
32
    <input class="submit" type="submit" name="action" value="[% 'Post Payment' | $T8 %]">
33
    <input type="button" class="submit" onclick="follow_up_window()" value="[% 'Follow-Up' | $T8 %]">
34
    <input type="button" class="submit" onclick="set_history_window([% id %], 'glid');" name="history" id="history" value="[% 'history' | $T8 %]">
35
  [% ELSE %]
36
    [% IF ( !is_closed ) %]
37
      <input class="submit" type="submit" name="action" value="[% 'Post' | $T8 %]">
38
      [% L.button_tag('kivi.Draft.popup("ar", "invoice", "' _ draft_id _ '", "' _ draft_description _ '")', LxERP.t8('Drafts')) %]
39
    [% END %]
40
  [% END %]
41

  
42
  [% IF ( show_mark_as_paid_button ) %]
43
    [% L.submit_tag("action", LxERP.t8('Mark as paid'), confirm=LxERP.t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?')) %]
44
  [% END %]
45

  
46
  [% L.button_tag("kivi.RecordTemplate.popup('ar_transaction')", LxERP.t8("Record templates")) %]
47

  
48 13
</form>
49 14

  
50 15
<script type="text/javascript">

Auch abrufbar als: Unified diff