<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Create direct invoice programmatically]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=2963&amp;type=atom" />
	<updated>2012-04-27T20:12:32Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=2963</id>
		<entry>
			<title type="html"><![CDATA[Re: Create direct invoice programmatically]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=12338#p12338" />
			<content type="html"><![CDATA[<p>I, for one, would find a transaction import module very helpful. Have you made progress on this?</p>]]></content>
			<author>
				<name><![CDATA[sticmann]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=13743</uri>
			</author>
			<updated>2012-04-27T20:12:32Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=12338#p12338</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Create direct invoice programmatically]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=12171#p12171" />
			<content type="html"><![CDATA[<p>To save people&#039;s time, I got a better solution that works (after I had fixed some missing join columns in the customer and branch tables!), using routines in the sales_order_ui include:</p><p>&nbsp; &nbsp; $entry = new Cart(ST_SALESINVOICE, 0, true);<br />&nbsp; &nbsp; get_customer_details_to_order($entry, $customer_id, $branch_id);<br />&nbsp; &nbsp; add_to_order($entry, $item_code, 1, $gross, 0, $item_title);<br />&nbsp; &nbsp; $entry-&gt;cust_ref = $ref;<br />&nbsp; &nbsp; $taxes = $entry-&gt;get_taxes($shipping);<br />&nbsp; &nbsp; $entry-&gt;write(0);</p><p>When I had created the customer and branch records prior to creating the invoice, I had missed location, and shipper id, both of which are needed in order to re-read the sales order when it generates delivery notes and invoices.</p><p>When I have the customer payment allocation working, I&#039;ll submit the module to Joe in case anyone else finds it useful.</p>]]></content>
			<author>
				<name><![CDATA[asro]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=13855</uri>
			</author>
			<updated>2012-04-06T02:55:41Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=12171#p12171</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Create direct invoice programmatically]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=12170#p12170" />
			<content type="html"><![CDATA[<p>I&#039;m struggling with an add-on I&#039;m writing to import transactions from paypal. I have a version working fine creating bank deposits as cash sales, but what I&#039;d really like to do is create/update customer records, create direct invoices, and then allocate payments. The reason being that many customers might start with a paypal payment but later get invoiced directly for other work. Having all their details already in the system makes it less work later.</p><p>I have tried stepping though the cart class as a direct invoice is entered in the screen, and as far as I can see the following code might be the minimum required:</p><p>&nbsp; &nbsp; $entry = new Cart(ST_SALESINVOICE, 0);<br />&nbsp; &nbsp; $entry-&gt;set_customer($customer_id, $company, $currency, 0, -1, 0); <br />&nbsp; &nbsp; $myrow = get_sales_type($paypal_sales_type_id);<br />&nbsp; &nbsp; $entry-&gt;set_sales_type($myrow[&#039;id&#039;], $myrow[&#039;sales_type&#039;],<br />&nbsp; &nbsp; &nbsp; &nbsp; $myrow[&#039;tax_included&#039;], $myrow[&#039;factor&#039;]);<br />&nbsp; &nbsp; $entry-&gt;add_to_cart(0, $item_code, 1, $gross, 0, 0, $item_title, 0, 0, 0);<br />&nbsp; &nbsp; $taxes = $entry-&gt;get_taxes($shipping);<br />&nbsp; &nbsp; $entry-&gt;write(1);</p><p>There is a value in every variable, and the customer records have been set up, and I&#039;ve created direct invoices through FA using those generated customers.</p><p>But when I run my import I get an error for every transaction:</p><p>You have missing or invalid sales document in database (type:30, number:x).</p><p>Is anyone able to help?</p><p>Many thanks<br />Alastair</p>]]></content>
			<author>
				<name><![CDATA[asro]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=13855</uri>
			</author>
			<updated>2012-04-05T23:59:45Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=12170#p12170</id>
		</entry>
</feed>
