]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/Helper/ZUGFeRD.pm
ZUGFeRD: UStID des Kunden angeben, sofern bekannt
[mfinanz.git] / SL / DB / Helper / ZUGFeRD.pm
index ae64c7981f53ee56bb5f25e685bda822aa5b2d51..826cef1a94dc3422395d6835f0684f6e6310b9b0 100644 (file)
@@ -50,7 +50,10 @@ sub _type_code {
   # 381 (Credit note)
   # 389 (Credit note, self billed invoice)
 
-  return $type eq 'credit_note' ? 381 : 380;
+  return $type eq 'credit_note'        ? 381
+       : $type eq 'invoice_storno'     ? 457
+       : $type eq 'credit_note_storno' ? 458
+       :                                 380;
 }
 
 sub _unit_code {
@@ -365,6 +368,20 @@ sub _exchanged_document {
   #   </rsm:ExchangedDocument>
 }
 
+sub _specified_tax_registration {
+  my ($ustid_nr, %params) = @_;
+
+  return unless $ustid_nr;
+
+  $ustid_nr = "DE$ustid_nr" unless $ustid_nr =~ m{^[A-Z]{2}};
+
+  #         <ram:SpecifiedTaxRegistration>
+  $params{xml}->startTag("ram:SpecifiedTaxRegistration");
+  $params{xml}->dataElement("ram:ID", _u8($ustid_nr), "schemeID" => "VA");
+  $params{xml}->endTag;
+  #         </ram:SpecifiedTaxRegistration>
+}
+
 sub _seller_trade_party {
   my ($self, %params) = @_;
 
@@ -411,15 +428,7 @@ sub _seller_trade_party {
     #         </ram:PostalTradeAddress>
   }
 
-  my $ustid_nr = $::instance_conf->get_co_ustid;
-  if ($ustid_nr) {
-    $ustid_nr = "DE$ustid_nr" unless $ustid_nr =~ m{^[A-Z]{2}};
-    #         <ram:SpecifiedTaxRegistration>
-    $params{xml}->startTag("ram:SpecifiedTaxRegistration");
-    $params{xml}->dataElement("ram:ID", _u8($ustid_nr), "schemeID" => "VA");
-    $params{xml}->endTag;
-    #         </ram:SpecifiedTaxRegistration>
-  }
+  _specified_tax_registration($::instance_conf->get_co_ustid, %params);
 
   $params{xml}->endTag;
   #     </ram:SellerTradeParty>
@@ -434,6 +443,7 @@ sub _buyer_trade_party {
   $params{xml}->dataElement("ram:Name", _u8($self->customer->name));
 
   _customer_postal_trade_address(%params, customer => $self->customer);
+  _specified_tax_registration($self->customer->ustid, %params);
 
   $params{xml}->endTag;
   #       </ram:BuyerTradeParty>