2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 /* definition of the Debtor Receipt/Credit note allocation class */
14 //-----------------------------------------------------------------------------------
24 var $amount; /*Total amount of the transaction in FX */
26 var $allocs; /*array of transactions allocated to */
28 function allocation($trans_no, $type, $person_id, $person_name, $amount, $date_)
30 $this->allocs = array();
32 $this->trans_no = $trans_no;
34 $this->person_id = $person_id;
35 $this->person_name = $person_name;
36 $this->amount = $amount;
37 $this->date_ = $date_;
40 function add_item($type, $type_no, $date_, $due_date, $amount, $amount_allocated,
45 $this->allocs[count($this->allocs)] = new allocation_item($type, $type_no,
46 $date_, $due_date, $amount, $amount_allocated, $current_allocated);
55 function update_item($index, $type, $type_no, $date_, $due_date,
56 $amount, $amount_allocated, $current_allocated)
60 $this->allocs[$index] = new allocation_item($type, $type_no,
61 $date_, $due_date, $amount, $amount_allocated, $current_allocated);
70 function add_or_update_item($type, $type_no, $date_, $due_date,
71 $amount, $amount_allocated, $current_allocated)
73 for ($i = 0; $i < count($this->allocs); $i++)
75 $item = $this->allocs[$i];
76 if (($item->type == $type) && ($item->type_no == $type_no))
78 return $this->update_item($i, $type, $type_no, $date_, $due_date,
79 $amount, $amount_allocated, $current_allocated);
82 return $this->add_item($type, $type_no, $date_, $due_date,
83 $amount, $amount_allocated, $current_allocated);
88 //-----------------------------------------------------------------------------------
99 var $amount_allocated;
102 var $current_allocated;
104 function allocation_item ($type, $type_no, $date_, $due_date, $amount,
105 $amount_allocated, $current_allocated)
109 $this->type_no = $type_no;
111 $this->date_ = $date_;
112 $this->due_date = $due_date;
114 $this->amount = $amount;
115 $this->amount_allocated = $amount_allocated;
116 $this->current_allocated = $current_allocated;
120 //-----------------------------------------------------------------------------------