-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.nero.vyapar.di | ||
|
||
import android.app.Application | ||
import androidx.room.Room | ||
import com.nero.vyapar.local.database.VyaparDatabase | ||
import com.nero.vyapar.repository.ItemsRepository | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
class AppModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun provideDataBase( | ||
app: Application | ||
): VyaparDatabase { | ||
return Room.databaseBuilder(app, VyaparDatabase::class.java, "VyaparDatabase") | ||
.fallbackToDestructiveMigration().build() | ||
} | ||
|
||
|
||
@Provides | ||
@Singleton | ||
fun provideItemRepository( | ||
database: VyaparDatabase | ||
): ItemsRepository { | ||
return ItemsRepository(database.getDAO()) | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.nero.vyapar.di | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class MyApplication : Application() { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.nero.vyapar.local.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import com.nero.vyapar.local.entity.ItemsEntity | ||
import com.nero.vyapar.local.entity.PartyEntity | ||
import com.nero.vyapar.local.entity.TransactionEntity | ||
|
||
@Dao | ||
interface VyaparDAO { | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
fun insertItem(itemsEntity: ItemsEntity) | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
fun insertParty(partyEntity: PartyEntity) | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
fun insertTransaction(transactionEntity: TransactionEntity) | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.nero.vyapar.local.database | ||
|
||
import androidx.room.Database | ||
import androidx.room.RoomDatabase | ||
import com.nero.vyapar.local.dao.VyaparDAO | ||
import com.nero.vyapar.local.entity.ItemsEntity | ||
import com.nero.vyapar.local.entity.PartyEntity | ||
import com.nero.vyapar.local.entity.TransactionEntity | ||
|
||
@Database( | ||
entities = [ItemsEntity::class, PartyEntity::class, TransactionEntity::class], | ||
version = 1 | ||
) | ||
abstract class VyaparDatabase : RoomDatabase() { | ||
abstract fun getDAO(): VyaparDAO | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.nero.vyapar.local.entity | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "ItemsTable") | ||
data class ItemsEntity( | ||
@ColumnInfo(name = "itemName") var name: String?, | ||
@ColumnInfo(name = "type") var type: String?, | ||
@ColumnInfo(name = "itemCode") var itemCode: String?, | ||
@ColumnInfo(name = "sacCode") var sacCode: String?, | ||
@ColumnInfo(name = "salePrice") var salePrice: Long?, | ||
@ColumnInfo(name = "purchasePrice") var purchasePrice: Long?, | ||
@ColumnInfo(name = "taxRate") var taxRate: Float?, | ||
) { | ||
@ColumnInfo(name = "id") | ||
@PrimaryKey(autoGenerate = true) | ||
var id: Int? = null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.nero.vyapar.local.entity | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "partyTable") | ||
data class PartyEntity( | ||
@ColumnInfo(name = "partyName") var partyName: String?, | ||
@ColumnInfo(name = "partyContactNumber") var partyContactNumber: String?, | ||
@ColumnInfo(name = "partyBillingAddress") var partyBillingAddress: String?, | ||
|
||
) { | ||
@ColumnInfo(name = "id") | ||
@PrimaryKey(autoGenerate = true) | ||
var id: Int? = null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.nero.vyapar.local.entity | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "transactionsTable") | ||
data class TransactionEntity( | ||
@ColumnInfo(name = "billNo") var billNo: Int?, | ||
@ColumnInfo(name = "type") var type: String?, | ||
@ColumnInfo(name = "partyName") var partyName: String?, | ||
@ColumnInfo(name = "billedItemNames") var billedItemNames: String?, | ||
@ColumnInfo(name = "billedItemQuantity") var billedItemQuantity: String?, | ||
@ColumnInfo(name = "paidAmt") var paidAmt: Long?, | ||
) { | ||
@ColumnInfo(name = "id") | ||
@PrimaryKey(autoGenerate = true) | ||
var id: Int? = null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.nero.vyapar.presentation.componenets | ||
|
||
/*import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxHeight | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.material.Card | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.nero.vyapar.local.entity.ItemsEntity*/ | ||
|
||
|
||
/* | ||
@Composable | ||
fun ItemCard(itemEntity: ItemsEntity) { | ||
Card(modifier = Modifier.height(65.dp)) { | ||
Column(modifier = Modifier.fillMaxHeight()) { | ||
Text( | ||
text = "A day wandering through the sandhills " + | ||
"in Shark Fin Cove, and a few of the " + | ||
"sights I saw", | ||
) | ||
} | ||
} | ||
} | ||
*/ | ||
|
||
/* | ||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewGreeting() { | ||
ItemCard(ItemsEntity("cola", "product", "dfs", "dfs", 21, 80, 0.3f)) | ||
}*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.nero.vyapar.repository | ||
|
||
import com.nero.vyapar.local.dao.VyaparDAO | ||
|
||
class ItemsRepository(databaseDao: VyaparDAO) { | ||
val data = "sda" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.nero.vyapar | ||
|
||
import androidx.lifecycle.ViewModel | ||
import com.nero.vyapar.local.database.VyaparDatabase | ||
import com.nero.vyapar.repository.ItemsRepository | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class viewmodel @Inject constructor( | ||
database: ItemsRepository | ||
) : ViewModel() { | ||
|
||
val data = database.data | ||
|
||
} |