我知道有一些这样的帖子,但我还没有看到解决我问题的帖子。我打电话给kashflow api插入发票。它需要一个“Invoice”类型的对象,而该对象又需要一组InvoiceLine类型的对象。
见这里:
http://www.kashflow.com/developers/soap-api/invoice/
http://www.kashflow.com/developers/soap-api/InvoiceLine/
以下是我目前正在使用的代码。
class Invoice{
public $InvoiceDBID = ''; //TSystem-wide unique number for this invoice (used internally only)
public $InvoiceNumber = ''; //Unique invoice number
public $InvoiceDate = ''; //Invoice date
public $DueDate = ''; //Invoice due date
public $SuppressTotal = ''; //1 to suppress the total (only used on Quotes)
public $ProjectID = ''; //The project ID for this invoice.
public $CurrencyCode = ''; //The currency code to be used for the invoice e.g. USD, GBP, ZAR
public $ExchangeRate = ''; //The exchange rate for the currency used.
public $Paid = 0; //1 for Paid, 0 for Unpaid. Set to 0 on Insert calls
public $CustomerID = ''; //The ID of the customer (or supplier int he case of receipts)
public $CustomerReference = '';
public $EstimateCategory = ''; //The category of the quote (only relevant when with Quotes)
public $NetAmount = 0; //The total net amount of the invoice
public $VatAmount = 0; //The total VAT amount of the invoice
public $AmountPaid = 0; //The sum of all payments made to this invoice
public $Permalink = ''; //A permanent link to access a PDF of the invoice.
public $Lines = ''; //A collection of type InvoiceLine.
}
class InvoiceLine{
public $LineID = ''; //System-wide unique number for this line
public $Quantity = ''; //Quantity invoiced
public $Description = ''; //Description of item invoiced
public $Rate = ''; //Rate per item
public $ChargeType = ''; //For Purchases: Related Nominal ID From GetNominalCodes.
public $ProjID = ''; //The Project to which this line should be assigned. Leave as 0 if in doubt
public $VatAmount = ''; //The VAT amount for this line
public $VatRate = ''; //The VAT rate applied to this line (e.g. 15 for 15%). For Vat Exempt (the n/a code) use -1
public $Sort = ''; //Sort order value
public $ProductID = ''; //An integer value representing the ID of a SubProduct (from GetSubProducts). Set to 0 for “None”
public $ValuesInCurrency = ''; //Set to “1? if the Rate and VATAmount is already in foreign currency
}
$client = new SoapClient("https://securedwebapp.com/api/service.asmx?WSDL");
$invoice_line = new InvoiceLine();
$invoice_line->Quantity = 1;
$invoice_line->Description = 'Delicious Irish Whisky';
$invoice_line->Rate = 20;
$invoice_line->ChargeType = 5614031;
$invoice_line->VatAmount = 4.00;
$invoice_line->VatRate = 20;
$invoice_line->ProductID = 618736;
$invoice = new Invoice();
$invoice->InvoiceDate = '11/10/2012';
$invoice->DueDate = '08/11/2012';
$invoice->CurrencyCode = 'GBP';
$invoice->ExchangeRate = 1.0000;
$invoice->CustomerID = '1780661';
$invoice->Lines = array($invoice_line);
$parameters['UserName'] = "xxxxxxxxx";
$parameters['Password'] = "xxxxxxxxx";
$parameters['Invoice'] = $invoice;
$response = $client->InsertInvoice($parameters);