add suppliers and distributors

This commit is contained in:
Patrick Alvin Alcala 2025-04-22 11:11:59 +08:00
parent 9cf3934f6f
commit 77fae74302
11 changed files with 426 additions and 33 deletions

View file

@ -0,0 +1,41 @@
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:uuid/uuid.dart';
class RefDistributors {
final SupabaseClient _supabase = Supabase.instance.client;
Future<List> getList() async {
try {
final data = await _supabase
.from('ref_distributors')
.select('distributor_name, distributor_address')
.order('distributor_name', ascending: true);
return data.toList();
} catch (e) {
return [];
}
}
Future<String> getUUID(String name) async {
try {
final data =
await _supabase.from('ref_distributors').select('ref_distributors_uuid').eq('distributor_name', name);
return data.first['ref_distributors_uuid'].toString();
} catch (e) {
return '';
}
}
Future<bool> postDistributor(String name, String address) async {
try {
final genericUUID = Uuid().v4();
await _supabase
.from('ref_distributors')
.insert({'ref_distributors_uuid': genericUUID, 'distributor_name': name, 'distributor_address': address});
return true;
} catch (e) {
return false;
}
}
}

View file

@ -86,14 +86,17 @@ class RefMedicines {
}
}
Future<bool> postMedicine(String uuid, String name, String muuid, String guuid, String tuuid, String barcode) async {
Future<bool> postMedicine(String uuid, String name, String muuid, String guuid, String tuuid, String barcode,
String distributor, String supplier) async {
final medicine = {
'ref_medicines_uuid': uuid,
'medicine_name': name,
'ref_manufacturers_uuid': muuid,
'ref_generic_names_uuid': guuid,
'ref_types_uuid': tuuid,
'barcode': barcode
'barcode': barcode,
'ref_distributors_uuid': distributor,
'ref_suppliers_uuid': supplier
};
try {

View file

@ -0,0 +1,36 @@
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:uuid/uuid.dart';
class RefSuppliers {
final SupabaseClient _supabase = Supabase.instance.client;
Future<List> getList() async {
try {
final data =
await _supabase.from('ref_suppliers').select('supplier_name').order('supplier_name', ascending: true);
return data.toList();
} catch (e) {
return [];
}
}
Future<String> getUUID(String name) async {
try {
final data = await _supabase.from('ref_suppliers').select('ref_suppliers_uuid').eq('supplier_name', name);
return data.first['ref_suppliers_uuid'].toString();
} catch (e) {
return '';
}
}
Future<bool> postSupplier(String name) async {
try {
final genericUUID = Uuid().v4();
await _supabase.from('ref_suppliers').insert({'ref_suppliers_uuid': genericUUID, 'supplier_name': name});
return true;
} catch (e) {
return false;
}
}
}