-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pages to see, import and delete scrips
- Loading branch information
1 parent
711a852
commit 86c89d8
Showing
17 changed files
with
2,031 additions
and
141 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import 'package:folio/helpers/database_actions.dart'; | ||
import 'package:folio/services/database/database.dart'; | ||
|
||
class Scrip { | ||
int stockID = -1; | ||
late String name; | ||
String? bseCode; | ||
String? nseCode; | ||
List<String> oldBSECodes = []; | ||
List<String> oldNSECodes = []; | ||
|
||
Scrip(this.name); | ||
|
||
Scrip.fromDbTuple(Map<String, dynamic> tuple) { | ||
stockID = tuple[Db.colRowID]; | ||
name = tuple[Db.colName]; | ||
bseCode = tuple[Db.colBSECode]; | ||
nseCode = tuple[Db.colNSECode]; | ||
oldBSECodes = | ||
tuple[Db.colOldBSECodes]?.split(DatabaseActions.delimiter) ?? []; | ||
oldNSECodes = | ||
tuple[Db.colOldNSECodes]?.split(DatabaseActions.delimiter) ?? []; | ||
oldBSECodes.remove(""); | ||
oldNSECodes.remove(""); | ||
} | ||
|
||
Map<String, dynamic> toDbTuple() { | ||
return { | ||
Db.colName: name, | ||
Db.colBSECode: bseCode, | ||
Db.colNSECode: nseCode, | ||
Db.colOldBSECodes: oldBSECodes.join(DatabaseActions.delimiter), | ||
Db.colOldNSECodes: oldNSECodes.join(DatabaseActions.delimiter), | ||
}; | ||
} | ||
|
||
String? code(String exchange) { | ||
switch (exchange) { | ||
case "BSE": | ||
return bseCode; | ||
case "NSE": | ||
return nseCode; | ||
} | ||
throw Exception("Wrong exchange passed to code() of ${this.toString()}"); | ||
} | ||
|
||
List<String> oldCodes(String exchange) { | ||
switch (exchange) { | ||
case "BSE": | ||
return oldBSECodes; | ||
case "NSE": | ||
return oldNSECodes; | ||
} | ||
throw Exception( | ||
"Wrong exchange passed to oldCodes() of ${this.toString()}"); | ||
} | ||
|
||
void setCode(String exchange, String? code) { | ||
switch (exchange) { | ||
case "BSE": | ||
bseCode = code; | ||
return; | ||
case "NSE": | ||
nseCode = code; | ||
return; | ||
} | ||
throw Exception("Wrong exchange passed to setCode() of ${this.toString()}"); | ||
} | ||
|
||
void setOldCodes(String exchange, List<String> oldCodes) { | ||
switch (exchange) { | ||
case "BSE": | ||
oldBSECodes = oldCodes; | ||
return; | ||
case "NSE": | ||
oldNSECodes = oldCodes; | ||
return; | ||
} | ||
throw Exception( | ||
"Wrong exchange passed to setOldCodes() of ${this.toString()}"); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
class FileLog { | ||
DateTime? date; | ||
int? stockID; | ||
String? name; | ||
String? bseCode; | ||
String? nseCode; | ||
|
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
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
Oops, something went wrong.