@@ -46,7 +46,11 @@ public function create($request, $person = null, $organisation = null)
46
46
]);
47
47
48
48
if (isset ($ request ->invoiceLines )) {
49
+ $ invoiceLineOrder = 0 ;
50
+
49
51
foreach ($ request ->invoiceLines as $ invoiceLine ) {
52
+ $ invoiceLineOrder ++;
53
+
50
54
if (isset ($ invoiceLine ['product_id ' ]) && $ invoiceLine ['quantity ' ] > 0 ) {
51
55
if (! Product::find ($ invoiceLine ['product_id ' ])) {
52
56
$ newProduct = $ this ->addProduct ($ invoiceLine , $ request );
@@ -77,6 +81,7 @@ public function create($request, $person = null, $organisation = null)
77
81
'currency ' => $ request ->currency ,
78
82
'order_product_id ' => $ invoiceLine ['order_product_id ' ] ?? null ,
79
83
'comments ' => $ invoiceLine ['comments ' ],
84
+ 'order ' => $ invoiceLineOrder ,
80
85
]);
81
86
}
82
87
}
@@ -146,8 +151,11 @@ public function update($request, Invoice $invoice, $person = null, $organisation
146
151
147
152
if (isset ($ request ->invoiceLines )) {
148
153
$ invoiceLineIds = [];
154
+ $ invoiceLineOrder = 0 ;
149
155
150
156
foreach ($ request ->invoiceLines as $ line ) {
157
+ $ invoiceLineOrder ++;
158
+
151
159
if (isset ($ line ['invoice_line_id ' ]) && $ invoiceLine = InvoiceLine::find ($ line ['invoice_line_id ' ])) {
152
160
if (! isset ($ line ['product_id ' ]) || $ line ['quantity ' ] == 0 ) {
153
161
$ invoiceLine ->delete ();
@@ -179,6 +187,7 @@ public function update($request, Invoice $invoice, $person = null, $organisation
179
187
'tax_amount ' => $ line ['amount ' ] * ($ taxRate / 100 ),
180
188
'currency ' => $ request ->currency ,
181
189
'comments ' => $ line ['comments ' ],
190
+ 'order ' => $ invoiceLineOrder ,
182
191
]);
183
192
184
193
$ invoiceLineIds [] = $ invoiceLine ->id ;
@@ -212,6 +221,7 @@ public function update($request, Invoice $invoice, $person = null, $organisation
212
221
'tax_amount ' => $ line ['amount ' ] * ($ taxRate / 100 ),
213
222
'currency ' => $ request ->currency ,
214
223
'comments ' => $ line ['comments ' ],
224
+ 'order ' => $ invoiceLineOrder ,
215
225
]);
216
226
217
227
$ invoiceLineIds [] = $ invoiceLine ->id ;
0 commit comments