From 1fb67192f26c2b70e47ccd92109735ee8a2af5ee Mon Sep 17 00:00:00 2001 From: Blair2004 Date: Fri, 30 Jul 2021 16:39:13 +0100 Subject: [PATCH] Update - Added : refund receipt for orders - Fixed: issue while removing permissions - Added: enhanced refunds --- app/Crud/OrderCrud.php | 22 +++ .../Dashboard/OrdersController.php | 28 ++++ .../Dashboard/ProductsController.php | 9 +- app/Models/Order.php | 16 ++ app/Models/OrderRefund.php | 7 +- app/Models/Role.php | 2 +- app/Services/OrdersService.php | 36 ++++- .../dashboard/orders/ns-order-details.vue | 15 +- .../dashboard/orders/ns-order-refund.vue | 4 +- resources/ts/popups.ts | 2 + .../ts/popups/ns-orders-preview-popup.vue | 10 +- .../ts/popups/ns-orders-refund-popup.vue | 138 ++++++++++++++++++ .../popups/ns-pos-customer-select-popup.vue | 2 +- resources/ts/popups/ns-pos-customers.vue | 6 +- resources/ts/popups/ns-pos-units.vue | 1 + .../pages/dashboard/orders/list.blade.php | 15 ++ .../_dashboard_refund_receipt.blade.php | 16 ++ ...de.php => _naked_refund_receipt.blade.php} | 2 +- .../orders/templates/_receipt.blade.php | 10 +- .../templates/_refund_receipt.blade.php | 69 +++++++++ .../orders/templates/refund-receipt.blade.php | 2 + routes/api/orders.php | 2 + routes/nexopos.php | 1 + tests/Feature/HandlePermissionsManagement.php | 22 +++ tests/Feature/OrderRefundTest.php | 2 +- 25 files changed, 413 insertions(+), 26 deletions(-) create mode 100644 resources/ts/popups/ns-orders-refund-popup.vue create mode 100755 resources/views/pages/dashboard/orders/templates/_dashboard_refund_receipt.blade.php rename resources/views/pages/dashboard/orders/templates/{_naked_receipt.blade.php => _naked_refund_receipt.blade.php} (50%) create mode 100755 resources/views/pages/dashboard/orders/templates/_refund_receipt.blade.php create mode 100755 resources/views/pages/dashboard/orders/templates/refund-receipt.blade.php create mode 100644 tests/Feature/HandlePermissionsManagement.php diff --git a/app/Crud/OrderCrud.php b/app/Crud/OrderCrud.php index 31d6fc348..e743fd979 100755 --- a/app/Crud/OrderCrud.php +++ b/app/Crud/OrderCrud.php @@ -9,6 +9,7 @@ use Exception; use App\Models\Order; use App\Services\OrdersService; +use Illuminate\Support\Facades\DB; class OrderCrud extends CrudService { @@ -508,6 +509,27 @@ public function setActions( $entry, $namespace ) ] ]; + /** + * We'll check if the order has refunds + * to add a refund receipt for printing + */ + $refundCount = DB::table( Hook::filter( 'ns-model-table', 'nexopos_orders_refunds' ) ) + ->where( 'order_id', $entry->id ) + ->count(); + + $hasRefunds = $refundCount > 0; + + if ( $hasRefunds ) { + array_splice( $entry->{ '$actions' }, 3, 0, [ + [ + 'label' => ' ' . __( 'Refund Receipt' ), + 'type' => 'POPUP', + 'namespace' => 'ns.order-refunds', + 'url' => ns()->url( '/dashboard/' . 'orders' . '/refund-receipt/' . $entry->id ), + ] + ]); + } + return $entry; } diff --git a/app/Http/Controllers/Dashboard/OrdersController.php b/app/Http/Controllers/Dashboard/OrdersController.php index 251de2019..a5af4357e 100755 --- a/app/Http/Controllers/Dashboard/OrdersController.php +++ b/app/Http/Controllers/Dashboard/OrdersController.php @@ -22,6 +22,7 @@ use App\Crud\PaymentTypeCrud; use App\Exceptions\NotAllowedException; use App\Models\OrderInstalment; +use App\Models\OrderRefund; use App\Models\PaymentType; use Modules\NsMultiStore\Models\Store; @@ -122,6 +123,7 @@ public function getOrders( Order $id = null ) { $id->load( 'shipping_address' ); $id->load( 'billing_address' ); $id->load( 'products.unit' ); + $id->load( 'refundedProducts.unit', 'refundedProducts.product' ); return $id; } @@ -193,6 +195,22 @@ public function orderInvoice( Order $order ) ]); } + public function orderRefundReceipt( OrderRefund $refund ) + { + $refund->load( 'order.customer', 'order.refundedProducts', 'order.refund.author', 'order.shipping_address', 'order.billing_address', 'order.user' ); + $refund->load( 'refunded_products.product', 'refunded_products.unit' ); + + $refund->refunded_products = Hook::filter( 'ns-refund-receipt-products', $refund->refunded_products ); + + return $this->view( 'pages.dashboard.orders.templates.refund-receipt', [ + 'refund' => $refund, + 'ordersService' => app()->make( OrdersService::class ), + 'billing' => ( new CustomerCrud() )->getForm()[ 'tabs' ][ 'billing' ][ 'fields' ], + 'shipping' => ( new CustomerCrud() )->getForm()[ 'tabs' ][ 'shipping' ][ 'fields' ], + 'title' => sprintf( __( 'Order Refund Receipt — %s' ), $refund->order->code ) + ]); + } + public function orderReceipt( Order $order ) { $order->load( 'customer' ); @@ -334,5 +352,15 @@ public function updatePaymentType( PaymentType $paymentType ) { return PaymentTypeCrud::form( $paymentType ); } + + public function getOrderProductsRefunded( Request $request, Order $order ) + { + return $this->ordersService->getOrderRefundedProducts( $order ); + } + + public function getOrderRefunds( Request $request, Order $order ) + { + return $this->ordersService->getOrderRefunds( $order ); + } } diff --git a/app/Http/Controllers/Dashboard/ProductsController.php b/app/Http/Controllers/Dashboard/ProductsController.php index b043bc59d..ba4420d02 100755 --- a/app/Http/Controllers/Dashboard/ProductsController.php +++ b/app/Http/Controllers/Dashboard/ProductsController.php @@ -519,13 +519,12 @@ public function createAdjustment( Request $request ) public function searchUsingArgument( $reference ) { $procurementProduct = ProcurementProduct::barcode( $reference )->first(); - $productUnitQuantity = ProductUnitQuantity::barcode( $reference )->first(); + $productUnitQuantity = ProductUnitQuantity::barcode( $reference )->with( 'unit' )->first(); $product = Product::barcode( $reference ) ->searchable() ->first(); if ( $procurementProduct instanceof ProcurementProduct ) { - $product = $procurementProduct->product; /** @@ -547,7 +546,7 @@ public function searchUsingArgument( $reference ) $product->procurement_product_id = $procurementProduct->id; } else if ( $productUnitQuantity instanceof ProductUnitQuantity ) { - + /** * if a product unit quantity is loaded. Then we make sure to return the parent * product with the selected unit quantity. @@ -555,12 +554,12 @@ public function searchUsingArgument( $reference ) $productUnitQuantity->load( 'unit' ); $product = Product::find( $productUnitQuantity->product_id ); - $product->load( 'unit_quantities' ); + $product->load( 'unit_quantities.unit' ); $product->selectedUnitQuantity = $productUnitQuantity; } else if ( $product instanceof Product ) { - $product->load( 'unit_quantities' ); + $product->load( 'unit_quantities.unit' ); if ( $product->accurate_tracking ) { throw new NotAllowedException( __( 'Unable to add a product that has accurate tracking enabled, using an ordinary barcode.' ) ); diff --git a/app/Models/Order.php b/app/Models/Order.php index 3c6059888..42bb80b6f 100755 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -52,16 +52,32 @@ public function products() ); } + public function refundedProducts() + { + return $this->hasMany( + OrderProductRefund::class, + 'order_id' + ); + } + public function user() { return $this->hasOne( User::class, 'id', 'author' ); } + /** + * @deprecated + */ public function refund() { return $this->hasMany( OrderRefund::class, 'order_id', 'id' ); } + public function refunds() + { + return $this->hasMany( OrderRefund::class, 'order_id', 'id' ); + } + public function payments() { return $this->hasMany( OrderPayment::class, 'order_id' ); diff --git a/app/Models/OrderRefund.php b/app/Models/OrderRefund.php index 878d9e6d3..29c44baeb 100755 --- a/app/Models/OrderRefund.php +++ b/app/Models/OrderRefund.php @@ -12,11 +12,16 @@ class OrderRefund extends NsModel public function refunded_products() { - return $this->hasMany( OrderProductRefund::class, 'refund_order_id', 'id' ); + return $this->hasMany( OrderProductRefund::class, 'order_refund_id', 'id' ); } public function order() { return $this->belongsTo( Order::class, 'order_id', 'id' ); } + + public function author() + { + return $this->belongsTo( User::class, 'author', 'id' ); + } } \ No newline at end of file diff --git a/app/Models/Role.php b/app/Models/Role.php index 6ab0a6340..3a78f1f82 100755 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -153,7 +153,7 @@ private static function __createRelation( $role, $permission, $silent = true ) public function removePermissions( $permissionNamespace ) { if ( $permissionNamespace instanceof Collection ) { - $permissionNamespace->each( fn( $permission ) => $this->removePermissions( $permission->namespace ) ); + $permissionNamespace->each( fn( $permission ) => $this->removePermissions( $permission instanceof Permission ? $permission->namespace : $permission ) ); } else { $permission = Permission::where([ 'namespace' => $permissionNamespace ]) ->first(); diff --git a/app/Services/OrdersService.php b/app/Services/OrdersService.php index 05fe5b848..df3054ba6 100755 --- a/app/Services/OrdersService.php +++ b/app/Services/OrdersService.php @@ -1465,7 +1465,7 @@ public function refundOrder( Order $order, $fields ) $results = []; foreach( $fields[ 'products' ] as $product ) { - $results[] = $this->refundSingleProduct( $order, OrderProduct::find( $product[ 'id' ] ), $product ); + $results[] = $this->refundSingleProduct( $order, $orderRefund, OrderProduct::find( $product[ 'id' ] ), $product ); } /** @@ -1504,7 +1504,7 @@ public function refundOrder( Order $order, $fields ) * @param int product id * @param string status : sold, returned, defective */ - public function refundSingleProduct( Order $order, OrderProduct $orderProduct, $details ) + public function refundSingleProduct( Order $order, OrderRefund $orderRefund, OrderProduct $orderProduct, $details ) { if ( ! in_array( $details[ 'condition' ], [ OrderProductRefund::CONDITION_DAMAGED, @@ -1534,17 +1534,24 @@ public function refundSingleProduct( Order $order, OrderProduct $orderProduct, $ $this->computeOrderProduct( $orderProduct ); $orderProduct->save(); + /** + * Let's store a reference of + * the refunded product + */ $productRefund = new OrderProductRefund; $productRefund->condition = $details[ 'condition' ]; $productRefund->description = $details[ 'description' ]; $productRefund->unit_price = $details[ 'unit_price' ]; $productRefund->unit_id = $orderProduct->unit_id; - $productRefund->total_price = $this->currencyService->getRaw( $productRefund->unit_price * floatval( $details[ 'quantity' ] ) ); + $productRefund->total_price = $this->currencyService + ->getRaw( $productRefund->unit_price * floatval( $details[ 'quantity' ] ) ); $productRefund->quantity = $details[ 'quantity' ]; $productRefund->author = Auth::id(); $productRefund->order_id = $order->id; + $productRefund->order_refund_id = $orderRefund->id; $productRefund->order_product_id = $orderProduct->id; $productRefund->product_id = $orderProduct->product_id; + $productRefund->save(); event( new OrderAfterProductRefundedEvent( $order, $orderProduct ) ); @@ -2457,4 +2464,27 @@ public function getPaymentTypesReport( $startRange, $endRange ) 'entries' => $payments ]; } + + /** + * Will return the product that + * that has been refunded + * @param Order $order + * @return array + */ + public function getOrderRefundedProducts( Order $order ) + { + return $order->refundedProducts; + } + + /** + * Will return the order refund along + * with the product refunded + * @param Order $order + * @return OrderRefund + */ + public function getOrderRefunds( Order $order ) + { + $order->load( 'refunds.refunded_products.product', 'refunds.refunded_products.unit', 'refunds.author' ); + return $order; + } } diff --git a/resources/ts/pages/dashboard/orders/ns-order-details.vue b/resources/ts/pages/dashboard/orders/ns-order-details.vue index 59bdcc6a9..43d01304e 100755 --- a/resources/ts/pages/dashboard/orders/ns-order-details.vue +++ b/resources/ts/pages/dashboard/orders/ns-order-details.vue @@ -160,12 +160,23 @@

{{ __( 'Products' ) }}

-
+

{{ product.name }} (x{{ product.quantity }})

{{ product.unit.name || 'N/A' }}

-
{{ product.unit_price | currency }}
+
{{ product.total_price | currency }}
+
+ +
+

{{ __( 'Refunded Products' ) }}

+
+
+
+

{{ product.product.name }} (x{{ product.quantity }})

+

{{ product.unit.name || 'N/A' }} | {{ product.condition }}

+
+
{{ product.total_price | currency }}
diff --git a/resources/ts/pages/dashboard/orders/ns-order-refund.vue b/resources/ts/pages/dashboard/orders/ns-order-refund.vue index f0dc0da4e..5330b27a9 100755 --- a/resources/ts/pages/dashboard/orders/ns-order-refund.vue +++ b/resources/ts/pages/dashboard/orders/ns-order-refund.vue @@ -197,7 +197,7 @@ export default { nsHttpClient.post( `/api/nexopos/v4/orders/${this.order.id}/refund`, data ) .subscribe( result => { this.isSubmitting = false; - this.$emit( 'updated', true ); + this.$emit( 'changed', true ); nsSnackBar.success( result.message ).subscribe(); }, error => { this.isSubmitting = false; @@ -335,7 +335,7 @@ export default { nsHttpClient.get( '/api/nexopos/v4/orders/payments' ) .subscribe( paymentField => { this.paymentField = paymentField; - }) + }); } } \ No newline at end of file diff --git a/resources/ts/popups.ts b/resources/ts/popups.ts index 03feed646..86a166338 100755 --- a/resources/ts/popups.ts +++ b/resources/ts/popups.ts @@ -5,6 +5,7 @@ import { default as nsConfirmPopup } from '@/popups/ns-pos-confirm-popup.vue'; import { default as nsPromptPopup } from '@/popups/ns-prompt-popup.vue'; import { default as nsMediaPopup } from '@/pages/dashboard/ns-media.vue'; import { default as nsProcurementQuantity } from '@/popups/ns-procurement-quantity.vue'; +import { default as nsOrdersRefund } from '@/popups/ns-orders-refund-popup.vue'; const popups = { nsOrderPreview, @@ -14,6 +15,7 @@ const popups = { nsPromptPopup, nsMediaPopup, nsProcurementQuantity, + nsOrdersRefund, }; for( let index in popups ) { diff --git a/resources/ts/popups/ns-orders-preview-popup.vue b/resources/ts/popups/ns-orders-preview-popup.vue index 71fc86588..a6092fb0c 100755 --- a/resources/ts/popups/ns-orders-preview-popup.vue +++ b/resources/ts/popups/ns-orders-preview-popup.vue @@ -76,9 +76,9 @@ const nsOrderPreviewPopup = { nsHttpClient.get( `/api/nexopos/v4/orders/${orderId}/payments` ), ]) .subscribe( result => { - this.order = result[0]; - this.products = result[1]; - this.payments = result[2]; + this.order = result[0]; + this.products = result[1]; + this.payments = result[2]; }); }, deleteOrder() { @@ -200,10 +200,10 @@ export default nsOrderPreviewPopup;
- +
diff --git a/resources/ts/popups/ns-orders-refund-popup.vue b/resources/ts/popups/ns-orders-refund-popup.vue new file mode 100644 index 000000000..a0946e449 --- /dev/null +++ b/resources/ts/popups/ns-orders-refund-popup.vue @@ -0,0 +1,138 @@ + + \ No newline at end of file diff --git a/resources/ts/popups/ns-pos-customer-select-popup.vue b/resources/ts/popups/ns-pos-customer-select-popup.vue index e60b03207..b62650430 100755 --- a/resources/ts/popups/ns-pos-customer-select-popup.vue +++ b/resources/ts/popups/ns-pos-customer-select-popup.vue @@ -115,7 +115,7 @@ export default { openCustomerHistory( customer, event ) { event.stopImmediatePropagation(); this.$popup.close(); - Popup.show( nsPosCustomersVue, { customer, activeTab: 'customer-account' }); + Popup.show( nsPosCustomersVue, { customer, activeTab: 'account-payment' }); }, selectCustomer( customer ) { diff --git a/resources/ts/popups/ns-pos-customers.vue b/resources/ts/popups/ns-pos-customers.vue index 8f76eb3d3..6b2ff5240 100755 --- a/resources/ts/popups/ns-pos-customers.vue +++ b/resources/ts/popups/ns-pos-customers.vue @@ -17,7 +17,7 @@ - +

{{ __( 'No Customer Selected' ) }}

@@ -128,12 +128,12 @@ export default { this.subscription = POS.order.subscribe( order => { if ( order.customer !== undefined ) { - this.activeTab = 'customer-account'; + this.activeTab = 'account-payment'; this.customer = order.customer; this.loadCustomerOrders( this.customer.id ); } else { if ( this.$popupParams.customer !== undefined ) { - this.activeTab = 'customer-account'; + this.activeTab = 'account-payment'; this.customer = this.$popupParams.customer; this.loadCustomerOrders( this.customer.id ); } diff --git a/resources/ts/popups/ns-pos-units.vue b/resources/ts/popups/ns-pos-units.vue index e096671fb..0818d5292 100755 --- a/resources/ts/popups/ns-pos-units.vue +++ b/resources/ts/popups/ns-pos-units.vue @@ -101,6 +101,7 @@ export default { * @param Unit */ selectUnit( unitQuantity ) { + console.log( unitQuantity ); this.$popupParams.resolve({ unit_quantity_id : unitQuantity.id, unit_name : unitQuantity.unit.name, diff --git a/resources/views/pages/dashboard/orders/list.blade.php b/resources/views/pages/dashboard/orders/list.blade.php index b801eebfb..bc749639b 100755 --- a/resources/views/pages/dashboard/orders/list.blade.php +++ b/resources/views/pages/dashboard/orders/list.blade.php @@ -30,6 +30,14 @@ const deliveryStatuses = getDeliveryStatuses() ));?>; const typeLabels = getTypeLabels() ));?>; const paymentLabels = getPaymentLabels() ));?>; +const systemOptions = ns()->option->get( 'ns_pos_printing_document', 'receipt' ), + 'ns_pos_printing_gateway' => ns()->option->get( 'ns_pos_printing_gateway', 'default' ), +]);?> + +const systemSettings = ns()->url( '/dashboard/orders/refund-receipt/{order_id}' ) +]);?> document.addEventListener( 'DOMContentLoaded', () => { nsEvent.subject().subscribe( event => { @@ -39,6 +47,13 @@ ) { Popup.show( nsOrderPreview, { order : event.value.row, component : event.value.component }); } + + if ( + event.identifier === 'ns-table-row-action' && + event.value.action.namespace === 'ns.order-refunds' + ) { + Popup.show( nsOrdersRefund, { order : event.value.row, component : event.value.component }); + } }); }); diff --git a/resources/views/pages/dashboard/orders/templates/_dashboard_refund_receipt.blade.php b/resources/views/pages/dashboard/orders/templates/_dashboard_refund_receipt.blade.php new file mode 100755 index 000000000..cae991916 --- /dev/null +++ b/resources/views/pages/dashboard/orders/templates/_dashboard_refund_receipt.blade.php @@ -0,0 +1,16 @@ +@extends( 'layout.dashboard' ) +@section( 'layout.dashboard.body' ) +
+ @include( Hook::filter( 'ns-dashboard-header', '../common/dashboard-header' ) ) +
+
+

{!! sprintf( __( 'Receipt — %s' ), $refund->order->code ) !!}

+

{{ __( 'Refund receipt' ) }}

+
+
+ {{ __( 'Hide Dashboard' ) }} + @include( 'pages.dashboard.orders.templates._refund_receipt' ) +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/pages/dashboard/orders/templates/_naked_receipt.blade.php b/resources/views/pages/dashboard/orders/templates/_naked_refund_receipt.blade.php similarity index 50% rename from resources/views/pages/dashboard/orders/templates/_naked_receipt.blade.php rename to resources/views/pages/dashboard/orders/templates/_naked_refund_receipt.blade.php index a0ae54fe0..f2f5bbada 100755 --- a/resources/views/pages/dashboard/orders/templates/_naked_receipt.blade.php +++ b/resources/views/pages/dashboard/orders/templates/_naked_refund_receipt.blade.php @@ -1,4 +1,4 @@ @extends( 'layout.base' ) @section( 'layout.base.body' ) - @include( 'pages.dashboard.orders.templates._receipt' ) + @include( 'pages.dashboard.orders.templates._refund_receipt' ) @endsection \ No newline at end of file diff --git a/resources/views/pages/dashboard/orders/templates/_receipt.blade.php b/resources/views/pages/dashboard/orders/templates/_receipt.blade.php index 01be60fb6..58bfba6bb 100755 --- a/resources/views/pages/dashboard/orders/templates/_receipt.blade.php +++ b/resources/views/pages/dashboard/orders/templates/_receipt.blade.php @@ -59,7 +59,7 @@ {{ ns()->currency->define( $order->total_coupons ) }} @endif - @if ( $order->tax_value > 0 ) + @if ( $order->payment_status !== 'refunded' && $order->tax_value > 0 ) {{ __( 'Taxes' ) }} @@ -85,6 +85,14 @@ {{ __( 'Paid' ) }} {{ ns()->currency->define( $order->tendered ) }} + @if ( in_array( $order->payment_status, [ 'refunded', 'partially_refunded' ]) ) + @foreach( $order->refund as $refund ) + + {{ __( 'Refunded' ) }} + {{ ns()->currency->define( - $refund->total ) }} + + @endforeach + @endif @switch( $order->payment_status ) @case( Order::PAYMENT_PAID ) diff --git a/resources/views/pages/dashboard/orders/templates/_refund_receipt.blade.php b/resources/views/pages/dashboard/orders/templates/_refund_receipt.blade.php new file mode 100755 index 000000000..7d0cb6885 --- /dev/null +++ b/resources/views/pages/dashboard/orders/templates/_refund_receipt.blade.php @@ -0,0 +1,69 @@ + +
+
+
+

{{ ns()->option->get( 'ns_store_name' ) }}

+
+
+
+
+ {!! nl2br( $ordersService->orderTemplateMapping( 'ns_invoice_receipt_column_a', $refund->order ) ) !!} +
+
+ {!! nl2br( $ordersService->orderTemplateMapping( 'ns_invoice_receipt_column_b', $refund->order ) ) !!} +
+
+
+
+ + + + + + + + + @foreach( Hook::filter( 'ns-refund-receipt-products', $refund->refunded_products ) as $product ) + + + + + @endforeach + + + + + + + @if ( $refund->shipping > 0 ) + + + + + @endif + payment_method )->first(); + $paymentName = $paymentType instanceof PaymentType ? $paymentType->label : __( 'Unknown Payment' ); + ?> + + + + + +
{{ __( 'Product' ) }}{{ __( 'Total' ) }}
+ {{ $product->product->name }} (x{{ $product->quantity }}) +
+ {{ $product->unit->name }} +
{{ ns()->currency->define( $product->total_price ) }}
{{ __( 'Total' ) }}{{ ns()->currency->define( $refund->total ) }}
{{ __( 'Shipping' ) }}{{ ns()->currency->define( $refund->shipping ) }}
{{ $paymentName }}{{ ns()->currency->define( $refund->total ) }}
+
+ {{ ns()->option->get( 'ns_invoice_receipt_footer' ) }} +
+
+
+
+@includeWhen( request()->query( 'autoprint' ) === 'true', '/pages/dashboard/orders/templates/_autoprint' ) \ No newline at end of file diff --git a/resources/views/pages/dashboard/orders/templates/refund-receipt.blade.php b/resources/views/pages/dashboard/orders/templates/refund-receipt.blade.php new file mode 100755 index 000000000..578cbff1f --- /dev/null +++ b/resources/views/pages/dashboard/orders/templates/refund-receipt.blade.php @@ -0,0 +1,2 @@ +@includeWhen( request()->query( 'dash-visibility' ) === 'disabled', 'pages.dashboard.orders.templates._naked_refund_receipt' ) +@includeWhen( empty( request()->query( 'dash-visibility' ) ), 'pages.dashboard.orders.templates._dashboard_refund_receipt' ) \ No newline at end of file diff --git a/routes/api/orders.php b/routes/api/orders.php index f6b1584c6..22819ade5 100755 --- a/routes/api/orders.php +++ b/routes/api/orders.php @@ -7,6 +7,8 @@ Route::get( 'orders/payments', [ OrdersController::class, 'getSupportedPayments' ]); Route::get( 'orders/{id}/pos', [ OrdersController::class, 'getPosOrder' ])->where( 'id', '[0-9]+'); Route::get( 'orders/{id}/products', [ OrdersController::class, 'getOrderProducts' ])->where( 'id', '[0-9]+'); +Route::get( 'orders/{order}/products/refunded', [ OrdersController::class, 'getOrderProductsRefunded' ])->where( 'id', '[0-9]+'); +Route::get( 'orders/{order}/refunds', [ OrdersController::class, 'getOrderRefunds' ])->where( 'id', '[0-9]+'); Route::get( 'orders/{id}/payments', [ OrdersController::class, 'getOrderPayments' ])->where( 'id', '[0-9]+'); Route::get( 'orders/{order}/instalments', [ OrdersController::class, 'getOrderInstalments' ])->where( 'id', '[0-9]+')->middleware( 'ns.restrict:nexopos.read.orders-instalments' ); Route::get( 'orders/{order}/instalments/{instalment}/paid', [ OrdersController::class, 'markInstalmentAs' ])->where( 'id', '[0-9]+')->middleware( 'ns.restrict:nexopos.update.orders-instalments' ); diff --git a/routes/nexopos.php b/routes/nexopos.php index 027ad9f62..95e386428 100755 --- a/routes/nexopos.php +++ b/routes/nexopos.php @@ -30,6 +30,7 @@ Route::get( '/orders/payments-types/edit/{paymentType}', [ OrdersController::class, 'updatePaymentType' ])->name( Hook::filter( 'ns-route-name', 'ns.dashboard.orders-update-types' ) ); Route::get( '/orders/invoice/{order}', [ OrdersController::class, 'orderInvoice' ]); Route::get( '/orders/receipt/{order}', [ OrdersController::class, 'orderReceipt' ]); +Route::get( '/orders/refund-receipt/{refund}', [ OrdersController::class, 'orderRefundReceipt' ])->name( Hook::filter( 'ns-route-name', 'ns.dashboard.orders-refund-receipt' ) ); Route::get( '/pos', [ OrdersController::class, 'showPOS' ])->name( Hook::filter( 'ns-route-name', 'ns.dashboard.pos' ) ); Route::get( '/cash-registers', [ CashRegistersController::class, 'listRegisters' ])->name( Hook::filter( 'ns-route-name', 'ns.dashboard.registers-list' ) ); diff --git a/tests/Feature/HandlePermissionsManagement.php b/tests/Feature/HandlePermissionsManagement.php new file mode 100644 index 000000000..11097f9e4 --- /dev/null +++ b/tests/Feature/HandlePermissionsManagement.php @@ -0,0 +1,22 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Feature/OrderRefundTest.php b/tests/Feature/OrderRefundTest.php index 67a794e01..91b221417 100755 --- a/tests/Feature/OrderRefundTest.php +++ b/tests/Feature/OrderRefundTest.php @@ -112,7 +112,7 @@ public function testRefund() $response = $this->withSession( $this->app[ 'session' ]->all() ) ->json( 'POST', 'api/nexopos/v4/orders/' . $responseData[ 'data' ][ 'order' ][ 'id' ] . '/refund', [ 'payment' => [ - 'identifier' => 'customer-account', + 'identifier' => 'account-payment', ], 'total' => $responseData[ 'data' ][ 'order' ][ 'total' ], 'products' => $responseData[ 'data' ][ 'order' ][ 'products' ],