Run my Accounts API: Erstellen einer neuen Rechnung

Hier erfahren Sie, wie Sie eine neue Rechnung über das API von Run my Accounts erfassen können:

POST https://service.runmyaccounts.com/api/{version}/clients/{mandantenname}/invoices

Genau Definition der Anfrage in XML finden sich bei 'Ansicht einer Rechnung'. Dort beschrieben, sind die zwei Varianten: Buchungsmethode und Methode über Artikel. Auch der Kunde kann in der Rechnung über zwei Varianten gesetzt werden:

1. Vollständiges <customer> Element:

Falls der Kunde noch nicht existiert (id: customernumber), so wird er neu erstellt. Bestehende Kunden werden automatisch mutiert, deshalb ist es wichtig immer alle Kundendaten mitzuliefern.

XML:

<?xml version="1.0" encoding="UTF-8"?>
<invoice>
   <invnumber>R-002</invnumber>
   <ordnumber />
   <status>OVERDUE</status>
   <currency>CHF</currency>
   <ar_accno>1100</ar_accno>
   <transdate>2012-08-06T00:00:00+02:00</transdate>
   <duedate>2012-08-06T00:00:00+02:00</duedate>
   <description />
   <notes />
   <intnotes />
   <taxincluded>false</taxincluded>
   <dcn />
   <customer>
      <id>10199</id>
      <customernumber>K-001</customernumber>
      <name>Muster AG</name>
      <created>2012-02-21T00:00:00+01:00</created>
      <contactId>0</contactId>
      <salutation>Herr</salutation>
      <firstname>Hans</firstname>
      <lastname>Muster</lastname>
      <addressId>0</addressId>
      <address1>Rössliweg 1</address1>
      <address2 />
      <zipcode />
      <city>Tenna</city>
      <state />
      <country />
      <phone />
      <fax />
      <mobile />
      <email>hmuster@muster.ch</email>
      <taxnumber />
      <taxfree>false</taxfree>
      <bank_name>CREDIT SUISSE</bank_name>
      <bank_address1 />
      <bank_address2 />
      <bank_zipcode>8070</bank_zipcode>
      <bank_city>ZÜRICH</bank_city>
      <bank_country>SCHWEIZ</bank_country>
      <bank_iban>CH3304835172037151000</bank_iban>
      <bank_bic>CRESCHZZ80L</bank_bic>
   </customer>
   <parts>
      <part>
         <income_accno>0</income_accno>
         <expense_accno>0</expense_accno>
         <partnumber>ART-1</partnumber>
         <description>Beispiel Artikel 1</description>
         <unit />
         <quantity>5.0</quantity>
         <sellprice>99.0</sellprice>
         <discount>0.0</discount>
         <itemnote />
         <price_update>2012-08-06T09:51:42.818+02:00</price_update>
      </part>
   </parts>
</invoice>

JSON:

    {
       "invnumber": "R-002",
       "ordnumber": "",
       "status": "OPEN",
       "currency": "CHF",
       "ar_accno": "1100",
       "transdate": "2012-08-06T00:00:00+02:00",
       "duedate": "2012-08-06T00:00:00+02:00",
       "description": "",
       "notes": "",
       "intnotes": "",
       "taxincluded": "false",
       "dcn": "",
       "customer":
       {
           "id": "10199",
           "customernumber": "K-001",
           "name": "Muster AG",
           "created": "2012-02-21T00:00:00+01:00",
           "contactId": "0",
           "salutation": "Herr",
           "firstname": "Hans",
           "lastname": "Muster",
           "addressId": "0",
           "address1": "Rössliweg 1",
           "address2": "",
           "zipcode": "",
           "city": "Tenna",
           "state": "",
           "country": "",
           "phone": "",
           "fax": "",
           "mobile": "",
           "email": "hmuster@muster.ch",
           "taxnumber": "",
           "taxfree": "false",
           "bank_name": "CREDIT SUISSE",
           "bank_address1": "",
           "bank_address2": "",
           "bank_zipcode": "8070",
           "bank_city": "ZÜRICH",
           "bank_country": "SCHWEIZ",
           "bank_iban": "CH3304835172037151000",
           "bank_bic": "CRESCHZZ80L"
       },
       "parts":
       {
           "part":
           {
               "income_accno": "0",
               "expense_accno": "0",
               "partnumber": "ART-1",
               "description": "Beispiel Artikel 1",
               "unit": "",
               "quantity": "5.0",
               "sellprice": "99.0",
               "discount": "0.0",
               "itemnote": "",
               "price_update": "2012-08-06T09:30:54.679+02:00"
           }
       }
    }

2. Angabe des Kunden über die Kundennummer (<customernumber>)

Falls der Kunde über die Kundenschnittstelle erstellt wurde, kann in der Rechnung (Gutschrift) einfach die customernumber angegeben werden:

XML:

<?xml version="1.0" encoding="UTF-8"?>
<invoice>
   <invnumber>R-002</invnumber>
   <ordnumber />
   <status>OVERDUE</status>
   <currency>CHF</currency>
   <ar_accno>1100</ar_accno>
   <transdate>2012-08-06T00:00:00+02:00</transdate>
   <duedate>2012-08-06T00:00:00+02:00</duedate>
   <description />
   <notes />
   <intnotes />
   <taxincluded>false</taxincluded>
   <dcn />
   <customernumber>K-001</customernumber>
   <parts>
      <part>
         <income_accno>0</income_accno>
         <expense_accno>0</expense_accno>
         <partnumber>ART-1</partnumber>
         <description>Beispiel Artikel 1</description>
         <unit />
         <quantity>5.0</quantity>
         <sellprice>99.0</sellprice>
         <discount>0.0</discount>
         <itemnote />
         <price_update>2012-08-06T09:51:42.818+02:00</price_update>
      </part>
   </parts>
</invoice>

JSON:

    {
       "invnumber": "R-002",
       "ordnumber": "",
       "status": "OPEN",
       "currency": "CHF",
       "ar_accno": "1100",
       "transdate": "2012-08-06T00:00:00+02:00",
       "duedate": "2012-08-06T00:00:00+02:00",
       "description": "",
       "notes": "",
       "intnotes": "",
       "taxincluded": "false",
       "dcn": "",
       "customernumber": "K-001",
       "parts":
       {
           "part":
           {
               "income_accno": "0",
               "expense_accno": "0",
               "partnumber": "ART-1",
               "description": "Beispiel Artikel 1",
               "unit": "",
               "quantity": "5.0",
               "sellprice": "99.0",
               "discount": "0.0",
               "itemnote": "",
               "price_update": "2012-08-06T09:30:54.679+02:00"
           }
       }
    }

Beispiele