projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
CsvImport: Report-Begrenzung: Option "Nur Warnungen und Fehler" umbenannt. …
[kivitendo-erp.git]
/
bin
/
mozilla
/
io.pl
diff --git
a/bin/mozilla/io.pl
b/bin/mozilla/io.pl
index
7186533
..
377423d
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;
@@
-1852,7
+1852,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
+1922,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
+1946,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
+1978,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
+2001,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,
@@
-2118,11
+2134,14
@@
sub send_sales_purchase_email {
sub _maybe_attach_zugferd_data {
my ($form) = @_;
sub _maybe_attach_zugferd_data {
my ($form) = @_;
- return if !$::instance_conf->get_create_zugferd_invoices;
-
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;