Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d7d43eb2

Von Moritz Bunkus vor etwa 8 Jahren hinzugefügt

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

ActionBar: Verwendung bei Debitorenbuchungen

Unterschiede anzeigen:

bin/mozilla/ar.pl
use SL::DB::RecordTemplate;
use SL::DB::Tax;
use SL::Helper::Flash qw(flash);
use SL::Locale::String qw(t8);
use SL::ReportGenerator;
require "bin/mozilla/common.pl";
......
my $follow_up_vc = $form->{customer_id} ? SL::DB::Customer->load_cached($form->{customer_id})->name : '';
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)";
$::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");
$::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");
my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
my $first_taxchart;
......
],
);
setup_ar_form_header_action_bar();
$form->header;
print $::form->parse_html_template('ar/form_header', {
paid_missing => $::form->{invtotal} - $::form->{totalpaid},
......
}
}
my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
$form->{is_closed} = $transdate <= $closedto;
# ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it
$form->{show_storno_button} =
$form->{id} &&
!IS->has_storno(\%myconfig, $form, 'ar') &&
!IS->is_storno(\%myconfig, $form, 'ar') &&
($form->{totalpaid} == 0 || $form->{totalpaid} eq "");
$form->{show_mark_as_paid_button} = $form->{id} && $::instance_conf->get_ar_show_mark_as_paid();
print $::form->parse_html_template('ar/form_footer');
$main::lxdebug->leave_sub();
......
$::auth->assert('ar_transactions');
SL::DB::Invoice->new(id => $::form->{id})->load->mark_as_paid;
$::form->redirect($::locale->text("Marked as paid"));
}
......
my $form = $main::form;
my %myconfig = %main::myconfig;
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);
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);
$form->{paidaccounts} = 1;
$form->{rowcount}--;
$form->{invdate} = $form->current_date(\%myconfig);
&update;
$main::lxdebug->leave_sub();
}
sub delete {
$main::lxdebug->enter_sub();
$main::auth->assert('ar_transactions');
my $form = $main::form;
my $locale = $main::locale;
my $today = DateTime->today_local;
$form->{transdate} = $today->to_kivitendo;
$form->{duedate} = $form->{transdate};
$form->{title} = $locale->text('Confirm!');
$form->header;
delete $form->{header};
print qq|
<form method=post action=$form->{script}>
|;
foreach my $key (keys %$form) {
next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
$form->{$key} =~ s/\"/&quot;/g;
print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
if ($form->{customer_id}) {
my $payment_terms = SL::DB::Customer->load_cached($form->{customer_id})->payment;
$form->{duedate} = $payment_terms->calc_date(reference_date => $today)->to_kivitendo if $payment_terms;
}
print qq|
<h2 class=confirm>$form->{title}</h2>
<h4>|
. $locale->text('Are you sure you want to delete Transaction')
. qq| $form->{invnumber}</h4>
<input name=action class=submit type=submit value="|
. $locale->text('Yes') . qq|">
</form>
|;
&update;
$main::lxdebug->leave_sub();
}
sub yes {
$main::lxdebug->enter_sub();
$main::auth->assert('ar_transactions');
sub delete {
$::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
......
$form->redirect($locale->text('Transaction deleted!'));
}
$form->error($locale->text('Cannot delete transaction!'));
$main::lxdebug->leave_sub();
}
sub setup_ar_search_action_bar {
......
$main::lxdebug->leave_sub();
}
sub setup_ar_form_header_action_bar {
my $transdate = $::form->datetonum($::form->{transdate}, \%::myconfig);
my $closedto = $::form->datetonum($::form->{closedto}, \%::myconfig);
my $is_closed = $transdate <= $closedto;
my $change_never = $::instance_conf->get_ar_changeable == 0;
my $change_on_same_day_only = $::instance_conf->get_ar_changeable == 2 && ($::form->current_date(\%::myconfig) ne $::form->{gldate});
my $is_storno = IS->is_storno(\%::myconfig, $::form, 'ar', $::form->{id});
my $has_storno = IS->has_storno(\%::myconfig, $::form, 'ar');
for my $bar ($::request->layout->get('actionbar')) {
$bar->add(
action => [
t8('Update'),
submit => [ '#form', { action => "update" } ],
id => 'update_button',
accesskey => 'enter',
],
combobox => [
action => [
t8('Post'),
submit => [ '#form', { action => "post" } ],
checks => [ 'kivi.AR.check_fields_before_posting' ],
disabled => $is_closed ? t8('The billing period has already been locked.')
: $is_storno ? t8('A canceled invoice cannot be posted.')
: ($::form->{id} && $change_never) ? t8('Changing invoices has been disabled in the configuration.')
: ($::form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
: undef,
],
action => [
t8('Post Payment'),
submit => [ '#form', { action => "post_payment" } ],
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
],
action => [ t8('Mark as paid'),
submit => [ '#form', { action => "mark_as_paid" } ],
confirm => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
only_if => $::instance_conf->get_is_show_mark_as_paid,
],
], # end of combobox "Post"
combobox => [
action => [ t8('Storno'),
submit => [ '#form', { action => "storno" } ],
checks => [ 'kivi.AR.check_fields_before_posting' ],
confirm => t8('Do you really want to cancel this invoice?'),
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.')
: $has_storno ? t8('This invoice has been canceled already.')
: $is_storno ? t8('Reversal invoices cannot be canceled.')
: $::form->{totalpaid} ? t8('Invoices with payments cannot be canceled.')
: undef,
],
action => [ t8('Delete'),
submit => [ '#form', { action => "delete" } ],
confirm => t8('Do you really want to delete this object?'),
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.')
: $change_never ? t8('Changing invoices has been disabled in the configuration.')
: $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
: $is_closed ? t8('The billing period has already been locked.')
: undef,
],
], # end of combobox "Storno"
'separator',
combobox => [
action => [ t8('Workflow') ],
action => [
t8('Use As New'),
submit => [ '#form', { action => "use_as_new" } ],
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
],
], # end of combobox "Workflow"
combobox => [
action => [ t8('more') ],
action => [
t8('History'),
call => [ 'set_history_window', $::form->{id} * 1, 'glid' ],
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
],
action => [
t8('Follow-Up'),
call => [ 'follow_up_window' ],
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
],
action => [
t8('Record templates'),
call => [ 'kivi.RecordTemplate.popup', 'ar_transaction' ],
],
action => [
t8('Drafts'),
call => [ 'kivi.Draft.popup', 'ar', 'invoice', $::form->{draft_id}, $::form->{draft_description} ],
disabled => $::form->{id} ? t8('This invoice has already been posted.')
: $is_closed ? t8('The billing period has already been locked.')
: undef,
],
], # end of combobox "more"
);
}
}
1;
js/kivi.AR.js
namespace('kivi.AR', function(ns){
'use strict';
ns.check_fields_before_posting = function() {
var errors = [];
if ($('#transdate').val() === '')
errors.push(kivi.t8('Invoice Date missing!'));
if ($('#duedate').val() === '')
errors.push(kivi.t8('Due Date missing!'));
if ($('#customer').val() === '')
errors.push(kivi.t8('Customer missing!'));
if (errors.length === 0)
return true;
alert(errors.join(' '));
return false;
};
});
js/locale/de.js
"Create new quotation/order":"Neues Angebot/neuen Auftrag anlegen",
"Create new qutoation/order":"Neues Angebot/neuen Auftrag anlegen",
"Create new version":"Neue Version anlegen",
"Customer missing!":"Kundenname fehlt!",
"Database Connection Test":"Test der Datenbankverbindung",
"Delete":"Löschen",
"Delete picture":"Bild löschen",
......
"Do you really want to unimport the selected documents?":"Wollen Sie wirklich diese Dateien an die Quelle zurückgeben?",
"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?",
"Download picture":"Bild herunterladen",
"Due Date missing!":"Fälligkeitsdatum fehlt!",
"Edit":"Bearbeiten",
"Edit article/section assignments":"Zuweisung Artikel/Abschnitte bearbeiten",
"Edit custom shipto":"Individuelle Lieferadresse bearbeiten",
......
"History":"Historie",
"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.",
"Import documents from #1":"Importiere Dateien von Quelle '#1'",
"Invoice Date missing!":"Rechnungsdatum fehlt!",
"Map":"Karte",
"More than one file selected, please set only one checkbox!":"Mehr als ein Element selektiert, bitte nur eine Box anklicken",
"No":"Nein",
locale/de/all
'Invoice with Storno (abbreviation)' => 'R(S)',
'Invoices' => 'Rechnungen',
'Invoices can only be changed on the day they are posted.' => 'Rechnungen können nur am Buchungstag geändert werden.',
'Invoices with payments cannot be canceled.' => 'Rechnungen mit Zahlungen können nicht storniert werden.',
'Invoices, Credit Notes & AR Transactions' => 'Rechnungen, Gutschriften & Debitorenbuchungen',
'Is Searchable' => 'Durchsuchbar',
'Is this a summary account to record' => 'Sammelkonto für',
......
'Result' => 'Ergebnis',
'Revenue' => 'Erlöskonto',
'Revenue Account' => 'Erlöskonto',
'Reversal invoices cannot be canceled.' => 'Stornorechnungen können nicht storniert werden.',
'Revert to version' => 'Auf Version zurücksetzen',
'Review of Aging list' => 'Altersstrukturliste',
'Right' => 'Rechts',
......
'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.',
'This has been changed in this version.' => 'Ab dieser Version ist dies nicht mehr so.',
'This invoice has already been posted.' => 'Die Rechnung wurde bereits gebucht.',
'This invoice has been canceled already.' => 'Die Rechnung wurde bereits storniert.',
'This invoice has not been posted yet.' => 'Die Rechnung wurde noch nicht gebucht.',
'This invoice\'s dunning level: #1' => 'Mahnstufe dieser Rechnung: #1',
'This is a very critical problem.' => 'Dieses Problem ist sehr schwerwiegend.',
templates/webpages/ar/form_footer.html
<input type="hidden" name="callback" value="[% callback | html %]">
[% P.hidden_tag('draft_id', draft_id) %]
[% P.hidden_tag('draft_description', draft_description) %]
<br>
<input class="submit" type="submit" name="action" id="update_button" value="[% 'Update' | $T8 %]">
[% IF ( show_storno_button ) %]
<input class="submit" type="submit" name="action" value="[% 'Storno' | $T8 %]">
[% END %]
[% IF ( id ) %]
[% IF ( radier ) %]
<input class="submit" type="submit" name="action" value="[% 'Post' | $T8 %]">
<input class="submit" type="submit" name="action" value="[% 'Delete' | $T8 %]">
[% END %]
[% IF ( !is_closed ) %]
<input class="submit" type="submit" name="action" value="[% 'Use As New' | $T8 %]">
[% END %]
<input class="submit" type="submit" name="action" value="[% 'Post Payment' | $T8 %]">
<input type="button" class="submit" onclick="follow_up_window()" value="[% 'Follow-Up' | $T8 %]">
<input type="button" class="submit" onclick="set_history_window([% id %], 'glid');" name="history" id="history" value="[% 'history' | $T8 %]">
[% ELSE %]
[% IF ( !is_closed ) %]
<input class="submit" type="submit" name="action" value="[% 'Post' | $T8 %]">
[% L.button_tag('kivi.Draft.popup("ar", "invoice", "' _ draft_id _ '", "' _ draft_description _ '")', LxERP.t8('Drafts')) %]
[% END %]
[% END %]
[% IF ( show_mark_as_paid_button ) %]
[% 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?')) %]
[% END %]
[% L.button_tag("kivi.RecordTemplate.popup('ar_transaction')", LxERP.t8("Record templates")) %]
</form>
<script type="text/javascript">

Auch abrufbar als: Unified diff