dbh => $dbh);
# link previous items with invoice items See IS.pm (no credit note -> no invoice item)
- foreach (qw(delivery_order_items orderitems)) {
+ foreach (qw(delivery_order_items orderitems invoice)) {
if (!$form->{useasnew} && $form->{"converted_from_${_}_id_$i"}) {
RecordLinks->create_links('dbh' => $dbh,
'mode' => 'ids',
Common::webdav_folder($form);
- # Link this record to the records it was created from.
- if ($form->{convert_from_oe_ids}) {
- RecordLinks->create_links('dbh' => $dbh,
- 'mode' => 'ids',
- 'from_table' => 'oe',
- 'from_ids' => $form->{convert_from_oe_ids},
- 'to_table' => 'ap',
- 'to_id' => $form->{id},
+ # Link this record to the records it was created from order or invoice (storno)
+ foreach (qw(oe ap)) {
+ if ($form->{"convert_from_${_}_ids"}) {
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => $_,
+ 'from_ids' => $form->{"convert_from_${_}_ids"},
+ 'to_table' => 'ap',
+ 'to_id' => $form->{id},
);
- delete $form->{convert_from_oe_ids};
+ delete $form->{"convert_from_${_}_ids"};
+ }
}
my @convert_from_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{convert_from_do_ids};
max_dunning_level dunning_amount
shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptogln shiptocontact shiptophone shiptofax
shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts cursor_fokus
- convert_from_do_ids convert_from_oe_ids show_details gldate useasnew
+ convert_from_do_ids convert_from_oe_ids convert_from_ap_ids show_details gldate useasnew
), @custom_hiddens,
map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}];
$form->{paidaccounts} = 0;
map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ gldate_ acc_trans_id_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form };
# set new ids for storno invoice
- delete $form->{"invoice_id_$_"} for 1 .. $form->{"rowcount"};
+ # set new persistent ids for storno invoice items
+ $form->{"converted_from_invoice_id_$_"} = delete $form->{"invoice_id_$_"} for 1 .. $form->{"rowcount"};
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
}
# /saving the history
+ # record link invoice to storno
+ $form->{convert_from_ap_ids} = $form->{id};
$form->{storno_id} = $form->{id};
$form->{storno} = 1;
$form->{id} = "";