1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Invoice Designer (#3283)

* Working self-updater package

* Fixes for travis

* Working on invoice designs

* Working on invoice builder

* Tests for invoice design

* Working on invoice designs

* Minor fixes

* Minor fixes for randomdataseeder
This commit is contained in:
David Bomba 2020-02-05 15:06:03 +11:00 committed by GitHub
parent c2524f55da
commit 3ec996ee5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 732 additions and 40 deletions

View File

@ -456,8 +456,7 @@ class CreateTestData extends Command
$invoice = $invoice_calc->getInvoice(); $invoice = $invoice_calc->getInvoice();
$invoice->save(); $invoice->save();
$invoice->service()->createInvitations();
event(new CreateInvoiceInvitation($invoice));
UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance, $invoice->company); UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance, $invoice->company);

41
app/Designs/Bold.php Normal file
View File

@ -0,0 +1,41 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Designs\Bold;
class Bold
{
public function __construct()
{
}
public function header()
{
}
public function body()
{
}
public function table()
{
}
public function footer()
{
}
}

220
app/Designs/Designer.php Normal file
View File

@ -0,0 +1,220 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Designs;
class Designer
{
protected $design;
protected $input_variables;
protected $exported_variables;
protected $html;
private static $labels = [
'$client_details',
'$invoice_details',
'$company_details',
'$company_address',
'$invoice_details_labels',
'$invoice_details_labels',
'$invoice_details_labels',
];
public function __construct($design, array $input_variables)
{
$this->design = $design;
$this->input_variables = $input_variables;
}
/**
* Returns the design
* formatted HTML
* @return string The HTML design built
*/
public function build() :string
{
$this->setDesign($this->getSection('header'))
->setDesign($this->getSection('body'))
->setDesign($this->getSection('table'))
->setDesign($this->getSection('footer'));
return $this->html;
}
private function setDesign($section)
{
$this->html .= $section;
return $this;
}
/**
* Returns the template section on with the
* stacked variables replaced with single variables.
*
* @param string $section the method name to be executed ie header/body/table/footer
* @return string The HTML of the template section
*/
public function getSection($section) :string
{
$this->exportVariables();
return str_replace(array_keys($this->exported_variables), array_values($this->exported_variables), $this->design->{$section}());
}
private function exportVariables()
{
$this->exported_variables['$client_details'] = $this->processVariables($this->input_variables['client_details'], $this->clientDetails());
$this->exported_variables['$company_details'] = $this->processVariables($this->input_variables['company_details'], $this->companyDetails());
$this->exported_variables['$company_address'] = $this->processVariables($this->input_variables['company_address'], $this->companyAddress());
$this->exported_variables['$invoice_details_labels'] = $this->processLabels($this->input_variables['invoice_details'], $this->invoiceDetails());
$this->exported_variables['$invoice_details'] = $this->processVariables($this->input_variables['invoice_details'], $this->invoiceDetails());
return $this;
}
private function processVariables($input_variables, $variables) :string
{
$output = '';
foreach($input_variables as $value)
$output .= $variables[$value];
return $output;
}
private function processLabels($input_variables, $variables) :string
{
$output = '';
foreach($input_variables as $value) {
$tmp = str_replace("</span>", "_label</span>", $variables[$value]);
$output .= $tmp;
}
return $output;
}
// private function exportVariables()
// {
// /*
// * $invoice_details_labels
// * $invoice_details
// */
// $header = $this->design->header();
// /*
// * $company_logo - full URL
// * $client_details
// */
// $body = $this->design->body();
// /*
// * $table_header
// * $table_body
// * $total_labels
// * $total_values
// */
// $table = $this->design->table();
// /*
// * $company_details
// * $company_address
// */
// $footer = $this->design->footer();
// }
private function clientDetails()
{
return [
'name' => '<p>$client.name</p>',
'id_number' => '<p>$client.id_number</p>',
'vat_number' => '<p>$client.vat_number</p>',
'address1' => '<p>$client.address1</p>',
'address2' => '<p>$client.address2</p>',
'city_state_postal' => '<p>$client.city_state_postal</p>',
'postal_city_state' => '<p>$client.postal_city_state</p>',
'country' => '<p>$client.country</p>',
'email' => '<p>$client.email</p>',
'custom_value1' => '<p>$client.custom_value1</p>',
'custom_value2' => '<p>$client.custom_value2</p>',
'custom_value3' => '<p>$client.custom_value3</p>',
'custom_value4' => '<p>$client.custom_value4</p>',
];
}
private function companyDetails()
{
return [
'company_name' => '<span>$company.company_name</span>',
'id_number' => '<span>$company.id_number</span>',
'vat_number' => '<span>$company.vat_number</span>',
'website' => '<span>$company.website</span>',
'email' => '<span>$company.email</span>',
'phone' => '<span>$company.phone</span>',
'custom_value1' => '<span>$company.custom_value1</span>',
'custom_value2' => '<span>$company.custom_value2</span>',
'custom_value3' => '<span>$company.custom_value3</span>',
'custom_value4' => '<span>$company.custom_value4</span>',
];
}
private function companyAddress()
{
return [
'address1' => '<span>$company.address1</span>',
'address2' => '<span>$company.address1</span>',
'city_state_postal' => '<span>$company.city_state_postal</span>',
'postal_city_state' => '<span>$company.postal_city_state</span>',
'country' => '<span>$company.country</span>',
'custom_value1' => '<span>$company.custom_value1</span>',
'custom_value2' => '<span>$company.custom_value2</span>',
'custom_value3' => '<span>$company.custom_value3</span>',
'custom_value4' => '<span>$company.custom_value4</span>',
];
}
private function invoiceDetails()
{
return [
'invoice_number' => '<span>$invoice_number</span>',
'po_number' => '<span>$po_number</span>',
'date' => '<span>$date</span>',
'due_date' => '<span>$due_date</span>',
'balance_due' => '<span>$balance_due</span>',
'invoice_total' => '<span>$invoice_total</span>',
'partial_due' => '<span>$partial_due</span>',
'custom_value1' => '<span>$invoice.custom_value1</span>',
'custom_value2' => '<span>$invoice.custom_value2</span>',
'custom_value3' => '<span>$invoice.custom_value3</span>',
'custom_value4' => '<span>$invoice.custom_value4</span>',
];
}
}

158
app/Designs/Modern.php Normal file
View File

@ -0,0 +1,158 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Designs;
class Modern
{
public function __construct()
{
}
public function header()
{
return '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="stylesheet" href="/assets/build/css/main.css">
</head>
<body>
<div class="bg-orange-600 flex justify-between py-12 px-12">
<div class="w-1/2">
<h1 class="text-white font-bold text-5xl">$company.name</h1>
</div>
<div class="w-1/2 flex justify-end">
<div class="w-56 flex flex-col text-white">
$invoice_details_labels
</div>
<div class="w-32 flex flex-col text-left text-white">
$invoice_details
</div>
</div>
</div>
';
}
public function body()
{
return '
<div class="flex justify-between px-12 pt-12">
<div class="w-1/2">
$company_logo
</div>
<div class="w-1/2 flex justify-end">
<div class="w-56 flex flex-col">
$client_details
</div>
<div class="w-32">
<!-- -->
</div>
</div>
</div>
';
}
public function table_styles()
{
return [
'table_header_class' => "px-4 py-2",
'table_body_class' => "border-t border-b border-gray-900 px-4 py-4",
];
}
public function table()
{
return '
<div class="px-12 pt-5 pb-20">
<table class="w-full table-auto mt-8">
<thead class="text-left text-white bg-gray-900">
<tr>
$table_header
</tr>
</thead>
<tbody>
<tr>
$table_body
</tr>
</tbody>
</table>
<div class="flex px-4 mt-6 w-full">
<div class="w-1/2">
$invoice.public_notes
</div>
<div class="w-1/2 flex">
<div class="w-1/2 text-right flex flex-col">
$total_labels
</div>
<div class="w-1/2 text-right flex flex-col">
$total_values
</div>
</div>
</div>
<div class="flex px-4 mt-4 w-full items-end mt-5">
<div class="w-1/2">
<p class="font-semibold">$terms_label</p>
$terms
</div>
</div>
<div class="mt-8 px-4 py-2 bg-gray-900 text-white">
<div class="w-1/2"></div>
<div class="w-auto flex justify-end">
<div class="w-56">
<p class="font-bold">$balance_due_label</p>
</div>
<p>$balance_due</p>
</div>
</div>
</div>
';
}
public function footer()
{
return '
<div class="bg-orange-600 flex justify-between py-8 px-12">
<div class="w-1/2">
<!-- // -->
</div>
<div class="w-1/2 flex justify-end">
<div class="w-56 flex flex-col text-white">
$company_details
</div>
<div class="w-32 flex flex-col text-left text-white">
$company_address
</div>
</div>
</div>
</body>
</html>
';
}
}

View File

@ -0,0 +1,27 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Controllers;
class SelfUpdateController extends BaseController
{
use DispatchesJobs;
public function __construct()
{
}
public function update()
{
}
}

View File

@ -33,7 +33,7 @@ class ApiSecretCheck
'errors' => [] 'errors' => []
]; ];
return response() return response()
->json(json_encode($error, JSON_PRETTY_PRINT), 403) ->json($error, 403)
->header('X-App-Version', config('ninja.app_version')) ->header('X-App-Version', config('ninja.app_version'))
->header('X-Api-Version', config('ninja.api_version')); ->header('X-Api-Version', config('ninja.api_version'));
} }

View File

@ -34,10 +34,10 @@ class ContactSetDb
if ($request->header('X-API-TOKEN') && config('ninja.db.multi_db_enabled')) { if ($request->header('X-API-TOKEN') && config('ninja.db.multi_db_enabled')) {
if (! MultiDB::contactFindAndSetDb($request->header('X-API-TOKEN'))) { if (! MultiDB::contactFindAndSetDb($request->header('X-API-TOKEN'))) {
return response()->json(json_encode($error, JSON_PRETTY_PRINT), 403); return response()->json($error, 403);
} }
} else { } else {
return response()->json(json_encode($error, JSON_PRETTY_PRINT), 403); return response()->json($error, 403);
} }
return $next($request); return $next($request);

View File

@ -36,7 +36,7 @@ class ContactTokenAuth
//client_contact who once existed, but has been soft deleted //client_contact who once existed, but has been soft deleted
if (!$client_contact) { if (!$client_contact) {
return response()->json(json_encode($error, JSON_PRETTY_PRINT), 403); return response()->json($error, 403);
} }
@ -47,7 +47,7 @@ class ContactTokenAuth
//client_contact who has been disabled //client_contact who has been disabled
if ($client_contact->is_locked) { if ($client_contact->is_locked) {
return response()->json(json_encode($error, JSON_PRETTY_PRINT), 403); return response()->json($error, 403);
} }
//stateless, don't remember the contact. //stateless, don't remember the contact.
@ -60,7 +60,7 @@ class ContactTokenAuth
'errors' => [] 'errors' => []
]; ];
return response()->json(json_encode($error, JSON_PRETTY_PRINT), 403); return response()->json($error, 403);
} }
return $next($request); return $next($request);

View File

@ -35,7 +35,7 @@ class SetDomainNameDb
**/ **/
if ($request->getSchemeAndHttpHost() && config('ninja.db.multi_db_enabled') && ! MultiDB::findAndSetDbByDomain($request->getSchemeAndHttpHost())) { if ($request->getSchemeAndHttpHost() && config('ninja.db.multi_db_enabled') && ! MultiDB::findAndSetDbByDomain($request->getSchemeAndHttpHost())) {
if (request()->json) { if (request()->json) {
return response()->json(json_encode($error, JSON_PRETTY_PRINT), 403); return response()->json($error, 403);
} else { } else {
abort(404); abort(404);
} }

View File

@ -35,7 +35,7 @@ class SetInviteDb
**/ **/
if ($request->getSchemeAndHttpHost() && config('ninja.db.multi_db_enabled') && ! MultiDB::findAndSetDbByInvitation($request->route('entity'), $request->route('invitation_key'))) { if ($request->getSchemeAndHttpHost() && config('ninja.db.multi_db_enabled') && ! MultiDB::findAndSetDbByInvitation($request->route('entity'), $request->route('invitation_key'))) {
if (request()->json) { if (request()->json) {
return response()->json(json_encode($error, JSON_PRETTY_PRINT), 403); return response()->json($error, 403);
} else { } else {
abort(404); abort(404);
} }

View File

@ -37,7 +37,7 @@ class TokenAuth
]; ];
//user who once existed, but has been soft deleted //user who once existed, but has been soft deleted
if (!$user) { if (!$user) {
return response()->json(json_encode($error, JSON_PRETTY_PRINT), 403); return response()->json($error, 403);
} }
/* /*
@ -56,7 +56,7 @@ class TokenAuth
'errors' => [] 'errors' => []
]; ];
return response()->json(json_encode($error, JSON_PRETTY_PRINT), 403); return response()->json($error, 403);
} }
//stateless, don't remember the user. //stateless, don't remember the user.
@ -69,7 +69,7 @@ class TokenAuth
'errors' => [] 'errors' => []
]; ];
return response()->json(json_encode($error, JSON_PRETTY_PRINT), 403); return response()->json($error, 403);
} }
return $next($request); return $next($request);

View File

@ -68,7 +68,8 @@ class ReverseInvoicePayment implements ShouldQueue
UpdateCompanyLedgerWithPayment::dispatchNow($this->payment, ($this->payment->amount), $this->company); UpdateCompanyLedgerWithPayment::dispatchNow($this->payment, ($this->payment->amount), $this->company);
$client->updateBalance($this->payment->amount) $client->service()
->updateBalance($this->payment->amount)
->updatePaidToDate($this->payment->amount*-1) ->updatePaidToDate($this->payment->amount*-1)
->save(); ->save();

View File

@ -65,6 +65,7 @@ class UpdateInvoicePayment implements ShouldQueue
UpdateCompanyLedgerWithPayment::dispatchNow($this->payment, ($invoice->balance*-1), $this->company); UpdateCompanyLedgerWithPayment::dispatchNow($this->payment, ($invoice->balance*-1), $this->company);
$this->payment->client $this->payment->client
->service()
->updateBalance($invoice->balance*-1) ->updateBalance($invoice->balance*-1)
->updatePaidToDate($invoice->balance) ->updatePaidToDate($invoice->balance)
->save(); ->save();
@ -72,7 +73,8 @@ class UpdateInvoicePayment implements ShouldQueue
$invoice->pivot->amount = $invoice->balance; $invoice->pivot->amount = $invoice->balance;
$invoice->pivot->save(); $invoice->pivot->save();
$invoice->clearPartial() $invoice->service()
->clearPartial()
->updateBalance($invoice->balance*-1) ->updateBalance($invoice->balance*-1)
->save(); ->save();
}); });
@ -96,7 +98,8 @@ class UpdateInvoicePayment implements ShouldQueue
if ($invoice->hasPartial()) { if ($invoice->hasPartial()) {
UpdateCompanyLedgerWithPayment::dispatchNow($this->payment, ($invoice->partial*-1), $this->company); UpdateCompanyLedgerWithPayment::dispatchNow($this->payment, ($invoice->partial*-1), $this->company);
$this->payment->client->updateBalance($invoice->partial*-1) $this->payment->client->service()
->updateBalance($invoice->partial*-1)
->updatePaidToDate($invoice->partial) ->updatePaidToDate($invoice->partial)
->save(); ->save();
@ -111,14 +114,15 @@ class UpdateInvoicePayment implements ShouldQueue
} else { } else {
UpdateCompanyLedgerWithPayment::dispatchNow($this->payment, ($invoice->balance*-1), $this->company); UpdateCompanyLedgerWithPayment::dispatchNow($this->payment, ($invoice->balance*-1), $this->company);
$this->payment->client->updateBalance($invoice->balance*-1) $this->payment->client->service()
->updateBalance($invoice->balance*-1)
->updatePaidToDate($invoice->balance) ->updatePaidToDate($invoice->balance)
->save(); ->save();
$invoice->pivot->amount = $invoice->balance; $invoice->pivot->amount = $invoice->balance;
$invoice->pivot->save(); $invoice->pivot->save();
$invoice->clearPartial()->updateBalance($invoice->balance*-1)->save(); $invoice->service()->clearPartial()->updateBalance($invoice->balance*-1)->save();
} }
}); });
} else { } else {

View File

@ -212,15 +212,11 @@ class Client extends BaseModel
return new ClientService($this); return new ClientService($this);
} }
public function updatePaidToDate($amount) :ClientService
{
return $this->service()->updatePaidToDate($amount);
}
public function updateBalance($amount) :ClientService public function updateBalance($amount) :ClientService
{ {
return $this->service()->updateBalance($amount); return $this->service()->updateBalance($amount);
} }
/** /**
* Adjusts client "balances" when a client * Adjusts client "balances" when a client
* makes a payment that goes on file, but does * makes a payment that goes on file, but does

View File

@ -25,7 +25,11 @@ class CompanyPresenter extends EntityPresenter
*/ */
public function name() public function name()
{ {
return $this->entity->name ?: ctrans('texts.untitled_account'); $settings = $this->entity->settings;
return $this->settings->name ?: ctrans('texts.untitled_account');
//return $this->entity->name ?: ctrans('texts.untitled_account');
} }
public function logo($settings = null) public function logo($settings = null)

View File

@ -47,6 +47,12 @@ class EventServiceProvider extends ServiceProvider
* @var array * @var array
*/ */
protected $listen = [ protected $listen = [
\Codedge\Updater\Events\UpdateAvailable::class => [
\Codedge\Updater\Listeners\SendUpdateAvailableNotification::class
], // [3]
\Codedge\Updater\Events\UpdateSucceeded::class => [
\Codedge\Updater\Listeners\SendUpdateSucceededNotification::class
],
UserWasCreated::class => [ UserWasCreated::class => [
SendVerificationNotification::class, SendVerificationNotification::class,
], ],

View File

@ -77,7 +77,7 @@ class PaymentRepository extends BaseRepository
if (!$payment->number) if (!$payment->number)
$payment->number = $payment->client->getNextPaymentNumber($payment->client); $payment->number = $payment->client->getNextPaymentNumber($payment->client);
$payment->client->updatePaidToDate($payment->amount)->save(); $payment->client->service()->updatePaidToDate($payment->amount)->save();
$invoice_totals = 0; $invoice_totals = 0;
$credit_totals = 0; $credit_totals = 0;

View File

@ -31,7 +31,7 @@ class ApplyPayment
UpdateCompanyLedgerWithPayment::dispatchNow($payment, ($payment_amount*-1), $payment->company); UpdateCompanyLedgerWithPayment::dispatchNow($payment, ($payment_amount*-1), $payment->company);
$payment->client->updateBalance($payment_amount*-1)->save(); $payment->client->service()->updateBalance($payment_amount*-1)->save();
/* Update Pivot Record amount */ /* Update Pivot Record amount */
$payment->invoices->each(function ($inv) use($payment_amount){ $payment->invoices->each(function ($inv) use($payment_amount){

View File

@ -33,17 +33,15 @@ class MarkSent
return $invoice; return $invoice;
} }
$invoice->status_id = Invoice::STATUS_SENT;
$invoice->markInvitationsSent(); $invoice->markInvitationsSent();
$invoice->setReminder(); $invoice->setReminder();
event(new InvoiceWasMarkedSent($invoice, $invoice->company)); event(new InvoiceWasMarkedSent($invoice, $invoice->company));
$this->client->updateBalance($invoice->balance)->save(); $this->client->service()->updateBalance($invoice->balance)->save();
$invoice->service()->applyNumber()->save(); $invoice->service()->setStatus(Invoice::STATUS_SENT)->applyNumber()->save();
UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance, $invoice->company); UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance, $invoice->company);

View File

@ -121,6 +121,8 @@ trait MakesInvoiceValues
'unit_cost', 'unit_cost',
'custom_value1', 'custom_value1',
'custom_value2', 'custom_value2',
'custom_value3',
'custom_value4',
'delivery_note', 'delivery_note',
'date', 'date',
'method', 'method',
@ -197,6 +199,7 @@ trait MakesInvoiceValues
$data['$total'] = Number::formatMoney($this->calc()->getTotal(), $this->client); $data['$total'] = Number::formatMoney($this->calc()->getTotal(), $this->client);
$data['$invoice.total'] = &$data['$total']; $data['$invoice.total'] = &$data['$total'];
$data['$amount'] = &$data['$total']; $data['$amount'] = &$data['$total'];
$data['$invoice_total'] = &$data['$total'];
$data['$invoice.amount'] = &$data['$total']; $data['$invoice.amount'] = &$data['$total'];
$data['$balance'] = Number::formatMoney($this->calc()->getBalance(), $this->client); $data['$balance'] = Number::formatMoney($this->calc()->getBalance(), $this->client);
@ -205,6 +208,11 @@ trait MakesInvoiceValues
$data['$invoice.taxes'] = &$data['$taxes']; $data['$invoice.taxes'] = &$data['$taxes'];
$data['$terms'] = $this->terms; $data['$terms'] = $this->terms;
$data['$invoice.terms'] = &$data['$terms']; $data['$invoice.terms'] = &$data['$terms'];
$data['$invoice.custom_value1'] = $this->custom_value1;
$data['$invoice.custom_value2'] = $this->custom_value2;
$data['$invoice.custom_value3'] = $this->custom_value3;
$data['$invoice.custom_value4'] = $this->custom_value4;
$data['$invoice.public_notes'] = $this->public_notes;
// $data['$your_invoice'] = ; // $data['$your_invoice'] = ;
// $data['$quote'] = ; // $data['$quote'] = ;
// $data['$your_quote'] = ; // $data['$your_quote'] = ;
@ -247,14 +255,20 @@ trait MakesInvoiceValues
$data['$client.country'] = &$data['$country']; $data['$client.country'] = &$data['$country'];
$data['$email'] = isset($this->client->primary_contact()->first()->email) ?: 'no contact email on record'; $data['$email'] = isset($this->client->primary_contact()->first()->email) ?: 'no contact email on record';
$data['$client.email'] = &$data['$email']; $data['$client.email'] = &$data['$email'];
$data['$client.custom_value1'] = $this->client->custom_value1;
$data['$client.custom_value2'] = $this->client->custom_value2;
$data['$client.custom_value3'] = $this->client->custom_value3;
$data['$client.custom_value4'] = $this->client->custom_value4;
if ($contact) { if(!$contact)
$data['$contact_name'] = $contact->present()->name(); $contact = $this->client->primary_contact->first();
$data['$contact.name'] = &$data['$contact_name'];
} else { $data['$contact_name'] = $contact->present()->name();
$data['$contact_name'] = $this->client->present()->primary_contact_name(); $data['$contact.name'] = &$data['$contact_name'];
$data['$contact.name'] = &$data['$contact_name']; $data['$contact.custom_value1'] = $contact->custom_value1;
} $data['$contact.custom_value2'] = $contact->custom_value2;
$data['$contact.custom_value3'] = $contact->custom_value3;
$data['$contact.custom_value4'] = $contact->custom_value4;
$data['$company.name'] = $this->company->present()->name(); $data['$company.name'] = $this->company->present()->name();
$data['$company.address1'] = $settings->address1; $data['$company.address1'] = $settings->address1;
@ -269,6 +283,12 @@ trait MakesInvoiceValues
$data['$company.id_number'] = $settings->id_number; $data['$company.id_number'] = $settings->id_number;
$data['$company.address'] = $this->company->present()->address($settings); $data['$company.address'] = $this->company->present()->address($settings);
$data['$company.logo'] = $this->company->present()->logo($settings); $data['$company.logo'] = $this->company->present()->logo($settings);
$data['$company.custom_value1'] = $this->company->custom_value1;
$data['$company.custom_value2'] = $this->company->custom_value2;
$data['$company.custom_value3'] = $this->company->custom_value3;
$data['$company.custom_value4'] = $this->company->custom_value4;
$data['$company.city_state_postal'] = $this->company->present()->cityStateZip($settings->city, $settings->state, $settings->postal_code, false);
$data['$company.postal_city_state'] = $this->company->present()->cityStateZip($settings->city, $settings->state, $settings->postal_code, true);
//$data['$blank'] = ; //$data['$blank'] = ;
//$data['$surcharge'] = ; //$data['$surcharge'] = ;
/* /*
@ -286,7 +306,7 @@ trait MakesInvoiceValues
$data['$credit_to'] = ; $data['$credit_to'] = ;
$data['$your_credit'] = ; $data['$your_credit'] = ;
$data['$phone'] = ; $data['$phone'] = ;
$data['$invoice_total'] = ;
$data['$outstanding'] = ; $data['$outstanding'] = ;
$data['$invoice_due_date'] = ; $data['$invoice_due_date'] = ;
$data['$quote_due_date'] = ; $data['$quote_due_date'] = ;

View File

@ -21,6 +21,7 @@
"php": ">=7.3", "php": ">=7.3",
"anahkiasen/former": "^4.2", "anahkiasen/former": "^4.2",
"asgrim/ofxparser": "^1.2", "asgrim/ofxparser": "^1.2",
"codedge/laravel-selfupdater": "^2.4",
"dacastro4/laravel-gmail": "^3.2", "dacastro4/laravel-gmail": "^3.2",
"davejamesmiller/laravel-breadcrumbs": "5.x", "davejamesmiller/laravel-breadcrumbs": "5.x",
"fideloper/proxy": "^4.0", "fideloper/proxy": "^4.0",

View File

@ -178,6 +178,7 @@ return [
App\Providers\EventServiceProvider::class, App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
App\Providers\ComposerServiceProvider::class, App\Providers\ComposerServiceProvider::class,
Codedge\Updater\UpdaterServiceProvider::class,
], ],
@ -227,7 +228,7 @@ return [
'URL' => Illuminate\Support\Facades\URL::class, 'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class, 'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class, 'View' => Illuminate\Support\Facades\View::class,
'Updater' => Codedge\Updater\UpdaterFacade::class,
/* /*
* Dependency Facades * Dependency Facades
*/ */

125
config/self-update.php Normal file
View File

@ -0,0 +1,125 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default source repository type
|--------------------------------------------------------------------------
|
| The default source repository type you want to pull your updates from.
|
*/
'default' => env('SELF_UPDATER_SOURCE', 'github'),
/*
|--------------------------------------------------------------------------
| Version installed
|--------------------------------------------------------------------------
|
| Set this to the version of your software installed on your system.
|
*/
'version_installed' => env('SELF_UPDATER_VERSION_INSTALLED', ''),
/*
|--------------------------------------------------------------------------
| Repository types
|--------------------------------------------------------------------------
|
| A repository can be of different types, which can be specified here.
| Current options:
| - github
| - http
|
*/
'repository_types' => [
'github' => [
'type' => 'github',
'repository_vendor' => env('SELF_UPDATER_REPO_VENDOR', ''),
'repository_name' => env('SELF_UPDATER_REPO_NAME', ''),
'repository_url' => '',
'download_path' => env('SELF_UPDATER_DOWNLOAD_PATH', '/tmp'),
'private_access_token' => env('SELF_UPDATER_GITHUB_PRIVATE_ACCESS_TOKEN', ''),
],
'http' => [
'type' => 'http',
'repository_url' => env('SELF_UPDATER_REPO_URL', ''),
'pkg_filename_format' => env('SELF_UPDATER_PKG_FILENAME_FORMAT', 'v_VERSION_'),
'download_path' => env('SELF_UPDATER_DOWNLOAD_PATH', '/tmp'),
'private_access_token' => env('SELF_UPDATER_HTTP_PRIVATE_ACCESS_TOKEN', ''),
],
],
/*
|--------------------------------------------------------------------------
| Exclude folders from update
|--------------------------------------------------------------------------
|
| Specifiy folders which should not be updated and will be skipped during the
| update process.
|
| Here's already a list of good examples to skip. You may want to keep those.
|
*/
'exclude_folders' => [
'node_modules',
'bootstrap/cache',
'bower',
'storage/app',
'storage/framework',
'storage/logs',
'storage/self-update',
'vendor',
],
/*
|--------------------------------------------------------------------------
| Event Logging
|--------------------------------------------------------------------------
|
| Configure if fired events should be logged
|
*/
'log_events' => env('SELF_UPDATER_LOG_EVENTS', false),
/*
|--------------------------------------------------------------------------
| Mail To Settings
|--------------------------------------------------------------------------
|
| Configure if fired events should be logged
|
*/
'mail_to' => [
'address' => env('SELF_UPDATER_MAILTO_ADDRESS', ''),
'name' => env('SELF_UPDATER_MAILTO_NAME', ''),
'subject_update_available' => env('SELF_UPDATER_MAILTO_UPDATE_AVAILABLE_SUBJECT', 'Update available'),
'subject_update_succeeded' => env('SELF_UPDATER_MAILTO_UPDATE_SUCCEEDED_SUBJECT', 'Update succeeded'),
],
/*
|---------------------------------------------------------------------------
| Register custom artisan commands
|---------------------------------------------------------------------------
*/
'artisan_commands' => [
'pre_update' => [
//'command:signature' => [
// 'class' => Command class
// 'params' => []
//]
],
'post_update' => [
],
],
];

View File

@ -166,7 +166,7 @@ class RandomDataSeeder extends Seeder
UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance, $invoice->company); UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance, $invoice->company);
$invoice->markSent()->save(); $invoice->service()->markSent()->save();
event(new InvoiceWasMarkedSent($invoice, $company)); event(new InvoiceWasMarkedSent($invoice, $company));

View File

@ -0,0 +1,91 @@
<?php
namespace Tests\Integration;
use App\Designs\Designer;
use App\Designs\Modern;
use Tests\TestCase;
/**
* @test
* @covers App\Designs\Designer
*/
class InvoiceDesignTest extends TestCase
{
public function setUp() :void
{
parent::setUp();
}
public function testDesignExists()
{
$modern = new Modern();
$input_variables = [
'client_details' => [
'name',
'id_number',
'vat_number',
'address1',
'address2',
'city_state_postal',
'postal_city_state',
'country',
'email',
'custom_value1',
'custom_value2',
'custom_value3',
'custom_value4',
],
'company_details' => [
'company_name',
'id_number',
'vat_number',
'website',
'email',
'phone',
'custom_value1',
'custom_value2',
'custom_value3',
'custom_value4',
],
'company_address' => [
'address1',
'address2',
'city_state_postal',
'postal_city_state',
'country',
'custom_value1',
'custom_value2',
'custom_value3',
'custom_value4',
],
'invoice_details' => [
'invoice_number',
'po_number',
'date',
'due_date',
'balance_due',
'invoice_total',
'partial_due',
'custom_value1',
'custom_value2',
'custom_value3',
'custom_value4',
],
];
$designer = new Designer($modern, $input_variables);
$html = $designer->build();
$this->assertNotNull($html);
\Log::error($html);
}
}