Revision 289c5ed9
Von Werner Hahn vor mehr als 6 Jahren hinzugefügt
SL/DB/ShopOrder.pm | ||
---|---|---|
5 | 5 |
|
6 | 6 |
use strict; |
7 | 7 |
|
8 |
use SL::DB::Shop; |
|
8 | 9 |
use SL::DB::MetaSetup::ShopOrder; |
9 | 10 |
use SL::DB::Manager::ShopOrder; |
10 | 11 |
use SL::DB::Helper::LinkedRecords; |
... | ... | |
42 | 43 |
unless($part){ |
43 | 44 |
push @error_report, t8('Part with partnumber: #1 not found', $_->partnumber); |
44 | 45 |
}else{ |
45 |
my $shop_part = SL::DB::Manager::ShopPart->find_by( shop_id => $self->shop_id, part_id => $part->id ); |
|
46 |
|
|
47 | 46 |
my $current_order_item = SL::DB::OrderItem->new( |
48 | 47 |
parts_id => $part->id, |
49 | 48 |
description => $part->description, |
... | ... | |
51 | 50 |
sellprice => $_->price, |
52 | 51 |
unit => $part->unit, |
53 | 52 |
position => $_->position, |
54 |
active_price_source => $shop_part->active_price_source,
|
|
53 |
active_price_source => $_->active_price_source,
|
|
55 | 54 |
); |
56 | 55 |
} |
57 | 56 |
}@{ $self->shop_order_items }; |
... | ... | |
130 | 129 |
( street % ? AND zipcode ILIKE ?) |
131 | 130 |
OR |
132 | 131 |
email ILIKE ? |
133 |
) |
|
132 |
) AND obsolete = 'F'
|
|
134 | 133 |
SQL |
135 | 134 |
my @values = ($lastname, $company, $self->billing_zipcode, $street, $self->billing_zipcode, $self->billing_email); |
136 | 135 |
my $customers = SL::DB::Manager::Customer->get_objects_from_sql( |
... | ... | |
140 | 139 |
return $customers; |
141 | 140 |
} |
142 | 141 |
|
143 |
#auslagern in eigene subroutine, da auch für andere connectoren genutzt werden muss |
|
144 | 142 |
sub get_customer{ |
145 | 143 |
my ($self, %params) = @_; |
146 |
|
|
144 |
my $shop = SL::DB::Manager::Shop->find_by(id => $self->shop_id); |
|
147 | 145 |
my $customer_proposals = $self->check_for_existing_customers; |
148 | 146 |
my $name = $self->billing_firstname . " " . $self->billing_lastname; |
149 |
my $customer;
|
|
147 |
my $customer = 0;
|
|
150 | 148 |
if(!scalar(@{$customer_proposals})){ |
151 | 149 |
my %address = ( 'name' => $name, |
152 | 150 |
'department_1' => $self->billing_company, |
... | ... | |
160 | 158 |
'fax' => $self->billing_fax, |
161 | 159 |
'phone' => $self->billing_phone, |
162 | 160 |
'ustid' => $self->billing_vat, |
163 |
'taxincluded_checked' => $self->config->pricetype eq "brutto" ? 1 : 0,
|
|
164 |
'taxincluded' => $self->config->pricetype eq "brutto" ? 1 : 0,
|
|
165 |
'pricegroup_id' => (split '\/',$self->config->price_source)[0] eq "pricegroup" ? (split '\/',$self->config->price_source)[1] : undef,
|
|
166 |
'taxzone_id' => $self->config->taxzone_id,
|
|
161 |
'taxincluded_checked' => $shop->pricetype eq "brutto" ? 1 : 0,
|
|
162 |
'taxincluded' => $shop->pricetype eq "brutto" ? 1 : 0,
|
|
163 |
'pricegroup_id' => (split '\/',$shop->price_source)[0] eq "pricegroup" ? (split '\/',$shop->price_source)[1] : undef,
|
|
164 |
'taxzone_id' => $shop->taxzone_id,
|
|
167 | 165 |
'currency' => $::instance_conf->get_currency_id, |
168 | 166 |
#'payment_id' => 7345,# TODO hardcoded |
169 | 167 |
); |
... | ... | |
180 | 178 |
)->save(); |
181 | 179 |
|
182 | 180 |
}elsif(scalar(@{$customer_proposals}) == 1){ |
183 |
# hier überprüfen ob Kundendaten wirklich übereinstimmen auc auf ungültig überprüfen |
|
184 |
$customer = $customer_proposals->[0]; |
|
185 |
}else{ |
|
186 |
# hier überprüfen ob Kundendaten wirklich übereinstimmen und ob es nur einen datensatz gibt auc auf ungültig überprüfen |
|
187 |
$customer = SL::DB::Manager::Customer->find_by( name => $name, |
|
188 |
street => $self->billing_street, |
|
189 |
zipcode => $self->billing_zipcode, |
|
190 |
email => $self->billing_email, |
|
191 |
); |
|
192 |
|
|
181 |
# check if the proposal is the right customer, could be different names under the same address. Depends on how first- and familyname is handled. Here is for customername = companyname or customername = "firstname familyname" |
|
182 |
$customer = SL::DB::Manager::Customer->find_by( id => $customer_proposals->[0]->id, |
|
183 |
name => $name, |
|
184 |
email => $self->billing_email, |
|
185 |
street => $self->billing_street, |
|
186 |
zipcode => $self->billing_zipcode, |
|
187 |
city => $self->billing_city, |
|
188 |
obsolete => 'F', |
|
189 |
); |
|
193 | 190 |
} |
194 |
return \$customer; |
|
191 |
|
|
192 |
return $customer; |
|
195 | 193 |
} |
196 |
## EOF AUslagern |
|
194 |
|
|
197 | 195 |
sub compare_to { |
198 | 196 |
my ($self, $other) = @_; |
199 | 197 |
|
... | ... | |
233 | 231 |
|
234 | 232 |
Returns all found customers as an arrayref of SL::DB::Customer objects. |
235 | 233 |
|
234 |
=item C<get_customer> |
|
235 |
|
|
236 |
returns only one customer from the check_for_existing_customers if the return from it is 0 or 1 customer. |
|
237 |
|
|
238 |
When it is 0 get customer creates a new customer object of the shop order billing data and returns it |
|
239 |
|
|
236 | 240 |
=item C<compare_to> |
237 | 241 |
|
238 | 242 |
=back |
239 | 243 |
|
244 |
=head1 TODO |
|
245 |
|
|
246 |
some variables like payments could be better implemented. Transaction description is hardcoded |
|
247 |
|
|
240 | 248 |
=head1 AUTHORS |
241 | 249 |
|
242 | 250 |
Werner Hahn E<lt>wh@futureworldsearch.netE<gt> |
Auch abrufbar als: Unified diff
Shopmodul: ShopOrders Verschiedene Sachen aus dem Shopware Connector
ausgelagert. Da diese auch für andere Connectoren gültigkeit haben.
Anzahl der zu holenden Bestellungen anders geregelt. Es werden zuerst
alle Kopfzeilen der Bestellungen geholt und anhand dessen die einzelne
Bestellung. So wird die Schleife nicht überlaufen wenn es keine
Bestellung mehr gibt und Shopware schreibt keinen Fehler.
POD