Revision 1380222f
Von Bernd Bleßmann vor fast 4 Jahren hinzugefügt
SL/DN.pm | ||
---|---|---|
51 | 51 |
use SL::TransNumber; |
52 | 52 |
use SL::Util qw(trim); |
53 | 53 |
use SL::DB; |
54 |
use SL::Webdav; |
|
54 | 55 |
|
55 | 56 |
use File::Copy; |
56 | 57 |
|
... | ... | |
859 | 860 |
|
860 | 861 |
$dunning_id =~ s|[^\d]||g; |
861 | 862 |
|
862 |
my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates, @dunned_invoice_ids);
|
|
863 |
my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates, @dunned_invoices); |
|
863 | 864 |
if ($form->{"language_id"}) { |
864 | 865 |
($language_tc, $output_numberformat, $output_dateformat, $output_longdates) = |
865 | 866 |
AM->get_language_details($myconfig, $form, $form->{language_id}); |
... | ... | |
903 | 904 |
map { $ref->{$_} = $form->format_amount($myconfig, $ref->{$_}, 2) } qw(amount netamount paid open_amount fee interest linetotal); |
904 | 905 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
905 | 906 |
map { push @{ $form->{TEMPLATE_ARRAYS}->{"dn_$_"} }, $ref->{$_} } keys %$ref; |
906 |
push @dunned_invoice_ids, $ref->{dunned_invoice_id};
|
|
907 |
push @dunned_invoices, {id => $ref->{dunned_invoice_id}, invnumber => $ref->{invnumber}};
|
|
907 | 908 |
} |
908 | 909 |
$sth->finish(); |
909 | 910 |
|
... | ... | |
1017 | 1018 |
# this generates the file in the spool directory |
1018 | 1019 |
$form->parse_template($myconfig); |
1019 | 1020 |
|
1020 |
# save dunning pdf in filemanagement for each invoice |
|
1021 |
if ($::instance_conf->get_doc_storage) {
|
|
1022 |
foreach my $dunned_invoice_id (@dunned_invoice_ids) {
|
|
1021 |
# save dunning pdf in filemanagement/webdav for each invoice
|
|
1022 |
foreach my $dunned_invoice (@dunned_invoices) {
|
|
1023 |
if ($::instance_conf->get_doc_storage) {
|
|
1023 | 1024 |
SL::File->save( |
1024 |
object_id => $dunned_invoice_id,
|
|
1025 |
object_id => $dunned_invoice->{id},
|
|
1025 | 1026 |
object_type => $form->{attachment_type}, |
1026 | 1027 |
mime_type => 'application/pdf', |
1027 | 1028 |
source => 'created', |
... | ... | |
1030 | 1031 |
file_path => "${spool}/$filename", |
1031 | 1032 |
); |
1032 | 1033 |
} |
1034 |
|
|
1035 |
if ($::instance_conf->get_webdav_documents) { |
|
1036 |
my $webdav = SL::Webdav->new( |
|
1037 |
type => 'invoice', |
|
1038 |
number => $dunned_invoice->{invnumber}, |
|
1039 |
); |
|
1040 |
my $webdav_file = SL::Webdav::File->new( |
|
1041 |
webdav => $webdav, |
|
1042 |
filename => $form->{attachment_filename}, |
|
1043 |
); |
|
1044 |
$webdav_file->store(file => "${spool}/$filename"); |
|
1045 |
} |
|
1033 | 1046 |
} |
1034 | 1047 |
|
1035 | 1048 |
$main::lxdebug->leave_sub(); |
... | ... | |
1133 | 1146 |
push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'path' => "${spool}/$filename", |
1134 | 1147 |
'name' => $attachment_filename }; |
1135 | 1148 |
|
1136 |
# save dunning fee pdf in filemanagement for each dunned invoice |
|
1137 |
if ($::instance_conf->get_doc_storage) { |
|
1138 |
$query = qq|SELECT trans_id FROM dunning WHERE dunning_id = ?|; |
|
1139 |
my @dunned_invoice_ids = selectall_array_query($form, $dbh, $query, $dunning_id); |
|
1140 |
foreach my $dunned_invoice_id (@dunned_invoice_ids) { |
|
1141 |
SL::File->save( |
|
1142 |
object_id => $dunned_invoice_id, |
|
1143 |
object_type => 'dunning', |
|
1144 |
mime_type => 'application/pdf', |
|
1145 |
source => 'created', |
|
1146 |
file_type => 'document', |
|
1147 |
file_name => $attachment_filename, |
|
1148 |
file_path => "${spool}/$filename", |
|
1149 |
); |
|
1149 |
# save dunning fee pdf in filemanagement/webdav for each dunned invoice |
|
1150 |
if ($::instance_conf->get_doc_storage || $::instance_conf->get_webdav_documents) { |
|
1151 |
$query = qq|SELECT trans_id, invnumber FROM dunning LEFT JOIN ar ON (ar.id = trans_id) WHERE dunning_id = ?|; |
|
1152 |
my $dunned_invoices = selectall_hashref_query($form, $dbh, $query, $dunning_id); |
|
1153 |
|
|
1154 |
foreach my $dunned_invoice (@$dunned_invoices) { |
|
1155 |
if ($::instance_conf->get_doc_storage) { |
|
1156 |
SL::File->save( |
|
1157 |
object_id => $dunned_invoice->{trans_id}, |
|
1158 |
object_type => 'dunning', |
|
1159 |
mime_type => 'application/pdf', |
|
1160 |
source => 'created', |
|
1161 |
file_type => 'document', |
|
1162 |
file_name => $attachment_filename, |
|
1163 |
file_path => "${spool}/$filename", |
|
1164 |
); |
|
1165 |
} |
|
1166 |
|
|
1167 |
if ($::instance_conf->get_webdav_documents) { |
|
1168 |
my $webdav = SL::Webdav->new( |
|
1169 |
type => 'invoice', |
|
1170 |
number => $dunned_invoice->{invnumber}, |
|
1171 |
); |
|
1172 |
my $webdav_file = SL::Webdav::File->new( |
|
1173 |
webdav => $webdav, |
|
1174 |
filename => $attachment_filename, |
|
1175 |
); |
|
1176 |
$webdav_file->store(file => "${spool}/$filename"); |
|
1177 |
} |
|
1150 | 1178 |
} |
1151 | 1179 |
} |
1152 | 1180 |
|
... | ... | |
1222 | 1250 |
|
1223 | 1251 |
$form->{recipient_locale} = $saved_reicpient_locale; |
1224 | 1252 |
|
1225 |
# save original invoice pdf in filemanagement for dunned invoice |
|
1253 |
# save original invoice pdf in filemanagement/webdav for dunned invoice
|
|
1226 | 1254 |
if ($::instance_conf->get_doc_storage) { |
1227 | 1255 |
SL::File->save( |
1228 | 1256 |
object_id => $invoice_id, |
... | ... | |
1234 | 1262 |
file_path => "${spool}/$file_name", |
1235 | 1263 |
); |
1236 | 1264 |
} |
1265 |
if ($::instance_conf->get_webdav_documents) { |
|
1266 |
my $webdav = SL::Webdav->new( |
|
1267 |
type => 'invoice', |
|
1268 |
number => $invoice->invnumber, |
|
1269 |
); |
|
1270 |
my $webdav_file = SL::Webdav::File->new( |
|
1271 |
webdav => $webdav, |
|
1272 |
filename => $attachment_filename, |
|
1273 |
); |
|
1274 |
$webdav_file->store(file => "${spool}/$file_name"); |
|
1275 |
} |
|
1237 | 1276 |
|
1238 | 1277 |
} |
1239 | 1278 |
|
Auch abrufbar als: Unified diff
Mahnungen: alle erzeugten Dokumente zu jeder gemahnten Rechnung ins WebDAV