Merge branch 'v5-develop' into v5-develop

Signed-off-by: David Bomba <turbo124@gmail.com>
This commit is contained in:
David Bomba 2024-01-16 14:28:45 +11:00 committed by GitHub
commit db2a2ea998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36702 additions and 36644 deletions

View File

@ -64,88 +64,83 @@ use Log;
class TransactionTransformer implements BankRevenueInterface
{
use AppSetup;
use AppSetup;
public function transform($transactionResponse)
{
$data = [];
public function transform($transactionResponse)
{
$data = [];
if (!array_key_exists('transactions', $transactionResponse) || !array_key_exists('booked', $transactionResponse["transactions"])) {
throw new \Exception('invalid dataset');
}
if (!array_key_exists('transactions', $transactionResponse) || !array_key_exists('booked', $transactionResponse["transactions"]))
throw new \Exception('invalid dataset');
foreach ($transactionResponse["transactions"]["booked"] as $transaction) {
$data[] = $this->transformTransaction($transaction);
}
foreach ($transactionResponse["transactions"]["booked"] as $transaction) {
$data[] = $this->transformTransaction($transaction);
}
return $data;
}
return $data;
public function transformTransaction($transaction)
{
if (!array_key_exists('transactionId', $transaction) || !array_key_exists('transactionAmount', $transaction))
throw new \Exception('invalid dataset');
// description could be in varios places
$description = '';
if (array_key_exists('remittanceInformationStructured', $transaction))
$description = $transaction["remittanceInformationStructured"];
else if (array_key_exists('remittanceInformationStructuredArray', $transaction))
$description = implode('\n', $transaction["remittanceInformationStructuredArray"]);
else if (array_key_exists('remittanceInformationUnstructured', $transaction))
$description = $transaction["remittanceInformationUnstructured"];
else if (array_key_exists('remittanceInformationUnstructuredArray', $transaction))
$description = implode('\n', $transaction["remittanceInformationUnstructuredArray"]);
else
Log::warning("Missing description for the following transaction: " . json_encode($transaction));
// participant
$participant = array_key_exists('debtorAccount', $transaction) && array_key_exists('iban', $transaction["debtorAccount"]) ?
$transaction['debtorAccount']['iban'] :
(array_key_exists('creditorAccount', $transaction) && array_key_exists('iban', $transaction["creditorAccount"]) ?
$transaction['creditorAccount']['iban'] : null);
$participant_name = array_key_exists('debtorName', $transaction) ?
$transaction['debtorName'] :
(array_key_exists('creditorName', $transaction) ?
$transaction['creditorName'] : null);
return [
'transaction_id' => $transaction["transactionId"],
'amount' => (float) $transaction["transactionAmount"]["amount"],
'currency_id' => $this->convertCurrency($transaction["transactionAmount"]["currency"]),
'category_id' => null,
'category_type' => array_key_exists('additionalInformation', $transaction) ? $transaction["additionalInformation"] : '',
'date' => $transaction["bookingDate"],
'description' => $description,
'participant' => $participant,
'participant_name' => $participant_name,
'base_type' => (int) $transaction["transactionAmount"]["amount"] <= 0 ? 'DEBIT' : 'CREDIT',
];
}
private function convertCurrency(string $code)
{
$currencies = Cache::get('currencies');
if (!$currencies) {
$this->buildCache(true);
}
public function transformTransaction($transaction)
{
$currency = $currencies->filter(function ($item) use ($code) {
return $item->code == $code;
})->first();
if (!array_key_exists('transactionId', $transaction) || !array_key_exists('transactionAmount', $transaction)) {
throw new \Exception('invalid dataset');
}
if ($currency)
return $currency->id;
// description could be in varios places
$description = '';
if (array_key_exists('remittanceInformationStructured', $transaction)) {
$description = $transaction["remittanceInformationStructured"];
} elseif (array_key_exists('remittanceInformationStructuredArray', $transaction)) {
$description = implode('\n', $transaction["remittanceInformationStructuredArray"]);
} elseif (array_key_exists('remittanceInformationUnstructured', $transaction)) {
$description = $transaction["remittanceInformationUnstructured"];
} elseif (array_key_exists('remittanceInformationUnstructuredArray', $transaction)) {
$description = implode('\n', $transaction["remittanceInformationUnstructuredArray"]);
} else {
Log::warning("Missing description for the following transaction: " . json_encode($transaction));
}
return 1;
// participant
$participant = array_key_exists('debtorAccount', $transaction) && array_key_exists('iban', $transaction["debtorAccount"]) ?
$transaction['debtorAccount']['iban'] :
(array_key_exists('creditorAccount', $transaction) && array_key_exists('iban', $transaction["creditorAccount"]) ?
$transaction['creditorAccount']['iban'] : null);
$participant_name = array_key_exists('debtorName', $transaction) ?
$transaction['debtorName'] :
(array_key_exists('creditorName', $transaction) ?
$transaction['creditorName'] : null);
return [
'nordigen_transaction_id' => $transaction["transactionId"],
'amount' => abs((int) $transaction["transactionAmount"]["amount"]),
'currency_id' => $this->convertCurrency($transaction["transactionAmount"]["currency"]),
'category_id' => null,
'category_type' => array_key_exists('additionalInformation', $transaction) ? $transaction["additionalInformation"] : '',
'date' => $transaction["bookingDate"],
'description' => $description,
'participant' => $participant,
'participant_name' => $participant_name,
'base_type' => (int) $transaction["transactionAmount"]["amount"] <= 0 ? 'DEBIT' : 'CREDIT',
];
}
private function convertCurrency(string $code)
{
$currencies = Cache::get('currencies');
if (!$currencies) {
$this->buildCache(true);
}
$currency = $currencies->filter(function ($item) use ($code) {
return $item->code == $code;
})->first();
if ($currency) {
return $currency->id;
}
return 1;
}
}
}

View File

@ -5,7 +5,7 @@ const CACHE_NAME = 'flutter-app-cache';
const RESOURCES = {"flutter.js": "7d69e653079438abfbb24b82a655b0a4",
"manifest.json": "ef43d90e57aa7682d7e2cfba2f484a40",
"/": "a47ab5e8563a2381c4b4e59a5ceae293",
"/": "abef4f45465fc1ec27e5de605cdba933",
"assets/AssetManifest.bin": "bf3be26e7055ad9a32f66b3a56138224",
"assets/fonts/MaterialIcons-Regular.otf": "06c266d6fa0b6c2f861f5819063605fa",
"assets/assets/images/logo_dark.png": "a233ed1d4d0f7414bf97a9a10f11fb0a",
@ -296,7 +296,7 @@ const RESOURCES = {"flutter.js": "7d69e653079438abfbb24b82a655b0a4",
"assets/packages/window_manager/images/ic_chrome_minimize.png": "4282cd84cb36edf2efb950ad9269ca62",
"favicon.png": "dca91c54388f52eded692718d5a98b8b",
"favicon.ico": "51636d3a390451561744c42188ccd628",
"main.dart.js": "723d2c8935683471f1db5f4b9a245d1a",
"main.dart.js": "d997e506b40f104a5968da0c6583daa7",
"version.json": "0f3750d4080faad6f28563be98740046",
"canvaskit/canvaskit.wasm": "64edb91684bdb3b879812ba2e48dd487",
"canvaskit/skwasm.js": "87063acf45c5e1ab9565dcf06b0c18b8",

36729
public/main.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

36369
public/main.foss.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -100150,7 +100150,7 @@
filteredTransactionsSelector(selectionState, transactionMap, transactionList, invoiceMap, vendorMap, expenseMap, expenseCategoryMap, bankAccountMap, transactionListState) {
var t1 = transactionList._list$_list,
t2 = A._arrayInstanceType(t1)._eval$1("WhereIterable<1>"),
list = A.List_List$of(new A.WhereIterable(t1, new A.filteredTransactionsSelector_closure(transactionMap, selectionState, selectionState.filterEntityType, selectionState.filterEntityId, transactionListState), t2), true, t2._eval$1("Iterable.E"));
list = A.List_List$of(new A.WhereIterable(t1, new A.filteredTransactionsSelector_closure(transactionMap, selectionState, bankAccountMap, selectionState.filterEntityType, selectionState.filterEntityId, transactionListState), t2), true, t2._eval$1("Iterable.E"));
B.JSArray_methods.sort$1(list, new A.filteredTransactionsSelector_closure0(transactionMap, transactionListState, vendorMap, invoiceMap, expenseMap, expenseCategoryMap, bankAccountMap));
return list;
},
@ -100162,13 +100162,14 @@
},
memoizedFilteredTransactionList_closure: function memoizedFilteredTransactionList_closure() {
},
filteredTransactionsSelector_closure: function filteredTransactionsSelector_closure(t0, t1, t2, t3, t4) {
filteredTransactionsSelector_closure: function filteredTransactionsSelector_closure(t0, t1, t2, t3, t4, t5) {
var _ = this;
_.transactionMap = t0;
_.selectionState = t1;
_.filterEntityType = t2;
_.filterEntityId = t3;
_.transactionListState = t4;
_.bankAccountMap = t2;
_.filterEntityType = t3;
_.filterEntityId = t4;
_.transactionListState = t5;
},
filteredTransactionsSelector_closure0: function filteredTransactionsSelector_closure0(t0, t1, t2, t3, t4, t5, t6) {
var _ = this;
@ -366335,7 +366336,7 @@
response = B.JSString_methods.compareTo$1(clientA.idNumber, clientB.idNumber);
break;
case "number":
response = A.compareNatural(clientA.number.toLowerCase(), clientB.number.toLowerCase());
response = A.compareNatural(clientA.number, clientB.number);
break;
case "website":
response = B.JSString_methods.compareTo$1(clientA.website.toLowerCase(), clientB.website.toLowerCase());
@ -377007,7 +377008,7 @@
response = B.JSInt_methods.compareTo$1(expenseA.documents._list$_list.length, expenseB.documents._list$_list.length);
break;
case "number":
response = A.compareNatural(expenseA.number.toLowerCase(), expenseB.number.toLowerCase());
response = A.compareNatural(expenseA.number, expenseB.number);
break;
case "private_notes":
response = B.JSString_methods.compareTo$1(expenseA.privateNotes, expenseB.privateNotes);
@ -381179,9 +381180,7 @@
t1 = B.JSString_methods.startsWith$1(invoiceBNumber, recurringPrefix);
} else
t1 = false;
if (t1)
invoiceBNumber = B.JSString_methods.replaceFirst$2(invoiceBNumber, recurringPrefix, "");
response = A.compareNatural(invoiceANumber.toLowerCase(), invoiceBNumber.toLowerCase());
response = A.compareNatural(invoiceANumber, t1 ? B.JSString_methods.replaceFirst$2(invoiceBNumber, recurringPrefix, "") : invoiceBNumber);
break;
case "amount":
response = B.JSNumber_methods.compareTo$1(invoiceA.amount, invoiceB.amount);
@ -384796,7 +384795,7 @@
response = B.JSNumber_methods.compareTo$1(paymentA.refunded, paymentB.refunded);
break;
case "number":
response = B.JSString_methods.compareTo$1(paymentA.number.toLowerCase(), paymentB.number.toLowerCase());
response = A.compareNatural(paymentA.number, paymentB.number);
break;
case "transaction_reference":
response = B.JSString_methods.compareTo$1(paymentA.transactionReference, paymentB.transactionReference);
@ -387726,7 +387725,7 @@
response = B.JSInt_methods.compareTo$1(projectA.documents._list$_list.length, projectB.documents._list$_list.length);
break;
case "number":
response = B.JSString_methods.compareTo$1(projectA.number, projectB.number);
response = A.compareNatural(projectA.number, projectB.number);
break;
case "custom1":
response = B.JSString_methods.compareTo$1(projectA.customValue1, projectB.customValue1);
@ -400341,7 +400340,7 @@
response = B.JSInt_methods.compareTo$1(taskA.documents._list$_list.length, taskB.documents._list$_list.length);
break;
case "number":
response = A.compareNatural(taskA.number.toLowerCase(), taskB.number.toLowerCase());
response = A.compareNatural(taskA.number, taskB.number);
break;
case "created_by":
t1 = userMap._map$_map;
@ -406622,7 +406621,7 @@
response = B.JSInt_methods.compareTo$1(vendorA.documents._list$_list.length, vendorB.documents._list$_list.length);
break;
case "number":
response = A.compareNatural(vendorA.number.toLowerCase(), vendorB.number.toLowerCase());
response = A.compareNatural(vendorA.number, vendorB.number);
break;
case "address1":
response = B.JSString_methods.compareTo$1(vendorA.address1, vendorB.address1);
@ -429523,17 +429522,21 @@
};
A._createViewDashboard__closure.prototype = {
call$0() {
var _s10_ = "/dashboard",
var t3, t4, t5,
_s10_ = "/dashboard",
t1 = this.store,
t2 = t1.__Store__state_A;
t2 === $ && A.throwUnnamedLateFieldNI();
if (!t2.userCompanyStates._list$_list[t2.uiState.selectedCompanyIndex].userCompany.get$canViewDashboard()) {
t3 = t2.userCompanyStates;
t4 = t2.uiState.selectedCompanyIndex;
t3 = t3._list$_list;
t5 = t3[t4];
if (t5.lastUpdated > 0 && !t5.userCompany.get$canViewDashboard()) {
t2 = t1.__Store__dispatchers_F;
t2 === $ && A.throwUnnamedLateFieldNI();
t2[0].call$1(new A.ViewClientList(0));
} else {
t2 = t1.__Store__state_A;
if (t2.userCompanyStates._list$_list[t2.uiState.selectedCompanyIndex].get$isStale() || t2.staticState.get$isStale()) {
if (t3[t4].get$isStale() || t2.staticState.get$isStale()) {
t2 = t1.__Store__dispatchers_F;
t2 === $ && A.throwUnnamedLateFieldNI();
t2[0].call$1(new A.RefreshData(null, false, false, false));
@ -471845,26 +471848,48 @@
};
A.filteredTransactionsSelector_closure.prototype = {
call$1(transactionId) {
var t2, _this = this,
var t2, bankAccount, t3, _this = this,
t1 = _this.transactionMap._map$_map.$index(0, transactionId);
t1.toString;
if (t1.id === _this.selectionState.selectedId)
return true;
t2 = _this.filterEntityType;
if (t2 != null)
if (t2 === B.EntityType_expenseCategory && t1.categoryId !== _this.filterEntityId)
t2 = t1.bankAccountId;
bankAccount = _this.bankAccountMap._map$_map.$index(0, t2);
if (bankAccount == null)
bankAccount = A.BankAccountEntity_BankAccountEntity(null, null);
if (bankAccount.archivedAt > 0) {
t3 = bankAccount.isDeleted;
t3.toString;
t3 = !t3;
} else
t3 = false;
if (!t3) {
t3 = bankAccount.isDeleted;
t3.toString;
t3 = !t3;
} else
t3 = false;
if (!t3)
t3 = !(bankAccount.id === _this.filterEntityId && bankAccount.get$entityType() === _this.filterEntityType);
else
t3 = false;
if (t3)
return false;
t3 = _this.filterEntityType;
if (t3 != null)
if (t3 === B.EntityType_expenseCategory && t1.categoryId !== _this.filterEntityId)
return false;
else if (t2 === B.EntityType_vendor && t1.vendorId !== _this.filterEntityId)
else if (t3 === B.EntityType_vendor && t1.vendorId !== _this.filterEntityId)
return false;
else if (t2 === B.EntityType_invoice && !B.JSArray_methods.contains$1(A._setArrayType(t1.invoiceIds.split(","), type$.JSArray_String), _this.filterEntityId))
else if (t3 === B.EntityType_invoice && !B.JSArray_methods.contains$1(A._setArrayType(t1.invoiceIds.split(","), type$.JSArray_String), _this.filterEntityId))
return false;
else if (t2 === B.EntityType_expense && t1.expenseId !== _this.filterEntityId)
else if (t3 === B.EntityType_expense && t1.expenseId !== _this.filterEntityId)
return false;
else if (t2 === B.EntityType_bankAccount && t1.bankAccountId !== _this.filterEntityId)
else if (t3 === B.EntityType_bankAccount && t2 !== _this.filterEntityId)
return false;
else if (t2 === B.EntityType_transactionRule && t1.transactionRuleId !== _this.filterEntityId)
else if (t3 === B.EntityType_transactionRule && t1.transactionRuleId !== _this.filterEntityId)
return false;
else if (t2 === B.EntityType_payment && t1.paymentId !== _this.filterEntityId)
else if (t3 === B.EntityType_payment && t1.paymentId !== _this.filterEntityId)
return false;
t2 = _this.transactionListState;
if (!t1.matchesStates$1(t2.stateFilters))
@ -501093,7 +501118,7 @@
t4.toString;
t4 = J.$index$asx(t4, "provider");
t4.toString;
t6.$indexSet(0, t4, A.toTitleCase(bankAccount.provider));
t6.$indexSet(0, t4, bankAccount.provider);
if (t5) {
t1 = t1.get$autoSync();
if (bankAccount.autoSync) {
@ -571964,7 +571989,11 @@
t1.toString;
t1 = J.$index$asx(t1, _s14_);
t1.toString;
t1 = new A.AppButton(_null, B.IconData_57415_MaterialIcons_null_false, t1, state.isSaving ? _null : new A._MatchWithdrawalsState_build_closure22(_this, context), _null, _null);
if (!state.isSaving)
t2 = _this._selectedVendor == null && _this._selectedCategory == null;
else
t2 = true;
t1 = new A.AppButton(_null, B.IconData_57415_MaterialIcons_null_false, t1, t2 ? _null : new A._MatchWithdrawalsState_build_closure22(_this, context), _null, _null);
}
t3.push(new A.Padding(B.EdgeInsets_20_0_20_16, t1, _null));
return A.Column$(t3, B.CrossAxisAlignment_3, _null, B.MainAxisAlignment_0, B.MainAxisSize_1, B.VerticalDirection_1);