fix macos pdf
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||
import 'package:flux/features/settings/document_sequence/data/document_sequence_repository.dart';
|
||||
import 'package:flux/features/settings/document_sequence/models/document_sequence_model.dart';
|
||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
class TicketRepository {
|
||||
final SupabaseClient _supabase = GetIt.I.get<SupabaseClient>();
|
||||
final DocumentSequenceRepository _documentSequenceRepository = GetIt.I
|
||||
.get<DocumentSequenceRepository>();
|
||||
|
||||
TicketRepository();
|
||||
|
||||
@@ -192,29 +196,29 @@ class TicketRepository {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> generateTicketReference(String companyId) async {
|
||||
final response = await Supabase.instance.client.rpc(
|
||||
'get_next_document_number',
|
||||
params: {'p_company_id': companyId, 'p_doc_type': 'ticket'},
|
||||
);
|
||||
// Future<String> generateTicketReference(String companyId) async {
|
||||
// final response = await Supabase.instance.client.rpc(
|
||||
// 'get_next_document_number',
|
||||
// params: {'p_company_id': companyId, 'p_doc_type': 'ticket'},
|
||||
// );
|
||||
|
||||
// Estraiamo i dati dal JSON
|
||||
final int nextValue = response['next_value'];
|
||||
final String prefix = response['prefix'] ?? '';
|
||||
// // Estraiamo i dati dal JSON
|
||||
// final int nextValue = response['next_value'];
|
||||
// final String prefix = response['prefix'] ?? '';
|
||||
|
||||
final year = DateTime.now().year; // 2026
|
||||
// final year = DateTime.now().year; // 2026
|
||||
|
||||
// Formattazione con zeri iniziali (es. 000125)
|
||||
final paddedNumber = nextValue.toString().padLeft(6, '0');
|
||||
// // Formattazione con zeri iniziali (es. 000125)
|
||||
// final paddedNumber = nextValue.toString().padLeft(6, '0');
|
||||
|
||||
// Costruiamo la stringa. Se c'è un prefisso mette "TCK-2026-000125",
|
||||
// altrimenti solo "2026-000125"
|
||||
if (prefix.isNotEmpty) {
|
||||
return '$prefix-$year-$paddedNumber';
|
||||
} else {
|
||||
return '$year-$paddedNumber';
|
||||
}
|
||||
}
|
||||
// // Costruiamo la stringa. Se c'è un prefisso mette "TCK-2026-000125",
|
||||
// // altrimenti solo "2026-000125"
|
||||
// if (prefix.isNotEmpty) {
|
||||
// return '$prefix-$year-$paddedNumber';
|
||||
// } else {
|
||||
// return '$year-$paddedNumber';
|
||||
// }
|
||||
// }
|
||||
|
||||
/// Salva il ticket
|
||||
Future<TicketModel> insertTicket(TicketModel ticket) async {
|
||||
@@ -223,7 +227,9 @@ class TicketRepository {
|
||||
}
|
||||
try {
|
||||
final ticketToSave = ticket.copyWith(
|
||||
referenceId: await generateTicketReference(ticket.companyId),
|
||||
referenceId: await _documentSequenceRepository.getNextDocumentNumber(
|
||||
DocumentType.ticket.name,
|
||||
),
|
||||
);
|
||||
final response = await _supabase
|
||||
.from(_tableName)
|
||||
|
||||
Reference in New Issue
Block a user