show invoice/bill totals sorted
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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">
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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">
 | 
			
		||||
 
 | 
			
		||||
@@ -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">
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user