projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Doku: ZUGFeRD Feature Vorbedingung und Erläuterung
[kivitendo-erp.git]
/
bin
/
mozilla
/
io.pl
diff --git
a/bin/mozilla/io.pl
b/bin/mozilla/io.pl
index
0cde59c
..
a89a311
100644
(file)
--- a/
bin/mozilla/io.pl
+++ b/
bin/mozilla/io.pl
@@
-40,7
+40,7
@@
use Carp;
use CGI;
use List::MoreUtils qw(any uniq apply);
use Carp;
use CGI;
use List::MoreUtils qw(any uniq apply);
-use List::Util qw(min max first);
+use List::Util qw(
sum
min max first);
use List::UtilsBy qw(sort_by uniq_by);
use SL::ClientJS;
use List::UtilsBy qw(sort_by uniq_by);
use SL::ClientJS;
@@
-919,7
+919,6
@@
sub order {
$item->price_factor_id(undef) if !$item->price_factor_id;
$item->project_id(undef) if !$item->project_id;
$item->price_factor_id(undef) if !$item->price_factor_id;
$item->project_id(undef) if !$item->project_id;
- $item->discount($item->discount/100.0);
# autovivify all cvars that are not in the form (cvars_by_config can do it).
# workaround to pre-parse number-cvars (parse_custom_variable_values does not parse number values).
# autovivify all cvars that are not in the form (cvars_by_config can do it).
# workaround to pre-parse number-cvars (parse_custom_variable_values does not parse number values).
@@
-1661,7
+1660,7
@@
sub relink_accounts {
$form->{"taxaccounts"} =~ s/\s*$//;
$form->{"taxaccounts"} =~ s/^\s*//;
foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
$form->{"taxaccounts"} =~ s/\s*$//;
$form->{"taxaccounts"} =~ s/^\s*//;
foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
- map({ delete($form->{"${accno}_${_}"}); } qw(rate description taxnumber
));
+ map({ delete($form->{"${accno}_${_}"}); } qw(rate description taxnumber
tax_id)); # add tax_id ?
}
$form->{"taxaccounts"} = "";
}
$form->{"taxaccounts"} = "";
@@
-1852,7
+1851,7
@@
sub _remove_billed_or_delivered_rows {
# TODO: both of these are makeshift so that price sources can operate on rdbo objects. if
# this ever gets rewritten in controller style, throw this out
sub _make_record_item {
# TODO: both of these are makeshift so that price sources can operate on rdbo objects. if
# this ever gets rewritten in controller style, throw this out
sub _make_record_item {
- my ($row) = @_;
+ my ($row
, %params
) = @_;
my $class = {
sales_order => 'OrderItem',
my $class = {
sales_order => 'OrderItem',
@@
-1922,6
+1921,11
@@
sub _make_record_item {
$obj->part(SL::DB::Part->load_cached($::form->{"id_$row"}));
}
$obj->part(SL::DB::Part->load_cached($::form->{"id_$row"}));
}
+ if ($obj->can('qty')) {
+ $obj->qty( $obj->qty * $params{factor});
+ $obj->base_qty($obj->base_qty * $params{factor});
+ }
+
return $obj;
}
return $obj;
}
@@
-1941,6
+1945,8
@@
sub _make_record {
: do { die 'unknown invoice type' };
}
: do { die 'unknown invoice type' };
}
+ my $factor = $::form->{type} =~ m{credit_note} ? -1 : 1;
+
return unless $class;
$class = 'SL::DB::' . $class;
return unless $class;
$class = 'SL::DB::' . $class;
@@
-1971,12
+1977,21
@@
sub _make_record {
my @items;
for my $i (1 .. $::form->{rowcount}) {
next unless $::form->{"id_$i"};
my @items;
for my $i (1 .. $::form->{rowcount}) {
next unless $::form->{"id_$i"};
- push @items, _make_record_item($i);
+ push @items, _make_record_item($i
, factor => $factor
);
}
$obj->items(@items) if @items;
$obj->is_sales(!!$obj->customer_id) if $class eq 'SL::DB::DeliveryOrder';
}
$obj->items(@items) if @items;
$obj->is_sales(!!$obj->customer_id) if $class eq 'SL::DB::DeliveryOrder';
+ if ($class eq 'SL::DB::Invoice') {
+ my $paid = $factor *
+ sum
+ map { $::form->parse_amount(\%::myconfig, $::form->{$_}) }
+ grep { m{^paid_\d+$} }
+ keys %{ $::form };
+ $obj->paid($paid);
+ }
+
return $obj;
}
return $obj;
}
@@
-1985,7
+2000,7
@@
sub setup_sales_purchase_print_options {
$print_form->{printers} = SL::DB::Manager::Printer->get_all_sorted;
$print_form->{languages} = SL::DB::Manager::Language->get_all_sorted;
$print_form->{printers} = SL::DB::Manager::Printer->get_all_sorted;
$print_form->{languages} = SL::DB::Manager::Language->get_all_sorted;
- $print_form->{$_} = $::form->{$_} for qw(type media language_id printer_id storno);
+ $print_form->{$_} = $::form->{$_} for qw(type media language_id printer_id storno
formname groupitems
);
return SL::Helper::PrintOptions->get_print_options(
form => $print_form,
return SL::Helper::PrintOptions->get_print_options(
form => $print_form,
@@
-2120,7
+2135,12
@@
sub _maybe_attach_zugferd_data {
my $record = _make_record();
my $record = _make_record();
- return if !$record || !$record->can('create_pdf_a_print_options') || !$record->can('create_zugferd_data');
+ return if !$record
+ || !$record->can('customer')
+ || !$record->customer
+ || !$record->can('create_pdf_a_print_options')
+ || !$record->can('create_zugferd_data')
+ || !$record->customer->create_zugferd_invoices_for_this_customer;
eval {
my $xmlfile = File::Temp->new;
eval {
my $xmlfile = File::Temp->new;