Merge branch 'master' into nfc-android
commit
e6e2b3516b
|
|
@ -392,7 +392,7 @@
|
|||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = 94BM6VL7L8;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
|
@ -531,7 +531,7 @@
|
|||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = 94BM6VL7L8;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
|
@ -563,7 +563,7 @@
|
|||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = 94BM6VL7L8;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
|
|
|||
|
|
@ -1,62 +1,79 @@
|
|||
//import 'dart:developer' as prefix0;
|
||||
import 'dart:convert';
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
// class SimpleLogPrinter extends LogPrinter {
|
||||
// static int counter = 0;
|
||||
// final String className;
|
||||
class SimpleLogPrinter extends LogPrinter {
|
||||
final String className;
|
||||
static final _deviceStackTraceRegex = RegExp(r'#[0-9]+[\s]+(.+) \(([^\s]+)\)');
|
||||
static final _webStackTraceRegex = RegExp(r'^((packages|dart-sdk)\/[^\s]+\/)');
|
||||
SimpleLogPrinter(this.className);
|
||||
|
||||
// SimpleLogPrinter(this.className);
|
||||
@override
|
||||
List<String> log(LogEvent event) {
|
||||
var level = event.level;
|
||||
var message = stringifyMessage(event.message);
|
||||
var error = event.error?.toString() ?? '';
|
||||
var color = PrettyPrinter.levelColors[level];
|
||||
var emoji = PrettyPrinter.levelEmojis[level];
|
||||
String stack;
|
||||
if (event.stackTrace == null) {
|
||||
stack = formatStackTrace(StackTrace.current, 2);
|
||||
} else {
|
||||
stack = formatStackTrace(event.stackTrace, 2);
|
||||
}
|
||||
print(color(' $emoji $message $error -> $stack '));
|
||||
return [];
|
||||
}
|
||||
|
||||
// @override
|
||||
// List<String> log(LogEvent event) {
|
||||
// prefix0.log(
|
||||
// event.message,
|
||||
// time: DateTime.now(),
|
||||
// level: () {
|
||||
// switch (event.level) {
|
||||
// case Level.verbose:
|
||||
// return 0;
|
||||
// case Level.debug:
|
||||
// return 500;
|
||||
// case Level.info:
|
||||
// return 0;
|
||||
// case Level.warning:
|
||||
// return 1500;
|
||||
// case Level.error:
|
||||
// return 2000;
|
||||
// case Level.wtf:
|
||||
// return 2000;
|
||||
// default:
|
||||
// return 2000;
|
||||
// }
|
||||
// }(),
|
||||
// name: className,
|
||||
// error: event.error,
|
||||
// sequenceNumber: counter += 1,
|
||||
// );
|
||||
// return [];
|
||||
// }
|
||||
// }
|
||||
String stringifyMessage(dynamic message) {
|
||||
if (message is Map || message is Iterable) {
|
||||
var encoder = JsonEncoder.withIndent(' ');
|
||||
return encoder.convert(message);
|
||||
} else {
|
||||
return message.toString();
|
||||
}
|
||||
}
|
||||
|
||||
// Logger getLogger(String className) {
|
||||
// //return Logger(printer: SimpleLogPrinter(className));
|
||||
// return Logger(
|
||||
// printer: PrettyPrinter(
|
||||
// methodCount: 1, // number of method calls to be displayed
|
||||
// errorMethodCount: 1, // number of method calls if stacktrace is provided
|
||||
// lineLength: 120, // width of the output
|
||||
// colors: true, // Colorful log messages
|
||||
// printEmojis: false, // Print an emoji for each log message
|
||||
// printTime: false // Should each log print contain a timestamp
|
||||
// ));
|
||||
// }
|
||||
String formatStackTrace(StackTrace stackTrace, int methodPosition) {
|
||||
var lines = stackTrace.toString().split('\n');
|
||||
var formatted = <String>[];
|
||||
var count = 0;
|
||||
for (var line in lines) {
|
||||
if (_discardDeviceStacktraceLine(line) ||
|
||||
_discardWebStacktraceLine(line)) {
|
||||
continue;
|
||||
}
|
||||
formatted.add('${line.replaceFirst(RegExp(r'#\d+\s+'), '')}');
|
||||
if (++count == methodPosition) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (formatted.isEmpty) {
|
||||
return null;
|
||||
} else {
|
||||
//return formatted.join('\n');
|
||||
return formatted.last;
|
||||
}
|
||||
}
|
||||
|
||||
bool _discardDeviceStacktraceLine(String line) {
|
||||
var match = _deviceStackTraceRegex.matchAsPrefix(line);
|
||||
if (match == null) {
|
||||
return false;
|
||||
}
|
||||
return match.group(2).startsWith('package:logger');
|
||||
}
|
||||
|
||||
bool _discardWebStacktraceLine(String line) {
|
||||
var match = _webStackTraceRegex.matchAsPrefix(line);
|
||||
if (match == null) {
|
||||
return false;
|
||||
}
|
||||
return match.group(1).startsWith('packages/logger') ||
|
||||
match.group(1).startsWith('dart-sdk/lib');
|
||||
}
|
||||
}
|
||||
|
||||
Logger getLogger(String className) {
|
||||
//return Logger(printer: SimpleLogPrinter(className));
|
||||
return Logger(
|
||||
printer: SimplePrinter(
|
||||
colors: true, // Colorful log messages
|
||||
printTime: false // Should each log print contain a timestamp
|
||||
));
|
||||
}
|
||||
return Logger(printer: SimpleLogPrinter(className));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,13 +102,20 @@ class DataService extends BaseService {
|
|||
* name,
|
||||
* type
|
||||
*/
|
||||
Future<void> insertVoucher({ @required User user, String data, String base64Data, @required String name, double total = 0.0, String type = VoucherTypePayment, String url }) {
|
||||
Future<void> insertVoucher(
|
||||
{@required User user,
|
||||
String data,
|
||||
String base64Data,
|
||||
@required String name,
|
||||
double total = 0.0,
|
||||
String type = VoucherTypePayment,
|
||||
String url}) {
|
||||
assert(user != null);
|
||||
assert(name != null);
|
||||
Voucher voucher = Voucher()
|
||||
..name=name
|
||||
..url=url
|
||||
..total = total
|
||||
..name = name
|
||||
..url = url
|
||||
..total = total
|
||||
..appCompanyId = user.appCompanyId
|
||||
..kassaId = user.kassaId
|
||||
..data = data
|
||||
|
|
@ -141,13 +148,13 @@ class DataService extends BaseService {
|
|||
data = jsonEncode(checkData.toJson());
|
||||
}
|
||||
|
||||
log.i('token: $token');
|
||||
log.i('data: $data');
|
||||
// log.i('token: $token');
|
||||
// log.i('data: $data');
|
||||
Response<dynamic> response = await (operationType == OperationTypePay
|
||||
? _api.sell(token, data)
|
||||
: _api.sellReturn(token, data));
|
||||
log.i('response status: ${response.status}');
|
||||
log.i('response operation: ${response.operation}');
|
||||
// log.i('response status: ${response.status}');
|
||||
// log.i('response operation: ${response.operation}');
|
||||
if (response.status == 200 && response.operation == true) {
|
||||
User user = Redux.store.state.userState.user;
|
||||
String check = response?.body['check'];
|
||||
|
|
@ -155,19 +162,21 @@ class DataService extends BaseService {
|
|||
String url = response?.body['link'];
|
||||
int checkNum = journal['check_num'];
|
||||
var summ = journal['summ'];
|
||||
double total = summ!= null ? double.parse(summ.toString()) : 0.0;
|
||||
double total = summ != null ? double.parse(summ.toString()) : 0.0;
|
||||
this.insertVoucher(
|
||||
user: user,
|
||||
name: 'Чек №$checkNum',
|
||||
data: data ,
|
||||
base64Data: check,
|
||||
total: total,
|
||||
url: url,
|
||||
type: operationType == OperationTypeReturn ? VoucherTypeReturnPay : VoucherTypePayment );
|
||||
user: user,
|
||||
name: 'Чек №$checkNum',
|
||||
data: data,
|
||||
base64Data: check,
|
||||
total: total,
|
||||
url: url,
|
||||
type: operationType == OperationTypeReturn
|
||||
? VoucherTypeReturnPay
|
||||
: VoucherTypePayment);
|
||||
}
|
||||
return response;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
} catch (e, stack) {
|
||||
log.e("sellOrReturn", e, stack);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -191,33 +200,44 @@ class DataService extends BaseService {
|
|||
try {
|
||||
String token = user.token;
|
||||
Response<dynamic> goods = await _api.getGoodsFromServer(token);
|
||||
if(goods.operation==false){
|
||||
log.w('session is closed');
|
||||
return false;
|
||||
}
|
||||
Response<dynamic> categories = await _api.getCategoryFromServer(token);
|
||||
Response<dynamic> services = await _api.getServiceFromServer(token);
|
||||
await _db.deleteAll(Goog_tableName);
|
||||
await _db.deleteAll(Category_tableName);
|
||||
await _db.deleteAll(Service_tableName);
|
||||
log.i('All tables cleaned');
|
||||
for (var key in goods.body.keys) {
|
||||
Good row = Good.fromJson(goods.body[key]);
|
||||
await _db.insert(Goog_tableName, row.toMap());
|
||||
}
|
||||
log.i('Inserted ${goods.body.length} to table $Goog_tableName');
|
||||
|
||||
for (var el in categories.body) {
|
||||
Category row = Category.fromJson(el);
|
||||
await _db.insert(Category_tableName, row.toMap());
|
||||
}
|
||||
log.i('Inserted ${categories.body.length} to table $Category_tableName');
|
||||
|
||||
for (var key in services.body.keys) {
|
||||
Service row = Service.fromJson(services.body[key]);
|
||||
await _db.insert(Service_tableName, row.toMap());
|
||||
if (goods.body.isNotEmpty) {
|
||||
for (var key in goods.body.keys) {
|
||||
Good row = Good.fromJson(goods.body[key]);
|
||||
await _db.insert(Goog_tableName, row.toMap());
|
||||
}
|
||||
log.i('Inserted ${goods.body.length} to table $Goog_tableName');
|
||||
}
|
||||
if (categories.body.isNotEmpty) {
|
||||
for (var el in categories.body) {
|
||||
Category row = Category.fromJson(el);
|
||||
await _db.insert(Category_tableName, row.toMap());
|
||||
}
|
||||
log.i(
|
||||
'Inserted ${categories.body.length} to table $Category_tableName');
|
||||
}
|
||||
log.i('Inserted ${services.body.length} to table $Service_tableName');
|
||||
|
||||
if (services.body.isNotEmpty) {
|
||||
for (var key in services.body.keys) {
|
||||
Service row = Service.fromJson(services.body[key]);
|
||||
await _db.insert(Service_tableName, row.toMap());
|
||||
}
|
||||
log.i('Inserted ${services.body?.length} to table $Service_tableName');
|
||||
}
|
||||
return true;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
} catch (e, stack) {
|
||||
log.e("load from server", e, stack);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import 'package:aman_kassa_flutter/core/services/dialog_service.dart';
|
|||
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
||||
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||
import 'package:aman_kassa_flutter/shared/ui_helpers.dart';
|
||||
import 'package:aman_kassa_flutter/widgets/fields/busy_button.dart';
|
||||
import 'package:aman_kassa_flutter/widgets/fields/busy_button_icon.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||
import 'package:aman_kassa_flutter/shared/shared_styles.dart';
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// A button that shows a busy indicator in place of title
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ packages:
|
|||
name: http
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.1"
|
||||
version: "0.12.2"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
name: aman_kassa_flutter
|
||||
description: A new Flutter project.
|
||||
version: 1.0.1+21
|
||||
version: 1.0.3+23
|
||||
environment:
|
||||
sdk: '>=2.3.0 <3.0.0'
|
||||
dependencies:
|
||||
|
|
@ -17,7 +17,7 @@ dependencies:
|
|||
logger: ^0.9.1
|
||||
get_it: ^4.0.2
|
||||
equatable: ^1.2.2
|
||||
http: ^0.12.1
|
||||
http: ^0.12.2
|
||||
sqflite: ^1.3.1
|
||||
path_provider: ^1.6.11
|
||||
google_fonts: ^1.1.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue