diff --git a/src/Http/Controllers/InvoiceController.php b/src/Http/Controllers/InvoiceController.php index 2e005fd..de03b2f 100644 --- a/src/Http/Controllers/InvoiceController.php +++ b/src/Http/Controllers/InvoiceController.php @@ -16,6 +16,9 @@ class InvoiceController { + private $searchable = []; + private $validationRules = []; + public function __construct() { $this->searchable = ['name']; diff --git a/src/Jobs/Invoice/CreateInvoiceLine.php b/src/Jobs/Invoice/CreateInvoiceLine.php index b867ab6..b6d0d26 100644 --- a/src/Jobs/Invoice/CreateInvoiceLine.php +++ b/src/Jobs/Invoice/CreateInvoiceLine.php @@ -77,7 +77,7 @@ private function createItemTaxes($taxes, $line) { "concept" => $tax['description'] ?? $tax['concept'], "rate" => $taxRate, "type" => $tax['type'], - "amount" => $taxLineTotal, + "amount" => $tax['amount'] ?? $taxLineTotal, "amount_base" => $line->amount, "index" => $index, ]); diff --git a/src/Models/Invoice/Invoice.php b/src/Models/Invoice/Invoice.php index 0963e47..5e20f41 100644 --- a/src/Models/Invoice/Invoice.php +++ b/src/Models/Invoice/Invoice.php @@ -250,7 +250,9 @@ public static function setNumber($invoice) public static function calculateTotal($invoice) { $total = InvoiceLine::where(["invoice_id" => $invoice->id])->selectRaw('sum(price) as price, sum(discount) as discount, sum(amount) as amount')->get(); - $totalTax = InvoiceLineTax::where(["invoice_id" => $invoice->id])->selectRaw('sum(amount * type) as amount')->get(); + $totalTax = InvoiceLineTax::where(["invoice_id" => $invoice->id]) + ->selectRaw('sum(amount * type) as amount') + ->get(); $discount = $total[0]['discount'] ?? 0; $taxTotal = $totalTax[0]['amount'] ?? 0;