1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fixes for tax map display of surcharge taxes

This commit is contained in:
David Bomba 2024-07-05 11:47:38 +10:00
parent 96f980aa54
commit 0d654dae95
4 changed files with 45 additions and 7 deletions

View File

@ -320,7 +320,7 @@ class InvoiceFilters extends QueryFilters
{
$sort_col = explode('|', $sort);
if (!is_array($sort_col) || count($sort_col) != 2) {
if (!is_array($sort_col) || count($sort_col) != 2 || in_array($sort_col[0], ['documents'])) {
return $this->builder;
}

View File

@ -74,8 +74,8 @@ class InvoiceSumInclusive
{
$this->calculateLineItems()
->calculateDiscount()
->calculateInvoiceTaxes()
->calculateCustomValues()
->calculateCustomValues() //06-07-2024
->calculateInvoiceTaxes() //shuffle order of invoicetaxes/custom values to include the surcharge taxes in the tax map
->setTaxMap()
->calculateTotals() //just don't add the taxes!!
->calculateBalance()
@ -119,8 +119,6 @@ class InvoiceSumInclusive
$this->total_taxes += $this->multiInclusiveTax($this->invoice->custom_surcharge4, $this->invoice->custom_surcharge_tax4);
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge4);
$this->total += $this->total_custom_values;
return $this;
}
@ -172,6 +170,8 @@ class InvoiceSumInclusive
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.floatval($this->invoice->tax_rate3).'%', 'total' => $tax];
}
$this->total += $this->total_custom_values; //06-07-2024 add the custom surcharge totals here after the tax calculations.
return $this;
}
@ -395,4 +395,5 @@ class InvoiceSumInclusive
{
return $this;
}
}

View File

@ -47,11 +47,10 @@ class ExpenseRepository extends BaseRepository
$user = auth()->user();
$payment_date = &$data['payment_date'];
$vendor_id = &$data['vendor_id'];
if($payment_date && $payment_date == $expense->payment_date) {
//do nothing
} elseif($payment_date && strlen($payment_date) > 1 && $user->company()->notify_vendor_when_paid && ($vendor_id || $expense->vendor_id)) {
} elseif($payment_date && strlen($payment_date) > 1 && $user->company()->notify_vendor_when_paid && (isset($data['vendor_id']) || $expense->vendor_id)) {
$this->notify_vendor = true;
}

View File

@ -47,6 +47,44 @@ class ExpenseApiTest extends TestCase
Model::reguard();
}
public function testExpensePutWithVendorStatus()
{
$data =
[
'vendor_id' => $this->vendor->hashed_id,
'amount' => 10,
'date' => '2021-10-01',
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/expenses', $data);
$arr = $response->json();
$response->assertStatus(200);
$this->assertEquals($this->vendor->hashed_id, $arr['data']['vendor_id']);
$data = [
'payment_date' => now()->format('Y-m-d')
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/expenses/'.$arr['data']['id'], $data);
$arr = $response->json();
$response->assertStatus(200);
$this->assertEquals($this->vendor->hashed_id, $arr['data']['vendor_id']);
}
public function testTransactionIdClearedOnDelete()
{
$bi = BankIntegration::factory()->create([