Skip to content

Commit 67a6460

Browse files
authored
Merge pull request #1411 from Blair2004/v4.8.x
V4.8.x
2 parents 7e51e77 + 6dfb0d7 commit 67a6460

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1448
-680
lines changed

app/Crud/CustomerAccountCrud.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function __construct()
215215
public function hook( $query ): void
216216
{
217217
$query->orderBy( 'id', 'desc' );
218-
$query->where( 'nexopos_customers_account_history.customer_id', request()->query( 'customer_id' ) );
218+
$query->where( Hook::filter( 'ns-model-table', 'nexopos_customers_account_history.customer_id' ), request()->query( 'customer_id' ) );
219219
}
220220

221221
public function addFooterSummary( CrudBeforeExportEvent $event )

app/Crud/ExpenseCrud.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,16 @@ public function getForm( $entry = null )
222222
'value' => 'x_after_month_starts',
223223
],
224224
],
225-
'name' => 'occurence',
225+
'name' => 'occurrence',
226226
'label' => __( 'Occurrence' ),
227227
'description' => __( 'Define how often this expenses occurs' ),
228-
'value' => $entry->occurence ?? '',
228+
'value' => $entry->occurrence ?? '',
229229
], [
230230
'type' => 'text',
231-
'name' => 'occurence_value',
231+
'name' => 'occurrence_value',
232232
'label' => __( 'Occurrence Value' ),
233233
'description' => __( 'Must be used in case of X days after month starts and X days before month ends.' ),
234-
'value' => $entry->occurence_value ?? '',
234+
'value' => $entry->occurrence_value ?? '',
235235
], [
236236
'type' => 'textarea',
237237
'name' => 'description',
@@ -406,7 +406,7 @@ public function getColumns()
406406
'$direction' => '',
407407
'$sort' => false,
408408
],
409-
'occurence' => [
409+
'occurrence' => [
410410
'label' => __( 'Occurrence' ),
411411
'$direction' => '',
412412
'$sort' => false,
@@ -432,18 +432,18 @@ public function setActions( CrudEntry $entry, $namespace )
432432
$entry->value = (string) ns()->currency->value( $entry->value );
433433
$entry->recurring = (bool) $entry->recurring ? __( 'Yes' ) : __( 'No' );
434434

435-
switch ( $entry->occurence ) {
436-
case 'month_start' : $entry->occurence = __( 'Month Starts' );
435+
switch ( $entry->occurrence ) {
436+
case 'month_start' : $entry->occurrence = __( 'Month Starts' );
437437
break;
438-
case 'month_mid' : $entry->occurence = __( 'Month Middle' );
438+
case 'month_mid' : $entry->occurrence = __( 'Month Middle' );
439439
break;
440-
case 'month_end' : $entry->occurence = __( 'Month Ends' );
440+
case 'month_end' : $entry->occurrence = __( 'Month Ends' );
441441
break;
442-
case 'x_after_month_starts' : $entry->occurence = __( 'X Days Before Month Starts' );
442+
case 'x_after_month_starts' : $entry->occurrence = __( 'X Days Before Month Starts' );
443443
break;
444-
case 'x_before_month_ends' : $entry->occurence = __( 'X Days Before Month Ends' );
444+
case 'x_before_month_ends' : $entry->occurrence = __( 'X Days Before Month Ends' );
445445
break;
446-
default: $entry->occurence = __( 'Unknown Occurrence' );
446+
default: $entry->occurrence = __( 'Unknown Occurrence' );
447447
break;
448448
}
449449

app/Http/Controllers/Dashboard/OrdersController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ public function orderInvoice( Order $order )
233233

234234
$order->products = Hook::filter( 'ns-receipt-products', $order->products );
235235

236+
$order->paymentStatus = $this->ordersService->getPaymentLabel( $order->payment_status );
237+
$order->deliveryStatus = $this->ordersService->getPaymentLabel( $order->delivery_status );
238+
236239
return $this->view( 'pages.dashboard.orders.templates.invoice', [
237240
'order' => $order,
238241
'options' => $optionsService->get(),
@@ -244,7 +247,7 @@ public function orderInvoice( Order $order )
244247

245248
public function orderRefundReceipt( OrderRefund $refund )
246249
{
247-
$refund->load( 'order.customer', 'order.refundedProducts', 'order.refund.author', 'order.shipping_address', 'order.billing_address', 'order.user' );
250+
$refund->load( 'order.customer', 'order.refundedProducts', 'order.refunds.author', 'order.shipping_address', 'order.billing_address', 'order.user' );
248251
$refund->load( 'refunded_products.product', 'refunded_products.unit' );
249252

250253
$refund->refunded_products = Hook::filter( 'ns-refund-receipt-products', $refund->refunded_products );

app/Models/Order.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,6 @@ public function user()
143143
return $this->hasOne( User::class, 'id', 'author' );
144144
}
145145

146-
/**
147-
* @deprecated
148-
*/
149-
public function refund()
150-
{
151-
return $this->hasMany( OrderRefund::class, 'order_id', 'id' );
152-
}
153-
154146
public function refunds()
155147
{
156148
return $this->hasMany( OrderRefund::class, 'order_id', 'id' );

app/Models/OrderProduct.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public function product()
8888
return $this->hasOne( Product::class, 'id', 'product_id' );
8989
}
9090

91-
public function refunded_product()
91+
public function refunded_products()
9292
{
93-
return $this->hasOne(
93+
return $this->hasMany(
9494
related: OrderProductRefund::class,
9595
foreignKey: 'order_product_id',
9696
localKey: 'id'

app/Providers/AppServiceProvider.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Classes\Hook;
66
use App\Events\ModulesBootedEvent;
77
use App\Models\Order;
8+
use App\Models\OrderProductRefund;
89
use App\Models\Permission;
910
use App\Services\BarcodeService;
1011
use App\Services\CashRegistersService;
@@ -197,14 +198,15 @@ public function register()
197198

198199
$this->app->bind( OrdersService::class, function( $app ) {
199200
return new OrdersService(
200-
$app->make( CustomerService::class ),
201-
$app->make( ProductService::class ),
202-
$app->make( UnitService::class ),
203-
$app->make( DateService::class ),
204-
$app->make( CurrencyService::class ),
205-
$app->make( Options::class ),
206-
$app->make( TaxService::class ),
207-
$app->make( ReportService::class ),
201+
customerService: $app->make( CustomerService::class ),
202+
productService: $app->make( ProductService::class ),
203+
unitService: $app->make( UnitService::class ),
204+
dateService: $app->make( DateService::class ),
205+
currencyService: $app->make( CurrencyService::class ),
206+
optionsService: $app->make( Options::class ),
207+
taxService: $app->make( TaxService::class ),
208+
reportService: $app->make( ReportService::class ),
209+
mathService: $app->make( MathService::class ),
208210
);
209211
});
210212

@@ -287,5 +289,12 @@ protected function loadConfiguration()
287289
->mapWithKeys( fn( $type ) => [ $type[ 'identifier' ] => $type[ 'label' ] ])
288290
->toArray(),
289291
]);
292+
293+
config([
294+
'nexopos.orders.products.refunds' => [
295+
OrderProductRefund::CONDITION_DAMAGED => __( 'Damaged' ),
296+
OrderProductRefund::CONDITION_UNSPOILED => __( 'Good Condition' ),
297+
]
298+
]);
290299
}
291300
}

app/Services/DemoCoreService.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,31 @@ public function prepareDefaultUnitSystem()
109109
}
110110
}
111111

112+
public function createBaseSettings()
113+
{
114+
$orderTypes = app()->make( OrdersService::class )->getTypeLabels();
115+
116+
/**
117+
* @var Options $optionService
118+
*/
119+
$optionService = app()->make( Options::class );
120+
121+
$optionService->set(
122+
'ns_pos_order_types',
123+
array_values( $orderTypes )
124+
);
125+
126+
$optionService->set(
127+
'ns_currency_symbol',
128+
'$'
129+
);
130+
131+
$optionService->set(
132+
'ns_currency_iso',
133+
'USD'
134+
);
135+
}
136+
112137
public function createAccountingAccounts()
113138
{
114139
/**

app/Services/DemoService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public function run( $data )
9494
*/
9595
extract( $data );
9696

97+
$this->createBaseSettings();
9798
$this->prepareDefaultUnitSystem();
9899
$this->createCustomers();
99100
$this->createAccountingAccounts();

app/Services/ExpenseService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public function handleRecurringExpenses()
416416
->active()
417417
->get()
418418
->map( function( $expense ) {
419-
switch ( $expense->occurence ) {
419+
switch ( $expense->occurrence ) {
420420
case 'month_starts':
421421
$expenseScheduledDate = Carbon::parse( $this->dateService->copy()->startOfMonth() );
422422
break;
@@ -427,10 +427,10 @@ public function handleRecurringExpenses()
427427
$expenseScheduledDate = Carbon::parse( $this->dateService->copy()->endOfMonth() );
428428
break;
429429
case 'x_before_month_ends':
430-
$expenseScheduledDate = Carbon::parse( $this->dateService->copy()->endOfMonth()->subDays( $expense->occurence_value ) );
430+
$expenseScheduledDate = Carbon::parse( $this->dateService->copy()->endOfMonth()->subDays( $expense->occurrence_value ) );
431431
break;
432432
case 'x_after_month_starts':
433-
$expenseScheduledDate = Carbon::parse( $this->dateService->copy()->startOfMonth()->addDays( $expense->occurence_value ) );
433+
$expenseScheduledDate = Carbon::parse( $this->dateService->copy()->startOfMonth()->addDays( $expense->occurrence_value ) );
434434
break;
435435
}
436436

app/Services/Options.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ public function build()
100100
**/
101101
public function set( $key, $value, $expiration = null )
102102
{
103+
/**
104+
* We rather like to remove unecessary spaces. That might
105+
* cause unwanted behaviors.
106+
*/
107+
$key = trim( strtolower( $key ) );
108+
103109
/**
104110
* if an option has been found,
105111
* it will save the new value and update
@@ -118,7 +124,7 @@ public function set( $key, $value, $expiration = null )
118124
$option = $foundOption->first();
119125
}
120126

121-
$option->key = trim( strtolower( $key ) );
127+
$option->key = $key;
122128
$option->array = false;
123129

124130
if ( is_array( $value ) ) {

0 commit comments

Comments
 (0)