diff --git a/app/Factory/ClientContactFactory.php b/app/Factory/ClientContactFactory.php index 0676fc65ea..2eab3d90ef 100644 --- a/app/Factory/ClientContactFactory.php +++ b/app/Factory/ClientContactFactory.php @@ -21,6 +21,7 @@ class ClientContactFactory $client_contact->first_name = ""; $client_contact->user_id = $user_id; $client_contact->company_id = $company_id; + $client_contact->contact_key = \Illuminate\Support\Str::random(40); $client_contact->id = 0; return $client_contact; diff --git a/app/Factory/CloneInvoiceFactory.php b/app/Factory/CloneInvoiceFactory.php index 39faae8828..c6c46228b3 100644 --- a/app/Factory/CloneInvoiceFactory.php +++ b/app/Factory/CloneInvoiceFactory.php @@ -19,8 +19,8 @@ class CloneInvoiceFactory { $clone_invoice = $invoice->replicate(); $clone_invoice->status_id = Invoice::STATUS_DRAFT; - $clone_invoice->invoice_number = NULL; - $clone_invoice->invoice_date = null; + $clone_invoice->number = NULL; + $clone_invoice->date = null; $clone_invoice->due_date = null; $clone_invoice->partial_due_date = null; $clone_invoice->user_id = $user_id; diff --git a/app/Factory/InvoiceFactory.php b/app/Factory/InvoiceFactory.php index 5a9e2acc97..28c8ac2a90 100644 --- a/app/Factory/InvoiceFactory.php +++ b/app/Factory/InvoiceFactory.php @@ -22,7 +22,7 @@ class InvoiceFactory { $invoice = new Invoice(); $invoice->status_id = Invoice::STATUS_DRAFT; - $invoice->invoice_number = null; + $invoice->number = null; $invoice->discount = 0; $invoice->is_amount_discount = true; $invoice->po_number = ''; @@ -30,7 +30,7 @@ class InvoiceFactory $invoice->terms = ''; $invoice->public_notes = ''; $invoice->private_notes = ''; - $invoice->invoice_date = null; + $invoice->date = null; $invoice->due_date = null; $invoice->partial_due_date = null; $invoice->is_deleted = false; @@ -49,7 +49,7 @@ class InvoiceFactory $invoice->partial = 0; $invoice->user_id = $user_id; $invoice->company_id = $company_id; - $invoice->recurring_invoice_id = null; + $invoice->recurring_id = null; return $invoice; } diff --git a/app/Factory/InvoiceToRecurringInvoiceFactory.php b/app/Factory/InvoiceToRecurringInvoiceFactory.php index a53bf313f1..c70a5ae871 100644 --- a/app/Factory/InvoiceToRecurringInvoiceFactory.php +++ b/app/Factory/InvoiceToRecurringInvoiceFactory.php @@ -25,14 +25,14 @@ class InvoiceToRecurringInvoiceFactory $recurring_invoice->status_id = RecurringInvoice::STATUS_DRAFT; $recurring_invoice->discount = $invoice->discount; - $recurring_invoice->invoice_number = ''; + $recurring_invoice->number = ''; $recurring_invoice->is_amount_discount = $invoice->is_amount_discount; $recurring_invoice->po_number = $invoice->po_number; $recurring_invoice->footer = $invoice->footer; $recurring_invoice->terms = $invoice->terms; $recurring_invoice->public_notes = $invoice->public_notes; $recurring_invoice->private_notes = $invoice->private_notes; - $recurring_invoice->invoice_date = date_create()->format($invoice->client->date_format()); + $recurring_invoice->date = date_create()->format($invoice->client->date_format()); $recurring_invoice->due_date = $invoice->due_date; //todo calculate based on terms $recurring_invoice->is_deleted = $invoice->is_deleted; $recurring_invoice->line_items = $invoice->line_items; diff --git a/app/Factory/RecurringInvoiceFactory.php b/app/Factory/RecurringInvoiceFactory.php index abe19b4857..9f98b936b1 100644 --- a/app/Factory/RecurringInvoiceFactory.php +++ b/app/Factory/RecurringInvoiceFactory.php @@ -24,12 +24,12 @@ class RecurringInvoiceFactory $invoice->discount = 0; $invoice->is_amount_discount = true; $invoice->po_number = ''; - $invoice->invoice_number = ''; + $invoice->number = ''; $invoice->footer = ''; $invoice->terms = ''; $invoice->public_notes = ''; $invoice->private_notes = ''; - $invoice->invoice_date = null; + $invoice->date = null; $invoice->due_date = null; $invoice->partial_due_date = null; $invoice->is_deleted = false; diff --git a/app/Factory/RecurringInvoiceToInvoiceFactory.php b/app/Factory/RecurringInvoiceToInvoiceFactory.php index a1255976e9..f987a57b71 100644 --- a/app/Factory/RecurringInvoiceToInvoiceFactory.php +++ b/app/Factory/RecurringInvoiceToInvoiceFactory.php @@ -30,7 +30,7 @@ class recurring_invoiceToInvoiceFactory $invoice->terms = $recurring_invoice->terms; $invoice->public_notes = $recurring_invoice->public_notes; $invoice->private_notes = $recurring_invoice->private_notes; - $invoice->invoice_date = date_create()->format($client->date_format()); + $invoice->date = date_create()->format($client->date_format()); $invoice->due_date = $recurring_invoice->due_date; //todo calculate based on terms $invoice->is_deleted = $recurring_invoice->is_deleted; $invoice->line_items = $recurring_invoice->line_items; @@ -47,7 +47,7 @@ class recurring_invoiceToInvoiceFactory $invoice->balance = $recurring_invoice->balance; $invoice->user_id = $recurring_invoice->user_id; $invoice->company_id = $recurring_invoice->company_id; - $invoice->recurring_invoice_id = $recurring_invoice->id; + $invoice->recurring_id = $recurring_invoice->id; return $invoice; } diff --git a/app/Factory/RecurringQuoteFactory.php b/app/Factory/RecurringQuoteFactory.php index 2b55a61b53..1da8b1c669 100644 --- a/app/Factory/RecurringQuoteFactory.php +++ b/app/Factory/RecurringQuoteFactory.php @@ -28,8 +28,8 @@ class RecurringQuoteFactory $quote->terms = ''; $quote->public_notes = ''; $quote->private_notes = ''; - $quote->quote_date = null; - $quote->valid_until = null; + $quote->date = null; + $quote->due_date = null; $quote->partial_due_date = null; $quote->is_deleted = false; $quote->line_items = json_encode([]); diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 257e464ec4..ccdc33b835 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -79,9 +79,9 @@ class InvoiceFilters extends QueryFilters return $this->builder; return $this->builder->where(function ($query) use ($filter) { - $query->where('invoices.invoice_number', 'like', '%'.$filter.'%') + $query->where('invoices.number', 'like', '%'.$filter.'%') ->orWhere('invoices.po_number', 'like', '%'.$filter.'%') - ->orWhere('invoices.invoice_date', 'like', '%'.$filter.'%') + ->orWhere('invoices.date', 'like', '%'.$filter.'%') ->orWhere('invoices.amount', 'like', '%'.$filter.'%') ->orWhere('invoices.balance', 'like', '%'.$filter.'%') ->orWhere('invoices.custom_value1', 'like', '%'.$filter.'%') diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index d3580d4d26..0d6709d870 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -60,8 +60,8 @@ class InvoiceController extends Controller }) ->editColumn('status_id', function ($invoice){ return Invoice::badgeForStatus($invoice->status); - })->editColumn('invoice_date', function ($invoice){ - return $this->formatDate($invoice->invoice_date, $invoice->client->date_format()); + })->editColumn('date', function ($invoice){ + return $this->formatDate($invoice->date, $invoice->client->date_format()); })->editColumn('due_date', function ($invoice){ return $this->formatDate($invoice->due_date, $invoice->client->date_format()); })->editColumn('balance', function ($invoice) { diff --git a/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php b/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php index 4415374b0d..58c3b77b89 100644 --- a/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php +++ b/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php @@ -62,7 +62,7 @@ class RecurringInvoiceController extends Controller return RecurringInvoice::badgeForStatus($invoice->status); }) ->editColumn('start_date', function ($invoice){ - return $this->formatDate($invoice->invoice_date, $invoice->client->date_format()); + return $this->formatDate($invoice->date, $invoice->client->date_format()); }) ->editColumn('next_send_date', function ($invoice){ return $this->formatDate($invoice->next_send_date, $invoice->client->date_format()); diff --git a/app/Http/Controllers/OpenAPI/InvoiceSchema.php b/app/Http/Controllers/OpenAPI/InvoiceSchema.php index 9e94d2d1ad..1188cab414 100644 --- a/app/Http/Controllers/OpenAPI/InvoiceSchema.php +++ b/app/Http/Controllers/OpenAPI/InvoiceSchema.php @@ -9,7 +9,7 @@ * @OA\Property(property="client_id", type="string", example="", description="________"), * @OA\Property(property="status_id", type="string", example="", description="________"), * @OA\Property(property="invoice_type_id", type="string", example="", description="________"), - * @OA\Property(property="invoice_number", type="string", example="", description="________"), + * @OA\Property(property="number", type="string", example="INV_101", description="The invoice number - is a unique alpha numeric number per invoice per company"), * @OA\Property(property="po_number", type="string", example="", description="________"), * @OA\Property(property="terms", type="string", example="", description="________"), * @OA\Property(property="public_notes", type="string", example="", description="________"), @@ -33,7 +33,7 @@ * @OA\Property(property="is_amount_discount", type="boolean", example=true, description="_________"), * @OA\Property(property="is_deleted", type="boolean", example=true, description="_________"), * @OA\Property(property="uses_inclusive_taxes", type="boolean", example=true, description="Defines the type of taxes used as either inclusive or exclusive"), - * @OA\Property(property="invoice_date", type="string", format="date", example="1994-07-30", description="_________"), + * @OA\Property(property="date", type="string", format="date", example="1994-07-30", description="The Invoice Date"), * @OA\Property(property="partial_due_date", type="string", format="date", example="1994-07-30", description="_________"), * @OA\Property(property="due_date", type="string", format="date", example="1994-07-30", description="_________"), * @OA\Property(property="settings",ref="#/components/schemas/CompanySettings"), diff --git a/app/Jobs/Invoice/ApplyInvoiceNumber.php b/app/Jobs/Invoice/ApplyInvoiceNumber.php index face7abd7f..b8554f4c3d 100644 --- a/app/Jobs/Invoice/ApplyInvoiceNumber.php +++ b/app/Jobs/Invoice/ApplyInvoiceNumber.php @@ -54,16 +54,16 @@ class ApplyInvoiceNumber implements ShouldQueue public function handle() { //return early - if($this->invoice->invoice_number != '') + if($this->invoice->number != '') return $this->invoice; switch ($this->settings->counter_number_applied) { case 'when_saved': - $this->invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client); + $this->invoice->number = $this->getNextInvoiceNumber($this->invoice->client); break; case 'when_sent': if($this->invoice->status_id == Invoice::STATUS_SENT) - $this->invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client); + $this->invoice->number = $this->getNextInvoiceNumber($this->invoice->client); break; default: diff --git a/app/Jobs/Invoice/CreateInvoicePdf.php b/app/Jobs/Invoice/CreateInvoicePdf.php index c19a0967b9..6ea98b0dba 100644 --- a/app/Jobs/Invoice/CreateInvoicePdf.php +++ b/app/Jobs/Invoice/CreateInvoicePdf.php @@ -53,7 +53,7 @@ class CreateInvoicePdf implements ShouldQueue $this->invoice->load('client'); $path = 'public/' . $this->invoice->client->client_hash . '/invoices/'; - $file_path = $path . $this->invoice->invoice_number . '.pdf'; + $file_path = $path . $this->invoice->number . '.pdf'; //get invoice design $html = $this->generateInvoiceHtml($this->invoice->design(), $this->invoice); diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index 842e33dd21..c2811e31f7 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -53,7 +53,7 @@ class SendRecurring // Generate Standard Invoice $invoice = RecurringInvoiceToInvoiceFactory::create($this->recurring_invoice); - $invoice->invoice_number = $this->getNextRecurringInvoiceNumber($this->recurring_invoice->client); + $invoice->number = $this->getNextRecurringInvoiceNumber($this->recurring_invoice->client); $invoice->status_id = Invoice::STATUS_SENT; $invoice->save(); diff --git a/app/Mail/BouncedEmail.php b/app/Mail/BouncedEmail.php index 7360bf1994..3afbeafea3 100644 --- a/app/Mail/BouncedEmail.php +++ b/app/Mail/BouncedEmail.php @@ -41,7 +41,7 @@ class BouncedEmail extends Mailable implements ShouldQueue { $entity_type = class_basename(lcfirst($this->invitation->getEntityType())); - $subject = ctrans("texts.notification_{$entity_type}_bounced_subject", ['invoice' => $invoice->invoice_number]); + $subject = ctrans("texts.notification_{$entity_type}_bounced_subject", ['invoice' => $invoice->number]); return $this->from($invitation->user->email) diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 023984e50d..9e26c7e61c 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -54,10 +54,10 @@ class Invoice extends BaseModel ]; protected $fillable = [ - 'invoice_number', + 'number', 'discount', 'po_number', - 'invoice_date', + 'date', 'due_date', 'terms', 'public_notes', @@ -288,9 +288,9 @@ class Invoice extends BaseModel /** TODO// DOCUMENT THIS FUNCTIONALITY */ public function pdf_url() { - $public_path = 'storage/' . $this->client->client_hash . '/invoices/'. $this->invoice_number . '.pdf'; + $public_path = 'storage/' . $this->client->client_hash . '/invoices/'. $this->number . '.pdf'; - $storage_path = 'public/' . $this->client->client_hash . '/invoices/'. $this->invoice_number . '.pdf'; + $storage_path = 'public/' . $this->client->client_hash . '/invoices/'. $this->number . '.pdf'; if(!Storage::exists($storage_path)) { event(new InvoiceWasUpdated($this)); @@ -301,7 +301,7 @@ class Invoice extends BaseModel public function pdf_file_path() { - $storage_path = 'storage/' . $this->client->client_hash . '/invoices/'. $this->invoice_number . '.pdf'; + $storage_path = 'storage/' . $this->client->client_hash . '/invoices/'. $this->number . '.pdf'; if(!Storage::exists($storage_path)) { CreateInvoicePdf::dispatchNow($this); diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index 94cc67b335..ad7656b01c 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -40,6 +40,19 @@ class RecurringInvoice extends BaseModel /** * Recurring intervals //todo MAP WHEN WE MIGRATE */ + +/* Make sure we support overflow!!!!!!!!!! +$start = Carbon::today(); +$subscription = Carbon::parse('2017-12-31'); + +foreach (range(1, 12) as $month) { + $day = $start->addMonthNoOverflow()->thisDayOrLast($subscription->day); + + echo "You will be billed on {$day} in month {$month}\n"; +} + */ + + const FREQUENCY_DAILY = 1; const FREQUENCY_WEEKLY = 2; const FREQUENCY_TWO_WEEKS = 3; @@ -57,11 +70,11 @@ class RecurringInvoice extends BaseModel protected $fillable = [ 'client_id', - 'invoice_number', + 'number', 'discount', 'is_amount_discount', 'po_number', - 'invoice_date', + 'date', 'due_date', 'line_items', 'settings', @@ -120,7 +133,7 @@ class RecurringInvoice extends BaseModel public function invoices() { - return $this->hasMany(Invoice::class, "id", "recurring_invoice_id")->withTrashed(); + return $this->hasMany(Invoice::class, "id", "recurring_id")->withTrashed(); } public function invitations() diff --git a/app/Notifications/ClientContactRequestCancellation.php b/app/Notifications/ClientContactRequestCancellation.php index 410b58a583..53c8fa2cd0 100644 --- a/app/Notifications/ClientContactRequestCancellation.php +++ b/app/Notifications/ClientContactRequestCancellation.php @@ -64,7 +64,7 @@ class ClientContactRequestCancellation extends Notification implements ShouldQue $client_contact_name = $this->client_contact->present()->name(); $client_name = $this->client_contact->client->present()->name(); - $recurring_invoice_number = $this->recurring_invoice->invoice_number; + $recurring_invoice_number = $this->recurring_invoice->number; return (new MailMessage) @@ -93,7 +93,7 @@ class ClientContactRequestCancellation extends Notification implements ShouldQue $name = $this->client_contact->present()->name(); $client_name = $this->client_contact->client->present()->name(); - $recurring_invoice_number = $this->recurring_invoice->invoice_number; + $recurring_invoice_number = $this->recurring_invoice->number; return (new SlackMessage) ->success() diff --git a/app/PaymentDrivers/BasePaymentDriver.php b/app/PaymentDrivers/BasePaymentDriver.php index 781f0df7fb..d6c2ce93f3 100644 --- a/app/PaymentDrivers/BasePaymentDriver.php +++ b/app/PaymentDrivers/BasePaymentDriver.php @@ -35,8 +35,8 @@ use Omnipay\Omnipay; 'currency' => $invoice->getCurrencyCode(), 'returnUrl' => $completeUrl, 'cancelUrl' => $this->invitation->getLink(), - 'description' => trans('texts.' . $invoice->getEntityType()) . " {$invoice->invoice_number}", - 'transactionId' => $invoice->invoice_number, + 'description' => trans('texts.' . $invoice->getEntityType()) . " {$invoice->number}", + 'transactionId' => $invoice->number, 'transactionType' => 'Purchase', 'clientIp' => Request::getClientIp(), ]; diff --git a/app/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/PaymentDrivers/PayPalExpressPaymentDriver.php index 72a25f9e0a..d3be8b23bb 100644 --- a/app/PaymentDrivers/PayPalExpressPaymentDriver.php +++ b/app/PaymentDrivers/PayPalExpressPaymentDriver.php @@ -213,7 +213,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver foreach($input['invoices'] as $invoice) { - $invoice_numbers .= $invoice->invoice_number." "; + $invoice_numbers .= $invoice->number." "; } return ctrans('texts.invoice_number'). ": {$invoice_numbers}"; diff --git a/app/Transformers/Contact/InvoiceTransformer.php b/app/Transformers/Contact/InvoiceTransformer.php index 061802d462..7deaca6f1c 100644 --- a/app/Transformers/Contact/InvoiceTransformer.php +++ b/app/Transformers/Contact/InvoiceTransformer.php @@ -35,10 +35,10 @@ class InvoiceTransformer extends EntityTransformer 'status_id' => (int) ($invoice->status_id ?: 1), 'updated_at' => $invoice->updated_at, 'archived_at' => $invoice->deleted_at, - 'invoice_number' => $invoice->invoice_number, + 'number' => $invoice->number, 'discount' => (float) $invoice->discount, 'po_number' => $invoice->po_number, - 'invoice_date' => $invoice->invoice_date ?: '', + 'date' => $invoice->date ?: '', 'due_date' => $invoice->due_date ?: '', 'terms' => $invoice->terms ?: '', 'public_notes' => $invoice->public_notes ?: '', diff --git a/app/Transformers/InvoiceTransformer.php b/app/Transformers/InvoiceTransformer.php index 52a01e273a..e66ea9ff7f 100644 --- a/app/Transformers/InvoiceTransformer.php +++ b/app/Transformers/InvoiceTransformer.php @@ -92,10 +92,10 @@ class InvoiceTransformer extends EntityTransformer 'design_id' => (string) ($invoice->design_id ?: 1), 'updated_at' => $invoice->updated_at, 'archived_at' => $invoice->deleted_at, - 'invoice_number' => $invoice->invoice_number ?: '', + 'number' => $invoice->number ?: '', 'discount' => (float) $invoice->discount, 'po_number' => $invoice->po_number ?: '', - 'invoice_date' => $invoice->invoice_date ?: '', + 'date' => $invoice->date ?: '', 'due_date' => $invoice->due_date ?: '', 'terms' => $invoice->terms ?: '', 'public_notes' => $invoice->public_notes ?: '', diff --git a/app/Transformers/RecurringInvoiceTransformer.php b/app/Transformers/RecurringInvoiceTransformer.php index b313c82988..0734cbe173 100644 --- a/app/Transformers/RecurringInvoiceTransformer.php +++ b/app/Transformers/RecurringInvoiceTransformer.php @@ -91,7 +91,7 @@ class RecurringInvoiceTransformer extends EntityTransformer 'archived_at' => $invoice->deleted_at, 'discount' => (float) $invoice->discount ?: '', 'po_number' => $invoice->po_number ?: '', - 'invoice_date' => $invoice->invoice_date ?: '', + 'date' => $invoice->date ?: '', 'due_date' => $invoice->due_date ?: '', 'terms' => $invoice->terms ?: '', 'public_notes' => $invoice->public_notes ?: '', diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index b427092dfc..6207f517bb 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -196,13 +196,13 @@ trait GeneratesCounter $number = $this->applyNumberPattern($client, $number, $pattern); if($class == Invoice::class || $class == RecurringInvoice::class) - $check = $class::whereCompanyId($client->company_id)->whereInvoiceNumber($number)->withTrashed()->first(); + $check = $class::whereCompanyId($client->company_id)->whereNumber($number)->withTrashed()->first(); elseif($class == Client::class) $check = $class::whereCompanyId($client->company_id)->whereIdNumber($number)->withTrashed()->first(); elseif($class == Credit::class) - $check = $class::whereCompanyId($client->company_id)->whereCreditNumber($number)->withTrashed()->first(); + $check = $class::whereCompanyId($client->company_id)->whereNumber($number)->withTrashed()->first(); elseif($class == Quote::class) - $check = $class::whereCompanyId($client->company_id)->whereQuoteNumber($number)->withTrashed()->first(); + $check = $class::whereCompanyId($client->company_id)->whereNumber($number)->withTrashed()->first(); $counter++; diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index bb93f2ebd5..2d6ac90ba9 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -46,9 +46,9 @@ trait MakesInvoiceValues * @var array */ private static $labels = [ - 'invoice_date', + 'date', 'due_date', - 'invoice_number', + 'number', 'po_number', 'discount', 'taxes', @@ -161,9 +161,9 @@ trait MakesInvoiceValues $data = []; - $data['$invoice_date'] = $this->invoice_date; + $data['$date'] = $this->date; $data['$due_date'] = $this->due_date; - $data['$invoice_number'] = $this->invoice_number; + $data['$invoice_number'] = $this->number; $data['$po_number'] = $this->po_number; $data['$line_taxes'] = $this->makeLineTaxes(); $data['$total_taxes'] = $this->makeTotalTaxes(); @@ -196,7 +196,7 @@ trait MakesInvoiceValues // $data['$invoice_to'] = ; // $data['$quote_to'] = ; // $data['$details'] = ; - $data['$invoice_no'] = $this->invoice_number; + $data['$invoice_no'] = $this->number; // $data['$quote_no'] = ; // $data['$valid_until'] = ; $data['$client_name'] = $this->present()->clientName(); diff --git a/database/factories/ClientContactFactory.php b/database/factories/ClientContactFactory.php index e67302e1ce..23be366c43 100644 --- a/database/factories/ClientContactFactory.php +++ b/database/factories/ClientContactFactory.php @@ -22,7 +22,7 @@ $factory->define(App\Models\ClientContact::class, function (Faker $faker) { 'email' => $faker->unique()->safeEmail, 'password' => bcrypt('password'), 'remember_token' => \Illuminate\Support\Str::random(10), - 'token' => \Illuminate\Support\Str::random(64), + 'contact_key' => \Illuminate\Support\Str::random(40), ]; }); diff --git a/database/factories/InvoiceFactory.php b/database/factories/InvoiceFactory.php index c573bdf40c..c746c32038 100644 --- a/database/factories/InvoiceFactory.php +++ b/database/factories/InvoiceFactory.php @@ -8,7 +8,7 @@ use Faker\Generator as Faker; $factory->define(App\Models\Invoice::class, function (Faker $faker) { return [ 'status_id' => App\Models\Invoice::STATUS_SENT, - 'invoice_number' => $faker->ean13(), + 'number' => $faker->ean13(), 'discount' => $faker->numberBetween(1,10), 'is_amount_discount' => (bool)random_int(0,1), 'tax_name1' => 'GST', @@ -23,7 +23,7 @@ $factory->define(App\Models\Invoice::class, function (Faker $faker) { // 'custom_value4' => $faker->numberBetween(1,4), 'is_deleted' => false, 'po_number' => $faker->text(10), - 'invoice_date' => $faker->date(), + 'date' => $faker->date(), 'due_date' => $faker->date(), 'line_items' => InvoiceItemFactory::generate(5), 'backup' => '', diff --git a/database/factories/QuoteFactory.php b/database/factories/QuoteFactory.php index d0a4c25c94..989654d44a 100644 --- a/database/factories/QuoteFactory.php +++ b/database/factories/QuoteFactory.php @@ -7,7 +7,7 @@ use Faker\Generator as Faker; $factory->define(App\Models\Quote::class, function (Faker $faker) { return [ 'status_id' => App\Models\Quote::STATUS_DRAFT, - 'quote_number' => $faker->text(256), + 'number' => $faker->text(256), 'discount' => $faker->numberBetween(1,10), 'is_amount_discount' => $faker->boolean(), 'tax_name1' => 'GST', @@ -22,8 +22,8 @@ $factory->define(App\Models\Quote::class, function (Faker $faker) { 'custom_value4' => $faker->numberBetween(1,4), 'is_deleted' => false, 'po_number' => $faker->text(10), - 'quote_date' => $faker->date(), - 'valid_until' => $faker->date(), + 'date' => $faker->date(), + 'due_date' => $faker->date(), 'line_items' => false, 'backup' => '', ]; diff --git a/database/factories/RecurringInvoiceFactory.php b/database/factories/RecurringInvoiceFactory.php index a630d8b445..89aae51a8c 100644 --- a/database/factories/RecurringInvoiceFactory.php +++ b/database/factories/RecurringInvoiceFactory.php @@ -21,7 +21,7 @@ $factory->define(App\Models\RecurringInvoice::class, function (Faker $faker) { 'custom_value4' => $faker->numberBetween(1,4), 'is_deleted' => false, 'po_number' => $faker->text(10), - 'invoice_date' => $faker->date(), + 'date' => $faker->date(), 'due_date' => $faker->date(), 'line_items' => false, 'backup' => '', diff --git a/database/factories/RecurringQuoteFactory.php b/database/factories/RecurringQuoteFactory.php index bf84367ba9..748826099c 100644 --- a/database/factories/RecurringQuoteFactory.php +++ b/database/factories/RecurringQuoteFactory.php @@ -7,7 +7,7 @@ use Faker\Generator as Faker; $factory->define(App\Models\RecurringQuote::class, function (Faker $faker) { return [ 'status_id' => App\Models\RecurringQuote::STATUS_DRAFT, - 'quote_number' => $faker->text(256), + 'number' => $faker->text(256), 'discount' => $faker->numberBetween(1,10), 'is_amount_discount' => $faker->boolean(), 'tax_name1' => 'GST', @@ -22,8 +22,8 @@ $factory->define(App\Models\RecurringQuote::class, function (Faker $faker) { 'custom_value4' => $faker->numberBetween(1,4), 'is_deleted' => false, 'po_number' => $faker->text(10), - 'quote_date' => $faker->date(), - 'valid_until' => $faker->date(), + 'date' => $faker->date(), + 'due_date' => $faker->date(), 'line_items' => false, 'backup' => '', 'frequency_id' => App\Models\RecurringQuote::FREQUENCY_MONTHLY, 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 aa5a588e1a..6c7436e217 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -407,21 +407,20 @@ class CreateUsersTable extends Migration $t->unsignedInteger('company_id')->index(); $t->unsignedInteger('status_id'); - $t->unsignedInteger('recurring_invoice_id')->nullable(); + $t->unsignedInteger('recurring_id')->nullable(); $t->unsignedInteger('design_id')->nullable(); - $t->string('invoice_number')->nullable(); + $t->string('number')->nullable(); $t->float('discount')->default(0); $t->boolean('is_amount_discount')->default(0); $t->string('po_number')->nullable(); - $t->date('invoice_date')->nullable(); + $t->date('date')->nullable(); $t->datetime('due_date')->nullable(); $t->boolean('is_deleted')->default(false); $t->mediumText('line_items')->nullable(); - //$t->text('settings')->nullable(); $t->mediumText('backup')->nullable(); $t->text('footer')->nullable(); @@ -468,7 +467,7 @@ class CreateUsersTable extends Migration $t->timestamps(6); $t->softDeletes('deleted_at', 6); - $t->unique(['company_id', 'invoice_number']); + $t->unique(['company_id', 'number']); }); Schema::create('recurring_invoices', function ($t) { @@ -479,13 +478,13 @@ class CreateUsersTable extends Migration $t->unsignedInteger('company_id')->index(); $t->unsignedInteger('status_id')->index(); - $t->text('invoice_number')->nullable(); + $t->text('number')->nullable(); $t->float('discount')->default(0); $t->boolean('is_amount_discount')->default(false); $t->string('po_number')->nullable(); - $t->date('invoice_date')->nullable(); + $t->date('date')->nullable(); $t->datetime('due_date')->nullable(); $t->boolean('is_deleted')->default(false); @@ -545,11 +544,11 @@ class CreateUsersTable extends Migration $t->float('discount')->default(0); $t->boolean('is_amount_discount')->default(false); - $t->string('quote_number')->nullable(); + $t->string('number')->nullable(); $t->string('po_number')->nullable(); - $t->date('quote_date')->nullable(); - $t->datetime('valid_until')->nullable(); + $t->date('date')->nullable(); + $t->datetime('due_date')->nullable(); $t->boolean('is_deleted')->default(false); @@ -602,15 +601,17 @@ class CreateUsersTable extends Migration $t->unsignedInteger('assigned_user_id')->nullable(); $t->unsignedInteger('company_id')->index(); $t->unsignedInteger('status_id'); - $t->unsignedInteger('design_id'); - $t->string('quote_number')->nullable(); + $t->unsignedInteger('recurring_id')->nullable(); + $t->unsignedInteger('design_id')->nullable(); + + $t->string('number')->nullable(); $t->float('discount')->default(0); - $t->boolean('is_amount_discount')->default(false); + $t->boolean('is_amount_discount')->default(0); $t->string('po_number')->nullable(); - $t->date('quote_date')->nullable(); - $t->datetime('valid_until')->nullable(); + $t->date('date')->nullable(); + $t->datetime('due_date')->nullable(); $t->boolean('is_deleted')->default(false); @@ -622,7 +623,6 @@ class CreateUsersTable extends Migration $t->text('private_notes')->nullable(); $t->text('terms')->nullable(); - $t->string('tax_name1')->nullable(); $t->decimal('tax_rate1', 13, 3)->default(0); @@ -632,13 +632,24 @@ class CreateUsersTable extends Migration $t->string('tax_name3')->nullable(); $t->decimal('tax_rate3', 13, 3)->default(0); + $t->boolean('uses_inclusive_taxes')->default(0); + $t->string('custom_value1')->nullable(); $t->string('custom_value2')->nullable(); $t->string('custom_value3')->nullable(); $t->string('custom_value4')->nullable(); - $t->decimal('amount', 16, 4)->default(0); - $t->decimal('balance', 16, 4)->default(0); + $t->string('custom_surcharge1')->nullable(); + $t->string('custom_surcharge2')->nullable(); + $t->string('custom_surcharge3')->nullable(); + $t->string('custom_surcharge4')->nullable(); + $t->boolean('custom_surcharge_tax1')->default(false); + $t->boolean('custom_surcharge_tax2')->default(false); + $t->boolean('custom_surcharge_tax3')->default(false); + $t->boolean('custom_surcharge_tax4')->default(false); + + $t->decimal('amount', 16, 4); + $t->decimal('balance', 16, 4); $t->decimal('partial', 16, 4)->nullable(); $t->datetime('partial_due_date')->nullable(); @@ -651,7 +662,7 @@ class CreateUsersTable extends Migration $t->timestamps(6); $t->softDeletes('deleted_at', 6); - $t->unique(['company_id', 'quote_number']); + $t->unique(['company_id', 'number']); }); Schema::create('invoice_invitations', function ($t) { diff --git a/resources/views/portal/default/gateways/pay_now.blade.php b/resources/views/portal/default/gateways/pay_now.blade.php index 08ef3faaaf..21d1010648 100644 --- a/resources/views/portal/default/gateways/pay_now.blade.php +++ b/resources/views/portal/default/gateways/pay_now.blade.php @@ -16,7 +16,7 @@ @foreach($invoices as $invoice)
-
# {{ $invoice->invoice_number }}
+
# {{ $invoice->number }}
{{ $invoice->due_date }}

{{ $invoice->balance }}

diff --git a/resources/views/portal/default/invoices/payment.blade.php b/resources/views/portal/default/invoices/payment.blade.php index 9c69a79742..e3f78e9ddd 100644 --- a/resources/views/portal/default/invoices/payment.blade.php +++ b/resources/views/portal/default/invoices/payment.blade.php @@ -29,7 +29,7 @@ @foreach($invoices as $invoice)
-
# {{ $invoice->invoice_number }}
+
# {{ $invoice->number }}
{{ $invoice->due_date }}

{{ $invoice->balance }}

diff --git a/resources/views/portal/default/payments/show.blade.php b/resources/views/portal/default/payments/show.blade.php index ee0f531bc7..bb1870f2ce 100644 --- a/resources/views/portal/default/payments/show.blade.php +++ b/resources/views/portal/default/payments/show.blade.php @@ -22,7 +22,7 @@ @foreach($payment->invoices as $invoice) - + @endforeach
{{ ctrans('texts.invoice_number')}}{{ $invoice->invoice_number }}
{{ ctrans('texts.invoice_number')}}{{ $invoice->number }}
diff --git a/tests/Feature/InvoiceTest.php b/tests/Feature/InvoiceTest.php index 238926edaa..ae79a3b5ea 100644 --- a/tests/Feature/InvoiceTest.php +++ b/tests/Feature/InvoiceTest.php @@ -144,7 +144,7 @@ class InvoiceTest extends TestCase { $invoice = [ 'status_id' => 1, - 'invoice_number' => 'dfdfd', + 'number' => 'dfdfd', 'discount' => 0, 'is_amount_discount' => 1, 'po_number' => '3434343', diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php index b79d39e812..70bb9714b3 100644 --- a/tests/MockAccountData.php +++ b/tests/MockAccountData.php @@ -164,7 +164,7 @@ trait MockAccountData $recurring_invoice->start_date = Carbon::now(); $recurring_invoice->save(); - $recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client); + $recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client); $recurring_invoice->save(); $recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice); @@ -174,7 +174,7 @@ trait MockAccountData $recurring_invoice->start_date = Carbon::now(); $recurring_invoice->save(); - $recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client); + $recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client); $recurring_invoice->save(); $recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice); @@ -184,7 +184,7 @@ trait MockAccountData $recurring_invoice->start_date = Carbon::now(); $recurring_invoice->save(); - $recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client); + $recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client); $recurring_invoice->save(); $recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice); @@ -194,7 +194,7 @@ trait MockAccountData $recurring_invoice->start_date = Carbon::now(); $recurring_invoice->save(); - $recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client); + $recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client); $recurring_invoice->save(); @@ -205,7 +205,7 @@ trait MockAccountData $recurring_invoice->start_date = Carbon::now(); $recurring_invoice->save(); - $recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client); + $recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client); $recurring_invoice->save(); $recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice); @@ -215,7 +215,7 @@ trait MockAccountData $recurring_invoice->start_date = Carbon::now(); $recurring_invoice->save(); - $recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client); + $recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client); $recurring_invoice->save(); $gs = new GroupSetting;