Created with <3 with dartpad.dev.
Created
January 29, 2024 08:49
-
-
Save ANNASBlackHat/66fd1a4fc06ce3606dccb1d0264769bf to your computer and use it in GitHub Desktop.
Generate Display Nota
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
import 'dart:math'; | |
String generateDisplayNota(int? adminId, int? outletId, int salesCount) { | |
var nota = StringBuffer(); | |
try { | |
var id = (outletId ?? 0) + (adminId ?? 1); | |
var words = [ | |
"A", | |
"P", | |
"L", | |
"I", | |
"K", | |
"U", | |
"N", | |
"Q", | |
"D", | |
"E" | |
]; | |
id.toString().split("").forEach((element) { | |
if (isNumeric(element)) { | |
nota.write(words[int.parse(element)]); | |
} | |
}); | |
var now = DateTime.now(); | |
nota.write(now.year); | |
nota.write(now.month.toString().padLeft(2, '0')); | |
nota.write(now.day.toString().padLeft(2, '0')); | |
nota.write(salesCount + 1); | |
} catch (e) { | |
print('Generate Display Nota error: $e'); | |
} | |
return nota.toString(); | |
} | |
bool isNumeric(String str) { | |
if(int.tryParse(str) != null || double.tryParse(str) != null) { | |
return true; | |
} | |
return false; | |
} | |
void main() { | |
print('Display Nota: ${generateDisplayNota(1, 10, 45)}'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment