step 23 : home screen, repository, provider
This commit is contained in:
61
app_petty_cash/lib/repository/home_repository.dart
Normal file
61
app_petty_cash/lib/repository/home_repository.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:app_petty_cash/model/list_type_model.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
import '../model/info_account_balance.dart';
|
||||
import '../model/list_transaksi_model.dart';
|
||||
import 'base_repository.dart';
|
||||
|
||||
class HomeRepository extends BaseRepository {
|
||||
HomeRepository({required super.dio});
|
||||
|
||||
// list transaksi home
|
||||
Future<List<ListTransaksiHomeModel>> getTransaksiListHome(
|
||||
String companyid,
|
||||
) async {
|
||||
final service =
|
||||
"${Constant.baseUrlDevone}homescreen/list_transaction/?companyid=$companyid";
|
||||
final resp = await get(
|
||||
// param: {
|
||||
// "": "",
|
||||
// },
|
||||
service: service,
|
||||
);
|
||||
|
||||
print("url list transaksi home : $service");
|
||||
|
||||
final result = List<ListTransaksiHomeModel>.empty(growable: true);
|
||||
resp['data'].forEach((e) {
|
||||
final model = ListTransaksiHomeModel.fromJson(e);
|
||||
result.add(model);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// info account balance
|
||||
Future<InfoAccountBalanceModel> getInfoAccountBalance(
|
||||
String companyid,
|
||||
) async {
|
||||
final service =
|
||||
"${Constant.baseUrlDevone}homescreen/list_total/?companyid=$companyid";
|
||||
final resp = await get(
|
||||
// param: {
|
||||
// "": "",
|
||||
// },
|
||||
service: service,
|
||||
);
|
||||
|
||||
print("url card info account balance home : $service");
|
||||
|
||||
InfoAccountBalanceModel result = InfoAccountBalanceModel(
|
||||
debit: "0",
|
||||
kredit: "0",
|
||||
totalAll: "0",
|
||||
);
|
||||
|
||||
print(resp['data']);
|
||||
|
||||
final model = InfoAccountBalanceModel.fromJson(resp['data']);
|
||||
result = model;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user