/** * @covers Intacct\Functions\Purchasing\PurchasingTransactionLineCreate::writeXml */ public function testParamsOverrides() { $expected = <<<EOF <?xml version="1.0" encoding="UTF-8"?> <potransitem> <itemid>26323</itemid> <itemdesc>Item Description</itemdesc> <taxable>true</taxable> <warehouseid>93294</warehouseid> <quantity>2340</quantity> <unit>593</unit> <price>32.35</price> <overridetaxamount>1.23</overridetaxamount> <tax>9.23</tax> <locationid>SF</locationid> <departmentid>Purchasing</departmentid> <memo>Memo</memo> <itemdetails> <itemdetail> <quantity>52</quantity> <lotno>3243</lotno> </itemdetail> </itemdetails> <form1099>true</form1099> <customfields> <customfield> <customfieldname>customfield1</customfieldname> <customfieldvalue>customvalue1</customfieldvalue> </customfield> </customfields> <projectid>235</projectid> <customerid>23423434</customerid> <vendorid>797656</vendorid> <employeeid>90295</employeeid> <classid>243609</classid> <contractid>9062</contractid> <billable>true</billable> </potransitem> EOF; $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->setIndentString(' '); $xml->startDocument(); $entry = new PurchasingTransactionLineCreate(); $entry->setItemId('26323'); $entry->setItemDescription('Item Description'); $entry->setTaxable(true); $entry->setWarehouseId('93294'); $entry->setQuantity(2340); $entry->setUnit('593'); $entry->setPrice(32.35); $entry->setOverrideTaxAmount(1.23); $entry->setTax(9.23); $entry->setMemo('Memo'); $entry->setBillable(true); $entry->setForm1099(true); $entry->setLocationId('SF'); $entry->setDepartmentId('Purchasing'); $entry->setProjectId('235'); $entry->setCustomerId('23423434'); $entry->setVendorId('797656'); $entry->setEmployeeId('90295'); $entry->setClassId('243609'); $entry->setContractId('9062'); $itemDetail1 = new TransactionItemDetail(); $itemDetail1->setQuantity(52); $itemDetail1->setLotNumber('3243'); $entry->setItemDetails([$itemDetail1]); $entry->setCustomFields(['customfield1' => 'customvalue1']); $entry->writeXml($xml); $this->assertXmlStringEqualsXmlString($expected, $xml->flush()); }
/** * @covers Intacct\Functions\Purchasing\PurchasingTransactionCreate::writeXml */ public function testParamOverrides() { $expected = <<<EOF <?xml version="1.0" encoding="UTF-8"?> <function controlid="unittest"> <create_potransaction> <transactiontype>Purchase Order</transactiontype> <datecreated> <year>2015</year> <month>06</month> <day>30</day> </datecreated> <dateposted> <year>2015</year> <month>06</month> <day>30</day> </dateposted> <createdfrom>Purchase Order-P1002</createdfrom> <vendorid>23530</vendorid> <documentno>23430</documentno> <referenceno>234235</referenceno> <termname>N30</termname> <datedue> <year>2020</year> <month>09</month> <day>24</day> </datedue> <message>Submit</message> <shippingmethod>USPS</shippingmethod> <returnto> <contactname>Bobbi Reese</contactname> </returnto> <payto> <contactname>Henry Jones</contactname> </payto> <supdocid>6942</supdocid> <externalid>20394</externalid> <basecurr>USD</basecurr> <currency>USD</currency> <exchratedate> <year>2015</year> <month>06</month> <day>30</day> </exchratedate> <exchratetype>Intacct Daily Rate</exchratetype> <customfields> <customfield> <customfieldname>customfield1</customfieldname> <customfieldvalue>customvalue1</customfieldvalue> </customfield> </customfields> <state>Pending</state> <potransitems> <potransitem> <itemid>2390552</itemid> <quantity>223</quantity> </potransitem> </potransitems> <subtotals> <subtotal> <description>Subtotal description</description> <total>223</total> </subtotal> </subtotals> </create_potransaction> </function> EOF; $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->setIndentString(' '); $xml->startDocument(); $transaction = new PurchasingTransactionCreate('unittest'); $transaction->setTransactionDefinition('Purchase Order'); $transaction->setTransactionDate(new DateType('2015-06-30')); $transaction->setGlPostingDate(new DateType('2015-06-30')); $transaction->setCreatedFrom('Purchase Order-P1002'); $transaction->setVendorId('23530'); $transaction->setDocumentNumber('23430'); $transaction->setReferenceNumber('234235'); $transaction->setPaymentTerm('N30'); $transaction->setDueDate(new DateType('2020-09-24')); $transaction->setMessage('Submit'); $transaction->setShippingMethod('USPS'); $transaction->setReturnToContactName('Bobbi Reese'); $transaction->setPayToContactName('Henry Jones'); $transaction->setAttachmentsId('6942'); $transaction->setExternalId('20394'); $transaction->setBaseCurrency('USD'); $transaction->setTransactionCurrency('USD'); $transaction->setExchangeRateDate(new DateType('2015-06-30')); $transaction->setExchangeRateType('Intacct Daily Rate'); $transaction->setState('Pending'); $transaction->setCustomFields(['customfield1' => 'customvalue1']); $line1 = new PurchasingTransactionLineCreate(); $line1->setItemId('2390552'); $line1->setQuantity(223); $transaction->setLines([$line1]); $subtotal1 = new TransactionSubtotalCreate(); $subtotal1->setDescription('Subtotal description'); $subtotal1->setTotal(223); $transaction->setSubtotals([$subtotal1]); $transaction->writeXml($xml); $this->assertXmlStringEqualsXmlString($expected, $xml->flush()); }