176

(114 replies, posted in Reporting)

@boxygen

Thanks for setting up the testing for this.

The bug arises only when adding g/l tax accounts to a supplier invoice, otherwise all seems to work correctly.   Then the totals do not match and the tax report shows a double entry.   I reproduced this on your testsite with supplier invoice reference "abcde".

#4 is a separate issue and results in different totals, because as I recall, the inquiry adds the journal amount to both input and output and the report adds it just once.

177

(114 replies, posted in Reporting)

@itronics

Thanks for your explanation which really helps to define what is and what isn't a bug in these reports.

I think that if only the third assumption is mistaken, then perhaps I could add a check box that could add in deposits or payments.    With this box checked, then it is easy to reconcile the report/inquiry with G/L inquiry of a given tax account, since the balances should then match (except if tax register is not checked in case 4). 

I do believe that the current 2.4.4 reports have bugs based on assumptions 1,2, an 4.   I will wait until boxygen reports the results of his investigation and then open a bug report and offer my code as a possible solution.

If you click on a link that pops up a window, and then you close the popup window, the search criteria should not be affected, because you never left the page.  For example, if you are in Journal Inquiry and you click on the open book to display the g/l entries, and then close that window, the search criteria should not be reset because nothing has changed in that window.

If you click on a link that takes you to another page (say the pencil to modify a transaction), the back button will return to the page with the search criteria reset.

179

(114 replies, posted in Reporting)

@itronics

I would be happy to open a bug report in Mantis, however I also do not claim to understand the issues either which is why this thread is so long and no bug report was ever opened.  This thread is over a year old and I entered the discussion only recently when sledge stated that he did not see any purchases tax and I wondered why.   Then rafat chimed in and stated one way it could arise: by adding g/l tax accounts on a supplier invoice.   I did some testing and found out that these tax entries had reg_type set to NULL and the 2.4 code was ignoring that.   Others have mentioned that the results returned by the 2.3 pages and 2.4 pages differ.

To summarize how I thought it should work:

1. the tax inquiry page and the tax report should have the same totals and no duplicate entries
2. g/l entries to tax accounts on supplier invoices should included as input tax
3. bank payments to tax accounts should be included as input tax
4. g/ journal entries to/from tax accounts where the tax register box is clicked should be included as input or output tax.

With these assumptions,  the tax inquiry page/report would give a picture of how much is owed to a tax authority.  For me, that would be useful, because I can use these pages to see how my collections are tracking with my payments which I could use to discover if my collections or payments are in error, or if I need to use g/j entries to reset these accounts and declare income/loss on the difference (for example, if I was only collecting say 5% but really owed 6% on the tax forms that were paid).

Note that I use different g/l accounts to track taxes paid on actual purchases so that these g/l accounts do not skew the above.

But perhaps this was not the way these reports were intended to work in 2.4 and I respect that.   I only entered this discussion out of curiosity and am satisfied with how my modified pages work on my site, which has a different core anyway.

180

(114 replies, posted in Reporting)

@rafat
@itronics

I think the reason why tax inquiry and the tax report are not working in 2.4 is because of the changes introduced by adding reg_type to the trans_tax_details table.  This commit added the reg_type and changed how these pages work.  As I said earlier in this thread, it would be nice if reg_type was not NULL in several cases which perhaps has defeated the reason why reg_type was added to 2.4.   Here is the latest gl/includes/db/gl_db_trans.inc which seems to fix the tax inquiry page for journal entries by removing more code that was deliberately introduced in 2.4 and which I do not understand.

181

(114 replies, posted in Reporting)

@seahawk
@rafat

I updated the rep709.php to show more of the bank payment/deposit fields (account name, bottom memo, line memo).   It uses an additional line rather than trying to pick and choose what to display in the reference number column.  Let me know what you think.

182

(114 replies, posted in Reporting)

@seahawk

Were you testing the 2.4.6 tax report or my version?

If you were using my version, and the report showed a bank payment or journal with the bottom memo, was the person a quick entry or a supplier, customer, or miscellaneous name?

183

(114 replies, posted in Reporting)

@rafat

The tax report fails to show miscellaneous names because they are missing from the gl_trans table.  The gl_trans table neglects to store the person_id for miscellaneous names because the function add_gl_trans in gl_db_trans.inc calls this code:

    if (!is_subledger_account($account) || $account==get_company_pref('grn_clearing_act'))
        $person_id = $person_type_id = null;

The function is_subledger_account returns true only for customer or supplier names, so clears the name for miscellaneous names.

I have run into this before and do not understand why it does this, but the names can be retrieved with an additional sql step.  So this is a bug that I suspect you may see on other reports as well.

I updated the rep_709.php with this change.

184

(114 replies, posted in Reporting)

I think it needs more testing.  I was hoping seahawk and perhaps others would try out the code and see if it works on their sites.  rafat isn't able to see the name on payments/deposit.  But yes, if this fixes something that people need, then both the tax report and tax inquiry should be included in the core.

185

(114 replies, posted in Reporting)

@rafat

Double check if your rep_709.php has the code change:

+++ b/core/reporting/rep709.php
@@ -35,9 +35,10 @@ function getTaxTransactions($from, $to)
 
        $sql = "SELECT tt.name as taxname, taxrec.*, taxrec.amount*ex_rate AS amount,
                    taxrec.net_amount*ex_rate AS net_amount,
-                               IF(taxrec.trans_type=".ST_BANKPAYMENT." OR taxrec.trans_type=".ST_BANKDEPOSIT.", 
-                                       IF(gl.person_type_id<>".PT_MISC.", gl.memo_, gl.person_id), 
-                                       IF(ISNULL(supp.supp_name), debt.name, supp.supp_name)) as name,
+                IF(ISNULL(supp.supp_name),
+                    IF(ISNULL(debt.name),
+                        IF(gl.person_type_id<>".PT_MISC.", gl.memo_, gl.person_id), debt.name),
+                        supp.supp_name) as name,
                                branch.br_name
                FROM ".TB_PREF."trans_tax_details taxrec
                LEFT JOIN ".TB_PREF."tax_types tt

With the new code, if the transaction (including bank payments and deposits) has a supplier name or customer name, it will be used.  Then if it has a miscellaneous name, it will be used.  Finally, it would use the memo.

So I think the name field must be non-blank, unless the payment was a quickentry and the memo was blank.

186

(114 replies, posted in Reporting)

@rafat

Sorry, the memo is in the tax table and not the ref# for bank payments, although with some more sql it may be possible to retrieve it.

Note that for suppliers the report prints the supplier reference number, usually the supplier check number.   But FA lacks bank check numbers, so if one enters the bank check number into the memo field, then it appears on the report, which is actually what we do.

Here is the blank name fix:
rep_709.php.

187

(114 replies, posted in Reporting)

@rafat

Thanks for testing this.  I updated gl_db_trans.inc (tax inquiry) and rep_709.php.  The inquiry should match the report and include payments and deposits as well as supplier invoices.

188

(10 replies, posted in Dimensions)

Yes, customers are your landlord clients.  Dimensions are your properties.   This structure is similar to job costing.

You will just have to experiment to see if FA can meet your needs.   You may have already identified one weakness in that there might not be a way to tie a landlord (customer) to the properties (dimensions) and generate a report for just the properties that belong to that landlord.

Or maybe you could use tags?  Each landlord could be a tag and each property is tagged with the landlord tag.   As I said, tags are useful for grouping but there is limited support for tags.  I don't know if it would work.

Or maybe you could use 2 sets of dimensions (Company->Setup dimensions=2) where the first dimension could be the landlord and the second dimension the property.   That may allow FA to generate a report per landlord showing the properties?  I don't use 2 sets of dimensions so I really do not know how that would work.

Unless you have financial dealings with tenants, they might just be an informational item in the customer notes.

Best of luck.  Post again if you discover a structure that works for you or if you are unable to make it work.   Perhaps it may help someone else in a similar evaluation.

189

(10 replies, posted in Dimensions)

There is no support for restricting access to a given dimension.

If the sides of the business (brokerage/property management) are indeed completely separate and do not share any transactions in any bank account or credit card, then separate companies are in order.

However, if any banking is shared, it is better to use one company with two dimensions.   You cannot restrict your bookkeeper from viewing both dimensions.  However, you can limit the ability to edit transactions (Access Setup->Edit other users transactions), so if you enter all the transactions for the brokerage side, the bookkeeper cannot change them.

190

(114 replies, posted in Reporting)

Interesting.

The sql change in the report for 2.4.6 is this:

-            AND taxrec.trans_type <> ".ST_CUSTDELIVERY."
+            AND !ISNULL(taxrec.reg_type)

This makes all the difference because NULL reg_types occur in supplier invoices, general journal, payments and deposits if one uses a tax g/l account.  The 2.4.6 code filters them out.

I modified the 2.4.6 report for rafat:

            AND (!ISNULL(taxrec.reg_type) OR taxrec.trans_type=".ST_SUPPINVOICE.")

to handle the NULL  reg_type for supplier invoices, but I mentioned that I knew it did not handle g/j, payments or deposits.

I would suggest next reverting the 2.4.6 sql change while retaining the GROUP BY taxrec.id that I added.  Here is the link rep709.php that perhaps seahawk could test.

Does anyone know who made this change and why?

191

(10 replies, posted in Dimensions)

Quickbooks classes are the same as FA dimensions.

Tags were introduced for filtering G/L accounts on reports. They could work for you by using separate G/L accounts (or sub accounts) where transactions are posted and tagging each G/L account .   Every property transaction would need the correct G/L account.   Support for tags is limited.  Tagging would be useful if you need to examine profitability of groups of properties.

Simpler would be to assign a dimension to each property.  Every property transaction would need a dimension.

FA supports two levels of dimensions.   You can have a single company with two dimensions (brokerage and property management).  The property management side can have property dimensions.  Then you can generate separate P/L statements for the brokerage and property management side, as well as separate P/L for each property.

You are better off with using dimensions than creating two sets of books in most cases.  That is because bank accounts and expenses can be shared within a single company.  For example, if you have a single credit card and pay for expenses for both sides of the company, reconciliation is simple if both sides are part of the same company but impossible with two sets of books.

You should experiment by creating a company and trying out your ideas and look at the P/L statements.  Run those by your accountant or bookkeeper and see if they make sense.   You will save yourself and others time if you set up a system that everyone is comfortable with.

Try to keep the number of G/L accounts/dimensions to a bare minimum.   The more you have, the more complex is the transaction data entry.   For example, if you pay for some item and it is not clear which property it is for or is shared between multiple properties, that bogs down data entry.   You may find that keeping data entry separate for each property is a nightmare and not worth the effort in tracking profitability.

192

(114 replies, posted in Reporting)

@rafat   I fixed the tax report and updated the link to the new code in my previous comment.

193

(114 replies, posted in Reporting)

@rafat

must be a typo somewhere.   I put the changes temporarily in my fork:
Tax Inquiry gl/includes/db/gl_db_trans.inc
Tax Report reporting/rep709.php

caveat: FA creates a bogus "net amount" (based on the tax amount and tax rate) for manually created tax g/l account transactions, so that will look strange.

caveat: this is only for g/l tax accounts on the supplier invoice.  It does not handle g/j, deposits, or payments to tax g/l accounts.

It is obvious to me that FA is not expecting users to create manual tax g/l accounts transactions.  Rather, it expects that the supplier be assigned a tax group and taxes be assigned through the tax system.  Then all seems to work fine.

194

(114 replies, posted in Reporting)

rafat is correct.  If tax g/l accounts are used on the supplier invoice, either by quick entry or g/l line items, the reg_type is NULL.

That is unfortunate because the tax inquiry report is not expecting that.   Without reg_type set correctly in the database, the tax inquiry or tax reports have to guess.

So the fix for Tax Inquiry has to be something like:

+++ b/core/gl/includes/db/gl_db_trans.inc
@@ -532,12 +532,12 @@ function get_tax_summary($from, $to, $also_zero_purchases=false)
                                        ), amount*ex_rate,0)) payable,
 
                                SUM(IF(trans_type IN(".ST_SUPPCREDIT."),-1,1)*
-                               IF(reg_type=".TR_INPUT
+                               IF((reg_type=".TR_INPUT." OR trans_type =".ST_SUPPINVOICE.")"
                                        . ($also_zero_purchases ? '': " AND tax_type_id AND taxrec.rate")
                                        .", net_amount*ex_rate, 0)) net_input,
 
                                SUM(IF(trans_type IN(".ST_SUPPCREDIT."),-1,1)*
-                               IF(reg_type=".TR_INPUT
+                               IF((reg_type=".TR_INPUT." OR trans_type =".ST_SUPPINVOICE.")"
                                        . ($also_zero_purchases ? '': " AND tax_type_id AND taxrec.rate ") 
                                        .", amount*ex_rate, 0)) collectible,
                                taxrec.rate,

But what about G/J entries, deposits and payments?

195

(114 replies, posted in Reporting)

@sledge

Before you go, it would be nice to learn why the tax inquiry report is showing zeroes for purchases in your database.  The tax inquiry report and sql is simple so it should not be difficult to find out why.  Because you already are familiar with phpmyadmin, you could use that to examine your database.

1. Click on your trans_tax_details file.
2. edit inline the select statement:

SELECT * FROM `trans_tax_details` where reg_type=1 and tax_type_id != 0

This shows you all the purchase taxes.   In order for the tax_inquiry report to show non-zero data, the trans_type field must be valid (20 for purchase invoices), the dates must be valid, the amount/rate fields must be non-zero, and most importantly the tax_type_id must point to a valid tax type.

Look it up by clicking on the tax_types table.  Is it a valid tax type id?

If all the data is valid, then the tax inquiry report will show non-zero purchased amounts.

Feel free to post your results.

FA requires a counterparty in G/J when referencing an accounts payable g/l account used by a supplier.  Thus using A/P in G/J requires a counterparty.

You can change the code to remove the restriction or simply use Payments or Deposits for the checking account against the A/P and FA will not require a counterparty.

You are right that my suggestion does not work, it caused sales order entry to completely fail.

The problem is not just limited to tax exempt suppliers.  STRICT_ALL_TABLES for also caused sales order entry for an order with a tax exempt item to fail as well:

Cannot save trans tax details
error code : 1366
error message : Incorrect integer value: '' for column 'tax_type_id' at row 1
sql that failed was : INSERT INTO 1_trans_tax_details (trans_type, trans_no, tran_date, tax_type_id, rate, ex_rate, included_in_price, net_amount, amount, memo, reg_type) VALUES ('13','6083','2019-01-24','','','1',1,'3.15','0','auto',NULL)

The sql failure is the same as the tax exempt supplier problem:

DATABASE ERROR : Cannot save trans tax details
error code : 1366
error message : Incorrect integer value: '' for column 'tax_type_id' at row 1
sql that failed was : INSERT INTO 0_trans_tax_details (trans_type, trans_no, tran_date, tax_type_id, rate, ex_rate, included_in_price, net_amount, amount, memo, reg_type) VALUES ('20','5','2018-12-31','','','1',0,'10','0','rr8','1')

On my site, these errors are easy to reproduce.  On the demo database, I changed DinoSaurius to Tax Exempt.  Then I tried to create a direct supplier invoice with a single item.

Modifying connect_db_mysqli.inc as notrinos suggests also fixes the problem.

My core is synced to apmuthus latest code.  Thus it has the recent commit with SQL_MODE set to STRICT_ALL_TABLES.  Thus it appears that this commit causes the problem.

I am using php 5.x on ubuntu 16 and php 7.2 on ubuntu 18.

I think it happened after I installed os updates with a mysql update on both Ubuntu 16 and 18, because it used to work fine, but I do muck with my core so maybe it is my own fault, but I couldn't see how I could have caused it.  I will try to reproduce this on standard FA when I have a chance.  If I can't, then I will delete this post.

Anyway, mysql failed on an insert to trans_tax_details because tax_type_id is blank and tax_type_id is defined as an integer in the table.  It also didn't like rate set to null, which is defined as not null in the table.

I fixed the problem in my core:

+++ b/core/taxes/tax_calc.inc
@@ -161,7 +161,7 @@ function get_tax_for_items($items, $prices, $shipping_cost, $tax_group, $tax_inc
                $ret_tax_array[$k]['Net'] = 0;
        }
        
-       $ret_tax_array['exempt'] = array('Value'=>0, 'Net'=>0, 'rate' => null, 'tax_type_id' => '', 'sales_gl_code' => '');
+       $ret_tax_array['exempt'] = array('Value'=>0, 'Net'=>0, 'rate' => 0, 'tax_type_id' => 0, 'sales_gl_code' => '');
        $dec = user_price_dec();
        // loop for all items

I wonder if this is some new feature of mysql and if there is some strictness configuration setting for it?  If so, I am sure someone can enlighten me.

200

(13 replies, posted in Accounts Receivable)

@boxygen:

I like your extension which should work correctly with invoices created by Direct Invoice.   I particularly like your approach of overriding existing FA pages in hooks.php, a technique I had not seen before.

However, I do not think it will work correctly with a manually created invoice, because the void_transaction() call in your sales_order_entry.php does not void the deliveries of this invoice type.

If so, you might want to consider adding code to limit the extension to direct invoices, or void all the deliveries, which is what I did in my code.