diff --git a/app/Jobs/Invoice/ApplyPaymentToInvoice.php b/app/Jobs/Invoice/ApplyPaymentToInvoice.php index 1dfa22e635be..3d3cb4b56b94 100644 --- a/app/Jobs/Invoice/ApplyPaymentToInvoice.php +++ b/app/Jobs/Invoice/ApplyPaymentToInvoice.php @@ -13,6 +13,7 @@ namespace App\Jobs\Invoice; use App\Models\Invoice; use App\Models\Payment; +use App\Models\PaymentTerm; use App\Repositories\InvoiceRepository; use App\Utils\Traits\NumberFormatter; use Illuminate\Bus\Queueable; @@ -85,7 +86,7 @@ class ApplyPaymentToInvoice implements ShouldQueue if(!$this->invoice->due_date) - $this->invoice->due_date = Carbon::now()->addDays($this->invoice->settings->payment_terms)->format(config('ninja.date_format')); + $this->invoice->due_date = Carbon::now()->addDays(PaymentTerm::find($this->invoice->settings->payment_terms)->num_days)->format(config('ninja.date_format')); } diff --git a/config/ninja.php b/config/ninja.php index 154ff554216d..115565e5a094 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -48,7 +48,7 @@ return [ 'datetime_moment_format' => env('DEFAULT_DATETIME_MOMENT_FORMAT', 'MMM D, YYYY h:mm:ss a'), 'locale' => env('DEFAULT_LOCALE', 'en'), 'map_zoom' => env('DEFAULT_MAP_ZOOM', 10), - 'payment_terms' => env('DEFAULT_PAYMENT_TERMS', 7), + 'payment_terms' => env('DEFAULT_PAYMENT_TERMS', 1), 'military_time' => env('MILITARY_TIME', 0), 'start_of_week' => env('START_OF_WEEK',1), 'financial_year_start' => env('FINANCIAL_YEAR_START', '2000-01-01') diff --git a/database/factories/ClientFactory.php b/database/factories/ClientFactory.php index c09628f546ff..026cf155bbf8 100644 --- a/database/factories/ClientFactory.php +++ b/database/factories/ClientFactory.php @@ -15,7 +15,7 @@ $factory->define(App\Models\Client::class, function (Faker $faker) { 'id_number' => $faker->text(20), 'custom_value1' => $faker->text(20), 'custom_value2' => $faker->text(20), - 'payment_terms' => $faker->text(40), + 'payment_terms' => 1, 'address1' => $faker->buildingNumber, 'address2' => $faker->streetAddress, 'city' => $faker->city, diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index 6d2e293c91c5..6cba4af54fc1 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -291,7 +291,7 @@ class CreateUsersTable extends Migration $table->text('settings'); $table->boolean('is_deleted')->default(false); - $table->string('payment_terms')->nullable(); //todo type? depends how we are storing this + $table->integer('payment_terms')->nullable(); $table->string('vat_number')->nullable(); $table->string('id_number')->nullable();