Revision 4f0087b8
Von Bernd Bleßmann vor etwa 3 Jahren hinzugefügt
SL/DN.pm | ||
---|---|---|
418 | 418 |
$self->print_dunning($myconfig, $form, $dunning_id, $dbh); |
419 | 419 |
|
420 | 420 |
if ($print_invoice) { |
421 |
$self->print_original_invoice($myconfig, $form, $_) for @invoice_ids; |
|
421 |
$self->print_original_invoice($myconfig, $form, $dunning_id, $_) for @invoice_ids;
|
|
422 | 422 |
} |
423 | 423 |
|
424 | 424 |
if ($send_email) { |
... | ... | |
862 | 862 |
|
863 | 863 |
$dunning_id =~ s|[^\d]||g; |
864 | 864 |
|
865 |
my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates, @dunned_invoices);
|
|
865 |
my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates); |
|
866 | 866 |
if ($form->{"language_id"}) { |
867 | 867 |
($language_tc, $output_numberformat, $output_dateformat, $output_longdates) = |
868 | 868 |
AM->get_language_details($myconfig, $form, $form->{language_id}); |
... | ... | |
884 | 884 |
ar.transdate, ar.duedate, ar.customer_id, |
885 | 885 |
ar.invnumber, ar.ordnumber, ar.cp_id, |
886 | 886 |
ar.amount, ar.netamount, ar.paid, |
887 |
ar.employee_id, ar.salesman_id, ar.id AS dunned_invoice_id,
|
|
887 |
ar.employee_id, ar.salesman_id, |
|
888 | 888 |
(SELECT cu.name FROM currencies cu WHERE cu.id = ar.currency_id) AS curr, |
889 | 889 |
(SELECT description from department WHERE id = ar.department_id) AS department, |
890 | 890 |
ar.amount - ar.paid AS open_amount, |
... | ... | |
906 | 906 |
map { $ref->{$_} = $form->format_amount($myconfig, $ref->{$_}, 2) } qw(amount netamount paid open_amount fee interest linetotal); |
907 | 907 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
908 | 908 |
map { push @{ $form->{TEMPLATE_ARRAYS}->{"dn_$_"} }, $ref->{$_} } keys %$ref; |
909 |
push @dunned_invoices, {id => $ref->{dunned_invoice_id}, invnumber => $ref->{invnumber}}; |
|
910 | 909 |
} |
911 | 910 |
$sth->finish(); |
912 | 911 |
|
... | ... | |
1020 | 1019 |
# this generates the file in the spool directory |
1021 | 1020 |
$form->parse_template($myconfig); |
1022 | 1021 |
|
1023 |
# save dunning pdf in filemanagement/webdav for each invoice |
|
1024 |
foreach my $dunned_invoice (@dunned_invoices) { |
|
1025 |
if ($::instance_conf->get_doc_storage) { |
|
1026 |
SL::File->save( |
|
1027 |
object_id => $dunned_invoice->{id}, |
|
1028 |
object_type => $form->{attachment_type}, |
|
1029 |
mime_type => 'application/pdf', |
|
1030 |
source => 'created', |
|
1031 |
file_type => 'document', |
|
1032 |
file_name => $form->{attachment_filename}, |
|
1033 |
file_path => "${spool}/$filename", |
|
1034 |
); |
|
1035 |
} |
|
1036 |
|
|
1037 |
if ($::instance_conf->get_webdav_documents) { |
|
1038 |
my $webdav = SL::Webdav->new( |
|
1039 |
type => 'invoice', |
|
1040 |
number => $dunned_invoice->{invnumber}, |
|
1041 |
); |
|
1042 |
my $webdav_file = SL::Webdav::File->new( |
|
1043 |
webdav => $webdav, |
|
1044 |
filename => $form->{attachment_filename}, |
|
1045 |
); |
|
1046 |
$webdav_file->store(file => "${spool}/$filename"); |
|
1047 |
} |
|
1022 |
# save dunning pdf in filemanagement/webdav |
|
1023 |
if ($::instance_conf->get_doc_storage) { |
|
1024 |
SL::File->save( |
|
1025 |
object_id => $dunning_id, |
|
1026 |
object_type => 'dunning', |
|
1027 |
mime_type => 'application/pdf', |
|
1028 |
source => 'created', |
|
1029 |
file_type => 'document', |
|
1030 |
file_name => $form->{attachment_filename}, |
|
1031 |
file_path => "${spool}/$filename", |
|
1032 |
); |
|
1033 |
} |
|
1034 |
if ($::instance_conf->get_webdav_documents) { |
|
1035 |
my $webdav = SL::Webdav->new( |
|
1036 |
type => 'dunning', |
|
1037 |
number => $dunning_id, |
|
1038 |
); |
|
1039 |
my $webdav_file = SL::Webdav::File->new( |
|
1040 |
webdav => $webdav, |
|
1041 |
filename => $form->{attachment_filename}, |
|
1042 |
); |
|
1043 |
$webdav_file->store(file => "${spool}/$filename"); |
|
1048 | 1044 |
} |
1049 | 1045 |
|
1050 | 1046 |
$main::lxdebug->leave_sub(); |
... | ... | |
1148 | 1144 |
push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'path' => "${spool}/$filename", |
1149 | 1145 |
'name' => $attachment_filename }; |
1150 | 1146 |
|
1151 |
# save dunning fee pdf in filemanagement/webdav for each dunned invoice |
|
1152 |
if ($::instance_conf->get_doc_storage || $::instance_conf->get_webdav_documents) { |
|
1153 |
$query = qq|SELECT trans_id, invnumber FROM dunning LEFT JOIN ar ON (ar.id = trans_id) WHERE dunning_id = ?|; |
|
1154 |
my $dunned_invoices = selectall_hashref_query($form, $dbh, $query, $dunning_id); |
|
1155 |
|
|
1156 |
foreach my $dunned_invoice (@$dunned_invoices) { |
|
1157 |
if ($::instance_conf->get_doc_storage) { |
|
1158 |
SL::File->save( |
|
1159 |
object_id => $dunned_invoice->{trans_id}, |
|
1160 |
object_type => 'dunning', |
|
1161 |
mime_type => 'application/pdf', |
|
1162 |
source => 'created', |
|
1163 |
file_type => 'document', |
|
1164 |
file_name => $attachment_filename, |
|
1165 |
file_path => "${spool}/$filename", |
|
1166 |
); |
|
1167 |
} |
|
1168 |
|
|
1169 |
if ($::instance_conf->get_webdav_documents) { |
|
1170 |
my $webdav = SL::Webdav->new( |
|
1171 |
type => 'invoice', |
|
1172 |
number => $dunned_invoice->{invnumber}, |
|
1173 |
); |
|
1174 |
my $webdav_file = SL::Webdav::File->new( |
|
1175 |
webdav => $webdav, |
|
1176 |
filename => $attachment_filename, |
|
1177 |
); |
|
1178 |
$webdav_file->store(file => "${spool}/$filename"); |
|
1179 |
} |
|
1180 |
} |
|
1147 |
# save dunning fee pdf in filemanagement/webdav |
|
1148 |
if ($::instance_conf->get_doc_storage) { |
|
1149 |
SL::File->save( |
|
1150 |
object_id => $dunning_id, |
|
1151 |
object_type => 'dunning', |
|
1152 |
mime_type => 'application/pdf', |
|
1153 |
source => 'created', |
|
1154 |
file_type => 'document', |
|
1155 |
file_name => $attachment_filename, |
|
1156 |
file_path => "${spool}/$filename", |
|
1157 |
); |
|
1158 |
} |
|
1159 |
if ($::instance_conf->get_webdav_documents) { |
|
1160 |
my $webdav = SL::Webdav->new( |
|
1161 |
type => 'dunning', |
|
1162 |
number => $dunning_id, |
|
1163 |
); |
|
1164 |
my $webdav_file = SL::Webdav::File->new( |
|
1165 |
webdav => $webdav, |
|
1166 |
filename => $attachment_filename, |
|
1167 |
); |
|
1168 |
$webdav_file->store(file => "${spool}/$filename"); |
|
1181 | 1169 |
} |
1182 | 1170 |
|
1183 | 1171 |
$main::lxdebug->leave_sub(); |
... | ... | |
1205 | 1193 |
} |
1206 | 1194 |
|
1207 | 1195 |
sub print_original_invoice { |
1208 |
my ($self, $myconfig, $form, $invoice_id) = @_; |
|
1196 |
my ($self, $myconfig, $form, $dunning_id, $invoice_id) = @_;
|
|
1209 | 1197 |
# get one invoice as object and print to pdf |
1210 | 1198 |
my $invoice = SL::DB::Invoice->new(id => $invoice_id)->load; |
1211 | 1199 |
|
... | ... | |
1252 | 1240 |
|
1253 | 1241 |
$form->{recipient_locale} = $saved_reicpient_locale; |
1254 | 1242 |
|
1255 |
# save original invoice pdf in filemanagement/webdav for dunned invoice
|
|
1243 |
# save original invoice pdf in filemanagement/webdav for dunning
|
|
1256 | 1244 |
if ($::instance_conf->get_doc_storage) { |
1257 | 1245 |
SL::File->save( |
1258 |
object_id => $invoice_id,
|
|
1259 |
object_type => 'dunning_orig_invoice',
|
|
1246 |
object_id => $dunning_id,
|
|
1247 |
object_type => 'dunning', |
|
1260 | 1248 |
mime_type => 'application/pdf', |
1261 | 1249 |
source => 'created', |
1262 | 1250 |
file_type => 'document', |
... | ... | |
1266 | 1254 |
} |
1267 | 1255 |
if ($::instance_conf->get_webdav_documents) { |
1268 | 1256 |
my $webdav = SL::Webdav->new( |
1269 |
type => 'invoice',
|
|
1270 |
number => $invoice->invnumber,
|
|
1257 |
type => 'dunning',
|
|
1258 |
number => $dunning_id,
|
|
1271 | 1259 |
); |
1272 | 1260 |
my $webdav_file = SL::Webdav::File->new( |
1273 | 1261 |
webdav => $webdav, |
Auch abrufbar als: Unified diff
Mahnungen: DMS/WebDAV: erzeugte Dokumente zum Mahnlauf ablegen …
und nicht zur gemahnten Rechnung.