diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index bd202b8a9141..b81ad887b555 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -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', diff --git a/app/Repositories/PurchaseOrderRepository.php b/app/Repositories/PurchaseOrderRepository.php index ff508f1f44d5..2ffdc0e93576 100644 --- a/app/Repositories/PurchaseOrderRepository.php +++ b/app/Repositories/PurchaseOrderRepository.php @@ -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(); diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index c7e34e3997d6..9e4b5efeec6b 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -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. diff --git a/app/Services/PurchaseOrder/CreateInvitations.php b/app/Services/PurchaseOrder/CreateInvitations.php index 141914faa8ed..fa01a8457b27 100644 --- a/app/Services/PurchaseOrder/CreateInvitations.php +++ b/app/Services/PurchaseOrder/CreateInvitations.php @@ -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; } } diff --git a/app/Utils/VendorHtmlEngine.php b/app/Utils/VendorHtmlEngine.php index f56b68245e9b..7e20a951684e 100644 --- a/app/Utils/VendorHtmlEngine.php +++ b/app/Utils/VendorHtmlEngine.php @@ -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']; } diff --git a/database/factories/CompanyFactory.php b/database/factories/CompanyFactory.php index 6fb2d23ef793..c2298fd718c5 100644 --- a/database/factories/CompanyFactory.php +++ b/database/factories/CompanyFactory.php @@ -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(), ]; } } diff --git a/database/factories/VendorFactory.php b/database/factories/VendorFactory.php index 1bca58436fac..152848e545ba 100644 --- a/database/factories/VendorFactory.php +++ b/database/factories/VendorFactory.php @@ -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), + ]; } } diff --git a/resources/views/pdf-designs/bold.html b/resources/views/pdf-designs/bold.html index d648ae8fc87b..de716f40d374 100644 --- a/resources/views/pdf-designs/bold.html +++ b/resources/views/pdf-designs/bold.html @@ -331,6 +331,7 @@
$entity_issued_to_label:
$to_label:
+$to_label:
+