step 27 : fix homescreen, report timestamp, filter history transaksi

This commit is contained in:
sindhu
2024-01-18 14:18:25 +07:00
parent 7986d68560
commit 60919d6d12
11 changed files with 220 additions and 184 deletions

View File

@@ -13,7 +13,7 @@ class Constant {
// static String version = "1.00";
// NOTE VERSI HARUS SAMA DENGAN PUBSPEC.YAML
static String version = "1.0.0";
static String version = "1.1.0";
// static String baseUrl = "https://devregonline.pramita.co.id/one-api/xdoc/";

View File

@@ -12,6 +12,7 @@ class HistoryTransaksiModel {
String? tanggalconfirm;
String? usertransaksi;
String? userconfirm;
String? tanggalcreated;
HistoryTransaksiModel(
{this.id,
@@ -26,7 +27,9 @@ class HistoryTransaksiModel {
this.isconfirm,
this.tanggalconfirm,
this.usertransaksi,
this.userconfirm});
this.userconfirm,
this.tanggalcreated
});
HistoryTransaksiModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
@@ -42,6 +45,7 @@ class HistoryTransaksiModel {
tanggalconfirm = json['tanggalconfirm'];
usertransaksi = json['usertransaksi'];
userconfirm = json['userconfirm'];
tanggalcreated = json['tanggalcreated'];
}
Map<String, dynamic> toJson() {
@@ -59,6 +63,7 @@ class HistoryTransaksiModel {
data['tanggalconfirm'] = this.tanggalconfirm;
data['usertransaksi'] = this.usertransaksi;
data['userconfirm'] = this.userconfirm;
data['tanggalcreated'] = this.tanggalcreated;
return data;
}
}

View File

@@ -12,21 +12,24 @@ class ListTransaksiHomeModel {
String? tanggalconfirm;
String? usertransaksi;
String? userconfirm;
String? tanggalcreated;
ListTransaksiHomeModel(
{this.id,
this.tanggaltransaksi,
this.tipe,
this.kategoriid,
this.kategoriname,
this.note,
this.amount,
this.sender,
this.imgurl,
this.isconfirm,
this.tanggalconfirm,
this.usertransaksi,
this.userconfirm});
ListTransaksiHomeModel({
this.id,
this.tanggaltransaksi,
this.tipe,
this.kategoriid,
this.kategoriname,
this.note,
this.amount,
this.sender,
this.imgurl,
this.isconfirm,
this.tanggalconfirm,
this.usertransaksi,
this.userconfirm,
this.tanggalcreated,
});
ListTransaksiHomeModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
@@ -42,6 +45,7 @@ class ListTransaksiHomeModel {
tanggalconfirm = json['tanggalconfirm'];
usertransaksi = json['usertransaksi'];
userconfirm = json['userconfirm'];
tanggalcreated = json['tanggalcreated'];
}
Map<String, dynamic> toJson() {
@@ -59,6 +63,7 @@ class ListTransaksiHomeModel {
data['tanggalconfirm'] = this.tanggalconfirm;
data['usertransaksi'] = this.usertransaksi;
data['userconfirm'] = this.userconfirm;
data['tanggalcreated'] = this.tanggalcreated;
return data;
}
}
}

View File

@@ -139,7 +139,7 @@ class TransaksiRepository extends BaseRepository {
String categoryid,
) async {
final service =
"${Constant.baseUrlDevone}/homescreen/list_transaction/?companyid=$companyid&startdate=$tglAwal&enddate=$tglAkhir&kategoriid=$categoryid";
"${Constant.baseUrlDevone}/history/list_transaction/?companyid=$companyid&startdate=$tglAwal&enddate=$tglAkhir&kategoriid=$categoryid";
// https://devone.aplikasi.web.id/one-api-pettycash/pettycash/history/list_transaction/?companyid=1&startdate=2023-12-01&enddate=2023-12-30&kategoriid=0
final resp = await get(
// param: {

View File

@@ -5,6 +5,7 @@ import 'package:app_petty_cash/screen/home/list_transaksi_home_provider.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../app/constant.dart';
@@ -140,6 +141,25 @@ class HomeScreen extends HookConsumerWidget {
},
);
String formatDateString(String inputDate) {
try {
// Parsing tanggal dari string input
DateTime date =
DateFormat('dd-MM-yyyy HH:mm:ss', 'id').parse(inputDate);
// Format tanggal ke '30 Des 2023'
String formattedDate =
DateFormat('dd MMM yyyy HH:mm:ss', 'id').format(date);
return formattedDate;
} catch (e) {
// Tangkap kesalahan jika format tanggal tidak sesuai
print('Error parsing date: $e');
// return 'Format Tanggal Salah';
return inputDate;
}
}
return Padding(
padding: EdgeInsets.only(
top: Constant.getActualYPhone(context: context, y: 30),
@@ -400,6 +420,60 @@ class HomeScreen extends HookConsumerWidget {
.value[idx].tipe
.toString(),
),
SizedBox(
height: Constant.getActualYPhone(
context: context, y: 10),
),
// catatan
Align(
alignment: Alignment.centerLeft,
child: Text(
listTransaksiHome.value[idx].note
.toString(),
style: Constant.body1(
context: context)
.copyWith(
fontWeight: FontWeight.w600,
color: Constant.textBlack,
),
),
),
SizedBox(
height: Constant.getActualYPhone(
context: context, y: 10),
),
// Tanggal Created align right
Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
Text(
'created : ' +
formatDateString(
listTransaksiHome
.value[idx]
.tanggalcreated
.toString(),
),
overflow:
TextOverflow.ellipsis,
style: Constant.body1(
context: context)
.copyWith(
fontWeight:
FontWeight.normal,
fontStyle: FontStyle.italic,
color: Constant.textBlack,
fontSize: 14,
),
),
],
),
],
),
),

View File

@@ -31,6 +31,10 @@ class ReportScreen extends HookConsumerWidget {
final tglAkhirTmp = useState<String>("");
String M_CompanyID = "0";
String timeStamp = DateFormat('dd-MM-yyyy').format(
DateTime.now(),
);
Future<String> getCompanyID() async {
final shared = await SharedPreferences.getInstance();
String M_CompanyID = "0";
@@ -328,8 +332,9 @@ class ReportScreen extends HookConsumerWidget {
),
onPressed: () async {
M_CompanyID = await getCompanyID();
if(M_CompanyID == "0"){
SanckbarWidget(context, 'Invalid Company', snackbarType.error);
if (M_CompanyID == "0") {
SanckbarWidget(
context, 'Invalid Company', snackbarType.error);
return;
}
// Awal
@@ -343,13 +348,13 @@ class ReportScreen extends HookConsumerWidget {
// Akhir
DateTime parsedDateAkhir =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
ctrlTglAkhir.value.text.toString(),
);
String formattedDateAkhir =
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
String url =
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=xls&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20";
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=xls&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20&tm=$timeStamp";
if (!await launchUrl(Uri.parse(url))) {
// throw Exception('Could not launch $url');
SanckbarWidget(context, 'Could not launch $url',
@@ -406,8 +411,9 @@ class ReportScreen extends HookConsumerWidget {
),
onPressed: () async {
M_CompanyID = await getCompanyID();
if(M_CompanyID == "0"){
SanckbarWidget(context, 'Invalid Company', snackbarType.error);
if (M_CompanyID == "0") {
SanckbarWidget(
context, 'Invalid Company', snackbarType.error);
return;
}
// Awal
@@ -421,13 +427,15 @@ class ReportScreen extends HookConsumerWidget {
// Akhir
DateTime parsedDateAkhir =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
ctrlTglAkhir.value.text.toString(),
);
String formattedDateAkhir =
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
String url =
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20";
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20&tm=$timeStamp";
print(url);
if (!await launchUrl(Uri.parse(url))) {
// throw Exception('Could not launch $url');
SanckbarWidget(context, 'Could not launch $url',

View File

@@ -464,6 +464,25 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
final FocusNode focusNodetglAkhir = useFocusNode();
final tglAkhirHasFocus = useState(false);
String formatDateString(String inputDate) {
try {
// Parsing tanggal dari string input
DateTime date =
DateFormat('dd-MM-yyyy HH:mm:ss', 'id').parse(inputDate);
// Format tanggal ke '30 Des 2023'
String formattedDate =
DateFormat('dd MMM yyyy HH:mm:ss', 'id').format(date);
return formattedDate;
} catch (e) {
// Tangkap kesalahan jika format tanggal tidak sesuai
print('Error parsing date: $e');
// return 'Format Tanggal Salah';
return inputDate;
}
}
return GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: Padding(
@@ -736,6 +755,7 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
value: option,
child: Text(
option.categoryname ?? "",
overflow: TextOverflow.ellipsis,
style: Constant.body1(context: context)
.copyWith(
color: Constant.textBlack,
@@ -875,13 +895,27 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
],
),
onPressed: () async {
DateTime parsedDate =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
);
String formattedDateAwal =
DateFormat('yyyy-MM-dd').format(parsedDate);
DateTime parsedDateAkhir =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAkhir.value.text.toString(),
);
String formattedDateAkhir = DateFormat('yyyy-MM-dd')
.format(parsedDateAkhir);
M_CompanyID.value = await getCompanyID();
ref
.read(searchHistoryTransaksiProvider.notifier)
.searchHistoryTransaksi(
M_CompanyID.value,
ctrlTglAwal.text,
ctrlTglAkhir.text,
formattedDateAwal,
formattedDateAkhir,
selectedListCategory.value.categoryid ?? "0",
);
},
@@ -1080,7 +1114,27 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
// ),
SizedBox(
height: Constant.getActualYPhone(
context: context, y: 6),
context: context, y: 10),
),
// catatan
Align(
alignment: Alignment.centerLeft,
child: Text(
listSearchHistory.value[idx].note
.toString(),
style: Constant.body1(
context: context)
.copyWith(
fontWeight: FontWeight.w600,
color: Constant.textBlack,
),
),
),
SizedBox(
height: Constant.getActualYPhone(
context: context, y: 10),
),
if (listSearchHistory
@@ -1308,70 +1362,32 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
),
],
),
// Row(
// children: [
// Container(
// width: Constant.getActualXPhone(
// context: context, x: 40),
// height: Constant.getActualYPhone(
// context: context,
// y: 40,
// ),
// child: Image.asset(
// "images/icon_delete.png",
// // scale: 1,
// ),
// ),
// SizedBox(
// height: Constant.getActualYPhone(
// context: context, y: 12),
// ),
// Expanded(
// child: ElevatedButton(
// style: ButtonStyle(
// backgroundColor: MaterialStateColor
// .resolveWith((st) => Constant
// .pcBtnBackgroundColor),
// shape:
// MaterialStateProperty.all<
// RoundedRectangleBorder>(
// RoundedRectangleBorder(
// borderRadius:
// BorderRadius.circular(
// 8),
// side: BorderSide(
// color: Constant
// .pcBtnBackgroundColor,
// ),
// ),
// ),
// shadowColor:
// MaterialStateProperty.all(
// Color(0xffff48423d)),
// elevation:
// MaterialStateProperty.all(
// 4.0),
// ),
// child: Stack(
// children: [
// Text(
// 'Confirmed',
// style: Constant.body1(
// context: context)
// .copyWith(
// fontWeight:
// FontWeight
// .w600,
// color: Constant
// .white),
// ),
// ],
// ),
// onPressed: () {},
// ),
// ),
// ],
// ),
// Tanggal Created align right
Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
Text(
'created : ' +
formatDateString(
listSearchHistory
.value[idx]
.tanggalcreated
.toString(),
),
overflow: TextOverflow.ellipsis,
style: Constant.body1(
context: context)
.copyWith(
fontWeight: FontWeight.normal,
fontStyle: FontStyle.italic,
color: Constant.textBlack,
fontSize: 14,
),
),
],
),
],
),
),

View File

@@ -39,6 +39,7 @@ class TransaksiSelectKategoriWidget extends StatelessWidget {
value: option,
child: Text(
option.categoryname ?? "",
overflow: TextOverflow.ellipsis,
style: Constant.body1(context: context).copyWith(
color: Constant.textBlack, fontWeight: FontWeight.w400),
),

View File

@@ -211,71 +211,6 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
Radius.circular(8.0),
),
),
// child: Text('s'),
// child: FutureBuilder<Widget>(
// future: checkFileExistence(
// 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg',
// ),
// builder: (context, snapshot) {
// // if (snapshot.connectionState == ConnectionState.waiting) {
// // // return CircularProgressIndicator();
// // return Text('');
// // } else if (snapshot.hasError) {
// // return Icon(
// // Icons.error,
// // color: Colors.red,
// // );
// // } else {
// // return snapshot.data ?? Container();
// // }
// if (snapshot.connectionState == ConnectionState.done) {
// return snapshot.data ?? Container();
// } else if (snapshot.hasError) {
// return Icon(
// Icons.error,
// color: Colors.red,
// );
// } else {
// return Text('');
// }
// },
// ),
// child: Consumer(
// builder: (context, watch, child) {
// String iconUrl =
// 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg';
// final iconAsyncValue = ref.read(
// iconProvider(
// iconUrl,
// ),
// );
// return iconAsyncValue.when(
// loading: () {
// print('loading iconurl : $iconUrl');
// return CircularProgressIndicator();
// },
// error: (error, stackTrace) {
// print('error iconurl : $iconUrl');
// return Icon(
// Icons.error,
// color: Colors.red,
// );
// },
// data: (iconWidget) {
// print('data iconurl : $iconUrl');
// return iconWidget ?? Container();
// }
// );
// },
// ),
// child: SvgPicture.network(
// 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg',
// semanticsLabel: 'Icon pizza',
// ),
child: getIconUrl(icon_category_id),
),

View File

@@ -85,10 +85,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
url: "https://pub.dev"
source: hosted
version: "1.18.0"
version: "1.17.1"
convert:
dependency: transitive
description:
@@ -436,26 +436,26 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.15"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.2.0"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.9.1"
mime:
dependency: "direct main"
description:
@@ -689,18 +689,18 @@ packages:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.9.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
url: "https://pub.dev"
source: hosted
version: "1.11.1"
version: "1.11.0"
state_notifier:
dependency: transitive
description:
@@ -713,10 +713,10 @@ packages:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.1"
string_scanner:
dependency: transitive
description:
@@ -737,10 +737,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.5.1"
top_snackbar_flutter:
dependency: "direct main"
description:
@@ -893,14 +893,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.17"
web:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.3.0"
win32:
dependency: transitive
description:
@@ -934,5 +926,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.2.0-194.0.dev <4.0.0"
dart: ">=3.0.6 <4.0.0"
flutter: ">=3.10.0"

View File

@@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
version: 1.1.0
environment:
sdk: '>=3.0.6 <4.0.0'