Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
BillMapper | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
1 | <?php |
2 | /** |
3 | * Jingga |
4 | * |
5 | * PHP Version 8.1 |
6 | * |
7 | * @package Modules\Billing\Models |
8 | * @copyright Dennis Eichhorn |
9 | * @license OMS License 2.0 |
10 | * @version 1.0.0 |
11 | * @link https://jingga.app |
12 | */ |
13 | declare(strict_types=1); |
14 | |
15 | namespace Modules\Billing\Models; |
16 | |
17 | use Modules\Admin\Models\AccountMapper; |
18 | use Modules\Billing\Models\Attribute\BillAttributeMapper; |
19 | use Modules\ClientManagement\Models\ClientMapper; |
20 | use Modules\Editor\Models\EditorDocMapper; |
21 | use Modules\Media\Models\CollectionMapper; |
22 | use Modules\Media\Models\MediaMapper; |
23 | use Modules\SupplierManagement\Models\SupplierMapper; |
24 | use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; |
25 | |
26 | /** |
27 | * Mapper class. |
28 | * |
29 | * WARNING: This mapper may use a trigger to update the sequence number on insert. |
30 | * |
31 | * @package Modules\Billing\Models |
32 | * @license OMS License 2.0 |
33 | * @link https://jingga.app |
34 | * @since 1.0.0 |
35 | * |
36 | * @template T of Bill |
37 | * @extends DataMapperFactory<T> |
38 | */ |
39 | class BillMapper extends DataMapperFactory |
40 | { |
41 | /** |
42 | * Columns. |
43 | * |
44 | * @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}> |
45 | * @since 1.0.0 |
46 | */ |
47 | public const COLUMNS = [ |
48 | 'billing_bill_id' => ['name' => 'billing_bill_id', 'type' => 'int', 'internal' => 'id'], |
49 | 'billing_bill_sequence' => ['name' => 'billing_bill_sequence', 'type' => 'int', 'internal' => 'sequence'], |
50 | 'billing_bill_number' => ['name' => 'billing_bill_number', 'type' => 'string', 'internal' => 'number'], |
51 | 'billing_bill_type' => ['name' => 'billing_bill_type', 'type' => 'int', 'internal' => 'type'], |
52 | 'billing_bill_template' => ['name' => 'billing_bill_template', 'type' => 'int', 'internal' => 'template'], |
53 | 'billing_bill_header' => ['name' => 'billing_bill_header', 'type' => 'string', 'internal' => 'header'], |
54 | 'billing_bill_footer' => ['name' => 'billing_bill_footer', 'type' => 'string', 'internal' => 'footer'], |
55 | 'billing_bill_info' => ['name' => 'billing_bill_info', 'type' => 'string', 'internal' => 'info'], |
56 | 'billing_bill_status' => ['name' => 'billing_bill_status', 'type' => 'int', 'internal' => 'status'], |
57 | 'billing_bill_paymentstatus' => ['name' => 'billing_bill_paymentstatus', 'type' => 'int', 'internal' => 'paymentStatus'], |
58 | 'billing_bill_shipTo' => ['name' => 'billing_bill_shipTo', 'type' => 'string', 'internal' => 'shipTo'], |
59 | 'billing_bill_shipFAO' => ['name' => 'billing_bill_shipFAO', 'type' => 'string', 'internal' => 'shipFAO'], |
60 | 'billing_bill_shipAddr' => ['name' => 'billing_bill_shipAddr', 'type' => 'string', 'internal' => 'shipAddress'], |
61 | 'billing_bill_shipCity' => ['name' => 'billing_bill_shipCity', 'type' => 'string', 'internal' => 'shipCity'], |
62 | 'billing_bill_shipZip' => ['name' => 'billing_bill_shipZip', 'type' => 'string', 'internal' => 'shipZip'], |
63 | 'billing_bill_shipCountry' => ['name' => 'billing_bill_shipCountry', 'type' => 'string', 'internal' => 'shipCountry'], |
64 | 'billing_bill_billTo' => ['name' => 'billing_bill_billTo', 'type' => 'string', 'internal' => 'billTo'], |
65 | 'billing_bill_billFAO' => ['name' => 'billing_bill_billFAO', 'type' => 'string', 'internal' => 'billFAO'], |
66 | 'billing_bill_billAddr' => ['name' => 'billing_bill_billAddr', 'type' => 'string', 'internal' => 'billAddress'], |
67 | 'billing_bill_billCity' => ['name' => 'billing_bill_billCity', 'type' => 'string', 'internal' => 'billCity'], |
68 | 'billing_bill_billZip' => ['name' => 'billing_bill_billZip', 'type' => 'string', 'internal' => 'billZip'], |
69 | 'billing_bill_billCountry' => ['name' => 'billing_bill_billCountry', 'type' => 'string', 'internal' => 'billCountry'], |
70 | 'billing_bill_netprofit' => ['name' => 'billing_bill_netprofit', 'type' => 'Serializable', 'internal' => 'netProfit'], |
71 | 'billing_bill_grossprofit' => ['name' => 'billing_bill_grossprofit', 'type' => 'Serializable', 'internal' => 'grossProfit'], |
72 | 'billing_bill_netcosts' => ['name' => 'billing_bill_netcosts', 'type' => 'Serializable', 'internal' => 'netCosts'], |
73 | 'billing_bill_grosscosts' => ['name' => 'billing_bill_grosscosts', 'type' => 'Serializable', 'internal' => 'grossCosts'], |
74 | 'billing_bill_netsales' => ['name' => 'billing_bill_netsales', 'type' => 'Serializable', 'internal' => 'netSales'], |
75 | 'billing_bill_grosssales' => ['name' => 'billing_bill_grosssales', 'type' => 'Serializable', 'internal' => 'grossSales'], |
76 | 'billing_bill_netdiscount' => ['name' => 'billing_bill_netdiscount', 'type' => 'Serializable', 'internal' => 'netDiscount'], |
77 | 'billing_bill_grossdiscount' => ['name' => 'billing_bill_grossdiscount', 'type' => 'Serializable', 'internal' => 'grossDiscount'], |
78 | 'billing_bill_currency' => ['name' => 'billing_bill_currency', 'type' => 'string', 'internal' => 'currency'], |
79 | 'billing_bill_language' => ['name' => 'billing_bill_language', 'type' => 'string', 'internal' => 'language'], |
80 | 'billing_bill_referral' => ['name' => 'billing_bill_referral', 'type' => 'int', 'internal' => 'referral'], |
81 | 'billing_bill_referral_name' => ['name' => 'billing_bill_referral_name', 'type' => 'string', 'internal' => 'referralName'], |
82 | 'billing_bill_reference' => ['name' => 'billing_bill_reference', 'type' => 'int', 'internal' => 'reference'], |
83 | 'billing_bill_payment' => ['name' => 'billing_bill_payment', 'type' => 'int', 'internal' => 'payment'], |
84 | 'billing_bill_payment_text' => ['name' => 'billing_bill_payment_text', 'type' => 'string', 'internal' => 'paymentText'], |
85 | 'billing_bill_paymentterms' => ['name' => 'billing_bill_paymentterms', 'type' => 'int', 'internal' => 'terms'], |
86 | 'billing_bill_paymentterms_text' => ['name' => 'billing_bill_paymentterms_text', 'type' => 'string', 'internal' => 'termsText'], |
87 | 'billing_bill_ship_type' => ['name' => 'billing_bill_ship_type', 'type' => 'int', 'internal' => 'shipping'], |
88 | 'billing_bill_ship_text' => ['name' => 'billing_bill_ship_text', 'type' => 'string', 'internal' => 'shippingText'], |
89 | 'billing_bill_account_no' => ['name' => 'billing_bill_account_no', 'type' => 'string', 'internal' => 'accountNumber'], |
90 | 'billing_bill_client' => ['name' => 'billing_bill_client', 'type' => 'int', 'internal' => 'client'], |
91 | 'billing_bill_supplier' => ['name' => 'billing_bill_supplier', 'type' => 'int', 'internal' => 'supplier'], |
92 | 'billing_bill_created_by' => ['name' => 'billing_bill_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], |
93 | 'billing_bill_date' => ['name' => 'billing_bill_date', 'type' => 'DateTime', 'internal' => 'billDate'], |
94 | 'billing_bill_performance_date' => ['name' => 'billing_bill_performance_date', 'type' => 'DateTime', 'internal' => 'performanceDate', 'readonly' => true], |
95 | 'billing_bill_created_at' => ['name' => 'billing_bill_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], |
96 | 'billing_bill_unit' => ['name' => 'billing_bill_unit', 'type' => 'int', 'internal' => 'unit'], |
97 | ]; |
98 | |
99 | /** |
100 | * Has many relation. |
101 | * |
102 | * @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}> |
103 | * @since 1.0.0 |
104 | */ |
105 | public const HAS_MANY = [ |
106 | 'elements' => [ |
107 | 'mapper' => BillElementMapper::class, |
108 | 'table' => 'billing_bill_element', |
109 | 'self' => 'billing_bill_element_bill', |
110 | 'external' => null, |
111 | ], |
112 | 'files' => [ |
113 | 'mapper' => MediaMapper::class, |
114 | 'table' => 'billing_bill_media', |
115 | 'external' => 'billing_bill_media_dst', |
116 | 'self' => 'billing_bill_media_src', |
117 | ], |
118 | 'notes' => [ |
119 | 'mapper' => EditorDocMapper::class, /* mapper of the related object */ |
120 | 'table' => 'billing_bill_note', /* table of the related object, null if no relation table is used (many->1) */ |
121 | 'external' => 'billing_bill_note_doc', |
122 | 'self' => 'billing_bill_note_bill', |
123 | ], |
124 | ]; |
125 | |
126 | /** |
127 | * Has one relation. |
128 | * |
129 | * @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}> |
130 | * @since 1.0.0 |
131 | */ |
132 | public const OWNS_ONE = [ |
133 | 'type' => [ |
134 | 'mapper' => BillTypeMapper::class, |
135 | 'external' => 'billing_bill_type', |
136 | ], |
137 | 'referral' => [ |
138 | 'mapper' => AccountMapper::class, |
139 | 'external' => 'billing_bill_referral', |
140 | ], |
141 | 'template' => [ |
142 | 'mapper' => CollectionMapper::class, |
143 | 'external' => 'billing_bill_template', |
144 | ], |
145 | ]; |
146 | |
147 | /** |
148 | * Belongs to. |
149 | * |
150 | * @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}> |
151 | * @since 1.0.0 |
152 | */ |
153 | public const BELONGS_TO = [ |
154 | 'createdBy' => [ |
155 | 'mapper' => AccountMapper::class, |
156 | 'external' => 'billing_bill_created_by', |
157 | ], |
158 | 'client' => [ |
159 | 'mapper' => ClientMapper::class, |
160 | 'external' => 'billing_bill_client', |
161 | ], |
162 | 'supplier' => [ |
163 | 'mapper' => SupplierMapper::class, |
164 | 'external' => 'billing_bill_supplier', |
165 | ], |
166 | 'attributes' => [ |
167 | 'mapper' => BillAttributeMapper::class, |
168 | 'table' => 'billing_bill_attr', |
169 | 'self' => 'billing_bill_attr_bill', |
170 | 'conditional' => true, |
171 | 'external' => null, |
172 | ], |
173 | ]; |
174 | |
175 | /** |
176 | * Primary field name. |
177 | * |
178 | * @var string |
179 | * @since 1.0.0 |
180 | */ |
181 | public const PRIMARYFIELD = 'billing_bill_id'; |
182 | |
183 | /** |
184 | * Primary table. |
185 | * |
186 | * @var string |
187 | * @since 1.0.0 |
188 | */ |
189 | public const TABLE = 'billing_bill'; |
190 | } |