1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Update for invoice designs

This commit is contained in:
David Bomba 2022-06-07 20:36:47 +10:00
parent a6327b7694
commit d7c7289ca9
19 changed files with 67 additions and 30 deletions

View File

@ -656,6 +656,14 @@ class CompanySettings extends BaseSettings
'$vendor.phone',
'$contact.email',
],
'purchase_order_details' => [
'$purchase_order.number',
'$purchase_order.po_number',
'$purchase_order.date',
'$purchase_order.due_date',
'$purchase_order.total',
'$purchase_order.balance_due',
],
'company_details' => [
'$company.name',
'$company.id_number',

View File

@ -83,8 +83,6 @@ class PurchaseOrderRepository extends BaseRepository
/* If no invitations have been created, this is our fail safe to maintain state*/
if ($purchase_order->invitations()->count() == 0)
$purchase_order->service()->createInvitations();
nlog("4");
/* Recalculate invoice amounts */
$purchase_order = $purchase_order->calc()->getPurchaseOrder();

View File

@ -252,6 +252,8 @@ class Design extends BaseDesign
public function entityDetails(): array
{
if ($this->type === 'statement') {
$s_date = $this->translateDate(now(), $this->client->date_format(), $this->client->locale());
@ -286,6 +288,12 @@ class Design extends BaseDesign
$variables = $this->context['pdf_variables']['credit_details'];
}
if($this->vendor){
$variables = $this->context['pdf_variables']['purchase_order_details'];
}
$elements = [];
// We don't want to show account balance or invoice total on PDF.. or any amount with currency.

View File

@ -44,8 +44,6 @@ class CreateInvitations extends AbstractService
{
$contacts = $this->purchase_order->vendor->contacts()->where('send_email', true)->get();
nlog("a");
if($contacts->count() == 0){
$this->createBlankContact();
@ -53,8 +51,6 @@ nlog("a");
$contacts = $this->purchase_order->vendor->contacts;
}
nlog("b");
nlog($contacts->count());
$contacts->each(function ($contact) {
$invitation = PurchaseOrderInvitation::where('company_id', $this->purchase_order->company_id)
@ -79,9 +75,6 @@ nlog($contacts->count());
}
});
nlog("c");
if($this->purchase_order->invitations()->count() == 0) {
if($contacts->count() == 0){
@ -102,9 +95,6 @@ nlog("c");
}
}
nlog("d");
$ii = PurchaseOrderInvitationFactory::create($this->purchase_order->company_id, $this->purchase_order->user_id);
$ii->key = $this->createDbHash($this->purchase_order->company->db);
$ii->purchase_order_id = $this->purchase_order->id;
@ -112,8 +102,6 @@ nlog("d");
$ii->save();
}
nlog("e");
return $this->purchase_order;
}
}

View File

@ -149,10 +149,12 @@ class VendorHtmlEngine
$data['$view_button'] = &$data['$view_link'];
$data['$paymentButton'] = &$data['$payment_button'];
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
$data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->company->date_format(), $this->company->locale()) ?: ' ', 'label' => ctrans('texts.invoice_date')];
$data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->company->date_format(), $this->company->locale()) ?: ' ', 'label' => ctrans('texts.date')];
$data['$purchase_order.number'] = &$data['$number'];
$data['$purchase_order.date'] = &$data['$date'];
$data['$purchase_order.po_number'] = &$data['$poNumber'];
$data['$purchase_order.due_date'] = &$data['$due_date'];
$data['$portal_url'] = ['value' => $this->invitation->getPortalLink(), 'label' =>''];
@ -192,6 +194,9 @@ class VendorHtmlEngine
$data['$partial'] = &$data['$partial_due'];
$data['$total'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->vendor) ?: ' ', 'label' => ctrans('texts.total')];
$data['$purchase_order.total'] = &$data['$total'];
$data['$amount'] = &$data['$total'];
$data['$amount_due'] = ['value' => &$data['$total']['value'], 'label' => ctrans('texts.amount_due')];
$data['$balance'] = ['value' => Number::formatMoney($this->entity_calc->getBalance(), $this->vendor) ?: ' ', 'label' => ctrans('texts.balance')];
@ -429,8 +434,6 @@ class VendorHtmlEngine
$values = $this->buildEntityDataArray();
foreach ($values as $key => $value) {
nlog($key);
nlog($value);
$data['values'][$key] = $value['value'];
$data['labels'][$key.'_label'] = $value['label'];
}

View File

@ -12,10 +12,12 @@ namespace Database\Factories;
use App\DataMapper\CompanySettings;
use App\Models\Company;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Factories\Factory;
class CompanyFactory extends Factory
{
use MakesHash;
/**
* The name of the factory's corresponding model.
*
@ -41,6 +43,7 @@ class CompanyFactory extends Factory
'enabled_modules' => config('ninja.enabled_modules'),
'custom_fields' => (object) [
],
'company_key' => $this->createHash(),
];
}
}

View File

@ -12,6 +12,7 @@ namespace Database\Factories;
use App\Models\Vendor;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class VendorFactory extends Factory
{
@ -45,6 +46,8 @@ class VendorFactory extends Factory
'state' => $this->faker->state,
'postal_code' => $this->faker->postcode,
'country_id' => 4,
'vendor_hash' => Str::random(40),
];
}
}

View File

@ -331,6 +331,7 @@
<div class="client-wrapper-left-side">
<h4 class="entity-label">$entity_label</h4>
<div id="client-details" cellspacing="0"></div>
<div id="vendor-details" cellspacing="0"></div>
</div>
<div class="entity-details-wrapper-right-side">
@ -380,7 +381,8 @@ $entity_images
let tables = [
'product-table', 'task-table', 'delivery-note-table',
'statement-invoice-table', 'statement-payment-table', 'statement-aging-table-totals',
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table'
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table',
'vendor-details', 'client-details'
];
tables.forEach((tableIdentifier) => {

View File

@ -324,6 +324,7 @@
<p class="entity-issued-to">$entity_issued_to_label:</p>
<div class="client-and-entity-wrapper">
<div id="client-details"></div>
<div id="vendor-details"></div>
<div class="entity-details-wrapper">
<table id="entity-details" cellspacing="0" dir="$dir"></table>
</div>
@ -365,6 +366,7 @@ $entity_images
let tables = [
'product-table', 'task-table', 'delivery-note-table',
'statement-invoice-table', 'statement-payment-table', 'statement-aging-table-totals',
'vendor-details','client-details'
];
tables.forEach((tableIdentifier) => {

View File

@ -295,7 +295,7 @@
<table id="entity-details" cellspacing="0" dir="$dir"></table>
</div>
<div id="client-details"></div>
<div id="client-details"></div>
<div id="vendor-details"></div>
</div>
<table id="product-table" cellspacing="0" data-ref="table"></table>
<table id="task-table" cellspacing="0" data-ref="table"></table>

View File

@ -267,6 +267,7 @@
<div id="body">
<div class="header-wrapper">
<div id="client-details"></div>
<div id="vendor-details"></div>
<div class="company-info-wrapper">
<div id="company-details"></div>
<div id="company-address"></div>
@ -322,7 +323,8 @@ $entity_images
let tables = [
'product-table', 'task-table', 'delivery-note-table',
'statement-invoice-table', 'statement-payment-table', 'statement-aging-table-totals',
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table'
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table',
'vendor-details', 'client-details'
];
tables.forEach((tableIdentifier) => {

View File

@ -279,6 +279,7 @@
<div class="text-with-client">
<h2 class="wrapper-info-text">$to_label</h2>
<div id="client-details"></div>
<div id="vendor-details"></div>
</div>
<div class="company-info">
<h2 class="wrapper-info-text">$from_label</h2>
@ -328,7 +329,8 @@ $entity_images
let tables = [
'product-table', 'task-table', 'delivery-note-table',
'statement-invoice-table', 'statement-payment-table', 'statement-aging-table-totals',
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table'
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table',
'client-details','vendor-details'
];
tables.forEach((tableIdentifier) => {

View File

@ -297,6 +297,7 @@
<div class="header-right-side-wrapper-left">
<p class="header-text-label">$to_label:</p>
<div id="client-details"></div>
<div id="vendor-details"></div>
</div>
<div class="header-right-side-wrapper-right">
<img
@ -369,7 +370,8 @@ $entity_images
let tables = [
'product-table', 'task-table', 'delivery-note-table',
'statement-invoice-table', 'statement-payment-table', 'statement-aging-table-totals',
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table'
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table',
'vendor-details','client-details'
];
tables.forEach((tableIdentifier) => {

View File

@ -320,6 +320,7 @@
<div class="logo-client-wrapper">
<img class="company-logo" src="$company.logo" alt="$company.name logo"/>
<div id="client-details"></div>
<div id="vendor-details"></div>
</div>
<div class="table-wrapper">
<table id="product-table" cellspacing="0" data-ref="table"></table>
@ -364,7 +365,8 @@ $entity_images
let tables = [
'product-table', 'task-table', 'delivery-note-table',
'statement-invoice-table', 'statement-payment-table', 'statement-aging-table-totals',
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table'
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table',
'client-details','vendor-details'
];
tables.forEach((tableIdentifier) => {

View File

@ -270,6 +270,7 @@
</div>
</div>
<div id="client-details"></div>
<div id="vendor-details"></div>
<table id="product-table" cellspacing="0" data-ref="table"></table>
<table id="task-table" cellspacing="0" data-ref="table"></table>
<table id="delivery-note-table" cellspacing="0" data-ref="table"></table>
@ -306,7 +307,8 @@ $entity_images
let tables = [
'product-table', 'task-table', 'delivery-note-table',
'statement-invoice-table', 'statement-payment-table', 'statement-aging-table-totals',
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table'
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table',
'client-details','vendor-details'
];
tables.forEach((tableIdentifier) => {

View File

@ -349,6 +349,7 @@
<div class="contact-wrapper-right-side">
<p class="contact-label">$to_label:</p>
<div id="client-details"></div>
<div id="vendor-details"></div>
</div>
</div>
<table id="product-table" cellspacing="0" data-ref="table"></table>
@ -409,7 +410,8 @@ $entity_images
let tables = [
'product-table', 'task-table', 'delivery-note-table',
'statement-invoice-table', 'statement-payment-table', 'statement-aging-table-totals',
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table'
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table',
'client-details','vendor-details'
];
tables.forEach((tableIdentifier) => {

View File

@ -321,6 +321,7 @@
<div class="client-details">
<span class="client-details-to-label">$from_label:</span>
<div id="client-details"></div>
<div id="vendor-details"></div>
</div>
<div class="company-details">
<span class="client-details-to-label">$to_label:</span>
@ -369,7 +370,8 @@ $entity_images
let tables = [
'product-table', 'task-table', 'delivery-note-table',
'statement-invoice-table', 'statement-payment-table', 'statement-aging-table-totals',
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table'
'statement-invoice-table-totals', 'statement-payment-table-totals', 'statement-aging-table',
'client-details','vendor-details'
];
tables.forEach((tableIdentifier) => {

View File

@ -19,6 +19,7 @@ use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
class PurchaseOrderTest extends TestCase
{
@ -46,7 +47,12 @@ class PurchaseOrderTest extends TestCase
'status_id' => 1,
'discount' => 0,
'is_amount_discount' => 1,
'number' => '34343xx43',
'number' => Str::random(10),
'po_number' => Str::random(5),
'due_date' => '2022-01-01',
'date' => '2022-01-01',
'balance' => 100,
'amount' => 100,
'public_notes' => 'notes',
'is_deleted' => 0,
'custom_value1' => 0,
@ -69,8 +75,9 @@ class PurchaseOrderTest extends TestCase
$this->assertNotNull($purchase_order);
$purchase_order->service()->markSent()->getPurchaseOrderPdf();
$x = $purchase_order->service()->markSent()->getPurchaseOrderPdf();
nlog($x);
}
public function testPurchaseOrderRest()

View File

@ -56,6 +56,7 @@ use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
/**
* Class MockAccountData.