X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FShopOrder.pm;h=6a53387b52de4df62441a347c604b157f83bc0c5;hb=e6349b94e3541e363e8c40dcd938d65a272ec51c;hp=2752de6271a32ad896811bfea4ace1871c114207;hpb=94589a4e7e0f88fc71034182e007afe3d0e65952;p=kivitendo-erp.git diff --git a/SL/DB/ShopOrder.pm b/SL/DB/ShopOrder.pm index 2752de627..6a53387b5 100644 --- a/SL/DB/ShopOrder.pm +++ b/SL/DB/ShopOrder.pm @@ -9,6 +9,7 @@ use SL::DBUtils; use SL::DB::Shop; use SL::DB::MetaSetup::ShopOrder; use SL::DB::Manager::ShopOrder; +use SL::DB::PaymentTerm; use SL::DB::Helper::LinkedRecords; use SL::Locale::String qw(t8); use Carp; @@ -47,7 +48,8 @@ sub convert_to_sales_order { }else{ my $current_order_item = SL::DB::OrderItem->new( parts_id => $part->id, - description => $part->description, + description => $_->description, # description from the shop + longdescription => $part->notes, # longdescription from parts. TODO locales qty => $_->quantity, sellprice => $_->price, unit => $part->unit, @@ -95,7 +97,7 @@ sub convert_to_sales_order { intnotes => $customer->notes, salesman_id => $employee->id, taxincluded => $self->tax_included, - payment_id => $customer->payment_id, + payment_id => $self->payment_id, taxzone_id => $customer->taxzone_id, currency_id => $customer->currency_id, transaction_description => $shop->transaction_description, @@ -136,11 +138,11 @@ WHERE ( OR ( street % ? AND zipcode ILIKE ?) OR - email ILIKE ? + ( email ILIKE ? OR invoice_mail ILIKE ? ) ) AND obsolete = 'F' SQL - my @values = ($lastname, $company, $self->billing_zipcode, $street, $self->billing_zipcode, $self->billing_email); + my @values = ($lastname, $company, $self->billing_zipcode, $street, $self->billing_zipcode, $self->billing_email, $self->billing_email); $customers = SL::DB::Manager::Customer->get_objects_from_sql( sql => $fs_query, @@ -150,20 +152,24 @@ SQL # If trgm extension is not installed $customers = SL::DB::Manager::Customer->get_all( where => [ - or => [ - and => [ - or => [ 'name' => { ilike => $lastname }, - 'name' => { ilike => $company }, - ], - 'zipcode' => { ilike => $zipcode }, + or => [ + and => [ + or => [ 'name' => { ilike => $lastname }, + 'name' => { ilike => $company }, + ], + 'zipcode' => { ilike => $zipcode }, ], - and => [ - and => [ 'street' => { ilike => $street_not_fuzzy }, - 'zipcode' => { ilike => $zipcode }, + and => [ + and => [ 'street' => { ilike => $street_not_fuzzy }, + 'zipcode' => { ilike => $zipcode }, ], ], - or => [ 'email' => { ilike => $email } ], - ], + or => [ + 'email' => { ilike => $email }, + 'invoice_mail' => { ilike => $email }, + ], + ], + and => [ obsolete => 'F' ] ], ); } @@ -187,6 +193,8 @@ sub get_customer{ my $customer_proposals = $self->check_for_existing_customers; my $name = $self->billing_firstname . " " . $self->billing_lastname; my $customer = 0; + my $default_payment = SL::DB::Manager::PaymentTerm->get_first(); + my $payment_id = $default_payment ? $default_payment->id : undef; if(!scalar(@{$customer_proposals})){ my %address = ( 'name' => $name, 'department_1' => $self->billing_company, @@ -195,6 +203,7 @@ sub get_customer{ 'zipcode' => $self->billing_zipcode, 'city' => $self->billing_city, 'email' => $self->billing_email, + 'invoice_mail' => $self->billing_email, 'country' => $self->billing_country, 'greeting' => $self->billing_greeting, 'fax' => $self->billing_fax, @@ -205,7 +214,7 @@ sub get_customer{ 'pricegroup_id' => (split '\/',$shop->price_source)[0] eq "pricegroup" ? (split '\/',$shop->price_source)[1] : undef, 'taxzone_id' => $shop->taxzone_id, 'currency' => $::instance_conf->get_currency_id, - #'payment_id' => 7345,# TODO hardcoded + 'payment_id' => $payment_id, ); $customer = SL::DB::Customer->new(%address); @@ -230,6 +239,7 @@ sub get_customer{ obsolete => 'F', ); } + $customer->update_attributes(invoice_mail => $self->billing_email) if $customer->invoice_mail ne $self->billing_email; return $customer; }