Skip to content

Commit

Permalink
Merge pull request #308 from Blair2004/v4.5.x
Browse files Browse the repository at this point in the history
V4.5.x
  • Loading branch information
Blair2004 authored Sep 20, 2021
2 parents 221ae3e + f706b01 commit 98a6b23
Show file tree
Hide file tree
Showing 33 changed files with 266 additions and 141 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ public/mapping.json
storage/module.zip
tests/database.sqlite
tests/database.sqlite-journal
storage/snapshots/*.sql
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->command( 'telescope:prune' )->daily();
$schedule->job( new TaskSchedulingPingJob )->hourly();
$schedule->job( new ExecuteExpensesJob )->daily( '00:01' );
$schedule->job( new StockProcurementJob() )->daily( '00:05' );
Expand Down
9 changes: 9 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace App\Exceptions;

use App\Exceptions\QueryException as ExceptionsQueryException;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Validation\ValidationException as MainValidationException;
use Throwable;
Expand Down Expand Up @@ -45,6 +47,8 @@ public function report(Throwable $exception)
/**
* We want to use our defined route
* instead of what is provided by laravel.
* @return \Illuminate\Routing\Redirector
*
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
Expand All @@ -71,6 +75,11 @@ public function render($request, Throwable $exception)
->render( $request );
}

if ( $exception instanceof QueryException ) {
return ( new ExceptionsQueryException( $exception->getMessage() ) )
->render( $request );
}

return parent::render($request, $exception);
}
}
15 changes: 15 additions & 0 deletions app/Exceptions/QueryException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Exceptions;

use Exception;

class QueryException extends Exception
{
public function render( $message )
{
$message = $this->getMessage();
$title = __( 'Query Exception' );
return response()->view( 'pages.errors.db-exception', compact( 'message', 'title' ), 500 );
}
}
9 changes: 7 additions & 2 deletions app/Http/Controllers/Dashboard/CustomersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use App\Crud\CustomerCrud;
use App\Crud\CustomerOrderCrud;
use App\Crud\CustomerRewardCrud;
use App\Exceptions\NotFoundException;
use App\Models\Customer;

use Illuminate\Http\Request;
Expand Down Expand Up @@ -65,8 +66,12 @@ public function get( $customer_id = null )
{
$customer = Customer::with( 'group' )->find( $customer_id );

if ( $customer instanceof Customer ) {
return $customer;
if ( $customer_id !== null ) {
if ( $customer instanceof Customer ) {
return $customer;
}

throw new NotFoundException( __( 'The requested customer cannot be fonud.' ) );
}

return $this->customerService->get();
Expand Down
19 changes: 10 additions & 9 deletions app/Providers/ModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class ModulesServiceProvider extends ServiceProvider
{
protected $modulesCommands = [];
protected $modules;

/**
* Bootstrap the application services.
Expand Down Expand Up @@ -43,16 +44,16 @@ public function register()
{
// register module singleton
$this->app->singleton( ModulesService::class, function( $app ) {
$modules = new ModulesService;
$modules->load();
collect( $modules->getEnabled() )->each( fn( $module ) => $modules->boot( $module ) );

$this->modules = new ModulesService;
$this->modules->load();

collect( $this->modules->getEnabled() )->each( fn( $module ) => $this->modules->boot( $module ) );
/**
* trigger register method only for enabled modules
* service providers that extends ModulesServiceProvider.
*/
collect( $modules->getEnabled() )->each( function( $module ) use ( $modules ) {
collect( $this->modules->getEnabled() )->each( function( $module ) {
/**
* register module commands
*/
Expand All @@ -61,12 +62,12 @@ public function register()
array_keys( $module[ 'commands' ] )
);

$modules->triggerServiceProviders( $module, 'register', ServiceProvider::class );
$this->modules->triggerServiceProviders( $module, 'register', ServiceProvider::class );
});

event( new ModulesLoadedEvent( $modules->get() ) );
event( new ModulesLoadedEvent( $this->modules->get() ) );

return $modules;
return $this->modules;
});
}
}
18 changes: 12 additions & 6 deletions app/Services/Helpers/App.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php
namespace App\Services\Helpers;

use App\Classes\Hook;
use Illuminate\Support\Facades\DB;
use Jackiedo\DotenvEditor\Facades\DotenvEditor;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;

trait App {
/**
Expand All @@ -12,12 +15,13 @@ trait App {
*/
static function installed()
{
if ( DotenvEditor::keyExists( 'NS_VERSION' ) ) {
$version = DotenvEditor::getValue( 'NS_VERSION' );
return ! in_array( $version, [ null, false ]);
try {
if( DB::connection()->getPdo() ){
return Schema::hasTable( 'nexopos_options' );
}
} catch (\Exception $e) {
return false;
}

return false;
}

/**
Expand All @@ -32,6 +36,8 @@ static function LoadInterface( $path, $data = [] )

static function pageTitle( $string )
{
return sprintf( __( '%s &mdash; NexoPOS 4' ), $string );
return sprintf(
Hook::filter( 'ns-page-title', __( '%s &mdash; NexoPOS 4' ) ),
$string );
}
}
24 changes: 5 additions & 19 deletions app/Services/OrdersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,20 +752,6 @@ public function makeOrderSinglePayment( $payment, Order $order )
if ( $paymentToday->count() === 0 ) {
throw new NotFoundException( __( 'No payment is expected at the moment. If the customer want to pay early, consider adjusting instalment payments date.' ) );
}

/**
* @todo don't think this restriction is actually necessary.
*/
// if (
// ns()->currency->getRaw( $paymentToday->sum( 'amount' ) ) !==
// ns()->currency->getRaw( $payment[ 'value' ] ) ) {
// throw new NotAllowedException(
// sprintf(
// __( 'The provided payment doesn\'t match the expected payment : %s. If the customer want to pay a different amount, consider adjusting the instalment amount.' ),
// ( string ) Currency::define( $paymentToday->sum( 'amount' ) )
// )
// );
// }
}

$this->__saveOrderSinglePayment( $payment, $order );
Expand Down Expand Up @@ -1536,7 +1522,7 @@ public function computeOrderTaxes( Order $order )
$taxType = ns()->option->get( 'ns_pos_tax_type' );
$subTotal = $order->products()->sum( 'total_price' );
$taxValue = $order->taxes->map( function( $tax ) use ( $taxType, $subTotal ) {
$tax->tax_value = $this->taxService->getComputedTaxValue( $taxType, $tax->rate, $subTotal );
$tax->tax_value = $this->taxService->getVatValue( $taxType, $tax->rate, $subTotal );
$tax->save();

return $tax->tax_value;
Expand Down Expand Up @@ -2365,8 +2351,8 @@ public function void( Order $order, $reason )
public function getPaidSales( $startDate, $endDate )
{
return Order::paid()
->where( 'created_at', '>=', Carbon::parse( $startDate )->startOfDay()->toDateTimeString() )
->where( 'created_at', '<=', Carbon::parse( $endDate )->endOfDay()->toDateTimeString() )
->where( 'created_at', '>=', Carbon::parse( $startDate )->toDateTimeString() )
->where( 'created_at', '<=', Carbon::parse( $endDate )->toDateTimeString() )
->get();
}

Expand All @@ -2378,8 +2364,8 @@ public function getPaidSales( $startDate, $endDate )
*/
public function getSoldStock( $startDate, $endDate )
{
$rangeStarts = Carbon::parse( $startDate )->startOfDay()->toDateTimeString();
$rangeEnds = Carbon::parse( $endDate )->endOfDay()->toDateTimeString();
$rangeStarts = Carbon::parse( $startDate )->toDateTimeString();
$rangeEnds = Carbon::parse( $endDate )->toDateTimeString();

$products = OrderProduct::whereHas( 'order', function( Builder $query ) {
$query->where( 'payment_status', Order::PAYMENT_PAID );
Expand Down
4 changes: 2 additions & 2 deletions app/Services/ProductCategoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public function getUsingName( $name )
* @param array details
* @return array
*/
public function create( $data )
public function create( $data, ProductCategory $productCategory = null )
{
$category = new ProductCategory;
$category = $productCategory === null ? new ProductCategory : $productCategory;
$category->author = Auth::id();
$category->description = $data[ 'description' ] ?? '';
$category->preview_url = $data[ 'preview_url' ] ?? '';
Expand Down
5 changes: 5 additions & 0 deletions config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
'root' => storage_path('app'),
],

'snapshots' => [
'driver' => 'local',
'root' => storage_path( 'snapshots' )
],

'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
Expand Down
2 changes: 1 addition & 1 deletion phpunit.ci.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@
<server name="BROADCAST_DRIVER" value="log"/>
<server name="SANCTUM_STATEFUL_DOMAINS" value="nexopos-v4.std"/>
<server name="SESSION_DOMAIN" value="nexopos-v4.std"/>
<server name="NS_VERSION" value="FALSE"/>
<server name="NS_VERSION" value="false"/>
</php>
</phpunit>
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/app.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/auth.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/bootstrap.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/cashier.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/dashboard.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/popups.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/pos-init.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/pos.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/setup.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/update.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/lang/en.json

Large diffs are not rendered by default.

65 changes: 37 additions & 28 deletions resources/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"This field must contain a valid email address.": "Este campo debe contener una direcci\u00f3n de correo electr\u00f3nico v\u00e1lida.",
"Clear Selected Entries ?": "Borrar entradas seleccionadas ?",
"Would you like to clear all selected entries ?": "\u00bfDesea borrar todas las entradas seleccionadas?",
"No bulk confirmation message provided on the CRUD class.": "No se proporciona ning\u00fan mensaje de confirmaci\u00f3n masivo en la clase CRUD.",
"No selection has been made.": "No se ha hecho ninguna selecci\u00f3n.",
"No action has been selected.": "No se ha seleccionado ninguna acci\u00f3n.",
"There is nothing to display...": "No hay nada que mostrar...",
Expand Down Expand Up @@ -340,7 +339,6 @@
"An unexpected error has occured while fecthing taxes.": "Ha ocurrido un error inesperado al cobrar impuestos.",
"OKAY": "OKEY",
"Loading...": "Cargando...",
"Howdy, %s": "Hola,%s",
"Profile": "Perfil",
"Logout": "Cerrar sesi\u00f3n",
"Unamed Page": "P\u00e1gina sin nombre",
Expand Down Expand Up @@ -1823,61 +1821,72 @@
"Unable to save an order with instalments amounts which additionnated is less than the order total.": "No se puede guardar un pedido con montos a plazos cuyo agregado es menor que el total del pedido.",
"Cash Register cash-in will be added to the cash flow account": "El ingreso de efectivo de la caja registradora se agregar\u00e1 a la cuenta de flujo de efectivo",
"Cash Register cash-out will be added to the cash flow account": "El retiro de efectivo de la caja registradora se agregar\u00e1 a la cuenta de flujo de efectivo",
"No module has been updated yet.": "No se ha actualizado ningún módulo.",
"The reason has been updated.": "La razón ha sido actualizada.",
"You must select a customer before applying a coupon.": "Debe seleccionar un cliente antes de aplicar un cupón.",
"No module has been updated yet.": "No se ha actualizado ning\u00fan m\u00f3dulo.",
"The reason has been updated.": "La raz\u00f3n ha sido actualizada.",
"You must select a customer before applying a coupon.": "Debe seleccionar un cliente antes de aplicar un cup\u00f3n.",
"No coupons for the selected customer...": "No hay cupones para el cliente seleccionado ...",
"Use Coupon": "Usar cupon",
"Use Customer ?": "Usar cliente?",
"No customer is selected. Would you like to proceed with this customer ?": "No se selecciona ningún cliente.¿Te gustaría proceder con este cliente?",
"No customer is selected. Would you like to proceed with this customer ?": "No se selecciona ning\u00fan cliente.\u00bfTe gustar\u00eda proceder con este cliente?",
"Change Customer ?": "Cambiar al cliente?",
"Would you like to assign this customer to the ongoing order ?": "¿Le gustaría asignar a este cliente a la orden en curso?",
"Would you like to assign this customer to the ongoing order ?": "\u00bfLe gustar\u00eda asignar a este cliente a la orden en curso?",
"Product \/ Service": "Producto \/ Servicio",
"An error has occured while computing the product.": "Se ha producido un error al calcular el producto.",
"Provide a unique name for the product.": "Proporcionar un nombre único para el producto.",
"Define what is the sale price of the item.": "Definir cuál es el precio de venta del artículo.",
"Provide a unique name for the product.": "Proporcionar un nombre \u00fanico para el producto.",
"Define what is the sale price of the item.": "Definir cu\u00e1l es el precio de venta del art\u00edculo.",
"Set the quantity of the product.": "Establecer la cantidad del producto.",
"Define what is tax type of the item.": "Definir qué es el tipo de impuesto del artículo.",
"Choose the tax group that should apply to the item.": "Elija el grupo de impuestos que debe aplicarse al artículo.",
"Define what is tax type of the item.": "Definir qu\u00e9 es el tipo de impuesto del art\u00edculo.",
"Choose the tax group that should apply to the item.": "Elija el grupo de impuestos que debe aplicarse al art\u00edculo.",
"Assign a unit to the product.": "Asignar una unidad al producto.",
"Some products has been added to the cart. Would youl ike to discard this order ?": "Algunos productos se han agregado al carrito.¿IKE IKE para descartar esta orden?",
"Some products has been added to the cart. Would youl ike to discard this order ?": "Algunos productos se han agregado al carrito.\u00bfIKE IKE para descartar esta orden?",
"Customer Accounts List": "Lista de cuentas de clientes",
"Display all customer accounts.": "Mostrar todas las cuentas de clientes.",
"No customer accounts has been registered": "No se han registrado cuentas de clientes.",
"Add a new customer account": "Añadir una nueva cuenta de cliente",
"Add a new customer account": "A\u00f1adir una nueva cuenta de cliente",
"Create a new customer account": "Crear una nueva cuenta de cliente",
"Register a new customer account and save it.": "Registre una nueva cuenta de cliente y guárdela.",
"Register a new customer account and save it.": "Registre una nueva cuenta de cliente y gu\u00e1rdela.",
"Edit customer account": "Editar cuenta de cliente",
"Modify Customer Account.": "Modificar la cuenta del cliente.",
"Return to Customer Accounts": "Volver a las cuentas de los clientes",
"This will be ignored.": "Esto será ignorado.",
"Define the amount of the transaction": "Definir la cantidad de la transacción.",
"Define what operation will occurs on the customer account.": "Defina qué operación ocurre en la cuenta del cliente.",
"This will be ignored.": "Esto ser\u00e1 ignorado.",
"Define the amount of the transaction": "Definir la cantidad de la transacci\u00f3n.",
"Define what operation will occurs on the customer account.": "Defina qu\u00e9 operaci\u00f3n ocurre en la cuenta del cliente.",
"Account History": "Historia de la cuenta",
"Provider Procurements List": "Lista de adquisiciones de proveedores",
"Display all provider procurements.": "Mostrar todas las adquisiciones de proveedores.",
"No provider procurements has been registered": "No se han registrado adquisiciones de proveedores.",
"Add a new provider procurement": "Añadir una nueva adquisición del proveedor",
"Create a new provider procurement": "Crear una nueva adquisición de proveedores",
"Register a new provider procurement and save it.": "Registre una nueva adquisición del proveedor y guárdela.",
"Edit provider procurement": "Editar adquisición del proveedor",
"Modify Provider Procurement.": "Modificar la adquisición del proveedor.",
"Add a new provider procurement": "A\u00f1adir una nueva adquisici\u00f3n del proveedor",
"Create a new provider procurement": "Crear una nueva adquisici\u00f3n de proveedores",
"Register a new provider procurement and save it.": "Registre una nueva adquisici\u00f3n del proveedor y gu\u00e1rdela.",
"Edit provider procurement": "Editar adquisici\u00f3n del proveedor",
"Modify Provider Procurement.": "Modificar la adquisici\u00f3n del proveedor.",
"Return to Provider Procurements": "Volver a las adquisiciones del proveedor",
"Delivered On": "Entregado en",
"Items": "Elementos",
"Displays the customer account history for %s": "Muestra el historial de la cuenta del cliente para% s",
"Procurements by \"%s\"": "Adquisiciones por \"%s\"",
"Crediting": "Acreditación",
"Deducting": "Deducción",
"Crediting": "Acreditaci\u00f3n",
"Deducting": "Deducci\u00f3n",
"Order Payment": "Orden de pago",
"Order Refund": "Reembolso de pedidos",
"Unknown Operation": "Operación desconocida",
"Unknown Operation": "Operaci\u00f3n desconocida",
"Unamed Product": "Producto por calificaciones",
"Bubble": "Burbuja",
"Ding": "Cosa",
"Pop": "Música pop",
"Pop": "M\u00fasica pop",
"Cash Sound": "Sonido en efectivo",
"Sale Complete Sound": "Venta de sonido completo",
"New Item Audio": "Nuevo artículo de audio",
"The sound that plays when an item is added to the cart.": "El sonido que se reproduce cuando se agrega un artículo al carrito.."
"New Item Audio": "Nuevo art\u00edculo de audio",
"The sound that plays when an item is added to the cart.": "El sonido que se reproduce cuando se agrega un art\u00edculo al carrito..",
"Howdy, {name}": "Howdy, {name}",
"Would you like to perform the selected bulk action on the selected entries ?": "¿Le gustaría realizar la acción a granel seleccionada en las entradas seleccionadas?",
"The payment to be made today is less than what is expected.": "El pago que se realizará hoy es menor que lo que se espera.",
"Unable to select the default customer. Looks like the customer no longer exists. Consider changing the default customer on the settings.": "No se puede seleccionar el cliente predeterminado.Parece que el cliente ya no existe.Considere cambiar el cliente predeterminado en la configuración.",
"How to change database configuration": "Cómo cambiar la configuración de la base de datos",
"Common Database Issues": "Problemas de base de datos comunes",
"Setup": "Configuración",
"Compute Products": "Cómputo Products",
"Query Exception": "Excepción de consulta",
"The category products has been refreshed": "Los productos de la categoría se han actualizado.",
"The requested customer cannot be fonud.": "El cliente solicitado no se puede encontrar."
}
Loading

0 comments on commit 98a6b23

Please sign in to comment.