Merge branch 'master' of github.com:akaunting/akaunting

This commit is contained in:
Cüneyt Şentürk 2020-04-18 18:44:31 +03:00
commit 69bbc9e1d6
13 changed files with 45 additions and 14 deletions

View File

@ -15,6 +15,11 @@ abstract class DocumentModel extends Model
{
use Cloneable, Currencies, DateTime, Media, Recurring;
public function totals_sorted()
{
return $this->totals()->orderBy('sort_order');
}
public function scopeDue($query, $date)
{
return $query->whereDate('due_at', '=', $date);

View File

@ -74,7 +74,7 @@ class Bills extends Controller
$date_format = $this->getCompanyDateFormat();
// Get Bill Totals
foreach ($bill->totals as $bill_total) {
foreach ($bill->totals_sorted as $bill_total) {
$bill->{$bill_total->code} = $bill_total->amount;
}
@ -343,7 +343,7 @@ class Bills extends Controller
$pdf = app('dompdf.wrapper');
$pdf->loadHTML($html);
$file_name = 'bill_' . time() . '.pdf';
$file_name = $this->getBillFileName($bill);
return $pdf->download($file_name);
}

View File

@ -77,7 +77,7 @@ class Invoices extends Controller
$date_format = $this->getCompanyDateFormat();
// Get Invoice Totals
foreach ($invoice->totals as $invoice_total) {
foreach ($invoice->totals_sorted as $invoice_total) {
$invoice->{$invoice_total->code} = $invoice_total->amount;
}
@ -332,7 +332,9 @@ class Invoices extends Controller
$pdf = app('dompdf.wrapper');
$pdf->loadHTML($html);
$file = storage_path('app/temp/invoice_'.time().'.pdf');
$file_name = $this->getInvoiceFileName($invoice);
$file = storage_path('app/temp/' . $file_name);
$invoice->pdf_path = $file;
@ -394,7 +396,7 @@ class Invoices extends Controller
//$pdf->setPaper('A4', 'portrait');
$file_name = 'invoice_'.time().'.pdf';
$file_name = $this->getInvoiceFileName($invoice);
return $pdf->download($file_name);
}

View File

@ -2,6 +2,8 @@
namespace App\Traits;
use Illuminate\Support\Str;
trait Purchases
{
/**
@ -58,4 +60,14 @@ trait Purchases
return $statuses;
}
public function getBillFileName($bill, $separator = '-', $extension = 'pdf')
{
return $this->getSafeBillNumber($bill, $separator) . $separator . time() . '.' . $extension;
}
public function getSafeBillNumber($bill, $separator = '-')
{
return Str::slug($bill->bill_number, $separator, language()->getShortCode());
}
}

View File

@ -2,6 +2,8 @@
namespace App\Traits;
use Illuminate\Support\Str;
trait Sales
{
/**
@ -60,4 +62,14 @@ trait Sales
return $statuses;
}
public function getInvoiceFileName($invoice, $separator = '-', $extension = 'pdf')
{
return $this->getSafeInvoiceNumber($invoice, $separator) . $separator . time() . '.' . $extension;
}
public function getSafeInvoiceNumber($invoice, $separator = '-')
{
return Str::slug($invoice->invoice_number, $separator, language()->getShortCode());
}
}

View File

@ -236,7 +236,7 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<tr>

View File

@ -184,7 +184,7 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach($invoice->totals as $total)
@foreach($invoice->totals_sorted as $total)
@if($total->code != 'total')
<tr>
<th>{{ trans($total['name']) }}:</th>

View File

@ -173,7 +173,7 @@
<div class="col-42">
<div class="text company pr-2">
@foreach ($bill->totals as $total)
@foreach ($bill->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<div class="border-top-1 py-2">

View File

@ -410,7 +410,7 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach ($bill->totals as $total)
@foreach ($bill->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<tr>

View File

@ -111,7 +111,7 @@
<span class="float-right">@date($invoice->due_at)</span><br><br>
@stack('due_at_input_end')
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code == 'total')
<strong>{{ trans($total->name) }}:</strong>
<span class="float-right">@money($total->amount - $invoice->paid, $invoice->currency_code, true)</span><br><br>
@ -189,7 +189,7 @@
<div class="col-42 float-right text-right">
<div class="text company pr-2">
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<div class="border-top-dashed py-2">

View File

@ -177,7 +177,7 @@
<div class="col-42 float-right text-right">
<div class="text company">
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<div class="border-top-1 py-2">

View File

@ -158,7 +158,7 @@
<div class="col-42 float-right text-right">
<div class="text company pr-2">
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<strong class="float-left">{{ trans($total->title) }}:</strong>

View File

@ -427,7 +427,7 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach ($invoice->totals as $total)
@foreach ($invoice->totals_sorted as $total)
@if ($total->code != 'total')
@stack($total->code . '_td_start')
<tr>