conv_i($form->{id}));
do_query($form, $dbh, $query, @values);
- # add shipto
$form->{name} = $form->{ $form->{vc} };
$form->{name} =~ s/--$form->{"$form->{vc}_id"}//;
+ # add shipto
if (!$form->{shipto_id}) {
$form->add_shipto($dbh, $form->{id}, "DO");
}
$self->{"employee_${_}"} = $defaults->$_ for qw(address businessnumber co_ustid company duns sepa_creditor_id taxnumber);
}
- # set shipto from billto unless set
- my $has_shipto = any { $self->{"shipto$_"} } qw(name street zipcode city country contact);
- if (!$has_shipto && ($self->{type} =~ m/^(?:purchase_order|request_quotation)$/)) {
- $self->{shiptoname} = $defaults->company;
- $self->{shiptostreet} = $defaults->address;
+ # Load shipping address from database if shipto_id is set.
+ if ($self->{shipto_id}) {
+ my $shipto = SL::DB::Shipto->new(id => $self->{shipto_id})->load;
+ $self->{$_} = $shipto->$_ for grep { m{^shipto} } map { $_->name } @{ $shipto->meta->columns };
}
my $language = $self->{language} ? '_' . $self->{language} : '';
}
- # add shipto
$form->{name} = $form->{vendor};
$form->{name} =~ s/--\Q$form->{vendor_id}\E//;
+
+ # add shipto
$form->add_shipto($dbh, $form->{id}, "AP");
# delete zero entries
}
$sth->finish();
- # get shipto if we do not convert an order or invoice
- if (!$params->{shipto}) {
- delete @{$params}{qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail)};
-
- $query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module= 'CT')|;
- $ref = selectfirst_hashref_query($form, $dbh, $query, $vid);
- @{$params}{keys %$ref} = @{$ref}{keys %$ref};
- map { $params->{$_} = $ref->{$_} } keys %$ref;
- }
-
if (!$params->{id} && $params->{type} !~ /_(order|quotation)/) {
# setup last accounts used
$query =
do_query($form, $dbh, qq|UPDATE ar SET paid = amount WHERE id = ?|, conv_i($form->{"id"}));
}
- # add shipto
$form->{name} = $form->{customer};
$form->{name} =~ s/--\Q$form->{customer_id}\E//;
+ # add shipto
if (!$form->{shipto_id}) {
$form->add_shipto($dbh, $form->{id}, "AR");
}
$form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "buy");
- # get shipto
- $query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module = 'AR')|;
- $ref = selectfirst_hashref_query($form, $dbh, $query, $id);
- delete $ref->{id};
- map { $form->{$_} = $ref->{$_} } keys %{ $ref };
-
foreach my $vc (qw(customer vendor)) {
next if !$form->{"delivery_${vc}_id"};
($form->{"delivery_${vc}_string"}) = selectrow_query($form, $dbh, qq|SELECT name FROM customer WHERE id = ?|, $id);
}
$sth->finish;
- # get shipto if we did not converted an order or invoice
- if (!$form->{shipto}) {
- map { delete $form->{$_} }
- qw(shiptoname shiptodepartment_1 shiptodepartment_2
- shiptostreet shiptozipcode shiptocity shiptocountry
- shiptocontact shiptophone shiptofax shiptoemail);
-
- $query = qq|SELECT * FROM shipto WHERE trans_id = ? AND module = 'CT'|;
- $ref = selectfirst_hashref_query($form, $dbh, $query, $cid);
- delete $ref->{id};
- map { $form->{$_} = $ref->{$_} } keys %$ref;
- }
-
# setup last accounts used for this customer
if (!$form->{id} && $form->{type} !~ /_(order|quotation)/) {
$query =
$form->{ordtotal} = $amount;
- # add shipto
$form->{name} = $form->{ $form->{vc} };
$form->{name} =~ s/--\Q$form->{"$form->{vc}_id"}\E//;
+ # add shipto
if (!$form->{shipto_id}) {
$form->add_shipto($dbh, $form->{id}, "OE");
}
'ids' => $form->{id});
$form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes delivery_term_id currency));
- $form->{shipto} = 1 if $form->{id} || $form->{convert_from_oe_ids};
# get customer / vendor
if ($form->{vc} eq 'vendor') {
require "bin/mozilla/$form->{script}";
my $currency = $form->{currency};
- $form->{shipto} = 1 if $form->{convert_from_do_ids};
invoice_links();
if ($form->{ordnumber}) {
}
$form->{script} = 'oe.pl';
- $form->{shipto} = 1;
-
$form->{rowcount}--;
$form->{cp_id} *= 1;
$form->{script} = 'oe.pl';
- $form->{shipto} = 1;
-
$form->{rowcount}--;
require "bin/mozilla/$form->{script}";
$form->get_shipto(\%myconfig);
}
- my @a = qw(name department_1 department_2 street zipcode city country contact phone fax email);
-
- my $shipto = 1;
-
- # if there is no shipto fill it in from billto
- foreach my $item (@a) {
- if ($form->{"shipto$item"}) {
- $shipto = 0;
- last;
- }
- }
-
- if ($shipto) {
- if ( $form->{formname} eq 'purchase_order'
- || $form->{formname} eq 'request_quotation') {
- $form->{shiptoname} = $defaults->company;
- $form->{shiptostreet} = $defaults->address;
- } else {
- map { $form->{"shipto$_"} = $form->{$_} } @a;
- }
- }
-
$form->{notes} =~ s/^\s+//g;
delete $form->{printer_command};
taxincluded currency cp_id intnotes id shipto_id
delivery_term_id));
- $form->{shipto} = 1 if $editing || $form->{convert_from_oe_ids} || $form->{convert_from_do_ids};
IS->get_customer(\%myconfig, \%$form);
#quote all_customer Bug 133
$form->{id} = '';
$form->{rowcount}--;
- $form->{shipto} = 1;
$form->{title} = $locale->text('Add Credit Note');
$form->{"$form->{vc}_id"} ||= $form->{"all_$form->{vc}"}->[0]->{id} if $form->{"all_$form->{vc}"};
$form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes shipto_id delivery_term_id currency));
- $form->{shipto} = 1 if $form->{id} || $form->{convert_from_oe_ids};
# get customer / vendor
IR->get_vendor(\%myconfig, \%$form) if $form->{type} =~ /(purchase_order|request_quotation)/;
$form->{convert_from_oe_ids} = $form->{id};
$form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
$form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
- $form->{shipto} = 1;
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
delete @{$form}{qw(id closed)};
$form->{direct_delivery_checked} = 1;
delete @{$form}{grep /^shipto/, keys %{ $form }};
map { s/^CFDD_//; $form->{$_} = $form->{"CFDD_${_}"} } grep /^CFDD_/, keys %{ $form };
- $form->{shipto} = 1;
$form->{CFDD_shipto} = 1;
purchase_order();
$main::lxdebug->leave_sub();