From: Sven Schöling Date: Thu, 24 May 2007 15:49:58 +0000 (+0000) Subject: Stornomoeglichkeit fuer Debitorenrechnungen X-Git-Tag: release-2.4.3^2~259 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=102600f0d1e5fc7b3acb620bde45bfd34f31f1cc;p=kivitendo-erp.git Stornomoeglichkeit fuer Debitorenrechnungen (plus die ueblichen Codekosmetika) --- diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index d218ff6ab..97eef052b 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -869,35 +869,28 @@ sub form_footer { $transdate = $form->datetonum($form->{transdate}, \%myconfig); $closedto = $form->datetonum($form->{closedto}, \%myconfig); - print qq| -|; + # ToDO: insert a global check for stornos, so that a storno is only possible a limited time after saving it + print qq||; + if $form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar'); + + print qq|\n|; if ($form->{id}) { if ($form->{radier}) { print qq| - - - |; + + |; } if ($transdate > $closedto) { print qq| - - |; + |; } print qq| - - |; + |; } else { if ($transdate > $closedto) { - print qq| | . - NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), - '-class' => 'submit')); + print qq| | . + NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit')); } } @@ -907,12 +900,7 @@ sub form_footer { } # button for saving history if($form->{id} ne "") { - print qq| - {id} - . qq|); name=history id=history value=| - . $locale->text('history') - . qq|>|; + print qq|{id}); name=history id=history value=| . $locale->text('history') . qq|>|; } # /button for saving history print " @@ -1058,15 +1046,8 @@ sub post { $transdate = $form->datetonum($form->{transdate}, \%myconfig); $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto); - my $zero_amount_posting = 1; - for $i (1 .. $form->{rowcount}) { - if ($form->parse_amount(\%myconfig, $form->{"amount_$i"})) { - $zero_amount_posting = 0; - last; - } - } - - $form->error($locale->text('Zero amount posting!')) if $zero_amount_posting; + $form->error($locale->text('Zero amount posting!')) + unless grep $_*1, map $form->parse_amount(\%myconfig, $form->{"amount_$_"}), 1..$form->{rowcount}; $form->isblank("exchangerate", $locale->text('Exchangerate missing!')) if ($form->{currency} ne $form->{defaultcurrency}); @@ -1083,10 +1064,8 @@ sub post { if ($datepaid <= $closedto); if ($form->{currency} ne $form->{defaultcurrency}) { - $form->{"exchangerate_$i"} = $form->{exchangerate} - if ($transdate == $datepaid); - $form->isblank("exchangerate_$i", - $locale->text('Exchangerate for payment missing!')); + $form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid); + $form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!')); } } } @@ -1104,9 +1083,9 @@ sub post { if (AR->post_transaction(\%myconfig, \%$form)) { # saving the history if(!exists $form->{addition} && $form->{id} ne "") { - $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; - $form->{addition} = "POSTED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->{snumbers} = "invnumber_$form->{invnumber}"; + $form->{addition} = "POSTED"; + $form->save_history($form->dbconnect(\%myconfig)); } # /saving the history remove_draft() if $form->{remove_draft}; @@ -1671,7 +1650,7 @@ sub ar_transactions { $column_data{invnumber} = "{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}"; - my $is_storno = $ar->{storno} && ($ar->{invnumber} =~ /^Storno zu/); + my $is_storno = $ar->{storno} && IS->is_storno(\%myconfig, $form, 'ar'); #($ar->{invnumber} =~ /^Storno zu/); # ToDO: fix this my $has_storno = $ar->{storno} && !$is_storno; $column_data{type} = "" . @@ -1805,3 +1784,55 @@ sub ar_subtotal { $lxdebug->leave_sub(); } + + +sub storno { + $lxdebug->enter_sub(); + + if (IS->has_storno(\%myconfig, $form, 'ar')) { + $form->{title} = $locale->text("Cancel Accounts Receivables Transaction"); + $form->error($locale->text("Transaction has already been cancelled!")); + } + + # ToDO: + # - nicht anzeigen wenn neue rechnung + # - nicht anzeigen wenn schons toniert + # - nicht anziegen wenn zahlungen da + + +# my %keep_keys = map { $_, 1 } qw(login password id stylesheet); +# map { delete $form->{$_} unless $keep_keys{$_} } keys %{ $form }; +# prepare_transaction(); + + # negate amount/taxes + for my $i (1 .. $form->{rowcount}) { + $form->{"amount_$i"} *= -1; + $form->{"tax_$i"} *= -1; + } + + # format things + for my $i (1 .. $form->{rowcount}) { + for (qw(amount tax)) { + $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) if $form->{"${_}_$i"}; + } + } + + $form->{storno} = 1; + $form->{storno_id} = $form->{id}; + $form->{id} = 0; + + $form->{invnumber} = "Storno-" . $form->{invnumber}; + + post(); + + # saving the history + if(!exists $form->{addition} && $form->{id} ne "") { + $form->{snumbers} = "ordnumber_$form->{ordnumber}"; + $form->{addition} = "STORNO"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history + + $lxdebug->leave_sub(); + +} diff --git a/locale/de/all b/locale/de/all index d06a9a86b..3fba12eec 100644 --- a/locale/de/all +++ b/locale/de/all @@ -210,6 +210,7 @@ aktualisieren wollen?', 'C' => 'G', 'CANCELED' => 'Storniert', 'Calculate' => 'Berechnen', + 'Cancel Accounts Receivables Transaction' => 'Debitorenbuchung stornieren', 'Cancel General Ledger Transaction' => 'Buchung stornieren', 'Cannot create Lock!' => 'System kann nicht gesperrt werden!', 'Cannot delete account!' => 'Konto kann nicht gelöscht werden!', @@ -823,7 +824,6 @@ gestartet', 'Port' => 'Port', 'Post' => 'Buchen', 'Post Payment' => 'Zahlung buchen', - 'Post as new' => 'Neu buchen', 'Postscript' => 'Postscript', 'Posustva_coa' => 'USTVA Kennz.', 'Preferences' => 'Benutzereinstellungen', diff --git a/locale/de/ar b/locale/de/ar index 0b069e412..c502979c5 100644 --- a/locale/de/ar +++ b/locale/de/ar @@ -19,6 +19,7 @@ $self->{texts} = { 'Bin List' => 'Lagerliste', 'Bis' => 'bis', 'CANCELED' => 'Storniert', + 'Cancel Accounts Receivables Transaction' => 'Debitorenbuchung stornieren', 'Cannot delete transaction!' => 'Buchung kann nicht gelöscht werden!', 'Cannot post payment for a closed period!' => 'Es können keine Zahlungen für abgeschlossene Bücher gebucht werden!', 'Cannot post payment!' => 'Zahlung kann nicht gebucht werden!', @@ -149,6 +150,7 @@ $self->{texts} = { 'Shipping Point' => 'Versandort', 'Skip' => 'Überspringen', 'Source' => 'Beleg', + 'Storno' => 'Storno', 'Storno (one letter abbreviation)' => 'S', 'Storno Invoice' => 'Stornorechnung', 'Storno Packing List' => 'Stornolieferschein', @@ -160,6 +162,7 @@ $self->{texts} = { 'Total' => 'Summe', 'Transaction deleted!' => 'Buchung gelöscht!', 'Transaction description' => 'Vorgangsbezeichnung', + 'Transaction has already been cancelled!' => 'Diese Buchung wurde bereits storniert.', 'Transaction posted!' => 'Buchung verbucht!', 'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.', 'Type' => 'Typ', @@ -244,6 +247,7 @@ $self->{subs} = { 'set_longdescription' => 'set_longdescription', 'show_history' => 'show_history', 'show_vc_details' => 'show_vc_details', + 'storno' => 'storno', 'update' => 'update', 'use_as_template' => 'use_as_template', 'vendor_invoice' => 'vendor_invoice', @@ -258,6 +262,7 @@ $self->{subs} = { 'rechnung' => 'sales_invoice', 'entwurf_speichern' => 'save_draft', 'Überspringen' => 'skip', + 'storno' => 'storno', 'erneuern' => 'update', 'als_vorlage_verwenden' => 'use_as_template', 'ja' => 'yes', diff --git a/locale/de/gl b/locale/de/gl index f9d95c6c2..9fb59ea83 100644 --- a/locale/de/gl +++ b/locale/de/gl @@ -118,7 +118,6 @@ $self->{texts} = { 'Pick List' => 'Sammelliste', 'Please enter values' => 'Bitte Werte eingeben', 'Post' => 'Buchen', - 'Post as new' => 'Neu buchen', 'Previous transdate text' => 'wurde gespeichert am', 'Previous transnumber text' => 'Letzte Buchung mit der Buchungsnummer', 'Proforma Invoice' => 'Proformarechnung', @@ -239,7 +238,6 @@ $self->{subs} = { 'löschen' => 'delete', 'dialogbuchung' => 'gl_transaction', 'buchen' => 'post', - 'neu_buchen' => 'post_as_new', 'rechnung' => 'sales_invoice', 'storno' => 'storno', 'erneuern' => 'update',