Andrew Wallo hace 6 meses
padre
commit
953fa48792

+ 13
- 9
app/Filament/Company/Resources/Sales/EstimateResource.php Ver fichero

@@ -153,15 +153,19 @@ class EstimateResource extends Resource
153 153
                                         $offeringId = $state;
154 154
                                         $offeringRecord = Offering::with(['salesTaxes', 'salesDiscounts'])->find($offeringId);
155 155
 
156
-                                        if ($offeringRecord) {
157
-                                            $set('description', $offeringRecord->description);
158
-                                            $set('unit_price', $offeringRecord->price);
159
-                                            $set('salesTaxes', $offeringRecord->salesTaxes->pluck('id')->toArray());
160
-
161
-                                            $discountMethod = DocumentDiscountMethod::parse($get('../../discount_method'));
162
-                                            if ($discountMethod->isPerLineItem()) {
163
-                                                $set('salesDiscounts', $offeringRecord->salesDiscounts->pluck('id')->toArray());
164
-                                            }
156
+                                        if (! $offeringRecord) {
157
+                                            return;
158
+                                        }
159
+
160
+                                        $unitPrice = CurrencyConverter::convertToFloat($offeringRecord->price, $get('../../currency_code') ?? CurrencyAccessor::getDefaultCurrency());
161
+
162
+                                        $set('description', $offeringRecord->description);
163
+                                        $set('unit_price', $unitPrice);
164
+                                        $set('salesTaxes', $offeringRecord->salesTaxes->pluck('id')->toArray());
165
+
166
+                                        $discountMethod = DocumentDiscountMethod::parse($get('../../discount_method'));
167
+                                        if ($discountMethod->isPerLineItem()) {
168
+                                            $set('salesDiscounts', $offeringRecord->salesDiscounts->pluck('id')->toArray());
165 169
                                         }
166 170
                                     }),
167 171
                                 Forms\Components\TextInput::make('description'),

+ 13
- 9
app/Filament/Company/Resources/Sales/InvoiceResource.php Ver fichero

@@ -167,15 +167,19 @@ class InvoiceResource extends Resource
167 167
                                         $offeringId = $state;
168 168
                                         $offeringRecord = Offering::with(['salesTaxes', 'salesDiscounts'])->find($offeringId);
169 169
 
170
-                                        if ($offeringRecord) {
171
-                                            $set('description', $offeringRecord->description);
172
-                                            $set('unit_price', $offeringRecord->price);
173
-                                            $set('salesTaxes', $offeringRecord->salesTaxes->pluck('id')->toArray());
174
-
175
-                                            $discountMethod = DocumentDiscountMethod::parse($get('../../discount_method'));
176
-                                            if ($discountMethod->isPerLineItem()) {
177
-                                                $set('salesDiscounts', $offeringRecord->salesDiscounts->pluck('id')->toArray());
178
-                                            }
170
+                                        if (! $offeringRecord) {
171
+                                            return;
172
+                                        }
173
+
174
+                                        $unitPrice = CurrencyConverter::convertToFloat($offeringRecord->price, $get('../../currency_code') ?? CurrencyAccessor::getDefaultCurrency());
175
+
176
+                                        $set('description', $offeringRecord->description);
177
+                                        $set('unit_price', $unitPrice);
178
+                                        $set('salesTaxes', $offeringRecord->salesTaxes->pluck('id')->toArray());
179
+
180
+                                        $discountMethod = DocumentDiscountMethod::parse($get('../../discount_method'));
181
+                                        if ($discountMethod->isPerLineItem()) {
182
+                                            $set('salesDiscounts', $offeringRecord->salesDiscounts->pluck('id')->toArray());
179 183
                                         }
180 184
                                     }),
181 185
                                 Forms\Components\TextInput::make('description'),

+ 12
- 8
app/Filament/Company/Resources/Sales/RecurringInvoiceResource.php Ver fichero

@@ -137,15 +137,19 @@ class RecurringInvoiceResource extends Resource
137 137
                                         $offeringId = $state;
138 138
                                         $offeringRecord = Offering::with(['salesTaxes', 'salesDiscounts'])->find($offeringId);
139 139
 
140
-                                        if ($offeringRecord) {
141
-                                            $set('description', $offeringRecord->description);
142
-                                            $set('unit_price', $offeringRecord->price);
143
-                                            $set('salesTaxes', $offeringRecord->salesTaxes->pluck('id')->toArray());
140
+                                        if (! $offeringRecord) {
141
+                                            return;
142
+                                        }
143
+
144
+                                        $unitPrice = CurrencyConverter::convertToFloat($offeringRecord->price, $get('../../currency_code') ?? CurrencyAccessor::getDefaultCurrency());
144 145
 
145
-                                            $discountMethod = DocumentDiscountMethod::parse($get('../../discount_method'));
146
-                                            if ($discountMethod->isPerLineItem()) {
147
-                                                $set('salesDiscounts', $offeringRecord->salesDiscounts->pluck('id')->toArray());
148
-                                            }
146
+                                        $set('description', $offeringRecord->description);
147
+                                        $set('unit_price', $unitPrice);
148
+                                        $set('salesTaxes', $offeringRecord->salesTaxes->pluck('id')->toArray());
149
+
150
+                                        $discountMethod = DocumentDiscountMethod::parse($get('../../discount_method'));
151
+                                        if ($discountMethod->isPerLineItem()) {
152
+                                            $set('salesDiscounts', $offeringRecord->salesDiscounts->pluck('id')->toArray());
149 153
                                         }
150 154
                                     }),
151 155
                                 Forms\Components\TextInput::make('description'),

Loading…
Cancelar
Guardar