WooCommerce Shopware: paymentid im Shoporder setzen
authorWerner Hahn <wh@futureworldsearch.net>
Thu, 24 Jun 2021 12:24:23 +0000 (14:24 +0200)
committerWerner Hahn <wh@futureworldsearch.net>
Thu, 24 Jun 2021 14:45:34 +0000 (16:45 +0200)
SL/ShopConnector/Shopware.pm
SL/ShopConnector/WooCommerce.pm

index 79f7cd6..9757160 100644 (file)
@@ -11,6 +11,7 @@ use LWP::Authen::Digest;
 use SL::DB::ShopOrder;
 use SL::DB::ShopOrderItem;
 use SL::DB::History;
+use SL::DB::PaymentTerm;
 use DateTime::Format::Strptime;
 use SL::DB::File;
 use Data::Dumper;
@@ -185,6 +186,11 @@ sub map_data_to_shoporder {
   my $shop_id      = $self->config->id;
   my $tax_included = $self->config->pricetype;
 
+  # Mapping Zahlungsmethoden muss an Firmenkonfiguration angepasst werden
+  my %payment_ids_methods = (
+    # shopware_paymentId => kivitendo_payment_id
+  );
+  my $default_payment_id = SL::DB::Manager::PaymentTerm->get_first()->id || undef;
   # Mapping to table shoporders. See http://community.shopware.com/_detail_1690.html#GET_.28Liste.29
   my %columns = (
     amount                  => $import->{data}->{invoiceAmount},
@@ -232,7 +238,7 @@ sub map_data_to_shoporder {
     netamount               => $import->{data}->{invoiceAmountNet},
     order_date              => $orderdate,
     payment_description     => $import->{data}->{payment}->{description},
-    payment_id              => $import->{data}->{paymentId},
+    payment_id              => $payment_ids_methods{$import->{data}->{paymentId}} || $default_payment_id,
     remote_ip               => $import->{data}->{remoteAddress},
     sepa_account_holder     => $import->{data}->{paymentIntances}->{accountHolder},
     sepa_bic                => $import->{data}->{paymentIntances}->{bic},
index 06a4b39..1be37d0 100644 (file)
@@ -9,6 +9,7 @@ use LWP::UserAgent;
 use LWP::Authen::Digest;
 use SL::DB::ShopOrder;
 use SL::DB::ShopOrderItem;
+use SL::DB::PaymentTerm;
 use SL::DB::History;
 use SL::DB::File;
 use Data::Dumper;
@@ -205,9 +206,9 @@ sub map_data_to_shoporder {
     }
   # Mapping Zahlungsmethoden muss an Firmenkonfiguration angepasst werden
   my %payment_ids_methods = (
-                              'paypal'                            => 2489,
-                              'german_market_purchase_on_account' => 2487,
-                            );
+    # woocommerce_payment_method_title => kivitendo_payment_id
+  );
+  my $default_payment_id = SL::DB::Manager::PaymentTerm->get_first()->id || undef;
   my %columns = (
 #billing Shop can have different billing addresses, and may have 1 customer_address
     billing_firstname       => $import->{billing}->{first_name},
@@ -297,7 +298,7 @@ sub map_data_to_shoporder {
     #prices_include_tax
     tax_included            => $tax_included,
     #payment_method
-    payment_id              => $payment_ids_methods{$import->{payment_method}} || 2487,
+    payment_id              => $payment_ids_methods{$import->{payment_method}} || $default_payment_id,
     #payment_method_title
     payment_description     => $import->{payment_method_title},
     #transaction_id