Add discount per item feature to the bills
This commit is contained in:
		| @@ -77,8 +77,6 @@ class Invoices extends Controller | |||||||
|  |  | ||||||
|         $date_format = $this->getCompanyDateFormat(); |         $date_format = $this->getCompanyDateFormat(); | ||||||
|  |  | ||||||
|         $discount_location = $invoice->totals->contains($invoice->totals->where('code', 'discount')->first()) ? 'in_totals' : 'per_item'; |  | ||||||
|  |  | ||||||
|         // Get Invoice Totals |         // Get Invoice Totals | ||||||
|         foreach ($invoice->totals as $invoice_total) { |         foreach ($invoice->totals as $invoice_total) { | ||||||
|             $invoice->{$invoice_total->code} = $invoice_total->amount; |             $invoice->{$invoice_total->code} = $invoice_total->amount; | ||||||
| @@ -92,22 +90,7 @@ class Invoices extends Controller | |||||||
|             $invoice->grand_total = round($invoice->total - $invoice->paid, $currency->precision); |             $invoice->grand_total = round($invoice->total - $invoice->paid, $currency->precision); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return view( |         return view('sales.invoices.show', compact('invoice', 'accounts', 'currencies', 'currency', 'account_currency_code', 'customers', 'categories', 'payment_methods', 'signed_url', 'date_format')); | ||||||
|             'sales.invoices.show', |  | ||||||
|             compact( |  | ||||||
|                 'invoice', |  | ||||||
|                 'accounts', |  | ||||||
|                 'currencies', |  | ||||||
|                 'currency', |  | ||||||
|                 'account_currency_code', |  | ||||||
|                 'customers', |  | ||||||
|                 'categories', |  | ||||||
|                 'payment_methods', |  | ||||||
|                 'signed_url', |  | ||||||
|                 'date_format', |  | ||||||
|                 'discount_location' |  | ||||||
|             ) |  | ||||||
|         ); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -40,7 +40,7 @@ class CreateBillItem extends Job | |||||||
|  |  | ||||||
|         // Apply discount to amount |         // Apply discount to amount | ||||||
|         if (!empty($this->request['discount'])) { |         if (!empty($this->request['discount'])) { | ||||||
|             $item_discounted_amount = $item_amount - ($item_amount * ($this->request['discount'] / 100)); |             $item_discounted_amount = $item_amount -= ($item_amount * ($this->request['discount'] / 100)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $tax_amount = 0; |         $tax_amount = 0; | ||||||
| @@ -138,6 +138,7 @@ class CreateBillItem extends Job | |||||||
|             'quantity' => (double) $this->request['quantity'], |             'quantity' => (double) $this->request['quantity'], | ||||||
|             'price' => (double) $this->request['price'], |             'price' => (double) $this->request['price'], | ||||||
|             'tax' => $item_tax_total, |             'tax' => $item_tax_total, | ||||||
|  |             'discount_rate' => $this->request['discount'], | ||||||
|             'total' => $item_amount, |             'total' => $item_amount, | ||||||
|         ]); |         ]); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -18,7 +18,18 @@ class BillItem extends Model | |||||||
|      * |      * | ||||||
|      * @var array |      * @var array | ||||||
|      */ |      */ | ||||||
|     protected $fillable = ['company_id', 'bill_id', 'item_id', 'name', 'quantity', 'price', 'total', 'tax']; |     protected $fillable = [ | ||||||
|  |         'company_id', | ||||||
|  |         'bill_id', | ||||||
|  |         'item_id', | ||||||
|  |         'name', | ||||||
|  |         'quantity', | ||||||
|  |         'price', | ||||||
|  |         'total', | ||||||
|  |         'tax', | ||||||
|  |         'discount_rate', | ||||||
|  |         'discount_type', | ||||||
|  |     ]; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Clonable relationships. |      * Clonable relationships. | ||||||
| @@ -84,6 +95,22 @@ class BillItem extends Model | |||||||
|         $this->attributes['tax'] = (double) $value; |         $this->attributes['tax'] = (double) $value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get the formatted discount. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getDiscountRateAttribute($value) | ||||||
|  |     { | ||||||
|  |         if (setting('localisation.percent_position', 'after') === 'after') { | ||||||
|  |             $text = ($this->discount_type === 'normal') ? $value . '%' : $value; | ||||||
|  |         } else { | ||||||
|  |             $text = ($this->discount_type === 'normal') ? '%' . $value : $value; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return $text; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Convert tax to Array. |      * Convert tax to Array. | ||||||
|      * |      * | ||||||
|   | |||||||
| @@ -1,42 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| namespace App\Models\Sale; |  | ||||||
|  |  | ||||||
| use App\Abstracts\Model; |  | ||||||
| use App\Traits\Currencies; |  | ||||||
| use Znck\Eloquent\Traits\BelongsToThrough; |  | ||||||
|  |  | ||||||
| class InvoiceItemDiscount extends Model |  | ||||||
| { |  | ||||||
|     use Currencies, BelongsToThrough; |  | ||||||
|  |  | ||||||
|     protected $table = 'invoice_item_discounts'; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Attributes that should be mass-assignable. |  | ||||||
|      * |  | ||||||
|      * @var array |  | ||||||
|      */ |  | ||||||
|     protected $fillable = ['company_id', 'invoice_id', 'invoice_item_id', 'rate', 'type', 'name', 'amount']; |  | ||||||
|  |  | ||||||
|     public function invoice() |  | ||||||
|     { |  | ||||||
|         return $this->belongsTo('App\Models\Sale\Invoice'); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function item() |  | ||||||
|     { |  | ||||||
|         return $this->belongsToThrough('App\Models\Common\Item', 'App\Models\Sale\InvoiceItem', 'invoice_item_id')->withDefault(['name' => trans('general.na')]); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Convert rate to double. |  | ||||||
|      * |  | ||||||
|      * @param  string  $value |  | ||||||
|      * @return void |  | ||||||
|      */ |  | ||||||
|     public function setRateAttribute($value) |  | ||||||
|     { |  | ||||||
|         $this->attributes['rate'] = (double) $value; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -32,8 +32,7 @@ class AddDiscountColumnsInvoiceItemsTable extends Migration | |||||||
|         Schema::table( |         Schema::table( | ||||||
|             'invoice_items', |             'invoice_items', | ||||||
|             function (Blueprint $table) { |             function (Blueprint $table) { | ||||||
|                 $table->dropColumn('discount_rate'); |                 $table->dropColumn(['discount_rate', 'discount_type']); | ||||||
|                 $table->dropColumn('discount_type'); |  | ||||||
|             } |             } | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -63,7 +63,6 @@ class Settings extends Seeder | |||||||
|             'invoice.color'                     => '#55588b', |             'invoice.color'                     => '#55588b', | ||||||
|             'default.payment_method'            => 'offline-payments.cash.1', |             'default.payment_method'            => 'offline-payments.cash.1', | ||||||
|             'default.list_limit'                => '25', |             'default.list_limit'                => '25', | ||||||
|             'default.discount_location'         => 'in_totals', |  | ||||||
|             'default.use_gravatar'              => '0', |             'default.use_gravatar'              => '0', | ||||||
|             'email.protocol'                    => 'mail', |             'email.protocol'                    => 'mail', | ||||||
|             'email.sendmail_path'               => '/usr/sbin/sendmail -bs', |             'email.sendmail_path'               => '/usr/sbin/sendmail -bs', | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								resources/assets/js/views/purchases/bills.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								resources/assets/js/views/purchases/bills.js
									
									
									
									
										vendored
									
									
								
							| @@ -50,7 +50,7 @@ const app = new Vue({ | |||||||
|             items: '', |             items: '', | ||||||
|             discount: false, |             discount: false, | ||||||
|             taxes: null, |             taxes: null, | ||||||
|             colspan: 5, |             colspan: 6, | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
| @@ -75,6 +75,7 @@ const app = new Vue({ | |||||||
|                     price: (item.price).toFixed(2), |                     price: (item.price).toFixed(2), | ||||||
|                     quantity: item.quantity, |                     quantity: item.quantity, | ||||||
|                     tax_id: item.tax_id, |                     tax_id: item.tax_id, | ||||||
|  |                     discount: item.discount_rate, | ||||||
|                     total: (item.total).toFixed(2) |                     total: (item.total).toFixed(2) | ||||||
|                 }); |                 }); | ||||||
|             }); |             }); | ||||||
| @@ -109,7 +110,8 @@ const app = new Vue({ | |||||||
|             let tax_total = 0; |             let tax_total = 0; | ||||||
|             let grand_total = 0; |             let grand_total = 0; | ||||||
|             let items = this.form.items; |             let items = this.form.items; | ||||||
|             let discount = this.form.discount; |             let discount_in_totals = this.form.discount; | ||||||
|  |             let discount = ''; | ||||||
|  |  | ||||||
|             if (items.length) { |             if (items.length) { | ||||||
|                 let index = 0; |                 let index = 0; | ||||||
| @@ -125,8 +127,14 @@ const app = new Vue({ | |||||||
|                     // item discount calculate. |                     // item discount calculate. | ||||||
|                     let item_discounted_total = item_sub_total; |                     let item_discounted_total = item_sub_total; | ||||||
|  |  | ||||||
|                     if (discount) { |                     if (discount_in_totals) { | ||||||
|                         item_discounted_total = item_sub_total - (item_sub_total * (discount / 100)); |                         item_discounted_total = item_sub_total - (item_sub_total * (discount_in_totals / 100)); | ||||||
|  |                         discount = discount_in_totals; | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     if (item.discount) { | ||||||
|  |                         item_discounted_total = item_sub_total = item_sub_total - (item_sub_total * (item.discount / 100)); | ||||||
|  |                         discount = item.discount; | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     // item tax calculate. |                     // item tax calculate. | ||||||
| @@ -202,12 +210,12 @@ const app = new Vue({ | |||||||
|             this.totals.tax = tax_total; |             this.totals.tax = tax_total; | ||||||
|  |  | ||||||
|             // Apply discount to total |             // Apply discount to total | ||||||
|             if (discount) { |             if (discount_in_totals) { | ||||||
|                 discount_total = sub_total * (discount / 100); |                 discount_total = sub_total * (discount_in_totals / 100); | ||||||
|  |  | ||||||
|                 this.totals.discount = discount_total; |                 this.totals.discount = discount_total; | ||||||
|  |  | ||||||
|                 sub_total = sub_total - (sub_total * (discount / 100)); |                 sub_total = sub_total - (sub_total * (discount_in_totals / 100)); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             // set all item grand total. |             // set all item grand total. | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								resources/assets/js/views/sales/invoices.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								resources/assets/js/views/sales/invoices.js
									
									
									
									
										vendored
									
									
								
							| @@ -50,7 +50,7 @@ const app = new Vue({ | |||||||
|             items: '', |             items: '', | ||||||
|             discount: false, |             discount: false, | ||||||
|             taxes: null, |             taxes: null, | ||||||
|             colspan: 5, |             colspan: 6, | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|   | |||||||
| @@ -62,9 +62,6 @@ return [ | |||||||
|         'description'       => 'Default account, currency, language of your company', |         'description'       => 'Default account, currency, language of your company', | ||||||
|         'list_limit'        => 'Records Per Page', |         'list_limit'        => 'Records Per Page', | ||||||
|         'use_gravatar'      => 'Use Gravatar', |         'use_gravatar'      => 'Use Gravatar', | ||||||
|         'discount_location'   => 'Discount', |  | ||||||
|         'discount_per_item'   => 'Per Item', |  | ||||||
|         'discount_in_totals'  => 'In Totals', |  | ||||||
|     ], |     ], | ||||||
|  |  | ||||||
|     'email' => [ |     'email' => [ | ||||||
|   | |||||||
| @@ -51,6 +51,10 @@ | |||||||
|                                             <th class="text-right border-right-0 border-bottom-0">{{ trans('bills.price') }}</th> |                                             <th class="text-right border-right-0 border-bottom-0">{{ trans('bills.price') }}</th> | ||||||
|                                         @stack('price_th_end') |                                         @stack('price_th_end') | ||||||
|  |  | ||||||
|  |                                         @stack('discount_th_start') | ||||||
|  |                                             <th class="text-right border-right-0 border-bottom-0">{{ trans('bills.discount') }}</th> | ||||||
|  |                                         @stack('discount_th_end') | ||||||
|  |  | ||||||
|                                         @stack('taxes_th_start') |                                         @stack('taxes_th_start') | ||||||
|                                             <th class="text-right border-right-0 border-bottom-0">{{ trans_choice('general.taxes', 1) }}</th> |                                             <th class="text-right border-right-0 border-bottom-0">{{ trans_choice('general.taxes', 1) }}</th> | ||||||
|                                         @stack('taxes_th_end') |                                         @stack('taxes_th_end') | ||||||
| @@ -69,13 +73,13 @@ | |||||||
|                                                 <button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i> |                                                 <button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i> | ||||||
|                                                 </button> |                                                 </button> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right border-bottom-0" colspan="5" :colspan="colspan"></td> |                                             <td class="text-right border-bottom-0" colspan="6" :colspan="colspan"></td> | ||||||
|                                         </tr> |                                         </tr> | ||||||
|                                     @stack('add_item_td_end') |                                     @stack('add_item_td_end') | ||||||
|  |  | ||||||
|                                     @stack('sub_total_td_start') |                                     @stack('sub_total_td_start') | ||||||
|                                         <tr id="tr-subtotal"> |                                         <tr id="tr-subtotal"> | ||||||
|                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0 border-bottom-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <strong>{{ trans('bills.sub_total') }}</strong> |                                                 <strong>{{ trans('bills.sub_total') }}</strong> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right border-bottom-0 long-texts"> |                                             <td class="text-right border-bottom-0 long-texts"> | ||||||
| @@ -88,7 +92,7 @@ | |||||||
|  |  | ||||||
|                                     @stack('add_discount_td_start') |                                     @stack('add_discount_td_start') | ||||||
|                                         <tr id="tr-discount"> |                                         <tr id="tr-discount"> | ||||||
|                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0 border-bottom-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <el-popover |                                                 <el-popover | ||||||
|                                                     popper-class="p-0 h-0" |                                                     popper-class="p-0 h-0" | ||||||
|                                                     placement="bottom" |                                                     placement="bottom" | ||||||
| @@ -140,7 +144,7 @@ | |||||||
|  |  | ||||||
|                                     @stack('tax_total_td_start') |                                     @stack('tax_total_td_start') | ||||||
|                                         <tr id="tr-tax"> |                                         <tr id="tr-tax"> | ||||||
|                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0 border-bottom-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <strong>{{ trans_choice('general.taxes', 1) }}</strong> |                                                 <strong>{{ trans_choice('general.taxes', 1) }}</strong> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right border-bottom-0 long-texts"> |                                             <td class="text-right border-bottom-0 long-texts"> | ||||||
| @@ -153,7 +157,7 @@ | |||||||
|  |  | ||||||
|                                     @stack('grand_total_td_start') |                                     @stack('grand_total_td_start') | ||||||
|                                         <tr id="tr-total"> |                                         <tr id="tr-total"> | ||||||
|                                             <td class="text-right border-right-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <strong>{{ trans('bills.total') }}</strong> |                                                 <strong>{{ trans('bills.total') }}</strong> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right long-texts"> |                                             <td class="text-right long-texts"> | ||||||
|   | |||||||
| @@ -52,6 +52,10 @@ | |||||||
|                                             <th class="text-right border-right-0 border-bottom-0">{{ trans('bills.price') }}</th> |                                             <th class="text-right border-right-0 border-bottom-0">{{ trans('bills.price') }}</th> | ||||||
|                                         @stack('price_th_end') |                                         @stack('price_th_end') | ||||||
|  |  | ||||||
|  |                                         @stack('discount_th_start') | ||||||
|  |                                         <th class="text-right border-right-0 border-bottom-0">{{ trans('bills.discount') }}</th> | ||||||
|  |                                         @stack('discount_th_end') | ||||||
|  |  | ||||||
|                                         @stack('taxes_th_start') |                                         @stack('taxes_th_start') | ||||||
|                                             <th class="text-right border-right-0 border-bottom-0">{{ trans_choice('general.taxes', 1) }}</th> |                                             <th class="text-right border-right-0 border-bottom-0">{{ trans_choice('general.taxes', 1) }}</th> | ||||||
|                                         @stack('taxes_th_end') |                                         @stack('taxes_th_end') | ||||||
| @@ -70,13 +74,13 @@ | |||||||
|                                                 <button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i> |                                                 <button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i> | ||||||
|                                                 </button> |                                                 </button> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right border-bottom-0" colspan="5" :colspan="colspan"></td> |                                             <td class="text-right border-bottom-0" colspan="6" :colspan="colspan"></td> | ||||||
|                                         </tr> |                                         </tr> | ||||||
|                                     @stack('add_item_td_end') |                                     @stack('add_item_td_end') | ||||||
|  |  | ||||||
|                                     @stack('sub_total_td_start') |                                     @stack('sub_total_td_start') | ||||||
|                                         <tr id="tr-subtotal"> |                                         <tr id="tr-subtotal"> | ||||||
|                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0 border-bottom-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <strong>{{ trans('bills.sub_total') }}</strong> |                                                 <strong>{{ trans('bills.sub_total') }}</strong> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right border-bottom-0 long-texts"> |                                             <td class="text-right border-bottom-0 long-texts"> | ||||||
| @@ -89,7 +93,7 @@ | |||||||
|  |  | ||||||
|                                     @stack('add_discount_td_start') |                                     @stack('add_discount_td_start') | ||||||
|                                         <tr id="tr-discount"> |                                         <tr id="tr-discount"> | ||||||
|                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0 border-bottom-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <el-popover |                                                 <el-popover | ||||||
|                                                     popper-class="p-0 h-0" |                                                     popper-class="p-0 h-0" | ||||||
|                                                     placement="bottom" |                                                     placement="bottom" | ||||||
| @@ -141,7 +145,7 @@ | |||||||
|  |  | ||||||
|                                     @stack('tax_total_td_start') |                                     @stack('tax_total_td_start') | ||||||
|                                         <tr id="tr-tax"> |                                         <tr id="tr-tax"> | ||||||
|                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0 border-bottom-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <strong>{{ trans_choice('general.taxes', 1) }}</strong> |                                                 <strong>{{ trans_choice('general.taxes', 1) }}</strong> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right border-bottom-0 long-texts"> |                                             <td class="text-right border-bottom-0 long-texts"> | ||||||
| @@ -154,7 +158,7 @@ | |||||||
|  |  | ||||||
|                                     @stack('grand_total_td_start') |                                     @stack('grand_total_td_start') | ||||||
|                                         <tr id="tr-total"> |                                         <tr id="tr-total"> | ||||||
|                                             <td class="text-right border-right-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <strong>{{ trans('bills.total') }}</strong> |                                                 <strong>{{ trans('bills.total') }}</strong> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right long-texts"> |                                             <td class="text-right long-texts"> | ||||||
|   | |||||||
| @@ -98,6 +98,37 @@ | |||||||
|         </td> |         </td> | ||||||
|     @stack('price_td_end') |     @stack('price_td_end') | ||||||
|  |  | ||||||
|  |     @stack('discount_td_start') | ||||||
|  |     <td class="border-right-0 border-bottom-0 w-12" | ||||||
|  |         :class="[{'has-error': form.errors.has('items.' + index + '.discount') }]"> | ||||||
|  |         @stack('discount_input_start') | ||||||
|  |         <div class="input-group input-group-merge"> | ||||||
|  |             <div class="input-group-prepend"> | ||||||
|  |                     <span class="input-group-text" id="input-discount"> | ||||||
|  |                         <i class="fa fa-percent"></i> | ||||||
|  |                     </span> | ||||||
|  |             </div> | ||||||
|  |             <input type="number" | ||||||
|  |                    max="100" | ||||||
|  |                    min="0" | ||||||
|  |                    class="form-control text-center" | ||||||
|  |                    :name="'items.' + index + '.discount'" | ||||||
|  |                    autocomplete="off" | ||||||
|  |                    required="required" | ||||||
|  |                    data-item="quantity" | ||||||
|  |                    v-model="row.discount" | ||||||
|  |                    @input="onCalculateTotal" | ||||||
|  |                    @change="form.errors.clear('items.' + index + '.discount')"> | ||||||
|  |  | ||||||
|  |             <div class="invalid-feedback d-block" | ||||||
|  |                  v-if="form.errors.has('items.' + index + '.discount')" | ||||||
|  |                  v-html="form.errors.get('items.' + index + '.discount')"> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  |         @stack('discount_input_end') | ||||||
|  |     </td> | ||||||
|  |     @stack('discount_td_end') | ||||||
|  |  | ||||||
|     @stack('taxes_td_start') |     @stack('taxes_td_start') | ||||||
|         <td class="border-right-0 border-bottom-0" |         <td class="border-right-0 border-bottom-0" | ||||||
|             :class="[{'has-error': form.errors.has('items.' + index + '.tax_id') }]"> |             :class="[{'has-error': form.errors.has('items.' + index + '.tax_id') }]"> | ||||||
|   | |||||||
| @@ -339,6 +339,10 @@ | |||||||
|                                                 <th class="col-sm-3 text-right d-none d-sm-block">{{ trans('bills.price') }}</th> |                                                 <th class="col-sm-3 text-right d-none d-sm-block">{{ trans('bills.price') }}</th> | ||||||
|                                             @stack('price_th_end') |                                             @stack('price_th_end') | ||||||
|  |  | ||||||
|  |                                             @stack('discount_th_start') | ||||||
|  |                                                 <th class="col-sm-1 text-center d-none d-sm-block">{{ trans('bills.discount') }}</th> | ||||||
|  |                                             @stack('discount_th_end') | ||||||
|  |  | ||||||
|                                             @stack('total_th_start') |                                             @stack('total_th_start') | ||||||
|                                                 <th class="col-xs-4 col-sm-3 text-right pr-5">{{ trans('bills.total') }}</th> |                                                 <th class="col-xs-4 col-sm-3 text-right pr-5">{{ trans('bills.total') }}</th> | ||||||
|                                             @stack('total_th_end') |                                             @stack('total_th_end') | ||||||
| @@ -362,6 +366,10 @@ | |||||||
|                                                     <td class="col-sm-3 text-right d-none d-sm-block">@money($bill_item->price, $bill->currency_code, true)</td> |                                                     <td class="col-sm-3 text-right d-none d-sm-block">@money($bill_item->price, $bill->currency_code, true)</td> | ||||||
|                                                 @stack('price_td_end') |                                                 @stack('price_td_end') | ||||||
|  |  | ||||||
|  |                                                 @stack('discount_td_start') | ||||||
|  |                                                     <td class="col-sm-1 text-center d-none d-sm-block">{{ $bill_item->discount_rate }}</td> | ||||||
|  |                                                 @stack('discount_td_end') | ||||||
|  |  | ||||||
|                                                 @stack('total_td_start') |                                                 @stack('total_td_start') | ||||||
|                                                     <td class="col-xs-4 col-sm-3 text-right pr-5">@money($bill_item->total, $bill->currency_code, true)</td> |                                                     <td class="col-xs-4 col-sm-3 text-right pr-5">@money($bill_item->total, $bill->currency_code, true)</td> | ||||||
|                                                 @stack('total_td_end') |                                                 @stack('total_td_end') | ||||||
|   | |||||||
| @@ -52,9 +52,7 @@ | |||||||
|                                         @stack('price_th_end') |                                         @stack('price_th_end') | ||||||
|  |  | ||||||
|                                         @stack('discount_th_start') |                                         @stack('discount_th_start') | ||||||
|                                             @if(setting('default.discount_location', 'in_totals') === 'per_item') |  | ||||||
|                                             <th class="text-right border-right-0 border-bottom-0">{{ trans('invoices.discount') }}</th> |                                             <th class="text-right border-right-0 border-bottom-0">{{ trans('invoices.discount') }}</th> | ||||||
|                                             @endif |  | ||||||
|                                         @stack('discount_th_end') |                                         @stack('discount_th_end') | ||||||
|  |  | ||||||
|                                         @stack('taxes_th_start') |                                         @stack('taxes_th_start') | ||||||
| @@ -93,7 +91,6 @@ | |||||||
|                                     @stack('sub_total_td_end') |                                     @stack('sub_total_td_end') | ||||||
|  |  | ||||||
|                                     @stack('add_discount_td_start') |                                     @stack('add_discount_td_start') | ||||||
|                                         @if(setting('default.discount_location', 'in_totals') === 'in_totals') |  | ||||||
|                                         <tr id="tr-discount"> |                                         <tr id="tr-discount"> | ||||||
|                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> | ||||||
|                                                 <el-popover |                                                 <el-popover | ||||||
| @@ -143,7 +140,6 @@ | |||||||
|                                                 {!! Form::hidden('discount', null, ['id' => 'discount', 'class' => 'form-control text-right', 'v-model' => 'form.discount']) !!} |                                                 {!! Form::hidden('discount', null, ['id' => 'discount', 'class' => 'form-control text-right', 'v-model' => 'form.discount']) !!} | ||||||
|                                             </td> |                                             </td> | ||||||
|                                         </tr> |                                         </tr> | ||||||
|                                         @endif |  | ||||||
|                                     @stack('add_discount_td_end') |                                     @stack('add_discount_td_end') | ||||||
|  |  | ||||||
|                                     @stack('tax_total_td_start') |                                     @stack('tax_total_td_start') | ||||||
|   | |||||||
| @@ -74,13 +74,13 @@ | |||||||
|                                                 <button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i> |                                                 <button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i> | ||||||
|                                                 </button> |                                                 </button> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right border-bottom-0" colspan="5" :colspan="colspan"></td> |                                             <td class="text-right border-bottom-0" colspan="6" :colspan="colspan"></td> | ||||||
|                                         </tr> |                                         </tr> | ||||||
|                                     @stack('add_item_td_end') |                                     @stack('add_item_td_end') | ||||||
|  |  | ||||||
|                                     @stack('sub_total_td_start') |                                     @stack('sub_total_td_start') | ||||||
|                                         <tr id="tr-subtotal"> |                                         <tr id="tr-subtotal"> | ||||||
|                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0 border-bottom-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <strong>{{ trans('invoices.sub_total') }}</strong> |                                                 <strong>{{ trans('invoices.sub_total') }}</strong> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right border-bottom-0 long-texts"> |                                             <td class="text-right border-bottom-0 long-texts"> | ||||||
| @@ -92,8 +92,8 @@ | |||||||
|                                     @stack('sub_total_td_end') |                                     @stack('sub_total_td_end') | ||||||
|  |  | ||||||
|                                     @stack('add_discount_td_start') |                                     @stack('add_discount_td_start') | ||||||
|                                         <tr v-if="totals.discount" id="tr-discount"> |                                         <tr id="tr-discount"> | ||||||
|                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0 border-bottom-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <el-popover |                                                 <el-popover | ||||||
|                                                     popper-class="p-0 h-0" |                                                     popper-class="p-0 h-0" | ||||||
|                                                     placement="bottom" |                                                     placement="bottom" | ||||||
| @@ -145,7 +145,7 @@ | |||||||
|  |  | ||||||
|                                     @stack('tax_total_td_start') |                                     @stack('tax_total_td_start') | ||||||
|                                         <tr id="tr-tax"> |                                         <tr id="tr-tax"> | ||||||
|                                             <td class="text-right border-right-0 border-bottom-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0 border-bottom-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <strong>{{ trans_choice('general.taxes', 1) }}</strong> |                                                 <strong>{{ trans_choice('general.taxes', 1) }}</strong> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right border-bottom-0 long-texts"> |                                             <td class="text-right border-bottom-0 long-texts"> | ||||||
| @@ -158,7 +158,7 @@ | |||||||
|  |  | ||||||
|                                     @stack('grand_total_td_start') |                                     @stack('grand_total_td_start') | ||||||
|                                         <tr id="tr-total"> |                                         <tr id="tr-total"> | ||||||
|                                             <td class="text-right border-right-0" colspan="5" :colspan="colspan"> |                                             <td class="text-right border-right-0" colspan="6" :colspan="colspan"> | ||||||
|                                                 <strong>{{ trans('invoices.total') }}</strong> |                                                 <strong>{{ trans('invoices.total') }}</strong> | ||||||
|                                             </td> |                                             </td> | ||||||
|                                             <td class="text-right long-texts"> |                                             <td class="text-right long-texts"> | ||||||
|   | |||||||
| @@ -357,9 +357,7 @@ | |||||||
|                                             @stack('price_th_end') |                                             @stack('price_th_end') | ||||||
|  |  | ||||||
|                                             @stack('discount_th_start') |                                             @stack('discount_th_start') | ||||||
|                                                 @if($discount_location === 'per_item') |  | ||||||
|                                                 <th class="col-sm-1 text-center d-none d-sm-block">{{ trans('invoices.discount') }}</th> |                                                 <th class="col-sm-1 text-center d-none d-sm-block">{{ trans('invoices.discount') }}</th> | ||||||
|                                                 @endif |  | ||||||
|                                             @stack('discount_th_end') |                                             @stack('discount_th_end') | ||||||
|  |  | ||||||
|                                             @stack('total_th_start') |                                             @stack('total_th_start') | ||||||
| @@ -386,9 +384,7 @@ | |||||||
|                                                 @stack('price_td_end') |                                                 @stack('price_td_end') | ||||||
|  |  | ||||||
|                                                 @stack('discount_td_start') |                                                 @stack('discount_td_start') | ||||||
|                                                     @if($discount_location === 'per_item') |  | ||||||
|                                                     <td class="col-sm-1 text-center d-none d-sm-block">{{ $invoice_item->discount_rate }}</td> |                                                     <td class="col-sm-1 text-center d-none d-sm-block">{{ $invoice_item->discount_rate }}</td> | ||||||
|                                                     @endif |  | ||||||
|                                                 @stack('discount_td_end') |                                                 @stack('discount_td_end') | ||||||
|  |  | ||||||
|                                                 @stack('total_td_start') |                                                 @stack('total_td_start') | ||||||
|   | |||||||
| @@ -30,8 +30,6 @@ | |||||||
|  |  | ||||||
|                 {{ Form::selectGroup('list_limit', trans('settings.default.list_limit'), 'columns', ['10' => '10', '25' => '25', '50' => '50', '100' => '100'], !empty($setting['list_limit']) ? $setting['list_limit'] : null, []) }} |                 {{ Form::selectGroup('list_limit', trans('settings.default.list_limit'), 'columns', ['10' => '10', '25' => '25', '50' => '50', '100' => '100'], !empty($setting['list_limit']) ? $setting['list_limit'] : null, []) }} | ||||||
|  |  | ||||||
|                 {{ Form::selectGroup('discount_location', trans('settings.default.discount_location'), 'percent', $discount_locations, !empty($setting['discount_location']) ? $setting['discount_location'] : 'in_totals', []) }} |  | ||||||
|  |  | ||||||
|                 {{ Form::radioGroup('use_gravatar', trans('settings.default.use_gravatar'), $setting->get('use_gravatar')) }} |                 {{ Form::radioGroup('use_gravatar', trans('settings.default.use_gravatar'), $setting->get('use_gravatar')) }} | ||||||
|             </div> |             </div> | ||||||
|         </div> |         </div> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user