Line item tax amounts

This commit is contained in:
David Bomba 2022-11-10 21:57:55 +11:00
parent ce30aa7702
commit b3d53a7cd8
9 changed files with 45 additions and 16 deletions

View File

@ -45,7 +45,7 @@ class InvoiceItem
public $gross_line_total = 0;
public $gross_tax_total = 0;
public $tax_amount = 0;
public $date = '';
@ -77,7 +77,7 @@ class InvoiceItem
'sort_id' => 'string',
'line_total' => 'float',
'gross_line_total' => 'float',
'gross_tax_total' => 'float',
'tax_amount' => 'float',
'date' => 'string',
'custom_value1' => 'string',
'custom_value2' => 'string',

View File

@ -30,7 +30,7 @@ class InvoiceItemSum
private $gross_line_total;
private $gross_tax_total;
private $tax_amount;
private $currency;
@ -158,7 +158,7 @@ class InvoiceItemSum
$this->item->gross_line_total = $this->getLineTotal() + $item_tax;
$this->item->gross_tax_total = $item_tax;
$this->item->tax_amount = $item_tax;
return $this;
}

View File

@ -40,7 +40,7 @@ class InvoiceItemSumInclusive
private $tax_collection;
private $gross_tax_total;
private $tax_amount;
public function __construct($invoice)
{
@ -146,7 +146,7 @@ class InvoiceItemSumInclusive
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
}
$this->item->gross_tax_total = $this->formatValue($item_tax, $this->currency->precision);
$this->item->tax_amount = $this->formatValue($item_tax, $this->currency->precision);
$this->setTotalTaxes($this->formatValue($item_tax, $this->currency->precision));

View File

@ -92,11 +92,14 @@ class MatchBankTransactions implements ShouldQueue
$this->company = Company::find($this->company_id);
$yodlee = new Yodlee($this->company->account->bank_integration_account_id);
if($this->company->account->bank_integration_account_id)
$yodlee = new Yodlee($this->company->account->bank_integration_account_id);
else
$yodlee = false;
$bank_categories = Cache::get('bank_categories');
if(!$bank_categories){
if(!$bank_categories && $yodlee){
$_categories = $yodlee->getTransactionCategories();
$this->categories = collect($_categories->transactionCategory);
Cache::forever('bank_categories', $this->categories);
@ -159,7 +162,7 @@ class MatchBankTransactions implements ShouldQueue
$_invoices = Invoice::withTrashed()->find($this->getInvoices($input['invoice_ids']));
$amount = $this->bt->amount;
$amount = $this->bt->amount;
if($_invoices && $this->checkPayable($_invoices)){
@ -220,7 +223,7 @@ class MatchBankTransactions implements ShouldQueue
$this->applied_amount += $this->invoice->balance;
$this->available_balance = $this->available_balance - $this->invoice->balance;
}
elseif(floatval($this->invoice->balance) > floatval($this->available_balance) && $this->available_balance > 0)
elseif(floatval($this->invoice->balance) >= floatval($this->available_balance) && $this->available_balance > 0)
{
$_amount = $this->available_balance;
$this->applied_amount += $this->available_balance;

View File

@ -11,6 +11,7 @@
namespace App\Models;
use App\Models\Invoice;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\SoftDeletes;
@ -95,4 +96,22 @@ class BankTransaction extends BaseModel
return $this->belongsTo(Account::class)->withTrashed();
}
public function matchInvoiceNumber()
{
if(strlen($this->description) > 1)
{
$i = Invoice::where('company_id', $this->company_id)
->whereIn('status_id', [1,2,3])
->where('is_deleted', 0)
->where('number', 'LIKE', '%'.$this->description.'%')
->first();
return $i ?: false;
}
return false;
}
}

View File

@ -31,6 +31,13 @@ class BankTransactionRepository extends BaseRepository
$bank_transaction->save();
if($bank_transaction->base_type == 'CREDIT' && $invoice = $bank_transaction->matchInvoiceNumber())
{
$bank_transaction->invoice_ids = $invoice->hashed_id;
$bank_transaction->status_id = BankTransaction::STATUS_MATCHED;
$bank_transaction->save();
}
return $bank_transaction;
}

View File

@ -485,7 +485,7 @@ class HtmlEngine
$data['$product.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
$data['$product.gross_line_total'] = ['value' => '', 'label' => ctrans('texts.gross_line_total')];
$data['$product.gross_tax_total'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.tax_amount'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.description'] = ['value' => '', 'label' => ctrans('texts.description')];
$data['$product.unit_cost'] = ['value' => '', 'label' => ctrans('texts.unit_cost')];
$data['$product.product1'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product1')];

View File

@ -206,7 +206,7 @@ trait MakesInvoiceValues
'tax_name1',
'tax_name2',
'tax_name3',
'gross_tax_total',
'tax_amount',
],
[
'tax',
@ -327,10 +327,10 @@ trait MakesInvoiceValues
$data[$key][$table_type.'.gross_line_total'] = '';
}
if (property_exists($item, 'gross_tax_total')) {
$data[$key][$table_type.'.gross_tax_total'] = ($item->gross_tax_total == 0) ? '' : Number::formatMoney($item->gross_tax_total, $entity);
if (property_exists($item, 'tax_amount')) {
$data[$key][$table_type.'.tax_amount'] = ($item->tax_amount == 0) ? '' : Number::formatMoney($item->tax_amount, $entity);
} else {
$data[$key][$table_type.'.gross_tax_total'] = '';
$data[$key][$table_type.'.tax_amount'] = '';
}
if (isset($item->discount) && $item->discount > 0) {

View File

@ -355,7 +355,7 @@ class VendorHtmlEngine
$data['$product.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
$data['$product.gross_line_total'] = ['value' => '', 'label' => ctrans('texts.gross_line_total')];
$data['$product.gross_tax_total'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.tax_amount'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$product.description'] = ['value' => '', 'label' => ctrans('texts.description')];
$data['$product.unit_cost'] = ['value' => '', 'label' => ctrans('texts.unit_cost')];
$data['$product.product1'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product1')];