Topic: Report branch customers

I need help I need in report customer balance filter by branch customer

For example customer 1 total is 3500
Branch 1 = 1500
Branch 2 =2000
I need report for this branch filter in customer balance

Re: Report branch customers

@joe: nice feature - can implement it - branch-wise split up of sales for each customer. A simple checkbox (boolean flag) for branch-wise reporting should be sufficient in the report request form.

Re: Report branch customers

Yes indeed. It looks a little overwhelming, but let us see. I will have a look.

/Joe

Re: Report branch customers

Hello again,

I have been looking into this, and also thought that this would be an ok task, but it turned out to be a complex task. The current options are many and one more would simple take a lot of work force.
For those who would like to give it a go, please create it as a module or own report in client folder.

/Joe

5 (edited by poncho1234 08/20/2020 06:05:17 pm)

Re: Report branch customers

I've modified rep115 a little; this is the result

Its a permanent modification so no option to turn off/on

If this meets the requirements I'll publish code changes and if ok will make it into an extension.

A total for the customer could be confusing as the customer has its own branch too and it can be selected in sales.

Post's attachments

BranchWise.png 32.4 kb, 1 downloads since 2020-08-20 

You don't have the permssions to download the attachments of this post.
The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Report branch customers

hello poncho1234

can you share this code report

Thanks

7 (edited by poncho1234 08/31/2020 06:19:08 pm)

Re: Report branch customers

Differences as follows

File: <unsaved>
01: ---   \reporting\rep115ORIGINAL.php
02: +++\reporting\rep115.php
03: @@ -29,7 +29,7 @@
04:  
05:  print_customer_balances();
06:  
07: -function get_open_balance($debtorno, $to)
08: +function get_open_balance($debtorno, $branchcode, $to)
09:  {
10:      if ($to)
11:          $to = date2sql($to);
12: @@ -43,17 +43,18 @@
13:      $sql .= "SUM(IF(t.type = ".ST_SALESINVOICE.", 1, -1) *
14:          (abs(t.ov_amount + t.ov_gst + t.ov_freight + t.ov_freight_tax + t.ov_discount) - abs(t.alloc))) AS OutStanding
15:          FROM ".TB_PREF."debtor_trans t
16: -        WHERE t.debtor_no = ".db_escape($debtorno)
17: +        WHERE t.debtor_no = ".db_escape($debtorno)."
18: +        AND t.branch_code=".db_escape($branchcode)
19:          ." AND t.type <> ".ST_CUSTDELIVERY;
20:      if ($to)
21:          $sql .= " AND t.tran_date < '$to'";
22: -    $sql .= " GROUP BY debtor_no";
23: +    // $sql .= " GROUP BY debtor_no";
24:  
25:      $result = db_query($sql,"No transactions were returned");
26:      return db_fetch($result);
27:  }
28:  
29: -function get_transactions($debtorno, $from, $to, $only_rec)
30: +function get_transactions($debtorno, $branchcode, $from, $to, $only_rec)
31:  {
32:      $from = date2sql($from);
33:      $to = date2sql($to);
34: @@ -82,7 +83,8 @@
35:          LEFT JOIN $allocated_to ON alloc_to.trans_type = trans.type AND alloc_to.trans_no = trans.trans_no
36:          WHERE trans.tran_date >= '$from'
37:          AND trans.tran_date <= '$to'
38: -        AND trans.debtor_no = ".db_escape($debtorno);
39: +        AND trans.debtor_no = ".db_escape($debtorno)."
40: +        AND trans.branch_code=".db_escape($branchcode);
41:      $sql .= " AND trans.type <> ".ST_CUSTDELIVERY;
42:      $sql .= " AND ISNULL(voided.id)
43:          ORDER BY trans.tran_date ";
44: @@ -158,7 +160,7 @@
45:      $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
46:      //$cols = array(0, 70, 140, 180, 230, 270, 350, 445, 495, 555);
47:  
48: -    $headers = array(_('Name'), '', '', _('Open Balance'), _('Debit'), _('Credit'), '', _('Balance'));
49: +    $headers = array(_('Name'), '', _('Branch'), _('Open Balance'), _('Debit'), _('Credit'), '', _('Balance'));
50:  
51:      $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
52:  
53: @@ -179,7 +181,7 @@
54:  
55:      $grandtotal = array(0,0,0,0);
56:  
57: -    $sql = "SELECT ".TB_PREF."debtors_master.debtor_no, name, curr_code FROM ".TB_PREF."debtors_master
58: +    $sql = "SELECT ".TB_PREF."debtors_master.debtor_no, name, br_name, branch_code, curr_code FROM ".TB_PREF."debtors_master
59:          INNER JOIN ".TB_PREF."cust_branch
60:          ON ".TB_PREF."debtors_master.debtor_no=".TB_PREF."cust_branch.debtor_no
61:          INNER JOIN ".TB_PREF."areas
62: @@ -204,7 +206,7 @@
63:          $sql .= " WHERE ".TB_PREF."salesman.salesman_code=".db_escape($folk);
64:      }
65:  
66: -    $sql .= " GROUP BY ".TB_PREF."debtors_master.debtor_no ORDER BY name";
67: +    // $sql .= " GROUP BY ".TB_PREF."debtors_master.debtor_no ORDER BY name";
68:  
69:      $result = db_query($sql, "The customers could not be retrieved");
70:  
71: @@ -215,7 +217,7 @@
72:  
73:          $accumulate = 0;
74:          $rate = $convert ? get_exchange_rate_from_home_currency($myrow['curr_code'], Today()) : 1;
75: -        $bal = get_open_balance($myrow['debtor_no'], $from, $convert);
76: +        $bal = get_open_balance($myrow['debtor_no'], $myrow['branch_code'], $from, $convert);
77:          $init[0] = $init[1] = 0.0;
78:          $init[0] = round2(abs($bal['charges'] * $rate), $dec);
79:          $init[1] = round2(Abs($bal['credits'] * $rate), $dec);
80: @@ -223,7 +225,7 @@
81:          $init[3] = $init[0] - $init[1];
82:          $accumulate += $init[3];
83:  
84: -        $res = get_transactions($myrow['debtor_no'], $from, $to, false);
85: +        $res = get_transactions($myrow['debtor_no'], $myrow['branch_code'], $from, $to, false);
86:  
87:          $total = array(0,0,0,0);
88:          for ($i = 0; $i < 4; $i++)
89: @@ -279,6 +281,7 @@
90:          }
91:          if ($no_zeros && $total[3] == 0.0 && $curr_db == 0.0 && $curr_cr == 0.0) continue;
92:          $rep->TextCol(0, 2, $myrow['name']);
93: +        $rep->TextCol(2, 3, $myrow['br_name']);
94:          $rep->AmountCol(3, 4, $total[3] + $curr_cr - $curr_db, $dec);
95:          $rep->AmountCol(4, 5, $curr_db, $dec);
96:          $rep->AmountCol(5, 6, $curr_cr, $dec);
The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Report branch customers

@joe: want to add in core?

Re: Report branch customers

@apmuthu: Probable demand for this is low/no customer totals/no branch filter

So best as an extension?

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Report branch customers

If all this needs is just a report request form check box without the need for any db changes or even sys_prefs changes, why not.

It is best if it is displayed for a specific customer so that totals do not get messed up for those witout multiple branches.