X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=eb344360d7c03fca5ad4f6fc36fe68a264ad9f0d;hb=e6ef45f2d8a980a68bd54df8c2afce4e0203c289;hp=7f670582c958dd88a3d19a7a7207b3d8f7f6ef2c;hpb=98662ad2b031a81c88ce6da0babf6f9d0b37059a;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 7f670582c..eb344360d 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -36,7 +36,7 @@ use SL::IS; use SL::PE; use Data::Dumper; -require "$form->{path}/arap.pl"; +require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; require "bin/mozilla/drafts.pl"; @@ -79,6 +79,7 @@ sub add { # saving the history if(!exists $form->{addition} && ($form->{id} ne "")) { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "ADDED"; $form->save_history($form->dbconnect(\%myconfig)); } @@ -86,7 +87,7 @@ sub add { $form->{title} = "Add"; $form->{callback} = - "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}" + "$form->{script}?action=add&login=$form->{login}&password=$form->{password}" unless $form->{callback}; AR->get_transdate(\%myconfig, $form); @@ -102,7 +103,7 @@ sub edit { # show history button $form->{javascript} = qq||; #/show hhistory button - + $form->{javascript} .= qq||; $form->{title} = "Edit"; &create_links; @@ -322,7 +323,7 @@ sub form_header { # show history button js $form->{javascript} .= qq||; #/show history button js - + $form->{javascript} .= qq||; $readonly = ($form->{id}) ? "readonly" : ""; $form->{radier} = @@ -388,7 +389,9 @@ sub form_header { $customer = ($form->{selectcustomer}) - ? qq|| + ? qq|| : qq||; $employee = qq| @@ -468,18 +471,18 @@ sub form_header { $form->{fokus} = "arledger.customer"; # use JavaScript Calendar or not - $form->{jsscript} = $jscalendar; + $form->{jsscript} = 1; $jsscript = ""; if ($form->{jsscript}) { # with JavaScript Calendar $button1 = qq| - {transdate}> + text('button') . qq|> |; $button2 = qq| - {duedate}> + text('button') . qq|> |; @@ -492,15 +495,21 @@ sub form_header { # without JavaScript Calendar $button1 = - qq|{transdate}>|; + qq||; $button2 = - qq|{duedate}>|; + qq||; } - $form->header; + $form->{javascript} .= + qq|| . + qq||; + $form->header; + $onload = qq|focus()|; + $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; + $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; print qq| - +
{script}> @@ -525,7 +534,7 @@ sub form_header { - + @@ -785,12 +794,12 @@ $jsscript |; $column_data{paid} = - qq||; + qq||; $column_data{AR_paid} = qq||; $column_data{exchangerate} = qq||; $column_data{datepaid} = - qq||; $column_data{source} = qq||; @@ -838,7 +847,6 @@ sub form_footer { -{path}> {login}> {password}> | @@ -861,50 +869,38 @@ 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') && !$form->{paid_1}); + + 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')); } } if ($form->{menubar}) { - require "$form->{path}/menu.pl"; + require "bin/mozilla/menu.pl"; &menubar; } # 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 " @@ -1011,7 +1007,7 @@ sub update { sub post_payment { $lxdebug->enter_sub(); for $i (1 .. $form->{paidaccounts}) { - if ($form->{"paid_$i"}) { + if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) { $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig); $form->isblank("datepaid_$i", $locale->text('Payment date missing!')); @@ -1048,9 +1044,10 @@ sub post { $closedto = $form->datetonum($form->{closedto}, \%myconfig); $transdate = $form->datetonum($form->{transdate}, \%myconfig); + $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto); - $form->error($locale->text('Cannot post transaction for a closed period!')) - if ($transdate <= $closedto); + $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}); @@ -1067,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!')); } } } @@ -1088,8 +1083,9 @@ sub post { if (AR->post_transaction(\%myconfig, \%$form)) { # saving the history if(!exists $form->{addition} && $form->{id} ne "") { - $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}; @@ -1106,6 +1102,7 @@ sub post_as_new { $form->{postasnew} = 1; # saving the history if(!exists $form->{addition} && $form->{id} ne "") { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "POSTED AS NEW"; $form->save_history($form->dbconnect(\%myconfig)); } @@ -1170,6 +1167,7 @@ sub yes { if (AR->delete_transaction(\%myconfig, \%$form, $spool)) { # saving the history if(!exists $form->{addition}) { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "DELETED"; $form->save_history($form->dbconnect(\%myconfig)); } @@ -1213,20 +1211,22 @@ sub search { | if $form->{selectdepartment}; $form->{title} = $locale->text('AR Transactions'); - + + $form->{javascript} .= qq||; + # use JavaScript Calendar or not - $form->{jsscript} = $jscalendar; + $form->{jsscript} = 1; $jsscript = ""; if ($form->{jsscript}) { # with JavaScript Calendar $button1 = qq| - |; $button2 = qq| - |; @@ -1239,9 +1239,9 @@ sub search { # without JavaScript Calendar $button1 = qq| - |; + |; $button2 = qq| - |; + |; } $form->get_lists("projects" => { "key" => "ALL_PROJECTS", @@ -1259,9 +1259,11 @@ sub search { $form->{fokus} = "search.customer"; $form->header; - + $onload = qq|focus()|; + $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; + $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; print qq| - +{script}> @@ -1284,6 +1286,10 @@ sub search { + + + + @@ -1360,6 +1366,8 @@ sub search { + +
| . $locale->text('Customer') . qq|$customer$customer {"paid_$i"}>${selectAR_paid}$exchangerate{"datepaid_$i"}> + qq| + text('button') . qq|> + text('button') . qq|> | . $locale->text('Order Number') . qq|
| . $locale->text('Transaction description') . qq|
| . $locale->text('Notes') . qq| | . $locale->text('Subtotal') . qq| | . $locale->text('Project Number') . qq|| . $locale->text('Transaction description') . qq|
@@ -1374,7 +1382,6 @@ sub search { {nextsub}> -{path}> {login}> {password}> @@ -1403,7 +1410,7 @@ sub ar_transactions { AR->ar_transactions(\%myconfig, \%$form); $callback = - "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + "$form->{script}?action=ar_transactions&login=$form->{login}&password=$form->{password}"; $href = $callback; if ($form->{customer}) { @@ -1436,6 +1443,12 @@ sub ar_transactions { $option .= "\n
" if $option; $option .= $locale->text('Notes') . " : $form->{notes}"; } + if ($form->{transaction_description}) { + $callback .= "&transaction_description=" . $form->escape($form->{transaction_description}, 1); + $href .= "&transaction_description=" . $form->escape($form->{transaction_description}); + $option .= "\n
" if $option; + $option .= $locale->text('Transaction description') . " : $form->{transaction_description}"; + } if ($form->{transdatefrom}) { $callback .= "&transdatefrom=$form->{transdatefrom}"; @@ -1472,7 +1485,7 @@ sub ar_transactions { @columns = qw(transdate id type invnumber ordnumber name netamount tax amount paid - datepaid due duedate notes employee shippingpoint shipvia + datepaid due duedate transaction_description notes employee shippingpoint shipvia globalprojectnumber); $form->{"l_type"} = "Y"; @@ -1548,6 +1561,8 @@ sub ar_transactions { . ""; $column_header{globalprojectnumber} = qq|| . $locale->text('Project Number') . qq||; + $column_header{transaction_description} = + "" . $locale->text('Transaction description') . ""; $form->{title} = $locale->text('AR Transactions'); @@ -1633,12 +1648,18 @@ sub ar_transactions { $module = ($ar->{invoice}) ? "is.pl" : $form->{script}; $column_data{invnumber} = - "{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}"; + "{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}"; + + my $is_storno = $ar->{storno} && IS->is_storno(\%myconfig, $form, 'ar'); + my $has_storno = $ar->{storno} && !$is_storno; + $column_data{type} = "" . - ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") : - $ar->{amount} < 0 ? - $locale->text("Credit note (one letter abbreviation)") : - $locale->text("Invoice (one letter abbreviation)")) . ""; + ($has_storno ? $locale->text("Invoice with Storno (abbreviation)") : + $is_storno ? $locale->text("Storno (one letter abbreviation)") : + $ar->{amount} < 0 ? $locale->text("Credit note (one letter abbreviation)") : + $ar->{invoice} ? $locale->text("Invoice (one letter abbreviation)") : + $locale->text("AR Transaction (abbreviation)")) + . ""; $column_data{ordnumber} = "$ar->{ordnumber} "; $column_data{name} = "$ar->{name}"; $ar->{notes} =~ s/\r\n/
/g; @@ -1648,6 +1669,8 @@ sub ar_transactions { $column_data{employee} = "$ar->{employee} "; $column_data{globalprojectnumber} = "" . H($ar->{globalprojectnumber}) . ""; + $column_data{transaction_description} = + "" . H($ar->{transaction_description}) . ""; $i++; $i %= 2; @@ -1708,7 +1731,6 @@ sub ar_transactions { -{path}> {login}> {password}> @@ -1762,3 +1784,44 @@ 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!")); + } + + # 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(); +}