Open GameCharmer opened 3 years ago
@GameCharmer : Did you pass the Entity which is of the type IPPIntuitEntity
to Add method? The Add method of the DataService object should return IPPIntuitEntity
of the entity that was created.
Take a look at the Samples folder if you haven't already :
https://github.com/intuit/QuickBooks-V3-PHP-SDK/blob/master/src/_Samples/ItemCreation.php
@abisalehalliprasan I passed it the result from Invoice::create()
I'm betting I have the wrong CustomerRef value and Invoice::create is just returning false. Either way, do you think I should put together a pull request to fix the doc blocks?
If you pass the request paylaod to the create method of the Invoice
facade as shown below :
//Add a new Invoice
$theResourceObj = Invoice::create([
"Line" => [
[
"Amount" => 100.00,
"DetailType" => "SalesItemLineDetail",
"SalesItemLineDetail" => [
"ItemRef" => [
"value" => 1,
"name" => "Services"
]
]
]
],
"CustomerRef"=> [
"value"=> 0
]
]);
print "The resource object is : " . PHP_EOL . print_r($theResourceObj) . PHP_EOL;
Output:
(
[Deposit] =>
[AllowIPNPayment] =>
[AllowOnlinePayment] =>
[AllowOnlineCreditCardPayment] =>
[AllowOnlineACHPayment] =>
[EInvoiceStatus] =>
[ECloudStatusTimeStamp] =>
[invoiceStatus] =>
[callToAction] =>
[invoiceStatusLog] =>
[InvoiceEx] =>
[LessCIS] =>
[InvoiceLink] =>
[PaymentDetailsMessage] =>
[ConvenienceFeeDetail] =>
[InvoiceLinkSecurityCode] =>
[InvoiceLinkExpiryDate] =>
[AutoDocNumber] =>
[CustomerRef] => QuickBooksOnline\API\Data\IPPReferenceType Object
(
[name] =>
[type] =>
[value] => 0
)
[CustomerMemo] =>
[BillAddr] =>
[ShipAddr] =>
[FreeFormAddress] =>
[ShipFromAddr] =>
[RemitToRef] =>
[ClassRef] =>
[SalesTermRef] =>
[DueDate] =>
[SalesRepRef] =>
[PONumber] =>
[FOB] =>
[ShipMethodRef] =>
[ShipDate] =>
[TrackingNum] =>
[GlobalTaxCalculation] =>
[TotalAmt] =>
[HomeTotalAmt] =>
[ApplyTaxAfterDiscount] =>
[TemplateRef] =>
[PrintStatus] =>
[EmailStatus] =>
[BillEmail] =>
[BillEmailCc] =>
[BillEmailBcc] =>
[ARAccountRef] =>
[Balance] =>
[HomeBalance] =>
[FinanceCharge] =>
[PaymentMethodRef] =>
[PaymentRefNum] =>
[PaymentType] =>
[CheckPayment] =>
[CreditCardPayment] =>
[DepositToAccountRef] =>
[DeliveryInfo] =>
[DiscountRate] =>
[DiscountAmt] =>
[GovtTxnRefIdentifier] =>
[TaxExemptionRef] =>
[DocNumber] =>
[TxnDate] =>
[DepartmentRef] =>
[CurrencyRef] =>
[ExchangeRate] =>
[PrivateNote] =>
[TxnStatus] =>
[LinkedTxn] =>
[Line] => Array
(
[0] => QuickBooksOnline\API\Data\IPPLine Object
(
[Id] =>
[LineNum] =>
[Description] =>
[Amount] => 100
[Received] =>
[LinkedTxn] =>
[DetailType] => QuickBooksOnline\API\Data\IPPLineDetailTypeEnum Object
(
[value] => SalesItemLineDetail
)
[PaymentLineDetail] =>
[DiscountLineDetail] =>
[TaxLineDetail] =>
[SalesItemLineDetail] => QuickBooksOnline\API\Data\IPPSalesItemLineDetail Object
(
[ServiceDate] =>
[TaxInclusiveAmt] =>
[DiscountRate] =>
[DiscountAmt] =>
[SalesItemLineDetailEx] =>
[ItemRef] => QuickBooksOnline\API\Data\IPPReferenceType Object
(
[name] => Services
[type] =>
[value] => 1
)
[ClassRef] =>
[UnitPrice] =>
[RatePercent] =>
[PriceLevelRef] =>
[MarkupInfo] =>
[Qty] =>
[UOMRef] =>
[ItemAccountRef] =>
[InventorySiteRef] =>
[TaxCodeRef] =>
[TaxClassificationRef] =>
)
[DescriptionLineDetail] =>
[ItemBasedExpenseLineDetail] =>
[AccountBasedExpenseLineDetail] =>
[ReimburseLineDetail] =>
[DepositLineDetail] =>
[PurchaseOrderItemLineDetail] =>
[SalesOrderItemLineDetail] =>
[ItemReceiptLineDetail] =>
[JournalEntryLineDetail] =>
[GroupLineDetail] =>
[SubTotalLineDetail] =>
[TDSLineDetail] =>
[CustomField] =>
[LineEx] =>
)
)
[TxnTaxDetail] =>
[TxnSource] =>
[TaxFormType] =>
[TaxFormNum] =>
[TransactionLocationType] =>
[Tag] =>
[TxnApprovalInfo] =>
[RecurDataRef] =>
[RecurringInfo] =>
[Id] =>
[SyncToken] =>
[MetaData] =>
[CustomField] =>
[AttachableRef] =>
[domain] =>
[status] =>
[sparse] =>
)
The resource object is :
1
If you do not pass a valid CustomerRef
for Creating Invoice
the exception SDK is throwing is :
Fatal error: Uncaught QuickBooksOnline\API\Exception\ServiceException: Http Status Code [400]: Request is not made successful. Response Code:[400] with body: [<?xml version="1.0" encoding="UTF-8" standalone="yes"?><IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2021-02-04T20:44:45.308-08:00"><Fault type="ValidationFault"><Error code="2500" element="Reference Id"><Message>Invalid Reference Id</Message><Detail>Invalid Reference Id : Names element id 0 not found</Detail></Error></Fault></IntuitResponse>].
Not sure how you are getting a boolean response. If you could post your payload ( make sure to mask any sensitive information ) before creating a PR would help.
@abisalehalliprasan the overarching problem here isn't the data, it's the returned values. I can't get past code validation when the returns don't line up. Add
says it only returns IPPIntuitEntity
, but it returns the result of sendRequestParseResponseBodyAndHandleHttpError
, which says it only returns null|string
.
The best I can think of here would be to fork and throw exceptions when returns don't line up.
@GameCharmer : Could you create a PR and we can take a look at this please?
@abisalehalliprasan PR: https://github.com/intuit/QuickBooks-V3-PHP-SDK/pull/394
in
src/DataService/DataService.php
L793in
src/DataService/DataService.php
L635The Add method is returning Boolean FALSE. Add says it's only returning IPPIntuitEntity, the method it's directly returning says it's only returning null or string. What are my actual options here?