mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f4a4c05b61 | |||
| 24637bff4a | |||
| 887ad9a73d | |||
| 339099bd34 | |||
| 9b9761aa5a | |||
| 00c917853c | |||
| 122c4f478f | |||
| edc0e115e4 | |||
| b388e7a237 | |||
| 6e3ed9b4f6 | |||
| 338dbb26a1 | |||
| f10e5e9d11 | |||
| 3a046b638c | |||
| 36242c516a | |||
| c8843eb544 | |||
| 37f2b6dfc7 | |||
| c90c14312a | |||
| b5b861bb36 | |||
| ab041743a2 | |||
| 9bcec9bd75 |
@ -24,6 +24,7 @@ class EstimateItem extends Model
|
||||
'price' => 'integer',
|
||||
'total' => 'integer',
|
||||
'discount' => 'float',
|
||||
'quantity' => 'float',
|
||||
'discount_val' => 'integer',
|
||||
'tax' => 'integer'
|
||||
];
|
||||
|
||||
@ -33,10 +33,14 @@ class EnvironmentController extends Controller
|
||||
*/
|
||||
public function saveDatabaseEnvironment(DatabaseEnvironmentRequest $request)
|
||||
{
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
$results = $this->EnvironmentManager->saveDatabaseVariables($request);
|
||||
|
||||
if(array_key_exists("success", $results)) {
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('cache:clear');
|
||||
Artisan::call('storage:link');
|
||||
Artisan::call('key:generate --force');
|
||||
Artisan::call('migrate --seed --force');
|
||||
|
||||
@ -82,7 +82,7 @@ class Invoice extends Model
|
||||
// So the substr returns this 000001
|
||||
|
||||
// Add the string in front and higher up the number.
|
||||
// the %05d part makes sure that there are always 6 numbers in the string.
|
||||
// the %06d part makes sure that there are always 6 numbers in the string.
|
||||
// so it adds the missing zero's when needed.
|
||||
|
||||
return sprintf('%06d', intval($number) + 1);
|
||||
|
||||
@ -30,6 +30,7 @@ class InvoiceItem extends Model
|
||||
'price' => 'integer',
|
||||
'total' => 'integer',
|
||||
'discount' => 'float',
|
||||
'quantity' => 'float',
|
||||
'discount_val' => 'integer',
|
||||
'tax' => 'integer'
|
||||
];
|
||||
|
||||
@ -15,7 +15,7 @@ class Listener
|
||||
protected function isListenerFired($event)
|
||||
{
|
||||
// Do not apply to the same or newer versions
|
||||
if (version_compare(static::VERSION, $event->old, '<')) {
|
||||
if (version_compare(static::VERSION, $event->old, '<=')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
87
app/Listeners/Updates/v2/Version201.php
Normal file
87
app/Listeners/Updates/v2/Version201.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Listeners\Updates\v2;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Crater\Events\UpdateFinished;
|
||||
use Crater\Listeners\Updates\Listener;
|
||||
use Crater\Setting;
|
||||
|
||||
class Version201 extends Listener
|
||||
{
|
||||
const VERSION = '2.0.1';
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(UpdateFinished $event)
|
||||
{
|
||||
if ($this->isListenerFired($event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the language files
|
||||
$this->removeLanguageFiles();
|
||||
|
||||
// Change estimate & invoice migrations
|
||||
$this->changeMigrations();
|
||||
|
||||
// Update Crater app version
|
||||
Setting::setSetting('version', static::VERSION);
|
||||
}
|
||||
|
||||
private function removeLanguageFiles() {
|
||||
$en = resource_path('assets/js/plugins/en.js');
|
||||
$es = resource_path('assets/js/plugins/es.js');
|
||||
$fr = resource_path('assets/js/plugins/fr.js');
|
||||
|
||||
if(file_exists($en)) {
|
||||
unlink($en);
|
||||
}
|
||||
|
||||
if(file_exists($es)) {
|
||||
unlink($es);
|
||||
}
|
||||
|
||||
if(file_exists($fr)) {
|
||||
unlink($fr);
|
||||
}
|
||||
}
|
||||
|
||||
private function changeMigrations()
|
||||
{
|
||||
\Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->decimal('discount', 15, 2)->nullable()->change();
|
||||
});
|
||||
|
||||
\Schema::table('estimates', function (Blueprint $table) {
|
||||
$table->decimal('discount', 15, 2)->nullable()->change();
|
||||
});
|
||||
|
||||
\Schema::table('invoice_items', function (Blueprint $table) {
|
||||
$table->decimal('quantity', 15, 2)->change();
|
||||
$table->decimal('discount', 15, 2)->nullable()->change();
|
||||
});
|
||||
|
||||
\Schema::table('estimate_items', function (Blueprint $table) {
|
||||
$table->decimal('quantity', 15, 2)->change();
|
||||
$table->decimal('discount', 15, 2)->nullable()->change();
|
||||
$table->unsignedBigInteger('discount_val')->nullable()->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Crater\Events\UpdateFinished;
|
||||
use Crater\Listeners\Updates\v1\Version110;
|
||||
use Crater\Listeners\Updates\v2\Version200;
|
||||
use Crater\Listeners\Updates\v2\Version201;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
@ -19,6 +20,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
UpdateFinished::class=> [
|
||||
Version110::class,
|
||||
Version200::class,
|
||||
Version201::class,
|
||||
],
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
|
||||
@ -48,17 +48,21 @@ class EnvironmentManager
|
||||
'DB_USERNAME='.$request->database_username."\n".
|
||||
'DB_PASSWORD='.$request->database_password."\n\n";
|
||||
|
||||
if (! $this->checkDatabaseConnection($request)) {
|
||||
try {
|
||||
|
||||
$this->checkDatabaseConnection($request);
|
||||
|
||||
return [
|
||||
'error' => 'connection_failed'
|
||||
];
|
||||
} else {
|
||||
if(\Schema::hasTable('users') ) {
|
||||
return [
|
||||
'error' => 'database_should_be_empty'
|
||||
];
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
return [
|
||||
'error' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
|
||||
try {
|
||||
@ -118,8 +122,6 @@ class EnvironmentManager
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'error' => 'mail_variables_save_error'
|
||||
@ -316,12 +318,6 @@ class EnvironmentManager
|
||||
],
|
||||
]);
|
||||
|
||||
try {
|
||||
DB::connection()->getPdo();
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
return DB::connection()->getPdo();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,6 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'version' => '2.0.0',
|
||||
'version' => '2.0.1',
|
||||
|
||||
];
|
||||
|
||||
@ -25,7 +25,7 @@ class CreateInvoicesTable extends Migration
|
||||
$table->string('discount_per_item');
|
||||
$table->text('notes')->nullable();
|
||||
$table->string('discount_type')->nullable();
|
||||
$table->unsignedBigInteger('discount')->nullable();
|
||||
$table->decimal('discount', 15, 2)->nullable();
|
||||
$table->unsignedBigInteger('discount_val')->nullable();
|
||||
$table->unsignedBigInteger('sub_total');
|
||||
$table->unsignedBigInteger('total');
|
||||
|
||||
@ -18,10 +18,10 @@ class CreateInvoiceItemsTable extends Migration
|
||||
$table->string('name');
|
||||
$table->string('description')->nullable();
|
||||
$table->string('discount_type');
|
||||
$table->unsignedBigInteger('quantity');
|
||||
$table->unsignedBigInteger('price');
|
||||
$table->decimal('quantity', 15, 2);
|
||||
$table->decimal('discount', 15, 2)->nullable();
|
||||
$table->unsignedBigInteger('discount_val');
|
||||
$table->unsignedBigInteger('discount');
|
||||
$table->unsignedBigInteger('tax');
|
||||
$table->unsignedBigInteger('total');
|
||||
$table->integer('invoice_id')->unsigned();
|
||||
|
||||
@ -23,8 +23,8 @@ class CreateEstimatesTable extends Migration
|
||||
$table->string('tax_per_item');
|
||||
$table->string('discount_per_item');
|
||||
$table->string('notes')->nullable();
|
||||
$table->decimal('discount', 15, 2)->nullable();
|
||||
$table->string('discount_type')->nullable();
|
||||
$table->unsignedBigInteger('discount')->nullable();
|
||||
$table->unsignedBigInteger('discount_val')->nullable();
|
||||
$table->unsignedBigInteger('sub_total');
|
||||
$table->unsignedBigInteger('total');
|
||||
|
||||
@ -18,9 +18,9 @@ class CreateEstimateItemsTable extends Migration
|
||||
$table->string('name');
|
||||
$table->string('description')->nullable();
|
||||
$table->string('discount_type');
|
||||
$table->unsignedBigInteger('quantity');
|
||||
$table->unsignedBigInteger('discount');
|
||||
$table->unsignedBigInteger('discount_val');
|
||||
$table->decimal('quantity', 15, 2);
|
||||
$table->decimal('discount', 15, 2)->nullable();
|
||||
$table->unsignedBigInteger('discount_val')->nullable();
|
||||
$table->unsignedBigInteger('price');
|
||||
$table->unsignedBigInteger('tax');
|
||||
$table->unsignedBigInteger('total');
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
{
|
||||
"/assets/js/app.js": "/assets/js/app.js?id=b43f30be09501b5efa70",
|
||||
"/assets/js/app.js": "/assets/js/app.js?id=2a5cfd8271e10bd501dc",
|
||||
"/assets/css/crater.css": "/assets/css/crater.css?id=108e3a8d009e7d38018c"
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
{{ selectedCustomer.billing_address.address_street_2 }}
|
||||
</label>
|
||||
<label v-if="selectedCustomer.billing_address.city && selectedCustomer.billing_address.state">
|
||||
{{ selectedCustomer.billing_address.city.name }}, {{ selectedCustomer.billing_address.state.name }} {{ selectedCustomer.billing_address.zip }}
|
||||
{{ selectedCustomer.billing_address.city }}, {{ selectedCustomer.billing_address.state }} {{ selectedCustomer.billing_address.zip }}
|
||||
</label>
|
||||
<label v-if="selectedCustomer.billing_address.country">
|
||||
{{ selectedCustomer.billing_address.country.name }}
|
||||
@ -71,7 +71,7 @@
|
||||
{{ selectedCustomer.shipping_address.address_street_2 }}
|
||||
</label>
|
||||
<label v-if="selectedCustomer.shipping_address.city && selectedCustomer.shipping_address">
|
||||
{{ selectedCustomer.shipping_address.city.name }}, {{ selectedCustomer.shipping_address.state.name }} {{ selectedCustomer.shipping_address.zip }}
|
||||
{{ selectedCustomer.shipping_address.city }}, {{ selectedCustomer.shipping_address.state }} {{ selectedCustomer.shipping_address.zip }}
|
||||
</label>
|
||||
<label v-if="selectedCustomer.shipping_address.country" class="country">
|
||||
{{ selectedCustomer.shipping_address.country.name }}
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
{{ selectedCustomer.billing_address.address_street_2 }}
|
||||
</label>
|
||||
<label v-if="selectedCustomer.billing_address.city && selectedCustomer.billing_address.state">
|
||||
{{ selectedCustomer.billing_address.city.name }}, {{ selectedCustomer.billing_address.state.name }} {{ selectedCustomer.billing_address.zip }}
|
||||
{{ selectedCustomer.billing_address.city }}, {{ selectedCustomer.billing_address.state }} {{ selectedCustomer.billing_address.zip }}
|
||||
</label>
|
||||
<label v-if="selectedCustomer.billing_address.country">
|
||||
{{ selectedCustomer.billing_address.country.name }}
|
||||
@ -69,7 +69,7 @@
|
||||
{{ selectedCustomer.shipping_address.address_street_2 }}
|
||||
</label>
|
||||
<label v-if="selectedCustomer.shipping_address.city && selectedCustomer.shipping_address">
|
||||
{{ selectedCustomer.shipping_address.city.name }}, {{ selectedCustomer.shipping_address.state.name }} {{ selectedCustomer.shipping_address.zip }}
|
||||
{{ selectedCustomer.shipping_address.city }}, {{ selectedCustomer.shipping_address.state }} {{ selectedCustomer.shipping_address.zip }}
|
||||
</label>
|
||||
<label v-if="selectedCustomer.shipping_address.country" class="country">
|
||||
{{ selectedCustomer.shipping_address.country.name }}
|
||||
|
||||
@ -286,7 +286,7 @@ export default {
|
||||
let request = await this.deleteInvoice(this.id)
|
||||
if (request.data.success) {
|
||||
window.toastr['success'](this.$tc('invoices.deleted_message', 1))
|
||||
this.$router.push('/admin/invoices/')
|
||||
this.$router.push('/admin/invoices')
|
||||
} else if (request.data.error) {
|
||||
window.toastr['error'](request.data.message)
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ export default {
|
||||
setTimeout(() => {
|
||||
location.reload()
|
||||
}, 2000)
|
||||
}, 5000)
|
||||
}, 1000)
|
||||
} else {
|
||||
console.log(res.data)
|
||||
window.toastr['error'](res.data.error)
|
||||
|
||||
@ -206,10 +206,10 @@ export default {
|
||||
} else {
|
||||
window.toastr['error'](this.$t('wizard.errors.' + response.data.error))
|
||||
}
|
||||
this.loading = false
|
||||
} catch (e) {
|
||||
console.log(e.response)
|
||||
window.toastr['error'](e.response.data.message)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
{{$estimate->user->billingaddress->address_street_2}}<br>
|
||||
@endif
|
||||
|
||||
@if($estimate->user->billingaddress->city && $estimate->user->billingaddress->city->name)
|
||||
{{$estimate->user->billingaddress->city->name}},
|
||||
@if($estimate->user->billingaddress->city && $estimate->user->billingaddress->city)
|
||||
{{$estimate->user->billingaddress->city}},
|
||||
@endif
|
||||
|
||||
@if($estimate->user->billingaddress->state && $estimate->user->billingaddress->state->name)
|
||||
{{$estimate->user->billingaddress->state->name}}.
|
||||
@if($estimate->user->billingaddress->state && $estimate->user->billingaddress->state)
|
||||
{{$estimate->user->billingaddress->state}}.
|
||||
@endif
|
||||
|
||||
@if($estimate->user->billingaddress->zip)
|
||||
|
||||
@ -12,10 +12,10 @@
|
||||
{{$company_address->addresses[0]['address_street_2']}} <br>
|
||||
@endif
|
||||
@if($company_address->addresses[0]['city'])
|
||||
{{$company_address->addresses[0]['city']->name}}
|
||||
{{$company_address->addresses[0]['city']}}
|
||||
@endif
|
||||
@if($company_address->addresses[0]['state'])
|
||||
{{$company_address->addresses[0]['state']->name}}
|
||||
{{$company_address->addresses[0]['state']}}
|
||||
@endif
|
||||
@if($company_address->addresses[0]['zip'])
|
||||
{{$company_address->addresses[0]['zip']}} <br>
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
{{$estimate->user->shippingaddress->address_street_2}}<br>
|
||||
@endif
|
||||
|
||||
@if($estimate->user->shippingaddress->city && $estimate->user->shippingaddress->city->name)
|
||||
{{$estimate->user->shippingaddress->city->name}},
|
||||
@if($estimate->user->shippingaddress->city && $estimate->user->shippingaddress->city)
|
||||
{{$estimate->user->shippingaddress->city}},
|
||||
@endif
|
||||
|
||||
@if($estimate->user->shippingaddress->state && $estimate->user->shippingaddress->state->name)
|
||||
{{$estimate->user->shippingaddress->state->name}}.
|
||||
@if($estimate->user->shippingaddress->state && $estimate->user->shippingaddress->state)
|
||||
{{$estimate->user->shippingaddress->state}}.
|
||||
@endif
|
||||
|
||||
@if($estimate->user->shippingaddress->zip)
|
||||
|
||||
@ -14,11 +14,11 @@
|
||||
@if($invoice->user->billingaddress->address_street_2)
|
||||
{{$invoice->user->billingaddress->address_street_2}}<br>
|
||||
@endif
|
||||
@if($invoice->user->billingaddress->city && $invoice->user->billingaddress->city->name)
|
||||
{{$invoice->user->billingaddress->city->name}},
|
||||
@if($invoice->user->billingaddress->city && $invoice->user->billingaddress->city)
|
||||
{{$invoice->user->billingaddress->city}},
|
||||
@endif
|
||||
@if($invoice->user->billingaddress->state && $invoice->user->billingaddress->state->name)
|
||||
{{$invoice->user->billingaddress->state->name}}.
|
||||
@if($invoice->user->billingaddress->state && $invoice->user->billingaddress->state)
|
||||
{{$invoice->user->billingaddress->state}}.
|
||||
@endif
|
||||
@if($invoice->user->billingaddress->zip)
|
||||
{{$invoice->user->billingaddress->zip}}<br>
|
||||
|
||||
@ -12,10 +12,10 @@
|
||||
{{$company_address->addresses[0]['address_street_2']}} <br>
|
||||
@endif
|
||||
@if($company_address->addresses[0]['city'])
|
||||
{{$company_address->addresses[0]['city']->name}}
|
||||
{{$company_address->addresses[0]['city']}}
|
||||
@endif
|
||||
@if($company_address->addresses[0]['state'])
|
||||
{{$company_address->addresses[0]['state']->name}}
|
||||
{{$company_address->addresses[0]['state']}}
|
||||
@endif
|
||||
@if($company_address->addresses[0]['zip'])
|
||||
{{$company_address->addresses[0]['zip']}} <br>
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
{{$invoice->user->shippingaddress->address_street_2}}<br>
|
||||
@endif
|
||||
|
||||
@if($invoice->user->shippingaddress->city && $invoice->user->shippingaddress->city->name)
|
||||
{{$invoice->user->shippingaddress->city->name}},
|
||||
@if($invoice->user->shippingaddress->city && $invoice->user->shippingaddress->city)
|
||||
{{$invoice->user->shippingaddress->city}},
|
||||
@endif
|
||||
|
||||
@if($invoice->user->shippingaddress->state && $invoice->user->shippingaddress->state->name)
|
||||
{{$invoice->user->shippingaddress->state->name}}.
|
||||
@if($invoice->user->shippingaddress->state && $invoice->user->shippingaddress->state)
|
||||
{{$invoice->user->shippingaddress->state}}.
|
||||
@endif
|
||||
|
||||
@if($invoice->user->shippingaddress->zip)
|
||||
|
||||
Reference in New Issue
Block a user