Topic: Import Transactions Direct Invoice paid by card

For some time I have been successfully using:
Import Transactions -> Direct Sales Invoice Processing
to import our cash sales...

Recently we started taking card payments,
so I set up the card payment terms, created a gl account and bank account, and POS for credit cards...

So I thought that in order to import the card payments I would just set the payment id in the csv to '11' (the card payment terms id from lookup), they are all imported without error, but the payment goes to the petty cash bank account instead of card merchant bank account

It seems to ignore the payment id of 11 and behaves as if it was set to 4

Am I missing something, or is it not possible - or where do I need to modify code to get the required result for payment id of 11?

Re: Import Transactions Direct Invoice paid by card

FA limits direct customer sales invoices to cash accounts.  This is because Setup->Points Of Sales->Default Cash Account is limited to cash accounts.  This is easily overridden with the code change:

--- a/core/sales/manage/sales_points.php
+++ b/core/sales/manage/sales_points.php
@@ -130,7 +130,11 @@ text_row_ex(_("Point of Sale Name").':', 'name', 20, 30);
 if($cash) {
        check_row(_('Allowed credit sale terms selection:'), 'credit', check_value('credit_sale'));
        check_row(_('Allowed cash sale terms selection:'), 'cash',  check_value('cash_sale'));
-       cash_accounts_list_row(_("Default cash account").':', 'account');
+        // POS systems often allow direct deposit into bank accounts,
+        // so do not restrict the POS "cash sale" to cash accounts
+       // cash_accounts_list_row(_("Default cash account").':', 'account');
+       bank_accounts_list_row(_("Default account").':', 'account');
 } else {
        hidden('credit', 1);
        hidden('account', 0);

By making this code change, a pos can be created with a non-cash account.   Then use Setup->User Accounts Setup to create a user with this POS.  Then try import transactions using this user.

I do not know if this will work, but it may get you further than before.

I do know that the rest of FA tolerates this change because my site uses this.  But I do not use Import Transactions for this purpose.

Re: Import Transactions Direct Invoice paid by card

@joe: Can we have a company specific flag to choose this option as a sys_prefs record? Or should we just have "cash and bank" accounts available in the select box?

4 (edited by drgrumpy 12/17/2020 07:49:38 pm)

Re: Import Transactions Direct Invoice paid by card

Hmm, thanks for the suggestion Braath Waite but I already have my 'merchant account' set as Cash account.

I have been importing as super admin, but perhaps I need to be logged in as specific user.

In trying to figure out how the code works, I see that payment_id is used to get payment terms
$cart->payment_terms = get_payment_terms($payment_id);

But I cannot locate where the get_payment_terms() function is defined....
I have searched the code, if anyone can give me a clue...
found it in db/

Re: Import Transactions Direct Invoice paid by card

So after some further testing....

If I log in as a user with 'card payments POS' then when I import, all payments are credited to the 'merchant account' even if they were cash payments with a payment_id of 4.

In the short term I can sort the payments into two separate files, then login as different users to import as cash and card... but this is not really satisfactory....

Re: Import Transactions Direct Invoice paid by card

Yes, that is the behavior that I would expect because import transactions inherits the POS from the user profile, which is why I suggested trying it as a first measure.

You could change the import transactions code to assign the POS based on some key in your input file.  It is not difficult.  The cart has a pos variable.  You just need to populate it with the pos that you want to use.  Define one POS for each payment method (cash, credit card, check, gift card, etc).

function get_sales_point_by_name($name)
        $sql = "SELECT pos.*, loc.location_name, acc.bank_account_name FROM "
                .TB_PREF."sales_pos as pos
                LEFT JOIN ".TB_PREF."locations as loc on pos.pos_location=loc.loc_code
                LEFT JOIN ".TB_PREF."bank_accounts as acc on
                WHERE pos.pos_name=".db_escape($name);

        $result = db_query($sql, "could not get POS definition");

        return db_fetch($result);

$cart->pos=get_sales_point_by_name("Credit Card");

Re: Import Transactions Direct Invoice paid by card

@braathwaate: Please specify which file this function can be in and how and where it may be called in the extension. Is it specific to your version of the Import Transactions extension?

Re: Import Transactions Direct Invoice paid by card

@apmuthu:  This function is in my osCommerce and Square extensions.  These extensions import sales orders into FA, which is the same purpose as Import Transactions -> Sales Orders.  The function retrieves the FA sales point by name suitable for populating $cart->pos, which allows an order to specify the bank account for a direct invoice payment.

The function isn't necessary.   The core provides get_sales_point($id) (sales/includes/db/ which can be used to populate $cart->pos, if you know the mysql key to the sales point.   The function that I suggested allows the sales point to be retrieved by name rather than id.

Import Transactions -> Sales Orders does not have the ability to specify multiple sales points and neither does the core.  By design, the core relies on a single POS per user.  All user transactions use this POS.  To me, that design seems rather inflexible, and discussions about changing that design have not been well received.

Therefore, customization is required to pick and choose multiple sales points when running under a single user.  Import Transactions -> Sales Order could be customized by adding a sales point field (id or name) to the import file and then in the code setting $cart->pos = get_sales_point($id) or $cart->pos = get_sales_point_by_name($name).

Re: Import Transactions Direct Invoice paid by card

Thanks for that suggestion, I will investigate...