Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 641440a9

Von Jan Büren vor etwa 3 Jahren hinzugefügt

  • ID 641440a9b4bd108a7ef58b22e338fe8922dafc76
  • Vorgänger 1afa3acb
  • Nachfolger 82bf0d51

Lokalisierung für Fehlermeldungen und Doku ergänzt

Unterschiede anzeigen:

SL/ShopConnector/Shopware6.pm
11 11

  
12 12
use SL::JSON;
13 13
use SL::Helper::Flash;
14
use SL::Locale::String qw(t8);
14 15

  
15 16
use Rose::Object::MakeMethods::Generic (
16 17
  'scalar --get_set_init' => [ qw(connector) ],
......
105 106
  my ($self, $shop_part, $todo) = @_;
106 107

  
107 108
  #shop_part is passed as a param
108
  croak "Need a valid Shop Part for updating Part" unless ref($shop_part) eq 'SL::DB::ShopPart';
109
  croak "Invalid todo for updating Part"           unless $todo =~ m/(price|stock|price_stock|active|all)/;
109
  croak t8("Need a valid Shop Part for updating Part") unless ref($shop_part) eq 'SL::DB::ShopPart';
110
  croak t8("Invalid todo for updating Part")           unless $todo =~ m/(price|stock|price_stock|active|all)/;
110 111

  
111 112
  my $part = SL::DB::Part->new(id => $shop_part->part_id)->load;
112 113
  die "Shop Part but no kivi Part?" unless ref $part eq 'SL::DB::Part';
......
453 454
sub get_one_order  {
454 455
  my ($self, $ordnumber) = @_;
455 456

  
456
  die "No ordnumber" unless $ordnumber;
457
  croak t8("No Order Number") unless $ordnumber;
457 458
  # set known params for the return structure
458 459
  my %fetched_order  = $self->get_fetched_order_structure;
459 460
  my $assoc          = $self->all_open_orders();
......
669 670
  my ($self, $import) = @_;
670 671

  
671 672
  # failsafe checks for not yet implemented
672
  die $::locale->text('Shipping cost article not implemented')          if $self->config->shipping_costs_parts_id;
673
  die t8('Shipping cost article not implemented') if $self->config->shipping_costs_parts_id;
673 674

  
674 675
  # no mapping unless we also have at least one shop order item ...
675 676
  my $order_pos = delete $import->{lineItems};
676
  croak("No Order items fetched") unless ref $order_pos eq 'ARRAY';
677
  croak t8("No Order items fetched") unless ref $order_pos eq 'ARRAY';
677 678

  
678 679
  my $shop_order = $self->map_data_to_shoporder($import);
679 680

  
......
704 705
    $shop_order->positions($position);
705 706

  
706 707
    if ( $self->config->shipping_costs_parts_id ) {
707
      die "Not yet implemented";
708
      die t8("Not yet implemented");
708 709
      # TODO NOT YET Implemented nor tested, this is shopware5 code:
709 710
      my $shipping_part = SL::DB::Part->find_by( id => $self->config->shipping_costs_parts_id);
710 711
      my %shipping_pos = ( description    => $import->{data}->{dispatch}->{name},
......
731 732

  
732 733
    1;
733 734

  
734
  }) || die ('error while saving shop order ' . $shop_order->{shop_ordernumber} . 'Error: ' . $shop_order->db->error . "\n" .
735
             'generic exception:' . $@);
735
  }) || die t8('Error while saving shop order #1. DB Error #2. Generic exception #3.',
736
                $shop_order->{shop_ordernumber}, $shop_order->db->error, $@);
736 737
}
737 738

  
738 739
sub map_data_to_shoporder {
......
746 747
                                                      && ref $import->{orderCustomer} eq 'HASH';
747 748

  
748 749
  my $shipto_id = $import->{deliveries}->[0]->{shippingOrderAddressId};
749
  die "Cannot get shippingOrderAddressId for $import->{orderNumber}" unless $shipto_id;
750
  die t8("Cannot get shippingOrderAddressId for #1", $import->{orderNumber}) unless $shipto_id;
750 751

  
751 752
  my $billing_ary = [ grep { $_->{id} == $import->{billingAddressId} }       @{ $import->{addresses} } ];
752 753
  my $shipto_ary  = [ grep { $_->{id} == $shipto_id }                        @{ $import->{addresses} } ];
753 754
  my $payment_ary = [ grep { $_->{id} == $import->{paymentMethodId} }        @{ $import->{paymentMethods} } ];
754 755

  
755
  croak("No Billing and ship to address, for Order Number " . $import->{orderNumber} .
756
        "ID Billing:" . $import->{billingAddressId} . " ID Shipping $shipto_id ")
756
  die t8("No Billing and ship to address, for Order Number #1 with ID Billing #2 and ID Shipping #3",
757
          $import->{orderNumber}, $import->{billingAddressId}, $import->{deliveries}->[0]->{shippingOrderAddressId})
757 758
    unless scalar @{ $billing_ary } == 1 && scalar @{ $shipto_ary } == 1;
758 759

  
759 760
  my $billing = $billing_ary->[0];
......
761 762
  # TODO payment info is not used at all
762 763
  my $payment = scalar @{ $payment_ary } ? delete $payment_ary->[0] : undef;
763 764

  
764
  croak "No billing city"   unless $billing->{city};
765
  croak "No shipto city"    unless $shipto->{city};
766
  croak "No customer email" unless $import->{orderCustomer}->{email};
765
  # check mandatory fields from shopware
766
  die t8("No billing city")   unless $billing->{city};
767
  die t8("No shipto city")    unless $shipto->{city};
768
  die t8("No customer email") unless $import->{orderCustomer}->{email};
767 769

  
768 770
  # extract order date
769 771
  my $parser = DateTime::Format::Strptime->new(pattern   => '%Y-%m-%dT%H:%M:%S',
......
777 779
  my $shop_id      = $self->config->id;
778 780
  my $tax_included = $self->config->pricetype;
779 781

  
782
  # TODO copied from shopware5 connector
780 783
  # Mapping Zahlungsmethoden muss an Firmenkonfiguration angepasst werden
781 784
  my %payment_ids_methods = (
782 785
    # shopware_paymentId => kivitendo_payment_id
......
888 891

  
889 892
=item C<sync_all_images (set_cover: 0|1, delete_orphaned: 0|1)>
890 893

  
891
The important key for shopware is the image name. To get distinct
892
entries the kivi partnumber is combined with the title (description)
894
The connecting key for shopware to kivi images is the image name.
895
To get distinct entries the kivi partnumber is combined with the title (description)
893 896
of the image. Therefore part1000_someTitlefromUser should be unique in
894 897
Shopware.
895 898
All image data is simply send to shopware whether or not image data
......
941 944
Missing fields are commented in the sub map_data_to_shoporder.
942 945
Some items are SEPA debit info, IP adress, delivery costs etc
943 946
Furthermore Shopware6 uses currency, country and locales information.
947
Detailed list:
948

  
949
    #customer_newsletter     => $customer}->{newsletter},
950
    #remote_ip               => $import->{remoteAddress},
951
    #sepa_account_holder     => $import->{paymentIntances}->{accountHolder},
952
    #sepa_bic                => $import->{paymentIntances}->{bic},
953
    #sepa_iban               => $import->{paymentIntances}->{iban},
954
    #shipping_costs          => $import->{invoiceShipping},
955
    #shipping_costs_net      => $import->{invoiceShippingNet},
956
    #shop_c_billing_id       => $import->{billing}->{customerId},
957
    #shop_c_billing_number   => $import->{billing}->{number},
958
    #shop_c_delivery_id      => $import->{shipping}->{id},
959
    #shop_customer_id        => $import->{customerId},
960
    #shop_customer_number    => $import->{billing}->{number},
961
    #shop_customer_comment   => $import->{customerComment},
944 962

  
945 963
=item * Use shipping_costs_parts_id for additional shipping costs
946 964

  

Auch abrufbar als: Unified diff