Skip to content

Commit

Permalink
added serialised name for json export/import
Browse files Browse the repository at this point in the history
  • Loading branch information
suyash01 committed May 11, 2024
1 parent b940d7f commit 8cda855
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 34 deletions.
8 changes: 5 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
kotlin("plugin.serialization")
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.gms.google-services")
id("com.google.dagger.hilt.android")
id("com.google.devtools.ksp")
id("androidx.room")
Expand All @@ -16,8 +15,8 @@ android {
applicationId = "com.suyash.creditmanager"
minSdk = 26
targetSdk = 34
versionCode = 12
versionName = "1.0.11"
versionCode = 13
versionName = "1.0.12"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -26,6 +25,9 @@ android {
}

buildTypes {
debug {
applicationIdSuffix = ".debug"
}
release {
isMinifyEnabled = true
proguardFiles(
Expand Down
29 changes: 0 additions & 29 deletions app/google-services.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.work.WorkManager
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import com.google.gson.Gson
import com.google.gson.annotations.SerializedName
import com.suyash.creditmanager.R
import com.suyash.creditmanager.domain.model.CreditCard
import com.suyash.creditmanager.domain.model.EMI
Expand Down Expand Up @@ -75,6 +76,7 @@ class BackupWorker @AssistedInject constructor(
}
Result.success()
} catch (e: Exception) {
e.printStackTrace()
Result.failure()
} finally {
setNotificationEnd(
Expand Down Expand Up @@ -109,9 +111,13 @@ class BackupWorker @AssistedInject constructor(
}

data class BackupData(
@SerializedName("creditCards")
val creditCards: List<CreditCard>,
@SerializedName("emis")
val emis: List<EMI>,
@SerializedName("transactions")
val transactions: List<Transaction>,
@SerializedName("txnCategories")
val txnCategories: List<TxnCategory>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@ package com.suyash.creditmanager.domain.model

import androidx.room.Entity
import androidx.room.PrimaryKey
import com.google.gson.annotations.SerializedName
import com.suyash.creditmanager.domain.util.CardType

@Entity(tableName = "credit_cards")
data class CreditCard(
@SerializedName("cardName")
var cardName: String,
@SerializedName("last4Digits")
var last4Digits: String,
@SerializedName("expiryDate")
var expiryDate: String,
@SerializedName("billDate")
var billDate: Int,
@SerializedName("dueDate")
var dueDate: Int,
@SerializedName("cardType")
var cardType: CardType,
@SerializedName("limit")
var limit: Int = 0,
@SerializedName("bankName")
var bankName: String?,
@SerializedName("id")
@PrimaryKey(autoGenerate = true)
var id: Int = 0
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@ package com.suyash.creditmanager.domain.model
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.TypeConverters
import com.google.gson.annotations.SerializedName
import java.time.LocalDate

@Entity(
tableName = "emis"
)
@TypeConverters(Converters::class)
data class EMI(
@SerializedName("name")
val name: String,
@SerializedName("amount")
val amount: Float,
@SerializedName("rate")
val rate: Float,
@SerializedName("months")
val months: Int,
@SerializedName("card")
val card: Int?,
@SerializedName("date")
val date: LocalDate,
@SerializedName("taxRate")
val taxRate: Float?,
@SerializedName("id")
@PrimaryKey(autoGenerate = true)
var id: Int = 0
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import androidx.room.TypeConverters
import com.google.gson.annotations.SerializedName
import com.suyash.creditmanager.domain.util.TransactionType
import java.time.LocalDate

Expand All @@ -13,11 +14,17 @@ import java.time.LocalDate
)
@TypeConverters(Converters::class)
data class Transaction(
@SerializedName("type")
val type: TransactionType,
@SerializedName("amount")
val amount: Float,
@SerializedName("card")
val card: Int,
@SerializedName("date")
val date: LocalDate,
@SerializedName("category")
val category: String?,
@SerializedName("id")
@PrimaryKey(autoGenerate = true)
var id: Int = 0
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ package com.suyash.creditmanager.domain.model

import androidx.room.Entity
import androidx.room.PrimaryKey
import com.google.gson.annotations.SerializedName
import com.suyash.creditmanager.domain.util.TransactionType

@Entity(
tableName = "txn_categories"
)
data class TxnCategory(
@SerializedName("type")
val type: TransactionType,
@SerializedName("name")
val name: String,
@SerializedName("id")
@PrimaryKey(autoGenerate = true)
var id: Int = 0
)
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
buildscript {
dependencies {
classpath("com.google.gms:google-services:4.4.1")
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.4.0" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
id("com.google.gms.google-services") version "4.4.0" apply false
id("com.google.dagger.hilt.android") version "2.49" apply false
id("com.google.devtools.ksp") version "1.9.0-1.0.12" apply false
id("androidx.room") version "2.6.1" apply false
Expand Down

0 comments on commit 8cda855

Please sign in to comment.