-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from suyash01/feature/emi
emi functionality
- Loading branch information
Showing
40 changed files
with
1,132 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
186 changes: 186 additions & 0 deletions
186
app/schemas/com.suyash.creditmanager.data.source.CreditDatabase/3.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 3, | ||
"identityHash": "efabf04763a0c05c6fa15fce67ac3c32", | ||
"entities": [ | ||
{ | ||
"tableName": "credit_cards", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cardName` TEXT NOT NULL, `last4Digits` TEXT NOT NULL, `expiryDate` TEXT NOT NULL, `billDate` INTEGER NOT NULL, `dueDate` INTEGER NOT NULL, `cardType` TEXT NOT NULL, `limit` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "cardName", | ||
"columnName": "cardName", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "last4Digits", | ||
"columnName": "last4Digits", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "expiryDate", | ||
"columnName": "expiryDate", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "billDate", | ||
"columnName": "billDate", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "dueDate", | ||
"columnName": "dueDate", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "cardType", | ||
"columnName": "cardType", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "limit", | ||
"columnName": "limit", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": true, | ||
"columnNames": [ | ||
"id" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "transactions", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`type` TEXT NOT NULL, `amount` REAL NOT NULL, `card` INTEGER NOT NULL, `date` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "type", | ||
"columnName": "type", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "amount", | ||
"columnName": "amount", | ||
"affinity": "REAL", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "card", | ||
"columnName": "card", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "date", | ||
"columnName": "date", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": true, | ||
"columnNames": [ | ||
"id" | ||
] | ||
}, | ||
"indices": [ | ||
{ | ||
"name": "index_transactions_date", | ||
"unique": false, | ||
"columnNames": [ | ||
"date" | ||
], | ||
"orders": [], | ||
"createSql": "CREATE INDEX IF NOT EXISTS `index_transactions_date` ON `${TABLE_NAME}` (`date`)" | ||
} | ||
], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "emis", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `amount` REAL NOT NULL, `rate` REAL NOT NULL, `months` INTEGER NOT NULL, `card` INTEGER, `date` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "name", | ||
"columnName": "name", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "amount", | ||
"columnName": "amount", | ||
"affinity": "REAL", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "rate", | ||
"columnName": "rate", | ||
"affinity": "REAL", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "months", | ||
"columnName": "months", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "card", | ||
"columnName": "card", | ||
"affinity": "INTEGER", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "date", | ||
"columnName": "date", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": true, | ||
"columnNames": [ | ||
"id" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
} | ||
], | ||
"views": [], | ||
"setupQueries": [ | ||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", | ||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'efabf04763a0c05c6fa15fce67ac3c32')" | ||
] | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/suyash/creditmanager/data/repository/EMIRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.suyash.creditmanager.data.repository | ||
|
||
import com.suyash.creditmanager.data.source.dao.EMIDao | ||
import com.suyash.creditmanager.domain.model.EMI | ||
import com.suyash.creditmanager.domain.repository.EMIRepository | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
class EMIRepositoryImpl(private val dao: EMIDao): EMIRepository { | ||
override suspend fun upsertEMI(emi: EMI) { | ||
dao.upsertEMI(emi) | ||
} | ||
|
||
override suspend fun deleteEMI(emi: EMI) { | ||
dao.deleteEMI(emi) | ||
} | ||
|
||
override fun getEMIs(): Flow<List<EMI>> { | ||
return dao.getEMIs() | ||
} | ||
|
||
override suspend fun getEMI(id: Int): EMI? { | ||
return dao.getEMI(id) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/suyash/creditmanager/data/source/dao/EMIDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.suyash.creditmanager.data.source.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Delete | ||
import androidx.room.Query | ||
import androidx.room.Upsert | ||
import com.suyash.creditmanager.domain.model.EMI | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
@Dao | ||
interface EMIDao { | ||
@Upsert | ||
suspend fun upsertEMI(emi: EMI) | ||
|
||
@Delete | ||
suspend fun deleteEMI(emi: EMI) | ||
|
||
@Query("SELECT * FROM emis") | ||
fun getEMIs(): Flow<List<EMI>> | ||
|
||
@Query("SELECT * FROM emis WHERE id = :id") | ||
suspend fun getEMI(id: Int): EMI? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/suyash/creditmanager/domain/model/EMI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.suyash.creditmanager.domain.model | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import androidx.room.TypeConverters | ||
import java.time.LocalDate | ||
|
||
@Entity( | ||
tableName = "emis" | ||
) | ||
@TypeConverters(Converters::class) | ||
data class EMI( | ||
val name: String, | ||
val amount: Float, | ||
val rate: Float, | ||
val months: Int, | ||
val card: Int?, | ||
val date: LocalDate, | ||
@PrimaryKey(autoGenerate = true) | ||
val id: Int = 0 | ||
) | ||
|
||
class InvalidEMIException(message: String): Exception(message) |
Oops, something went wrong.