我们正在将 Magento 中的订单和付款数据导入 Quickbooks 桌面版。下面是两个查询——它们给出了成功的响应,但没有导入数据。对我们有什么想法吗?
首先,我们创建一个查询来形成一个订单堆栈
$qb_order = new QuickBooks_IPP_Object_Invoice();
$qb_meta = new QuickBooks_IPP_Object_MetaData();
$qb_meta->setCreateTime($order->getCreatedAt());
$qb_meta->setLastUpdatedTime($order->getUpdatedAt());
$qb_order->setMetaData($qb_meta);
$qb_header = new QuickBooks_IPP_Object_Header();
$qb_header->setDocNumber($order->getIncrementId());
if (!$qb_customer_id = $this->_getQbCustomerId($order->getCustomerId())) return false;
$qb_header->setCustomerId($qb_customer_id);
$qb_header->setShipDate($order->getDeliveryDate());
$qb_header->setSubTotalAmt($order->getBaseSubtotal());
$qb_header->setTaxAmt($order->getBaseTaxAmount());
$qb_header->setTotalAmt($order->getBaseGrandTotal());
$qb_header->setARAccountId("Accounts Receivable");
if ($address = $order->getBillingAddress()) {
$qb_header->setBillAddr($this->_convertAddress($address, "Billing"));
}
if ($address = $order->getShippingAddress()) {
$qb_header->setShipAddr($this->_convertAddress($address, "Shipping"));
}
$qb_header->setDiscountAmt($order->getBaseDiscountAmount());
$qb_order->setHeader($qb_header);
foreach($order->getItemsCollection() as $item) {
$qb_order->addLine($this->_convertOrderItem($item));
}
这是查询后形成的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<Add xmlns="http://www.intuit.com/sb/cdm/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
RequestId="4562cdf8407178e362082c0441dffa74"
xsi:schemaLocation="http://www.intuit.com/sb/cdm/v2 ./RestDataFilter.xsd ">
<OfferingId>ipp</OfferingId>
<ExternalRealmId>631645715</ExternalRealmId>
<Object xsi:type="Invoice">
<Header>
<DocNumber>100001570</DocNumber>
<CustomerId>103699</CustomerId>
<ShipDate>2013-02-21</ShipDate>
<SubTotalAmt>33.0000</SubTotalAmt>
<TaxAmt>2.6400</TaxAmt>
<TotalAmt>35.64</TotalAmt>
<ARAccountId>Accounts Receivable</ARAccountId>
<BillAddr>
<Line1></Line1>
<Line2></Line2>
<Line3></Line3>
<Line4></Line4>
<City></City>
<Country></Country>
<CountrySubDivisionCode></CountrySubDivisionCode>
<PostalCode></PostalCode>
<Tag>Billing</Tag>
</BillAddr>
<ShipAddr>
<Line1></Line1>
<Line2></Line2>
<Line3></Line3>
<Line4></Line4>
<City></City>
<Country></Country>
<CountrySubDivisionCode></CountrySubDivisionCode>
<PostalCode></PostalCode>
<Tag>Shipping</Tag>
</ShipAddr>
<DiscountAmt>0.0000</DiscountAmt>
</Header>
<Line>
<Desc>Special Product For POS
sdf</Desc>
<Amount>33.0000</Amount>
<ItemType>Product</ItemType>
<UnitPrice>33.0000</UnitPrice>
<Qty>1</Qty>
</Line>
</Object>
</Add>
这是服务器响应:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
<Success RequestId="4562cdf8407178e362082c0441dffa74">
<ObjectRef>
<Id idDomain="NG">494527</Id>
<SyncToken>1</SyncToken>
<LastUpdatedTime>2013-02-21T05:44:12Z</LastUpdatedTime>
</ObjectRef>
<RequestName>InvoiceAdd</RequestName>
<ProcessedTime>2013-02-21T05:44:12Z</ProcessedTime>
</Success>
</RestResponse>
==================================================== ================
这是用于根据订单创建付款的第二组代码。同样的问题,成功的 XML 但没有导入数据:
$order = Mage::getModel("sales/order")->load($invoice->getOrderId());
if (!$qb_order_id = $this->getHelper()->getObjectQbId($order)) return false;
$qb_payment = new QuickBooks_IPP_Object_Payment();
$qb_meta = new QuickBooks_IPP_Object_MetaData();
$qb_meta->setCreateTime($invoice->getCreatedAt());
$qb_meta->setLastUpdatedTime($invoice->getUpdatedAt());
$qb_payment->setMetaData($qb_meta);
$qb_header = new QuickBooks_IPP_Object_Header();
$qb_header->setDocNumber($invoice->getIncrementId());
$qb_header->setTxnDate($invoice->getCreatedAt());
if (!$qb_customer_id = $this->_getQbCustomerId($order->getCustomerId())) return false;
$qb_header->setCustomerId($qb_customer_id);
$qb_header->setTotalAmt($invoice->getBaseGrandTotal());
$qb_header->setProcessPayment('false');
$qb_payment->setHeader($qb_header);
$qb_line = new QuickBooks_IPP_Object_Line();
$qb_line->setAmount($invoice->getBaseGrandTotal());
$qb_line->setTxnId($qb_order_id);
$qb_payment->addLine($qb_line);
这是在代码之后形成的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<Add xmlns="http://www.intuit.com/sb/cdm/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
RequestId="dc07317b838eb3d0c89e310b4984468a"
xsi:schemaLocation="http://www.intuit.com/sb/cdm/v2 ./RestDataFilter.xsd ">
<OfferingId>ipp</OfferingId>
<ExternalRealmId>631645715</ExternalRealmId>
<Object xsi:type="Payment">
<Header>
<DocNumber>100000265</DocNumber>
<TxnDate>2013-02-21</TxnDate>
<CustomerId>103699</CustomerId>
<TotalAmt>35.64</TotalAmt>
<ProcessPayment>false</ProcessPayment>
</Header>
<Line>
<Amount>35.6400</Amount>
<TxnId>494527</TxnId>
</Line>
</Object>
</Add>
这是来自服务器的答案:
<?xml version="1.0" ?>
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
<Success RequestId="dc07317b838eb3d0c89e310b4984468a">
<ObjectRef>
<Id idDomain="NG">494529</Id>
<SyncToken>1</SyncToken>
<LastUpdatedTime>2013-02-21T05:48:07Z</LastUpdatedTime>
</ObjectRef>
<RequestName>PaymentAdd</RequestName>
<ProcessedTime>2013-02-21T05:48:07Z</ProcessedTime>
</Success>
</RestResponse>