5 use Support::TestSetup;
9 use SL::Dev::Part qw(new_part);
10 use SL::Dev::Shop qw(new_shop new_shop_part);
11 use SL::Dev::CustomerVendor qw(new_customer);
13 use SL::DB::ShopOrder;
14 use SL::DB::ShopOrderItem;
15 use SL::Controller::ShopOrder;
19 use SL::ShopConnector::Shopware;
20 my ($shop, $shopware, $shop_order, $shop_part, $part, $customer, $employee, $json_import);
27 $shop = new_shop( connector => 'woocommerce',
28 last_order_number => 20000,
29 pricetype => 'brutto',
30 price_source => 'master_data',
33 $shopware = SL::Shop->new( config => $shop );
34 $part = new_part( partnumber => 'SW10002',
35 description => 'TITANIUM CARBON GS 12m cm',
37 $shop_part = new_shop_part(part => $part, shop => $shop);
39 $employee = SL::DB::Manager::Employee->current || croak "No employee";
41 $customer = new_customer( name => 'Evil Inc',
42 street => 'Evil Street',
44 email => 'evil@evilinc.com'
54 'href' => 'https://WOOCOMMERCESHOP/wp-json/wc/v3/orders'
59 'href' => 'https://WOOCOMMERCESHOP/wp-json/wc/v3/orders/8163'
64 'address_1' => 'Hauptstrasse 52a',
69 'email' => 'test@test.de',
70 'first_name' => 'Heike',
71 'last_name' => 'Mustermann',
73 'postcode' => '06118',
76 'cart_hash' => '4f978421d12277a81e8b6f83c02fba55',
79 'created_via' => 'checkout',
81 'currency_symbol' => "\x{20ac}",
83 'customer_ip_address' => '888.888.888.888',
84 'customer_note' => '',
85 'customer_user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0',
86 'date_completed' => '2021-04-13T10:04:12',
87 'date_completed_gmt' => '2021-04-13T08:04:12',
88 'date_created' => '2021-04-12T11:56:42',
89 'date_created_gmt' => '2021-04-12T09:56:42',
90 'date_modified' => '2021-04-13T10:04:12',
91 'date_modified_gmt' => '2021-04-13T08:04:12',
92 'date_paid' => '2021-04-12T11:56:44',
93 'date_paid_gmt' => '2021-04-12T09:56:44',
94 'discount_tax' => '0.00',
95 'discount_total' => '0.00',
103 'display_key' => 'Verpackungseinheit',
104 'display_value' => "P\x{e4}ckchen mit 12 Samen",
106 'key' => 'pa_verpackungseinheit',
107 'value' => 'paeckchen-mit-12-samen'
110 'display_key' => '_deliverytime',
111 'display_value' => '151',
113 'key' => '_deliverytime',
117 'name' => "Wassermelone M 11 (Blacktail Mountain) - P\x{e4}ckchen mit 12 Samen",
118 'parent_name' => 'Wassermelone M 11 (Blacktail Mountain)',
120 'product_id' => 4930,
123 'subtotal' => '2.95',
124 'subtotal_tax' => '0.21',
125 'tax_class' => 'reduced-rate',
129 'subtotal' => '0.2065',
134 'total_tax' => '0.21',
135 'variation_id' => 4931
141 'key' => '_billing_fax',
146 'key' => '_shipping_fax',
151 'key' => 'is_vat_exempt',
156 'key' => 'wpml_language',
161 'order_key' => 'wc_order_HjusTgQrJZHFQ',
163 'payment_method' => 'german_market_purchase_on_account',
164 'payment_method_title' => 'Kauf auf Rechnung',
165 'prices_include_tax' => '0',
168 'address_1' => 'Hauptstrasse 52a',
173 'first_name' => 'Heike',
174 'last_name' => 'Mustermann',
175 'postcode' => '06118',
178 'shipping_lines' => [
181 'instance_id' => '1',
184 'display_key' => 'Positionen',
185 'display_value' => "Wassermelone M 11 (Blacktail Mountain) - P\x{e4}ckchen mit 12 Samen × 1",
187 'key' => 'Positionen',
188 'value' => "Wassermelone M 11 (Blacktail Mountain) - P\x{e4}ckchen mit 12 Samen × 1"
191 'method_id' => 'flat_rate',
192 'method_title' => 'Versandkostenpauschale',
201 'total_tax' => '0.16'
204 'shipping_tax' => '0.16',
205 'shipping_total' => '2.34',
206 'status' => 'completed',
213 'rate_code' => 'DE-MWST.-2',
216 'shipping_tax_total' => '0.16',
217 'tax_total' => '0.21'
221 'total_tax' => '0.37',
222 'transaction_id' => '',
230 my $import = get_data();
231 note('testing shoporder mapping json good');
232 $shop_order = $shopware->connector->import_data_to_shop_order($import);
233 is($shop_order->shop_id , $shop->id , "shop_id ok");
236 Support::TestSetup::login();
249 "SL::DB::Manager::${_}"->delete_all(all => 1) for qw(OrderItem Order);
250 "SL::DB::Manager::${_}"->delete_all(all => 1) for qw(ShopPart Part ShopOrderItem ShopOrder Shop Customer);