Skip to content

Commit

Permalink
Merge pull request #26 from insane-code/fix/loger-changes
Browse files Browse the repository at this point in the history
fix: add support for tax amount from form
  • Loading branch information
jesusantguerrero authored Mar 16, 2023
2 parents 0e59523 + b4f5196 commit c9fcb4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/Http/Controllers/InvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

class InvoiceController
{
private $searchable = [];
private $validationRules = [];

public function __construct()
{
$this->searchable = ['name'];
Expand Down
2 changes: 1 addition & 1 deletion src/Jobs/Invoice/CreateInvoiceLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
Expand Down
4 changes: 3 additions & 1 deletion src/Models/Invoice/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c9fcb4e

Please sign in to comment.