Implemented saving bank data with CoreData
This commit is contained in:
parent
a06af50336
commit
d29965c77e
|
@ -22,9 +22,6 @@
|
||||||
36BCF87324BB2706005BEC29 /* BankingUiSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF87224BB2706005BEC29 /* BankingUiSwift.framework */; };
|
36BCF87324BB2706005BEC29 /* BankingUiSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF87224BB2706005BEC29 /* BankingUiSwift.framework */; };
|
||||||
36BCF87424BB2706005BEC29 /* BankingUiSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF87224BB2706005BEC29 /* BankingUiSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
36BCF87424BB2706005BEC29 /* BankingUiSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF87224BB2706005BEC29 /* BankingUiSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
36BCF87624BF114F005BEC29 /* UrlSessionWebClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF87524BF114F005BEC29 /* UrlSessionWebClient.swift */; };
|
36BCF87624BF114F005BEC29 /* UrlSessionWebClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF87524BF114F005BEC29 /* UrlSessionWebClient.swift */; };
|
||||||
36BCF87B24BFA87E005BEC29 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF87A24BFA87E005BEC29 /* Extensions.swift */; };
|
|
||||||
36BCF87F24BFAA7F005BEC29 /* TestEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF87E24BFAA7F005BEC29 /* TestEntity.swift */; };
|
|
||||||
36BCF88124BFAB4A005BEC29 /* DependendTestEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88024BFAB4A005BEC29 /* DependendTestEntity.swift */; };
|
|
||||||
36BCF88324C098BB005BEC29 /* BankListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88224C098BB005BEC29 /* BankListItem.swift */; };
|
36BCF88324C098BB005BEC29 /* BankListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88224C098BB005BEC29 /* BankListItem.swift */; };
|
||||||
36BCF88524C098C8005BEC29 /* BankAccountListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88424C098C8005BEC29 /* BankAccountListItem.swift */; };
|
36BCF88524C098C8005BEC29 /* BankAccountListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88424C098C8005BEC29 /* BankAccountListItem.swift */; };
|
||||||
36BCF88724C0A310005BEC29 /* PreviewData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88624C0A310005BEC29 /* PreviewData.swift */; };
|
36BCF88724C0A310005BEC29 /* PreviewData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88624C0A310005BEC29 /* PreviewData.swift */; };
|
||||||
|
@ -32,6 +29,9 @@
|
||||||
36BCF88B24C0BD2D005BEC29 /* AccountTransactionsDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88A24C0BD2D005BEC29 /* AccountTransactionsDialog.swift */; };
|
36BCF88B24C0BD2D005BEC29 /* AccountTransactionsDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88A24C0BD2D005BEC29 /* AccountTransactionsDialog.swift */; };
|
||||||
36BCF88D24C1C1EA005BEC29 /* TransferMoneyDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88C24C1C1EA005BEC29 /* TransferMoneyDialog.swift */; };
|
36BCF88D24C1C1EA005BEC29 /* TransferMoneyDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88C24C1C1EA005BEC29 /* TransferMoneyDialog.swift */; };
|
||||||
36BCF88F24C1DFF7005BEC29 /* SheetPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88E24C1DFF7005BEC29 /* SheetPresenter.swift */; };
|
36BCF88F24C1DFF7005BEC29 /* SheetPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF88E24C1DFF7005BEC29 /* SheetPresenter.swift */; };
|
||||||
|
36BCF89124C25971005BEC29 /* CoreDataBankingPersistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF89024C25971005BEC29 /* CoreDataBankingPersistence.swift */; };
|
||||||
|
36BCF89324C25BC3005BEC29 /* Mapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF89224C25BC3005BEC29 /* Mapper.swift */; };
|
||||||
|
36BCF89524C31F02005BEC29 /* AppData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BCF89424C31F02005BEC29 /* AppData.swift */; };
|
||||||
36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36E7BA1324B3D05C00757859 /* ViewExtensions.swift */; };
|
36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36E7BA1324B3D05C00757859 /* ViewExtensions.swift */; };
|
||||||
36FC929C24B39A05002B12E9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929B24B39A05002B12E9 /* AppDelegate.swift */; };
|
36FC929C24B39A05002B12E9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929B24B39A05002B12E9 /* AppDelegate.swift */; };
|
||||||
36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929D24B39A05002B12E9 /* SceneDelegate.swift */; };
|
36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929D24B39A05002B12E9 /* SceneDelegate.swift */; };
|
||||||
|
@ -97,9 +97,6 @@
|
||||||
36BCF86F24BB0F8A005BEC29 /* fints4kBankingClient.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = fints4kBankingClient.framework; path = "../fints4kBankingClient/build/xcode-frameworks/fints4kBankingClient.framework"; sourceTree = "<group>"; };
|
36BCF86F24BB0F8A005BEC29 /* fints4kBankingClient.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = fints4kBankingClient.framework; path = "../fints4kBankingClient/build/xcode-frameworks/fints4kBankingClient.framework"; sourceTree = "<group>"; };
|
||||||
36BCF87224BB2706005BEC29 /* BankingUiSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BankingUiSwift.framework; path = "../BankingUiNativeIntegration/build/xcode-frameworks/BankingUiSwift.framework"; sourceTree = "<group>"; };
|
36BCF87224BB2706005BEC29 /* BankingUiSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BankingUiSwift.framework; path = "../BankingUiNativeIntegration/build/xcode-frameworks/BankingUiSwift.framework"; sourceTree = "<group>"; };
|
||||||
36BCF87524BF114F005BEC29 /* UrlSessionWebClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UrlSessionWebClient.swift; sourceTree = "<group>"; };
|
36BCF87524BF114F005BEC29 /* UrlSessionWebClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UrlSessionWebClient.swift; sourceTree = "<group>"; };
|
||||||
36BCF87A24BFA87E005BEC29 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
|
|
||||||
36BCF87E24BFAA7F005BEC29 /* TestEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestEntity.swift; sourceTree = "<group>"; };
|
|
||||||
36BCF88024BFAB4A005BEC29 /* DependendTestEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DependendTestEntity.swift; sourceTree = "<group>"; };
|
|
||||||
36BCF88224C098BB005BEC29 /* BankListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankListItem.swift; sourceTree = "<group>"; };
|
36BCF88224C098BB005BEC29 /* BankListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankListItem.swift; sourceTree = "<group>"; };
|
||||||
36BCF88424C098C8005BEC29 /* BankAccountListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankAccountListItem.swift; sourceTree = "<group>"; };
|
36BCF88424C098C8005BEC29 /* BankAccountListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankAccountListItem.swift; sourceTree = "<group>"; };
|
||||||
36BCF88624C0A310005BEC29 /* PreviewData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewData.swift; sourceTree = "<group>"; };
|
36BCF88624C0A310005BEC29 /* PreviewData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewData.swift; sourceTree = "<group>"; };
|
||||||
|
@ -107,6 +104,9 @@
|
||||||
36BCF88A24C0BD2D005BEC29 /* AccountTransactionsDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountTransactionsDialog.swift; sourceTree = "<group>"; };
|
36BCF88A24C0BD2D005BEC29 /* AccountTransactionsDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountTransactionsDialog.swift; sourceTree = "<group>"; };
|
||||||
36BCF88C24C1C1EA005BEC29 /* TransferMoneyDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferMoneyDialog.swift; sourceTree = "<group>"; };
|
36BCF88C24C1C1EA005BEC29 /* TransferMoneyDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferMoneyDialog.swift; sourceTree = "<group>"; };
|
||||||
36BCF88E24C1DFF7005BEC29 /* SheetPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetPresenter.swift; sourceTree = "<group>"; };
|
36BCF88E24C1DFF7005BEC29 /* SheetPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetPresenter.swift; sourceTree = "<group>"; };
|
||||||
|
36BCF89024C25971005BEC29 /* CoreDataBankingPersistence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataBankingPersistence.swift; sourceTree = "<group>"; };
|
||||||
|
36BCF89224C25BC3005BEC29 /* Mapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Mapper.swift; sourceTree = "<group>"; };
|
||||||
|
36BCF89424C31F02005BEC29 /* AppData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppData.swift; sourceTree = "<group>"; };
|
||||||
36E7BA1324B3D05C00757859 /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = "<group>"; };
|
36E7BA1324B3D05C00757859 /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = "<group>"; };
|
||||||
36E7BA1824B9E70C00757859 /* xcode-frameworks */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "xcode-frameworks"; path = "../../tools/BankFinder/build/xcode-frameworks"; sourceTree = "<group>"; };
|
36E7BA1824B9E70C00757859 /* xcode-frameworks */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "xcode-frameworks"; path = "../../tools/BankFinder/build/xcode-frameworks"; sourceTree = "<group>"; };
|
||||||
36FC929824B39A05002B12E9 /* BankingiOSApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BankingiOSApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
36FC929824B39A05002B12E9 /* BankingiOSApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BankingiOSApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
@ -166,9 +166,9 @@
|
||||||
36BCF87924BFA679005BEC29 /* persistence */ = {
|
36BCF87924BFA679005BEC29 /* persistence */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
36BCF87A24BFA87E005BEC29 /* Extensions.swift */,
|
36BCF89024C25971005BEC29 /* CoreDataBankingPersistence.swift */,
|
||||||
36BCF87E24BFAA7F005BEC29 /* TestEntity.swift */,
|
36BCF89224C25BC3005BEC29 /* Mapper.swift */,
|
||||||
36BCF88024BFAB4A005BEC29 /* DependendTestEntity.swift */,
|
36BCF89424C31F02005BEC29 /* AppData.swift */,
|
||||||
);
|
);
|
||||||
path = persistence;
|
path = persistence;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -449,20 +449,20 @@
|
||||||
files = (
|
files = (
|
||||||
36FC92DC24B3A4A0002B12E9 /* AccountsTab.swift in Sources */,
|
36FC92DC24B3A4A0002B12E9 /* AccountsTab.swift in Sources */,
|
||||||
36BCF86E24BA691B005BEC29 /* DependencyInjector.swift in Sources */,
|
36BCF86E24BA691B005BEC29 /* DependencyInjector.swift in Sources */,
|
||||||
|
36BCF89124C25971005BEC29 /* CoreDataBankingPersistence.swift in Sources */,
|
||||||
36FC92A124B39A05002B12E9 /* BankingiOSApp.xcdatamodeld in Sources */,
|
36FC92A124B39A05002B12E9 /* BankingiOSApp.xcdatamodeld in Sources */,
|
||||||
|
36BCF89324C25BC3005BEC29 /* Mapper.swift in Sources */,
|
||||||
36FC92D724B3A3BA002B12E9 /* NSUrlWebClient.swift in Sources */,
|
36FC92D724B3A3BA002B12E9 /* NSUrlWebClient.swift in Sources */,
|
||||||
|
36BCF89524C31F02005BEC29 /* AppData.swift in Sources */,
|
||||||
36BCF88324C098BB005BEC29 /* BankListItem.swift in Sources */,
|
36BCF88324C098BB005BEC29 /* BankListItem.swift in Sources */,
|
||||||
36BCF87F24BFAA7F005BEC29 /* TestEntity.swift in Sources */,
|
|
||||||
36BCF88D24C1C1EA005BEC29 /* TransferMoneyDialog.swift in Sources */,
|
36BCF88D24C1C1EA005BEC29 /* TransferMoneyDialog.swift in Sources */,
|
||||||
36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */,
|
36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */,
|
||||||
36BCF88924C0A7D7005BEC29 /* Message.swift in Sources */,
|
36BCF88924C0A7D7005BEC29 /* Message.swift in Sources */,
|
||||||
36BCF86C24BA5E72005BEC29 /* DispatchQueueAsyncRunner.swift in Sources */,
|
36BCF86C24BA5E72005BEC29 /* DispatchQueueAsyncRunner.swift in Sources */,
|
||||||
36BCF88124BFAB4A005BEC29 /* DependendTestEntity.swift in Sources */,
|
|
||||||
36BCF86324BA5097005BEC29 /* SwiftUiRouter.swift in Sources */,
|
36BCF86324BA5097005BEC29 /* SwiftUiRouter.swift in Sources */,
|
||||||
36BCF88F24C1DFF7005BEC29 /* SheetPresenter.swift in Sources */,
|
36BCF88F24C1DFF7005BEC29 /* SheetPresenter.swift in Sources */,
|
||||||
36FC929C24B39A05002B12E9 /* AppDelegate.swift in Sources */,
|
36FC929C24B39A05002B12E9 /* AppDelegate.swift in Sources */,
|
||||||
36BCF88B24C0BD2D005BEC29 /* AccountTransactionsDialog.swift in Sources */,
|
36BCF88B24C0BD2D005BEC29 /* AccountTransactionsDialog.swift in Sources */,
|
||||||
36BCF87B24BFA87E005BEC29 /* Extensions.swift in Sources */,
|
|
||||||
36BCF87624BF114F005BEC29 /* UrlSessionWebClient.swift in Sources */,
|
36BCF87624BF114F005BEC29 /* UrlSessionWebClient.swift in Sources */,
|
||||||
36FC92A324B39A05002B12E9 /* ContentView.swift in Sources */,
|
36FC92A324B39A05002B12E9 /* ContentView.swift in Sources */,
|
||||||
36BCF88724C0A310005BEC29 /* PreviewData.swift in Sources */,
|
36BCF88724C0A310005BEC29 /* PreviewData.swift in Sources */,
|
||||||
|
|
|
@ -6,23 +6,26 @@ import BankingUiSwift
|
||||||
@UIApplicationMain
|
@UIApplicationMain
|
||||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
|
|
||||||
override init() {
|
|
||||||
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
|
setupDI()
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func setupDI() {
|
||||||
let appDataFolder = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.applicationSupportDirectory, .userDomainMask, true).first
|
let appDataFolder = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.applicationSupportDirectory, .userDomainMask, true).first
|
||||||
?? Bundle.main.resourceURL?.absoluteString ?? ""
|
?? Bundle.main.resourceURL?.absoluteString ?? ""
|
||||||
|
|
||||||
|
let persistence = CoreDataBankingPersistence(persistentContainer: self.persistentContainer)
|
||||||
|
|
||||||
let dataFolder = URL(fileURLWithPath: "data", isDirectory: true, relativeTo: URL(fileURLWithPath: appDataFolder))
|
let dataFolder = URL(fileURLWithPath: "data", isDirectory: true, relativeTo: URL(fileURLWithPath: appDataFolder))
|
||||||
|
|
||||||
let presenter = BankingPresenterSwift(dataFolder: dataFolder, router: SwiftUiRouter(), webClient: UrlSessionWebClient(), asyncRunner: DispatchQueueAsyncRunner())
|
let presenter = BankingPresenterSwift(dataFolder: dataFolder, router: SwiftUiRouter(), webClient: UrlSessionWebClient(), persistence: persistence, asyncRunner: DispatchQueueAsyncRunner())
|
||||||
|
|
||||||
DependencyInjector.register(dependency: presenter)
|
DependencyInjector.register(dependency: presenter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
|
||||||
// Override point for customization after application launch.
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: UISceneSession Lifecycle
|
// MARK: UISceneSession Lifecycle
|
||||||
|
|
||||||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||||
|
|
|
@ -1,4 +1,75 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="false" userDefinedModelVersionIdentifier="">
|
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="16119" systemVersion="19E287" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||||
<elements/>
|
<entity name="AccountTransaction" representedClassName="AccountTransaction" syncable="YES" codeGenerationType="class">
|
||||||
|
<attribute name="amount" attributeType="Decimal" defaultValueString="0.0"/>
|
||||||
|
<attribute name="bookingDate" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
|
<attribute name="bookingKey" attributeType="String"/>
|
||||||
|
<attribute name="bookingText" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="closingBalance" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
|
||||||
|
<attribute name="compensationAmount" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="creditorIdentifier" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="currency" attributeType="String"/>
|
||||||
|
<attribute name="currencyType" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="customerReference" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="deviantOriginator" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="deviantRecipient" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="endToEndReference" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="mandateReference" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="openingBalance" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
|
||||||
|
<attribute name="originalAmount" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="originatorsIdentificationCode" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="otherPartyAccountId" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="otherPartyBankCode" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="otherPartyName" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="primaNotaNumber" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="referenceForTheAccountOwner" attributeType="String"/>
|
||||||
|
<attribute name="referenceOfTheAccountServicingInstitution" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="relatedReferenceNumber" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="sepaUsage" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="sequenceNumber" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="statementNumber" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="supplementaryDetails" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="textKeySupplement" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="transactionReferenceNumber" attributeType="String"/>
|
||||||
|
<attribute name="unparsedUsage" attributeType="String"/>
|
||||||
|
<attribute name="usageWithNoSpecialType" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="valueDate" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
|
<relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="BankAccount" inverseName="transactions" inverseEntity="BankAccount"/>
|
||||||
|
</entity>
|
||||||
|
<entity name="BankAccount" representedClassName="BankAccount" syncable="YES" codeGenerationType="class">
|
||||||
|
<attribute name="accountHolderName" attributeType="String"/>
|
||||||
|
<attribute name="accountLimit" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="balance" attributeType="Decimal" defaultValueString="0.0"/>
|
||||||
|
<attribute name="currency" attributeType="String"/>
|
||||||
|
<attribute name="customerId" attributeType="String"/>
|
||||||
|
<attribute name="iban" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="identifier" attributeType="String"/>
|
||||||
|
<attribute name="lastRetrievedTransactionsTimestamp" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
|
<attribute name="productName" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="subAccountNumber" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="supportsInstantPaymentMoneyTransfer" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="supportsRetrievingAccountTransactions" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="supportsRetrievingBalance" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="supportsTransferringMoney" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="type" attributeType="String"/>
|
||||||
|
<relationship name="customer" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Customer" inverseName="accounts" inverseEntity="Customer"/>
|
||||||
|
<relationship name="transactions" toMany="YES" deletionRule="Cascade" destinationEntity="AccountTransaction" inverseName="account" inverseEntity="AccountTransaction"/>
|
||||||
|
</entity>
|
||||||
|
<entity name="Customer" representedClassName="Customer" syncable="YES" codeGenerationType="class">
|
||||||
|
<attribute name="bankCode" attributeType="String"/>
|
||||||
|
<attribute name="bankName" attributeType="String"/>
|
||||||
|
<attribute name="bic" attributeType="String"/>
|
||||||
|
<attribute name="customerId" attributeType="String"/>
|
||||||
|
<attribute name="customerName" attributeType="String"/>
|
||||||
|
<attribute name="finTsServerAddress" attributeType="String"/>
|
||||||
|
<attribute name="iconUrl" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="password" attributeType="String"/>
|
||||||
|
<attribute name="userId" attributeType="String"/>
|
||||||
|
<relationship name="accounts" toMany="YES" deletionRule="Cascade" destinationEntity="BankAccount" inverseName="customer" inverseEntity="BankAccount"/>
|
||||||
|
</entity>
|
||||||
|
<elements>
|
||||||
|
<element name="AccountTransaction" positionX="-36" positionY="45" width="128" height="553"/>
|
||||||
|
<element name="BankAccount" positionX="-54" positionY="63" width="128" height="28"/>
|
||||||
|
<element name="Customer" positionX="-63" positionY="-18" width="128" height="28"/>
|
||||||
|
</elements>
|
||||||
</model>
|
</model>
|
|
@ -0,0 +1,82 @@
|
||||||
|
import Foundation
|
||||||
|
import CoreData
|
||||||
|
import BankingUiSwift
|
||||||
|
|
||||||
|
|
||||||
|
class CoreDataBankingPersistence: BUCIBankingPersistence {
|
||||||
|
|
||||||
|
private let persistentContainer: NSPersistentContainer
|
||||||
|
|
||||||
|
private let mapper = Mapper()
|
||||||
|
|
||||||
|
private var context: NSManagedObjectContext {
|
||||||
|
return persistentContainer.viewContext
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
init(persistentContainer: NSPersistentContainer) {
|
||||||
|
self.persistentContainer = persistentContainer
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func saveOrUpdateAccount(customer: BUCCustomer, allCustomers: [BUCCustomer]) {
|
||||||
|
do {
|
||||||
|
let mapped = mapper.map(customer, context)
|
||||||
|
|
||||||
|
context.insert(mapped)
|
||||||
|
|
||||||
|
try context.save()
|
||||||
|
} catch {
|
||||||
|
print("Could not save Customer \(customer): \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func readPersistedAccounts_() -> [BUCCustomer] {
|
||||||
|
var customers: [Customer] = []
|
||||||
|
|
||||||
|
do {
|
||||||
|
let request: NSFetchRequest<Customer> = Customer.fetchRequest()
|
||||||
|
request.returnsObjectsAsFaults = false
|
||||||
|
|
||||||
|
try customers = context.fetch(request)
|
||||||
|
} catch {
|
||||||
|
NSLog("Could not request Customers: \(error)")
|
||||||
|
}
|
||||||
|
|
||||||
|
return customers.map( { mapper.map($0) } )
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteAccount(customer: BUCCustomer, allCustomers: [BUCCustomer]) {
|
||||||
|
do {
|
||||||
|
let mapped = mapper.map(customer, context)
|
||||||
|
|
||||||
|
context.delete(mapped)
|
||||||
|
|
||||||
|
try context.save()
|
||||||
|
} catch {
|
||||||
|
NSLog("Could not delete Customer \(customer): \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func saveOrUpdateAccountTransactions(bankAccount: BUCBankAccount, transactions: [BUCAccountTransaction]) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
func saveUrlToFile(url: String, file: URL) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func deleteAll() {
|
||||||
|
do {
|
||||||
|
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "Customer")
|
||||||
|
|
||||||
|
let deleteAll = NSBatchDeleteRequest(fetchRequest: request)
|
||||||
|
|
||||||
|
try context.execute(deleteAll)
|
||||||
|
} catch {
|
||||||
|
NSLog("Could not delete all Customers: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,227 @@
|
||||||
|
import Foundation
|
||||||
|
import CoreData
|
||||||
|
import BankingUiSwift
|
||||||
|
|
||||||
|
|
||||||
|
class Mapper {
|
||||||
|
|
||||||
|
func map(_ customer: Customer) -> BUCCustomer {
|
||||||
|
let mapped = BUCCustomer(bankCode: map(customer.bankCode), customerId: map(customer.customerId), password: map(customer.password), finTsServerAddress: map(customer.finTsServerAddress), bankName: map(customer.bankName), bic: map(customer.bic), customerName: map(customer.customerName), userId: map(customer.userId), iconUrl: customer.iconUrl, accounts: [])
|
||||||
|
|
||||||
|
mapped.accounts = map(mapped, customer.accounts as? Set<BankAccount>)
|
||||||
|
|
||||||
|
return mapped
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ customer: BUCCustomer, _ context: NSManagedObjectContext) -> Customer {
|
||||||
|
let mapped = Customer(context: context)
|
||||||
|
|
||||||
|
mapped.bankCode = customer.bankCode
|
||||||
|
mapped.customerId = customer.customerId
|
||||||
|
mapped.password = customer.password
|
||||||
|
mapped.finTsServerAddress = customer.finTsServerAddress
|
||||||
|
mapped.bankName = customer.bankName
|
||||||
|
mapped.bic = customer.bic
|
||||||
|
mapped.customerName = customer.customerName
|
||||||
|
mapped.userId = customer.userId
|
||||||
|
mapped.iconUrl = customer.iconUrl
|
||||||
|
|
||||||
|
mapped.accounts = NSSet(array: map(mapped, customer.accounts, context))
|
||||||
|
|
||||||
|
return mapped
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func map(_ customer: BUCCustomer, _ accounts: Set<BankAccount>?) -> [BUCBankAccount] {
|
||||||
|
return accounts?.map( { map(customer, $0) } ) ?? []
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ customer: BUCCustomer, _ account: BankAccount) -> BUCBankAccount {
|
||||||
|
let mapped = BUCBankAccount(customer: customer, identifier: map(account.identifier), accountHolderName: map(account.accountHolderName), iban: account.iban, subAccountNumber: account.subAccountNumber, customerId: map(account.customerId), balance: map(account.balance), currency: map(account.currency), type: map(account.type), productName: account.productName, accountLimit: account.accountLimit, lastRetrievedTransactionsTimestamp: map(account.lastRetrievedTransactionsTimestamp), supportsRetrievingAccountTransactions: account.supportsRetrievingAccountTransactions, supportsRetrievingBalance: account.supportsRetrievingBalance, supportsTransferringMoney: account.supportsTransferringMoney, supportsInstantPaymentMoneyTransfer: account.supportsInstantPaymentMoneyTransfer, bookedAccountTransactions: [])
|
||||||
|
|
||||||
|
mapped.bookedTransactions = map(mapped, account.transactions as? Set<AccountTransaction>)
|
||||||
|
|
||||||
|
return mapped
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ customer: Customer, _ accounts: [BUCBankAccount], _ context: NSManagedObjectContext) -> [BankAccount] {
|
||||||
|
return accounts.map( { map(customer, $0, context) } )
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ customer: Customer, _ account: BUCBankAccount, _ context: NSManagedObjectContext) -> BankAccount {
|
||||||
|
let mapped = BankAccount(context: context)
|
||||||
|
|
||||||
|
mapped.customer = customer
|
||||||
|
mapped.identifier = account.identifier
|
||||||
|
mapped.accountHolderName = account.accountHolderName
|
||||||
|
mapped.iban = account.iban
|
||||||
|
mapped.subAccountNumber = account.subAccountNumber
|
||||||
|
mapped.customerId = account.customerId
|
||||||
|
mapped.balance = account.balance.decimal
|
||||||
|
mapped.currency = account.currency
|
||||||
|
mapped.type = map(account.type)
|
||||||
|
mapped.productName = account.productName
|
||||||
|
mapped.accountLimit = account.accountLimit
|
||||||
|
mapped.lastRetrievedTransactionsTimestamp = account.lastRetrievedTransactionsTimestamp?.date
|
||||||
|
mapped.supportsRetrievingAccountTransactions = account.supportsRetrievingAccountTransactions
|
||||||
|
mapped.supportsRetrievingBalance = account.supportsRetrievingBalance
|
||||||
|
mapped.supportsTransferringMoney = account.supportsTransferringMoney
|
||||||
|
mapped.supportsInstantPaymentMoneyTransfer = account.supportsInstantPaymentMoneyTransfer
|
||||||
|
|
||||||
|
mapped.transactions = NSSet(array: map(mapped, account.bookedTransactions, context))
|
||||||
|
|
||||||
|
return mapped
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func map(_ type: BUCBankAccountType) -> String {
|
||||||
|
return type.name
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ type: String?) -> BUCBankAccountType {
|
||||||
|
switch type {
|
||||||
|
case BUCBankAccountType.girokonto.name:
|
||||||
|
return BUCBankAccountType.girokonto
|
||||||
|
case BUCBankAccountType.sparkonto.name:
|
||||||
|
return BUCBankAccountType.sparkonto
|
||||||
|
case BUCBankAccountType.festgeldkonto.name:
|
||||||
|
return BUCBankAccountType.festgeldkonto
|
||||||
|
case BUCBankAccountType.wertpapierdepot.name:
|
||||||
|
return BUCBankAccountType.wertpapierdepot
|
||||||
|
case BUCBankAccountType.darlehenskonto.name:
|
||||||
|
return BUCBankAccountType.darlehenskonto
|
||||||
|
case BUCBankAccountType.kreditkartenkonto.name:
|
||||||
|
return BUCBankAccountType.kreditkartenkonto
|
||||||
|
case BUCBankAccountType.fondsdepot.name:
|
||||||
|
return BUCBankAccountType.fondsdepot
|
||||||
|
case BUCBankAccountType.bausparvertrag.name:
|
||||||
|
return BUCBankAccountType.bausparvertrag
|
||||||
|
case BUCBankAccountType.versicherungsvertrag.name:
|
||||||
|
return BUCBankAccountType.versicherungsvertrag
|
||||||
|
case BUCBankAccountType.sonstige.name:
|
||||||
|
return BUCBankAccountType.sonstige
|
||||||
|
default:
|
||||||
|
return BUCBankAccountType.girokonto
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func map(_ account: BUCBankAccount, _ transactions: Set<AccountTransaction>?) -> [BUCAccountTransaction] {
|
||||||
|
return transactions?.map( {map(account, $0) } ) ?? []
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ account: BUCBankAccount, _ transaction: AccountTransaction) -> BUCAccountTransaction {
|
||||||
|
return BUCAccountTransaction(bankAccount: account, amount: map(transaction.amount), currency: map(transaction.currency), unparsedUsage: map(transaction.unparsedUsage), bookingDate: map(transaction.bookingDate), otherPartyName: transaction.otherPartyName, otherPartyBankCode: transaction.otherPartyBankCode, otherPartyAccountId: transaction.otherPartyAccountId, bookingText: transaction.bookingText, valueDate: map(transaction.valueDate), statementNumber: Int32(transaction.statementNumber), sequenceNumber: map(transaction.sequenceNumber), openingBalance: map(transaction.openingBalance), closingBalance: map(transaction.closingBalance), endToEndReference: transaction.endToEndReference, customerReference: transaction.customerReference, mandateReference: transaction.mandateReference, creditorIdentifier: transaction.creditorIdentifier, originatorsIdentificationCode: transaction.originatorsIdentificationCode, compensationAmount: transaction.compensationAmount, originalAmount: transaction.originalAmount, sepaUsage: transaction.sepaUsage, deviantOriginator: transaction.deviantOriginator, deviantRecipient: transaction.deviantRecipient, usageWithNoSpecialType: transaction.usageWithNoSpecialType, primaNotaNumber: transaction.primaNotaNumber, textKeySupplement: transaction.textKeySupplement, currencyType: transaction.currencyType, bookingKey: map(transaction.bookingKey), referenceForTheAccountOwner: map(transaction.referenceForTheAccountOwner), referenceOfTheAccountServicingInstitution: transaction.referenceOfTheAccountServicingInstitution, supplementaryDetails: transaction.supplementaryDetails, transactionReferenceNumber: map(transaction.transactionReferenceNumber), relatedReferenceNumber: transaction.relatedReferenceNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func map(_ account: BankAccount, _ transactions: [BUCAccountTransaction], _ context: NSManagedObjectContext) -> [AccountTransaction] {
|
||||||
|
return transactions.map( {map(account, $0, context) } )
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ account: BankAccount, _ transaction: BUCAccountTransaction, _ context: NSManagedObjectContext) -> AccountTransaction {
|
||||||
|
let mapped = AccountTransaction(context: context)
|
||||||
|
|
||||||
|
mapped.account = account
|
||||||
|
|
||||||
|
mapped.amount = map(transaction.amount)
|
||||||
|
mapped.currency = transaction.currency
|
||||||
|
mapped.unparsedUsage = transaction.unparsedUsage
|
||||||
|
mapped.bookingDate = map(transaction.bookingDate)
|
||||||
|
mapped.otherPartyName = transaction.otherPartyName
|
||||||
|
mapped.otherPartyBankCode = transaction.otherPartyBankCode
|
||||||
|
mapped.otherPartyAccountId = transaction.otherPartyAccountId
|
||||||
|
mapped.bookingText = transaction.bookingText
|
||||||
|
mapped.valueDate = map(transaction.valueDate)
|
||||||
|
|
||||||
|
mapped.statementNumber = transaction.statementNumber
|
||||||
|
mapped.sequenceNumber = map(transaction.sequenceNumber) ?? 0 // TODO: why doesn't it accept Int32? ?
|
||||||
|
mapped.openingBalance = mapOptional(transaction.openingBalance)
|
||||||
|
mapped.closingBalance = mapOptional(transaction.closingBalance)
|
||||||
|
|
||||||
|
mapped.endToEndReference = transaction.endToEndReference
|
||||||
|
mapped.customerReference = transaction.customerReference
|
||||||
|
mapped.mandateReference = transaction.mandateReference
|
||||||
|
mapped.creditorIdentifier = transaction.creditorIdentifier
|
||||||
|
mapped.originatorsIdentificationCode = transaction.originatorsIdentificationCode
|
||||||
|
mapped.compensationAmount = transaction.compensationAmount
|
||||||
|
mapped.originalAmount = transaction.originalAmount
|
||||||
|
mapped.sepaUsage = transaction.sepaUsage
|
||||||
|
mapped.deviantOriginator = transaction.deviantOriginator
|
||||||
|
mapped.deviantRecipient = transaction.deviantRecipient
|
||||||
|
mapped.usageWithNoSpecialType = transaction.usageWithNoSpecialType
|
||||||
|
mapped.primaNotaNumber = transaction.primaNotaNumber
|
||||||
|
mapped.textKeySupplement = transaction.textKeySupplement
|
||||||
|
|
||||||
|
mapped.currencyType = transaction.currencyType
|
||||||
|
mapped.bookingKey = transaction.bookingKey
|
||||||
|
mapped.referenceForTheAccountOwner = transaction.referenceForTheAccountOwner
|
||||||
|
mapped.referenceOfTheAccountServicingInstitution = transaction.referenceOfTheAccountServicingInstitution
|
||||||
|
mapped.supplementaryDetails = transaction.supplementaryDetails
|
||||||
|
|
||||||
|
mapped.transactionReferenceNumber = transaction.transactionReferenceNumber
|
||||||
|
mapped.relatedReferenceNumber = transaction.relatedReferenceNumber
|
||||||
|
|
||||||
|
return mapped
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func map(_ date: Date?) -> CommonDate {
|
||||||
|
if let date = date {
|
||||||
|
return CommonDate(date: date)
|
||||||
|
}
|
||||||
|
|
||||||
|
return CommonDate(millisSinceEpoch: 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ date: CommonDate) -> Date {
|
||||||
|
return date.date
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func map(_ decimal: NSDecimalNumber?) -> CommonBigDecimal {
|
||||||
|
if let decimal = decimal {
|
||||||
|
return map(decimal)
|
||||||
|
}
|
||||||
|
|
||||||
|
return CommonBigDecimal(double: 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ decimal: NSDecimalNumber) -> CommonBigDecimal {
|
||||||
|
return CommonBigDecimal(decimal_: decimal)
|
||||||
|
}
|
||||||
|
|
||||||
|
func mapOptional(_ decimal: CommonBigDecimal?) -> NSDecimalNumber? {
|
||||||
|
if let decimal = decimal {
|
||||||
|
return map(decimal)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ decimal: CommonBigDecimal) -> NSDecimalNumber {
|
||||||
|
return decimal.decimal
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func map(_ int: Int32?) -> KotlinInt? {
|
||||||
|
if let int = int {
|
||||||
|
return KotlinInt(int: int)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ int: KotlinInt?) -> Int32? {
|
||||||
|
if let int = int {
|
||||||
|
return Int32(int)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func map(_ string: String?) -> String {
|
||||||
|
return string ?? ""
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue