Merged changes from main trunk up to 2.2.5
[fa-stable.git] / includes / types.inc
1 <?php
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 //----------------------------------------------------------------------------------
13 //      FrontAccounting system transaction types
14 //
15 define('ST_JOURNAL', 0);
16
17 define('ST_BANKPAYMENT', 1);
18 define('ST_BANKDEPOSIT', 2);
19 define('ST_BANKTRANSFER', 4);
20
21 define('ST_SALESINVOICE', 10);
22 define('ST_CUSTCREDIT', 11);
23 define('ST_CUSTPAYMENT', 12);
24 define('ST_CUSTDELIVERY', 13);
25
26 define('ST_LOCTRANSFER', 16);
27 define('ST_INVADJUST', 17);
28
29 define('ST_PURCHORDER', 18);
30 define('ST_SUPPINVOICE', 20);
31 define('ST_SUPPCREDIT', 21);
32 define('ST_SUPPAYMENT', 22);
33 define('ST_SUPPRECEIVE', 25);
34
35 define('ST_WORKORDER', 26);
36 define('ST_MANUISSUE', 28);
37 define('ST_MANURECEIVE', 29);
38
39
40 define('ST_SALESORDER', 30);
41 define('ST_SALESQUOTE', 32);
42 define('ST_COSTUPDATE', 35);
43 define('ST_DIMENSION', 40);
44
45 // Don't include these defines in the $systypes_array.
46 // They are used for documents only.
47 define ('ST_STATEMENT', 91);
48 define ('ST_CHEQUE', 92);
49
50 $systypes_array = array (
51         ST_JOURNAL => _("Journal Entry"),
52         ST_BANKPAYMENT => _("Bank Payment"),
53         ST_BANKDEPOSIT => _("Bank Deposit"),
54         ST_BANKTRANSFER => _("Funds Transfer"),
55         ST_SALESINVOICE => _("Sales Invoice"),
56         ST_CUSTCREDIT => _("Customer Credit Note"),
57         ST_CUSTPAYMENT => _("Customer Payment"),
58         ST_CUSTDELIVERY => _("Delivery Note"),
59         ST_LOCTRANSFER => _("Location Transfer"),
60         ST_INVADJUST => _("Inventory Adjustment"),
61         ST_PURCHORDER => _("Purchase Order"),
62         ST_SUPPINVOICE => _("Supplier Invoice"),
63         ST_SUPPCREDIT => _("Supplier Credit Note"),
64         ST_SUPPAYMENT => _("Supplier Payment"),
65         ST_SUPPRECEIVE => _("Purchase Order Delivery"),
66         ST_WORKORDER => _("Work Order"),
67         ST_MANUISSUE => _("Work Order Issue"),
68         ST_MANURECEIVE => _("Work Order Production"),
69         ST_SALESORDER => _("Sales Order"),
70         ST_SALESQUOTE => _("Sales Quotation"),
71         ST_COSTUPDATE => _("Cost Update"),
72         ST_DIMENSION => _("Dimension")
73         );
74
75 //----------------------------------------------------------------------------------
76 //              Bank transaction types
77 //
78 define('BT_TRANSFER', 0);
79 define('BT_CHEQUE', 1);
80 define('BT_CREDIT', 2);
81 define('BT_CASH', 3);
82
83 $bank_account_types = array (
84         BT_TRANSFER => _("Savings Account"),
85                 _("Chequing Account"),
86                 _("Credit Account"),
87                 _("Cash Account")
88         );
89
90 $bank_transfer_types = array(
91         BT_TRANSFER => _("Transfer"),
92                         _("Cheque"),
93                         _("Credit"),
94                         _("Cash")
95         );
96
97 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
98 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
99 include_once($path_to_root . "/sales/includes/sales_db.inc");
100 include_once($path_to_root . "/dimensions/includes/dimensions_db.inc");
101 //----------------------------------------------------------------------------------
102 //      Payment types
103 //
104 define('PT_MISC', 0);
105 define('PT_WORKORDER', 1);
106 define('PT_CUSTOMER', 2);
107 define('PT_SUPPLIER', 3);
108 define('PT_QUICKENTRY', 4);
109 define('PT_DIMESION', 5);
110
111 $payment_person_types = array (
112         PT_MISC => _("Miscellaneous"),
113                                 _("Work Order"),
114                                 _("Customer"),
115                                 _("Supplier"),
116                                 _("Quick Entry")
117         );
118
119 function payment_person_currency($type, $person_id)  {
120         switch ($type)
121         {
122                 case PT_MISC :
123                 case PT_QUICKENTRY :
124                 case PT_WORKORDER :
125                         return get_company_currency();
126
127                 case PT_CUSTOMER :
128                         return get_customer_currency($person_id);
129
130                 case PT_SUPPLIER :
131                         return get_supplier_currency($person_id);
132
133                 default :
134                         return get_company_currency();
135         }
136 }
137
138 function payment_person_name($type, $person_id, $full=true) {
139         global $payment_person_types;
140
141         switch ($type)
142         {
143                 case PT_MISC :
144                         return $person_id;
145                 case PT_QUICKENTRY :
146                         $qe = get_quick_entry($person_id);
147                         return ($full ? $payment_person_types[$type] . " ":"") . $qe["description"];
148                 case PT_WORKORDER :
149                         global $wo_cost_types;
150                         return $wo_cost_types[$person_id];
151                 case PT_CUSTOMER :
152                         return ($full ?$payment_person_types[$type] . " ":"") . get_customer_name($person_id);
153                 case PT_SUPPLIER :
154                         return ($full ? $payment_person_types[$type] . " ":"") . get_supplier_name($person_id);
155                 default :
156                         //DisplayDBerror("Invalid type sent to person_name");
157                         //return;
158                         return '';
159         }
160 }
161
162 function payment_person_has_items($type) {
163         switch ($type)
164         {
165                 case PT_MISC :
166                         return true;
167                 case PT_QUICKENTRY :
168                         return db_has_quick_entries();
169                 case PT_WORKORDER : // 070305 changed to open workorders JH
170                         return db_has_open_workorders();
171                 case PT_CUSTOMER :
172                         return db_has_customers();
173                 case PT_SUPPLIER :
174                         return db_has_suppliers();
175                 default :
176                         display_db_error("Invalid type sent to has_items", "");
177                         return false;
178         }
179 }
180
181 //----------------------------------------------------------------------------------
182 //      Manufacturing types
183 //
184 define('WO_ASSEMBLY', 0);
185 define('WO_UNASSEMBLY', 1);
186 define('WO_ADVANCED', 2);
187
188 $wo_types_array = array (
189         WO_ASSEMBLY => _("Assemble"),
190         WO_UNASSEMBLY => _("Unassemble"),
191         WO_ADVANCED => _("Advanced Manufacture")
192         );
193
194 define('WO_LABOUR', 0);
195 define('WO_OVERHEAD', 1);
196
197 $wo_cost_types = array(
198                 WO_LABOUR => _("Labour Cost"),
199                 WO_OVERHEAD => _("Overhead Cost"),
200 );
201
202 //----------------------------------------------------------------------------------
203 //      GL account classes
204 //
205 define('CL_NONE', 0); // for backward compatibility
206 define('CL_ASSETS', 1);
207 define('CL_LIABILITIES', 2);
208 define('CL_EQUITY', 3);
209 define('CL_INCOME', 4);
210 define('CL_COGS', 5);
211 define('CL_EXPENSE', 6);
212
213 $class_types = array(
214                 CL_ASSETS => _("Assets"),
215                 CL_LIABILITIES => _("Liabilities"),
216                 CL_EQUITY => _("Equity"),
217                 CL_INCOME => _("Income"),
218                 CL_COGS => _("Cost of Goods Sold"),
219                 CL_EXPENSE => _("Expense"),
220 );
221
222 function get_class_type_convert($ctype)
223 {
224         global $use_oldstyle_convert;
225         if (isset($use_oldstyle_convert) && $use_oldstyle_convert == 1)
226                 return (($ctype >= CL_INCOME || $ctype == CL_NONE) ? -1 : 1);
227         else    
228                 return ((($ctype >= CL_LIABILITIES && $ctype <= CL_INCOME) || $ctype == CL_NONE) ? -1 : 1);
229 }
230 //----------------------------------------------------------------------------------
231 //      Quick entry types
232 //
233 $quick_actions = array(
234         '=' => _('Remainder'), // post current base amount to GL account
235         'a' => _('Amount'), // post amount to GL account
236         'a+' => _('Amount, increase base'), // post amount to GL account and increase base
237         'a-' => _('Amount, reduce base'), // post amount to GL account and reduce base
238         '%' => _('% amount of base'),   // store acc*amount% to GL account
239         '%+' => _('% amount of base, increase base'),   // ditto & increase base amount
240         '%-' => _('% amount of base, reduce base'),     // ditto & reduce base amount
241         'T' => _('Taxes added'), // post taxes calculated on base amount
242         'T+' => _('Taxes added, increase base'), // ditto & increase base amount
243         'T-' => _('Taxes added, reduce base'), // ditto & reduce base amount
244         't' => _('Taxes included'), // post taxes calculated on base amount
245         't+' => _('Taxes included, increase base'), // ditto & increase base amount
246         't-' => _('Taxes included, reduce base') // ditto & reduce base amount
247 );
248
249 define('QE_PAYMENT', '1');
250 define('QE_DEPOSIT', '2');
251 define('QE_JOURNAL', '3');
252 define('QE_SUPPINV', '4');
253
254 $quick_entry_types = array(
255                 QE_DEPOSIT => _("Bank Deposit"),
256                 QE_PAYMENT => _("Bank Payment"),
257                 QE_JOURNAL => _("Journal Entry"),
258                 QE_SUPPINV => _("Supplier Invoice/Credit")
259 );
260
261 //----------------------------------------------------------------------------------
262 //      Special option values for various list selectors.
263 //
264 define('ANY_TEXT', '');
265 define('ANY_NUMERIC', -1);
266 define('ALL_TEXT', '');
267 define('ALL_NUMERIC', -1);
268
269
270 //----------------------------------------------------------------------------------
271 // Types of stock items
272 $stock_types = array(
273                 'M' => _("Manufactured"),
274                 'B' => _("Purchased"),
275                 'D' => _("Service")
276 );
277
278 //----------------------------------------------------------------------------------
279
280 define('TAG_ACCOUNT',   1);
281 define('TAG_DIMENSION', 2);
282
283 $tag_types = array (
284                 TAG_ACCOUNT   => _("Account"),
285                 TAG_DIMENSION => _("Dimension")
286 );
287
288 ?>