mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
Fix tax per item issue & check currency key
This commit is contained in:
@ -23,11 +23,13 @@ class UpdateCompanySettingsController extends Controller
|
||||
$companyCurrency = CompanySetting::getSetting('currency', $request->header('company'));
|
||||
$data = $request->settings;
|
||||
|
||||
if ($companyCurrency !== $data['currency'] && $company->hasTransactions()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Cannot update company currency after transactions are created.'
|
||||
]);
|
||||
if (array_key_exists('currency', $data)) {
|
||||
if ($companyCurrency !== $data['currency'] && $company->hasTransactions()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Cannot update company currency after transactions are created.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
CompanySetting::setSettings($data, $request->header('company'));
|
||||
|
||||
@ -498,6 +498,10 @@ class Invoice extends Model implements HasMedia
|
||||
if (array_key_exists('taxes', $invoiceItem) && $invoiceItem['taxes']) {
|
||||
foreach ($invoiceItem['taxes'] as $tax) {
|
||||
$tax['company_id'] = $invoice->company_id;
|
||||
$tax['exchnage_rate'] = $invoice->exchange_rate;
|
||||
$tax['base_amount'] = $tax['amount'] * $exchange_rate;
|
||||
$tax['currency_id'] = $invoice->currency_id;
|
||||
|
||||
if (gettype($tax['amount']) !== "NULL") {
|
||||
if (array_key_exists('recurring_invoice_id', $invoiceItem)) {
|
||||
unset($invoiceItem['recurring_invoice_id']);
|
||||
|
||||
Reference in New Issue
Block a user