Skip to content

Commit

Permalink
Merge pull request #8664 from turbo124/v5-stable
Browse files Browse the repository at this point in the history
v5.6.21
  • Loading branch information
turbo124 committed Jul 23, 2023
2 parents 45e9c69 + 9a0cd96 commit f2b7b21
Show file tree
Hide file tree
Showing 21 changed files with 177,838 additions and 177,698 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.6.20
5.6.21
17 changes: 15 additions & 2 deletions app/Helpers/Bank/Yodlee/Transformer/AccountTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ public function transform($yodlee_account)

public function transformAccount($account)
{
$current_balance = 0;
$account_currency = '';

if(property_exists($account, 'currentBalance')) {
$current_balance = $account->currentBalance->amount ?? 0;
$account_currency = $account->currentBalance->currency ?? '';
}
elseif(property_exists($account, 'balance')){
$current_balance = $account->balance->amount ?? 0;
$account_currency = $account->balance->currency ?? '';
}


return [
'id' => $account->id,
'account_type' => $account->CONTAINER,
Expand All @@ -92,8 +105,8 @@ public function transformAccount($account)
'provider_id' => $account->providerId,
'provider_name' => $account->providerName,
'nickname' => property_exists($account, 'nickname') ? $account->nickname : '',
'current_balance' => property_exists($account, 'currentBalance') ? $account->currentBalance->amount : 0,
'account_currency' => property_exists($account, 'currency') ? $account->currentBalance->currency : '',
'current_balance' => $current_balance,
'account_currency' => $account_currency,
];
}
}
15 changes: 15 additions & 0 deletions app/Helpers/Bank/Yodlee/Yodlee.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,21 @@ public function getAccount($account_id)
}
}

public function getAccountSummary($account_id)
{
$token = $this->getAccessToken();

$response = Http::withHeaders($this->getHeaders(["Authorization" => "Bearer {$token}"]))->get($this->getEndpoint(). "/accounts/{$account_id}", []);

if ($response->successful()) {
return $response->object();
}

if ($response->failed()) {
return false;
}
}

public function deleteAccount($account_id)
{
$token = $this->getAccessToken();
Expand Down
7 changes: 6 additions & 1 deletion app/Http/Controllers/BankIntegrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ public function refreshAccounts(AdminBankIntegrationRequest $request)
$accounts = $yodlee->getAccounts();

foreach ($accounts as $account) {
if (!BankIntegration::withTrashed()->where('bank_account_id', $account['id'])->where('company_id', $user->company()->id)->exists()) {
if ($bi = BankIntegration::withTrashed()->where('bank_account_id', $account['id'])->where('company_id', $user->company()->id)->first()){
$bi->balance = $account['current_balance'];
$bi->currency = $account['account_currency'];
$bi->save();
}
else {
$bank_integration = new BankIntegration();
$bank_integration->company_id = $user->company()->id;
$bank_integration->account_id = $user->account_id;
Expand Down
17 changes: 14 additions & 3 deletions app/Http/Controllers/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public function preimport(PreImportRequest $request)
/** @var UploadedFile $file */
foreach ($request->files->get('files') as $entityType => $file) {
$contents = file_get_contents($file->getPathname());
// $contents = mb_convert_encoding($contents, 'UTF-16LE', 'UTF-8');

$contents = $this->convertEncoding($contents);

// Store the csv in cache with an expiry of 10 minutes
Cache::put($hash.'-'.$entityType, base64_encode($contents), 600);
Expand All @@ -97,11 +98,21 @@ public function preimport(PreImportRequest $request)
];
}

$data = mb_convert_encoding($data, 'UTF-8', 'UTF-8');

return response()->json($data);
}

private function convertEncoding($data)
{

$enc = mb_detect_encoding($data, mb_list_encodings(), true);

if($enc !== false) {
$data = mb_convert_encoding($data, "UTF-8", $enc);
}

return $data;
}

public function import(ImportRequest $request)
{
$data = $request->all();
Expand Down
5 changes: 3 additions & 2 deletions app/Import/Providers/BaseImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public function getCsvData($entity_type)
}

$csv = base64_decode($base64_encoded_csv);
$csv = mb_convert_encoding($csv, 'UTF-8', 'UTF-8');
nlog($csv);
$csv = Reader::createFromString($csv);
$csvdelimiter = self::detectDelimiter($csv);

Expand Down Expand Up @@ -765,8 +767,7 @@ public function preTransform(array $data, $entity_type)
{
$keys = array_shift($data);
ksort($keys);
// nlog($data);
// nlog($keys);

return array_map(function ($values) use ($keys) {
return array_combine($keys, $values);
}, $data);
Expand Down
19 changes: 19 additions & 0 deletions app/Jobs/Bank/ProcessBankTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use App\Notifications\Ninja\GenericNinjaAdminNotification;
use App\Helpers\Bank\Yodlee\Transformer\AccountTransformer;

class ProcessBankTransactions implements ShouldQueue
{
Expand Down Expand Up @@ -99,6 +100,24 @@ private function processTransactions()
return;
}

try {
$account_summary = $yodlee->getAccountSummary($this->bank_integration->bank_account_id);

if($account_summary) {

$at = new AccountTransformer();
$account = $at->transform($account_summary);

$this->bank_integration->balance = $account['current_balance'];
$this->bank_integration->currency = $account['account_currency'];
$this->bank_integration->save();

}
}
catch(\Exception $e) {
nlog("YODLEE: unable to update account summary for {$this->bank_integration->bank_account_id} => ". $e->getMessage());
}

$data = [
'top' => 500,
'fromDate' => $this->from_date,
Expand Down
6 changes: 5 additions & 1 deletion app/Jobs/Util/UnlinkFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function handle()
return;
}

Storage::disk($this->disk)->delete($this->file_path);
try {
Storage::disk($this->disk)->delete($this->file_path);
} catch (\Exception $e) {

}
}
}
12 changes: 6 additions & 6 deletions app/Services/Invoice/EInvoice/FacturaEInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ private function setFace(): array

private function setPoNumber(): self
{
if(strlen($this->invoice->po_number) > 1) {
$this->fac->setReferences($this->invoice->po_number);
}
$po = $this->invoice->po_number ?? '';

$this->fac->setReferences($po, $this->invoice->custom_value1, $this->invoice->custom_value2);

return $this;
}
Expand All @@ -233,10 +233,10 @@ private function buildItems(): self

foreach($this->invoice->line_items as $item) {
$this->fac->addItem(new FacturaeItem([
'name' => $item->product_key,
'description' => $item->notes,
'name' => $item->notes,
'description' => $item->product_key,
'quantity' => $item->quantity,
'unitPrice' => $item->cost,
'unitPriceWithoutTax' => $item->cost,
'discountsAndRebates' => $item->discount,
'charges' => [],
'discounts' => [],
Expand Down
2 changes: 1 addition & 1 deletion app/Transformers/ClientTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function transform(Client $client)
'has_valid_vat_number' => (bool) $client->has_valid_vat_number,
'is_tax_exempt' => (bool) $client->is_tax_exempt,
'routing_id' => (string) $client->routing_id,
'tax_data' => $client->tax_data ?: '',
'tax_info' => $client->tax_data ?: new \stdClass,
];
}
}
2 changes: 1 addition & 1 deletion app/Transformers/CompanyTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function transform(Company $company)
'show_product_details' => (bool) $company->show_product_details,
'enable_product_quantity' => (bool) $company->enable_product_quantity,
'default_quantity' => (bool) $company->default_quantity,
'custom_fields' => $company->custom_fields ?? $std,
'custom_fields' => (object) $company->custom_fields ?? $std,
'size_id' => (string) $company->size_id ?: '',
'industry_id' => (string) $company->industry_id ?: '',
'first_month_of_year' => (string) $company->first_month_of_year ?: '',
Expand Down
2 changes: 1 addition & 1 deletion app/Transformers/InvoiceTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function transform(Invoice $invoice)
'paid_to_date' => (float) $invoice->paid_to_date,
'subscription_id' => $this->encodePrimaryKey($invoice->subscription_id),
'auto_bill_enabled' => (bool) $invoice->auto_bill_enabled,
'tax_data' => $invoice->tax_data ?: '',
'tax_info' => $invoice->tax_data ?: new \stdClass,
];
}
}
4 changes: 2 additions & 2 deletions config/ninja.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => env('APP_VERSION','5.6.20'),
'app_tag' => env('APP_TAG','5.6.20'),
'app_version' => env('APP_VERSION','5.6.21'),
'app_tag' => env('APP_TAG','5.6.21'),
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$ir = \App\Models\Currency::where('code', 'IDR')->first();

if($ir){
$ir->thousand_separator = '.';
$ir->decimal_separator = ',';
$ir->save();
}

$ld = \App\Models\Currency::find(115);

if(!$ld) {
$ld = new \App\Models\Currency();
$ld->id = 115;
$ld->code = 'LYD';
$ld->name = 'Libyan Dinar';
$ld->symbol = 'LD';
$ld->thousand_separator = ',';
$ld->decimal_separator = '.';
$ld->precision = 3;
$ld->save();
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};
4 changes: 3 additions & 1 deletion database/seeders/CurrenciesSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function run()
['id' => 24, 'name' => 'Bangladeshi Taka', 'code' => 'BDT', 'symbol' => 'Tk', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 25, 'name' => 'United Arab Emirates Dirham', 'code' => 'AED', 'symbol' => 'DH ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 26, 'name' => 'Hong Kong Dollar', 'code' => 'HKD', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 27, 'name' => 'Indonesian Rupiah', 'code' => 'IDR', 'symbol' => 'Rp', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 27, 'name' => 'Indonesian Rupiah', 'code' => 'IDR', 'symbol' => 'Rp', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 28, 'name' => 'Mexican Peso', 'code' => 'MXN', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 29, 'name' => 'Egyptian Pound', 'code' => 'EGP', 'symbol' => 'E£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 30, 'name' => 'Colombian Peso', 'code' => 'COP', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
Expand Down Expand Up @@ -136,6 +136,8 @@ public function run()
['id' => 111, 'name' => 'Cuban Peso', 'code' => 'CUP', 'symbol' => '₱', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 112, 'name' => 'Cayman Island Dollar', 'code' => 'KYD', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 113, 'name' => 'Swazi lilangeni', 'code' => 'SZL', 'symbol' => 'E', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 114, 'name' => 'BZ Dollar', 'code' => 'BZD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 115, 'name' => 'Libyan Dinar', 'code' => 'LYD', 'symbol' => 'LD', 'precision' => '3', 'thousand_separator' => ',', 'decimal_separator' => '.'],
];

foreach ($currencies as $currency) {
Expand Down
4 changes: 2 additions & 2 deletions public/flutter_service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const MANIFEST = 'flutter-app-manifest';
const TEMP = 'flutter-temp-cache';
const CACHE_NAME = 'flutter-app-cache';
const RESOURCES = {
"/": "4c0d0481ceb2647c96c83df4e544c41c",
"/": "dad42af82faab711765c59e9a7596b11",
"flutter.js": "a85fcf6324d3c4d3ae3be1ae4931e9c5",
"favicon.png": "dca91c54388f52eded692718d5a98b8b",
"main.dart.js": "8f2a7bec4184b6bdfb96c53eb69b9376",
"main.dart.js": "b11ed73562dd3c3db2c346bc14702036",
"version.json": "bf49df736fed3f74ade0dbaebf08de11",
"canvaskit/profiling/canvaskit.js": "c21852696bc1cc82e8894d851c01921a",
"canvaskit/profiling/canvaskit.wasm": "371bc4e204443b0d5e774d64a046eb99",
Expand Down

0 comments on commit f2b7b21

Please sign in to comment.