<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Anatomy of a Sales Transaction]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=7267&amp;type=atom" />
	<updated>2018-01-15T17:21:05Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=7267</id>
		<entry>
			<title type="html"><![CDATA[Anatomy of a Sales Transaction]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=30528#p30528" />
			<content type="html"><![CDATA[<p>In the making of a New Invoice and receiving payment for it, the following SQLs by operation occur:</p><p>1. Make a Sales Order, effect a Customer Delivery and then raise an invoice for it (A Non Cash Direct Invoice):<br /></p><div class="codebox"><pre><code>-- Table Prefix _1
-- Order No. 8
-- Sales Delivery No. 5
-- Sales Invoice No. 5
-- debtor_no 4

-- ST_SALESORDER
INSERT INTO `1_sales_orders` VALUES
(&#039;8&#039;, &#039;30&#039;, &#039;1&#039;, &#039;0&#039;, &#039;1&#039;, &#039;1&#039;, &#039;auto&#039;, &#039;&#039;, NULL, &#039;2018-01-07&#039;, &#039;1&#039;, &#039;1&#039;, &#039;N/A&#039;, NULL, NULL, &#039;Donald Easter LLC&#039;, &#039;0&#039;, &#039;DEF&#039;, &#039;2018-01-17&#039;, &#039;3&#039;, &#039;400&#039;, &#039;0&#039;, &#039;0&#039;);
INSERT INTO `1_sales_order_details` VALUES
(NULL, &#039;8&#039;, &#039;30&#039;, &#039;103&#039;, &#039;iPhone Cover Case&#039;, &#039;2&#039;, &#039;50&#039;, &#039;2&#039;, &#039;0&#039;, &#039;0&#039;),
(NULL, &#039;8&#039;, &#039;30&#039;, &#039;101&#039;, &#039;iPad Air 2 16GB&#039;, &#039;1&#039;, &#039;300&#039;, &#039;1&#039;, &#039;0&#039;, &#039;0&#039;);
INSERT INTO `1_audit_trail` VALUES
(NULL, &#039;30&#039;, &#039;8&#039;, &#039;1&#039;, &#039;2018-01-07 10:09:06&#039;, NULL, &#039;3&#039;, &#039;2018-01-07&#039;, &#039;0&#039;);

-- ST_CUSTDELIVERY
INSERT INTO `1_stock_moves` VALUES
(NULL, &#039;5&#039;, &#039;103&#039;, &#039;13&#039;, &#039;DEF&#039;, &#039;2018-01-07&#039;, &#039;50&#039;, &#039;auto&#039;, &#039;-2&#039;, &#039;10&#039;),
(NULL, &#039;5&#039;, &#039;101&#039;, &#039;13&#039;, &#039;DEF&#039;, &#039;2018-01-07&#039;, &#039;300&#039;, &#039;auto&#039;, &#039;-1&#039;, &#039;200&#039;);
INSERT INTO `1_debtor_trans` VALUES
(&#039;5&#039;, &#039;13&#039;, &#039;1&#039;, &#039;1&#039;, &#039;1&#039;, &#039;2018-01-07&#039;, &#039;2018-01-17&#039;, &#039;auto&#039;, &#039;1&#039;, &#039;8&#039;, &#039;400&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, &#039;1&#039;, &#039;1&#039;, &#039;0&#039;, &#039;0&#039;, &#039;3&#039;, &#039;1&#039;);
INSERT INTO `1_debtor_trans_details` VALUES
(NULL, &#039;5&#039;, &#039;13&#039;, &#039;103&#039;, &#039;iPhone Cover Case&#039;, &#039;50&#039;, &#039;2.38&#039;, &#039;2&#039;, &#039;0&#039;, &#039;10&#039;, &#039;2&#039;, &#039;11&#039;),
(NULL, &#039;5&#039;, &#039;13&#039;, &#039;101&#039;, &#039;iPad Air 2 16GB&#039;, &#039;300&#039;, &#039;14.29&#039;, &#039;1&#039;, &#039;0&#039;, &#039;200&#039;, &#039;1&#039;, &#039;12&#039;);
INSERT INTO `1_gl_trans` VALUES
(NULL, &#039;13&#039;, &#039;5&#039;, &#039;2018-01-07&#039;, &#039;5010&#039;, &#039;&#039;, &#039;20&#039;, &#039;0&#039;, &#039;0&#039;, NULL, NULL),
(NULL, &#039;13&#039;, &#039;5&#039;, &#039;2018-01-07&#039;, &#039;1510&#039;, &#039;&#039;, &#039;-20&#039;, &#039;0&#039;, &#039;0&#039;, NULL, NULL),
(NULL, &#039;13&#039;, &#039;5&#039;, &#039;2018-01-07&#039;, &#039;5010&#039;, &#039;&#039;, &#039;200&#039;, &#039;0&#039;, &#039;0&#039;, NULL, NULL),
(NULL, &#039;13&#039;, &#039;5&#039;, &#039;2018-01-07&#039;, &#039;1510&#039;, &#039;&#039;, &#039;-200&#039;, &#039;0&#039;, &#039;0&#039;, NULL, NULL);
INSERT INTO `1_trans_tax_details` VALUES (
(NULL, &#039;13&#039;, &#039;5&#039;, &#039;2018-01-07&#039;, &#039;1&#039;, &#039;5&#039;, &#039;1&#039;, &#039;1&#039;, &#039;380.95&#039;, &#039;19.05&#039;, &#039;auto&#039;, NULL);
INSERT INTO `1_audit_trail` VALUES
(NULL, &#039;13&#039;, &#039;5&#039;, &#039;1&#039;, &#039;2018-01-07 10:09:06&#039;, NULL, &#039;3&#039;, &#039;2018-01-07&#039;, &#039;0&#039;);

ST_SALESINVOICE
INSERT INTO `1_refs` VALUES
(&#039;5&#039;, &#039;10&#039;, &#039;001/2018&#039;);
INSERT INTO `1_debtor_trans` VALUES
(&#039;5&#039;, &#039;10&#039;, &#039;0&#039;, &#039;1&#039;, &#039;1&#039;, &#039;2018-01-07&#039;, &#039;2018-01-17&#039;, &#039;001/2018&#039;, &#039;1&#039;, &#039;8&#039;, &#039;400&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, &#039;1&#039;, &#039;1&#039;, &#039;0&#039;, &#039;0&#039;, &#039;3&#039;, &#039;1&#039;),
INSERT INTO `1_debtor_trans_details` VALUES
(NULL, &#039;5&#039;, &#039;10&#039;, &#039;103&#039;, &#039;iPhone Cover Case&#039;, &#039;50&#039;, &#039;2.38&#039;, &#039;2&#039;, &#039;0&#039;, &#039;10&#039;, &#039;0&#039;, &#039;13&#039;),
(NULL, &#039;5&#039;, &#039;10&#039;, &#039;101&#039;, &#039;iPad Air 2 16GB&#039;, &#039;300&#039;, &#039;14.29&#039;, &#039;1&#039;, &#039;0&#039;, &#039;200&#039;, &#039;0&#039;, &#039;14&#039;);
INSERT INTO `1_gl_trans` VALUES
(NULL, &#039;10&#039;, &#039;5&#039;, &#039;2018-01-07&#039;, &#039;4010&#039;, &#039;&#039;, &#039;-95.24&#039;, &#039;0&#039;, &#039;0&#039;, NULL, NULL),
(NULL, &#039;10&#039;, &#039;5&#039;, &#039;2018-01-07&#039;, &#039;4010&#039;, &#039;&#039;, &#039;-285.71&#039;, &#039;0&#039;, &#039;0&#039;, NULL, NULL),
(NULL, &#039;10&#039;, &#039;5&#039;, &#039;2018-01-07&#039;, &#039;1200&#039;, &#039;&#039;, &#039;400&#039;, &#039;0&#039;, &#039;0&#039;, &#039;2&#039;, &#039;1&#039;),
(NULL, &#039;10&#039;, &#039;5&#039;, &#039;2018-01-07&#039;, &#039;2150&#039;, &#039;&#039;, &#039;-19.05&#039;, &#039;0&#039;, &#039;0&#039;, NULL, NULL);
INSERT INTO `1_trans_tax_details` VALUES (
(NULL, &#039;10&#039;, &#039;5&#039;, &#039;2018-01-07&#039;, &#039;1&#039;, &#039;5&#039;, &#039;1&#039;, &#039;1&#039;, &#039;380.95&#039;, &#039;19.05&#039;, &#039;001/2018&#039;, &#039;0&#039;);
INSERT INTO `1_audit_trail` VALUES
(NULL, &#039;10&#039;, &#039;5&#039;, &#039;1&#039;, &#039;2018-01-07 10:09:06&#039;, NULL, &#039;3&#039;, &#039;2018-01-07&#039;, &#039;0&#039;);</code></pre></div><p>2. Receive a payment for the customer and allocate it entireely to the above invoice:<br /></p><div class="codebox"><pre><code>SET @alloc=400;
SET @bankcharge=5;

INSERT INTO `1_refs` VALUES
(&#039;4&#039;, &#039;12&#039;, &#039;001/2018&#039;);
INSERT INTO `1_bank_trans` VALUES
(NULL, &#039;12&#039;, &#039;4&#039;, &#039;1&#039;, &#039;001/2018&#039;, &#039;2018-01-07&#039;, @alloc-@bankcharge, &#039;0&#039;, &#039;0&#039;, &#039;2&#039;, &#039;1&#039;, NULL);
INSERT INTO `1_comments` VALUES
(&#039;12&#039;, &#039;4&#039;, &#039;2018-01-07&#039;, &#039;by outstation cheque&#039;);
INSERT INTO `1_cust_allocations` VALUES
(NULL, &#039;1&#039;, @alloc, &#039;0000-00-00&#039;, &#039;4&#039;, &#039;12&#039;, &#039;5&#039;, &#039;10&#039;);
INSERT INTO `1_debtor_trans` VALUES
(&#039;4&#039;, &#039;12&#039;, &#039;0&#039;, &#039;1&#039;, &#039;1&#039;, &#039;2018-01-07&#039;, &#039;0000-00-00&#039;, &#039;001/2018&#039;, &#039;0&#039;, &#039;0&#039;, &#039;400&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, @alloc, &#039;0&#039;, &#039;1&#039;, &#039;0&#039;, &#039;0&#039;, &#039;0&#039;, NULL, &#039;0&#039;),
UPDATE `1_debtor_trans` SET `alloc`=`ov_amount`-@alloc WHERE `type`=&#039;10&#039; AND `trans_no`=&#039;5&#039; AND `debtor_no`=&#039;4&#039;
INSERT INTO `1_gl_trans` VALUES
(NULL, &#039;12&#039;, &#039;4&#039;, &#039;2018-01-07&#039;, &#039;1060&#039;, &#039;&#039;, @alloc-@bankcharge, &#039;0&#039;, &#039;0&#039;, NULL, NULL),
(NULL, &#039;12&#039;, &#039;4&#039;, &#039;2018-01-07&#039;, &#039;1200&#039;, &#039;&#039;, -@alloc, &#039;0&#039;, &#039;0&#039;, &#039;2&#039;, &#039;1&#039;),
(NULL, &#039;12&#039;, &#039;4&#039;, &#039;2018-01-07&#039;, &#039;5690&#039;, &#039;&#039;, @bankcharge, &#039;0&#039;, &#039;0&#039;, NULL, NULL);
INSERT INTO `1_audit_trail` VALUES
(NULL, &#039;12&#039;, &#039;4&#039;, &#039;1&#039;, &#039;2018-01-07 10:13:49&#039;, NULL, &#039;3&#039;, &#039;2018-01-07&#039;, &#039;0&#039;);</code></pre></div><p>Note that the date of allocation is &quot;0000-00-00&quot; in 2 places above.<br />The actual date of payment is entered in the case of a Direct Invoice in Cash mode.<br />An audit trail entry is made after each transaction.</p><p>This should be useful for anyone trying to directly insert transactions..<br />All Account codes and rates are as per the demo chart of accounts&nbsp; - en_US-demo.sql.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2018-01-15T17:21:05Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=30528#p30528</id>
		</entry>
</feed>
