Merge pull request 'dev' (#17) from dev into main
Reviewed-on: #17
This commit was merged in pull request #17.
This commit is contained in:
@@ -29,6 +29,8 @@ import java.nio.file.Paths;
|
|||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.Year;
|
import java.time.Year;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.format.FormatStyle;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -53,6 +55,9 @@ public class CustomQuoteRequestController {
|
|||||||
@Value("${app.mail.contact-request.admin.address:infog@3d-fab.ch}")
|
@Value("${app.mail.contact-request.admin.address:infog@3d-fab.ch}")
|
||||||
private String contactRequestAdminMailAddress;
|
private String contactRequestAdminMailAddress;
|
||||||
|
|
||||||
|
@Value("${app.mail.contact-request.customer.enabled:true}")
|
||||||
|
private boolean contactRequestCustomerMailEnabled;
|
||||||
|
|
||||||
// TODO: Inject Storage Service
|
// TODO: Inject Storage Service
|
||||||
private static final Path STORAGE_ROOT = Paths.get("storage_requests").toAbsolutePath().normalize();
|
private static final Path STORAGE_ROOT = Paths.get("storage_requests").toAbsolutePath().normalize();
|
||||||
private static final Pattern SAFE_EXTENSION_PATTERN = Pattern.compile("^[a-z0-9]{1,10}$");
|
private static final Pattern SAFE_EXTENSION_PATTERN = Pattern.compile("^[a-z0-9]{1,10}$");
|
||||||
@@ -97,6 +102,7 @@ public class CustomQuoteRequestController {
|
|||||||
"Accettazione Termini e Privacy obbligatoria."
|
"Accettazione Termini e Privacy obbligatoria."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
String language = normalizeLanguage(requestDto.getLanguage());
|
||||||
|
|
||||||
// 1. Create Request
|
// 1. Create Request
|
||||||
CustomQuoteRequest request = new CustomQuoteRequest();
|
CustomQuoteRequest request = new CustomQuoteRequest();
|
||||||
@@ -173,6 +179,7 @@ public class CustomQuoteRequestController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendAdminContactRequestNotification(request, attachmentsCount);
|
sendAdminContactRequestNotification(request, attachmentsCount);
|
||||||
|
sendCustomerContactRequestConfirmation(request, attachmentsCount, language);
|
||||||
|
|
||||||
return ResponseEntity.ok(request);
|
return ResponseEntity.ok(request);
|
||||||
}
|
}
|
||||||
@@ -258,6 +265,252 @@ public class CustomQuoteRequestController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendCustomerContactRequestConfirmation(CustomQuoteRequest request, int attachmentsCount, String language) {
|
||||||
|
if (!contactRequestCustomerMailEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (request.getEmail() == null || request.getEmail().isBlank()) {
|
||||||
|
logger.warn("Contact request confirmation skipped: missing customer email for request {}", request.getId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> templateData = new HashMap<>();
|
||||||
|
templateData.put("requestId", request.getId());
|
||||||
|
templateData.put(
|
||||||
|
"createdAt",
|
||||||
|
request.getCreatedAt().format(
|
||||||
|
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(localeForLanguage(language))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
templateData.put("recipientName", resolveRecipientName(request, language));
|
||||||
|
templateData.put("requestType", localizeRequestType(request.getRequestType(), language));
|
||||||
|
templateData.put("customerType", localizeCustomerType(request.getCustomerType(), language));
|
||||||
|
templateData.put("name", safeValue(request.getName()));
|
||||||
|
templateData.put("companyName", safeValue(request.getCompanyName()));
|
||||||
|
templateData.put("contactPerson", safeValue(request.getContactPerson()));
|
||||||
|
templateData.put("email", safeValue(request.getEmail()));
|
||||||
|
templateData.put("phone", safeValue(request.getPhone()));
|
||||||
|
templateData.put("message", safeValue(request.getMessage()));
|
||||||
|
templateData.put("attachmentsCount", attachmentsCount);
|
||||||
|
templateData.put("currentYear", Year.now().getValue());
|
||||||
|
String subject = applyCustomerContactRequestTexts(templateData, language, request.getId());
|
||||||
|
|
||||||
|
emailNotificationService.sendEmail(
|
||||||
|
request.getEmail(),
|
||||||
|
subject,
|
||||||
|
"contact-request-customer",
|
||||||
|
templateData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String applyCustomerContactRequestTexts(
|
||||||
|
Map<String, Object> templateData,
|
||||||
|
String language,
|
||||||
|
UUID requestId
|
||||||
|
) {
|
||||||
|
return switch (language) {
|
||||||
|
case "en" -> {
|
||||||
|
templateData.put("emailTitle", "Contact request received");
|
||||||
|
templateData.put("headlineText", "We received your contact request");
|
||||||
|
templateData.put("greetingText", "Hi " + templateData.get("recipientName") + ",");
|
||||||
|
templateData.put("introText", "Thank you for contacting us. Our team will reply as soon as possible.");
|
||||||
|
templateData.put("requestIdHintText", "Please keep this request ID for future order references:");
|
||||||
|
templateData.put("detailsTitleText", "Request details");
|
||||||
|
templateData.put("labelRequestId", "Request ID");
|
||||||
|
templateData.put("labelDate", "Date");
|
||||||
|
templateData.put("labelRequestType", "Request type");
|
||||||
|
templateData.put("labelCustomerType", "Customer type");
|
||||||
|
templateData.put("labelName", "Name");
|
||||||
|
templateData.put("labelCompany", "Company");
|
||||||
|
templateData.put("labelContactPerson", "Contact person");
|
||||||
|
templateData.put("labelEmail", "Email");
|
||||||
|
templateData.put("labelPhone", "Phone");
|
||||||
|
templateData.put("labelMessage", "Message");
|
||||||
|
templateData.put("labelAttachments", "Attachments");
|
||||||
|
templateData.put("supportText", "If you need help, reply to this email.");
|
||||||
|
templateData.put("footerText", "Automated request-receipt confirmation from 3D-Fab.");
|
||||||
|
yield "We received your contact request #" + requestId + " - 3D-Fab";
|
||||||
|
}
|
||||||
|
case "de" -> {
|
||||||
|
templateData.put("emailTitle", "Kontaktanfrage erhalten");
|
||||||
|
templateData.put("headlineText", "Wir haben Ihre Kontaktanfrage erhalten");
|
||||||
|
templateData.put("greetingText", "Hallo " + templateData.get("recipientName") + ",");
|
||||||
|
templateData.put("introText", "Vielen Dank fuer Ihre Anfrage. Unser Team antwortet Ihnen so schnell wie moeglich.");
|
||||||
|
templateData.put("requestIdHintText", "Bitte speichern Sie diese Anfrage-ID fuer zukuenftige Bestellreferenzen:");
|
||||||
|
templateData.put("detailsTitleText", "Anfragedetails");
|
||||||
|
templateData.put("labelRequestId", "Anfrage-ID");
|
||||||
|
templateData.put("labelDate", "Datum");
|
||||||
|
templateData.put("labelRequestType", "Anfragetyp");
|
||||||
|
templateData.put("labelCustomerType", "Kundentyp");
|
||||||
|
templateData.put("labelName", "Name");
|
||||||
|
templateData.put("labelCompany", "Firma");
|
||||||
|
templateData.put("labelContactPerson", "Kontaktperson");
|
||||||
|
templateData.put("labelEmail", "E-Mail");
|
||||||
|
templateData.put("labelPhone", "Telefon");
|
||||||
|
templateData.put("labelMessage", "Nachricht");
|
||||||
|
templateData.put("labelAttachments", "Anhaenge");
|
||||||
|
templateData.put("supportText", "Wenn Sie Hilfe brauchen, antworten Sie auf diese E-Mail.");
|
||||||
|
templateData.put("footerText", "Automatische Bestaetigung des Anfrageeingangs von 3D-Fab.");
|
||||||
|
yield "Wir haben Ihre Kontaktanfrage erhalten #" + requestId + " - 3D-Fab";
|
||||||
|
}
|
||||||
|
case "fr" -> {
|
||||||
|
templateData.put("emailTitle", "Demande de contact recue");
|
||||||
|
templateData.put("headlineText", "Nous avons recu votre demande de contact");
|
||||||
|
templateData.put("greetingText", "Bonjour " + templateData.get("recipientName") + ",");
|
||||||
|
templateData.put("introText", "Merci pour votre message. Notre equipe vous repondra des que possible.");
|
||||||
|
templateData.put("requestIdHintText", "Veuillez conserver cet ID de demande pour vos futures references de commande :");
|
||||||
|
templateData.put("detailsTitleText", "Details de la demande");
|
||||||
|
templateData.put("labelRequestId", "ID de demande");
|
||||||
|
templateData.put("labelDate", "Date");
|
||||||
|
templateData.put("labelRequestType", "Type de demande");
|
||||||
|
templateData.put("labelCustomerType", "Type de client");
|
||||||
|
templateData.put("labelName", "Nom");
|
||||||
|
templateData.put("labelCompany", "Entreprise");
|
||||||
|
templateData.put("labelContactPerson", "Contact");
|
||||||
|
templateData.put("labelEmail", "Email");
|
||||||
|
templateData.put("labelPhone", "Telephone");
|
||||||
|
templateData.put("labelMessage", "Message");
|
||||||
|
templateData.put("labelAttachments", "Pieces jointes");
|
||||||
|
templateData.put("supportText", "Si vous avez besoin d'aide, repondez a cet email.");
|
||||||
|
templateData.put("footerText", "Confirmation automatique de reception de demande par 3D-Fab.");
|
||||||
|
yield "Nous avons recu votre demande de contact #" + requestId + " - 3D-Fab";
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
templateData.put("emailTitle", "Richiesta di contatto ricevuta");
|
||||||
|
templateData.put("headlineText", "Abbiamo ricevuto la tua richiesta di contatto");
|
||||||
|
templateData.put("greetingText", "Ciao " + templateData.get("recipientName") + ",");
|
||||||
|
templateData.put("introText", "Grazie per averci contattato. Il nostro team ti rispondera' il prima possibile.");
|
||||||
|
templateData.put("requestIdHintText", "Conserva questo ID richiesta per i futuri riferimenti d'ordine:");
|
||||||
|
templateData.put("detailsTitleText", "Dettagli richiesta");
|
||||||
|
templateData.put("labelRequestId", "ID richiesta");
|
||||||
|
templateData.put("labelDate", "Data");
|
||||||
|
templateData.put("labelRequestType", "Tipo richiesta");
|
||||||
|
templateData.put("labelCustomerType", "Tipo cliente");
|
||||||
|
templateData.put("labelName", "Nome");
|
||||||
|
templateData.put("labelCompany", "Azienda");
|
||||||
|
templateData.put("labelContactPerson", "Contatto");
|
||||||
|
templateData.put("labelEmail", "Email");
|
||||||
|
templateData.put("labelPhone", "Telefono");
|
||||||
|
templateData.put("labelMessage", "Messaggio");
|
||||||
|
templateData.put("labelAttachments", "Allegati");
|
||||||
|
templateData.put("supportText", "Se hai bisogno, rispondi direttamente a questa email.");
|
||||||
|
templateData.put("footerText", "Conferma automatica di ricezione richiesta da 3D-Fab.");
|
||||||
|
yield "Abbiamo ricevuto la tua richiesta di contatto #" + requestId + " - 3D-Fab";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String localizeRequestType(String requestType, String language) {
|
||||||
|
if (requestType == null || requestType.isBlank()) {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
String normalized = requestType.trim().toLowerCase(Locale.ROOT);
|
||||||
|
return switch (language) {
|
||||||
|
case "en" -> switch (normalized) {
|
||||||
|
case "custom", "print_service" -> "Custom part request";
|
||||||
|
case "series" -> "Series production request";
|
||||||
|
case "consult", "design_service" -> "Consultation request";
|
||||||
|
case "question" -> "General question";
|
||||||
|
default -> requestType;
|
||||||
|
};
|
||||||
|
case "de" -> switch (normalized) {
|
||||||
|
case "custom", "print_service" -> "Anfrage fuer Einzelteil";
|
||||||
|
case "series" -> "Anfrage fuer Serienproduktion";
|
||||||
|
case "consult", "design_service" -> "Beratungsanfrage";
|
||||||
|
case "question" -> "Allgemeine Frage";
|
||||||
|
default -> requestType;
|
||||||
|
};
|
||||||
|
case "fr" -> switch (normalized) {
|
||||||
|
case "custom", "print_service" -> "Demande de piece personnalisee";
|
||||||
|
case "series" -> "Demande de production en serie";
|
||||||
|
case "consult", "design_service" -> "Demande de conseil";
|
||||||
|
case "question" -> "Question generale";
|
||||||
|
default -> requestType;
|
||||||
|
};
|
||||||
|
default -> switch (normalized) {
|
||||||
|
case "custom", "print_service" -> "Richiesta pezzo personalizzato";
|
||||||
|
case "series" -> "Richiesta produzione in serie";
|
||||||
|
case "consult", "design_service" -> "Richiesta consulenza";
|
||||||
|
case "question" -> "Domanda generale";
|
||||||
|
default -> requestType;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String localizeCustomerType(String customerType, String language) {
|
||||||
|
if (customerType == null || customerType.isBlank()) {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
String normalized = customerType.trim().toLowerCase(Locale.ROOT);
|
||||||
|
return switch (language) {
|
||||||
|
case "en" -> switch (normalized) {
|
||||||
|
case "private" -> "Private";
|
||||||
|
case "business" -> "Business";
|
||||||
|
default -> customerType;
|
||||||
|
};
|
||||||
|
case "de" -> switch (normalized) {
|
||||||
|
case "private" -> "Privat";
|
||||||
|
case "business" -> "Unternehmen";
|
||||||
|
default -> customerType;
|
||||||
|
};
|
||||||
|
case "fr" -> switch (normalized) {
|
||||||
|
case "private" -> "Prive";
|
||||||
|
case "business" -> "Entreprise";
|
||||||
|
default -> customerType;
|
||||||
|
};
|
||||||
|
default -> switch (normalized) {
|
||||||
|
case "private" -> "Privato";
|
||||||
|
case "business" -> "Azienda";
|
||||||
|
default -> customerType;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private Locale localeForLanguage(String language) {
|
||||||
|
return switch (language) {
|
||||||
|
case "en" -> Locale.ENGLISH;
|
||||||
|
case "de" -> Locale.GERMAN;
|
||||||
|
case "fr" -> Locale.FRENCH;
|
||||||
|
default -> Locale.ITALIAN;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalizeLanguage(String language) {
|
||||||
|
if (language == null || language.isBlank()) {
|
||||||
|
return "it";
|
||||||
|
}
|
||||||
|
String normalized = language.toLowerCase(Locale.ROOT).trim();
|
||||||
|
if (normalized.startsWith("en")) {
|
||||||
|
return "en";
|
||||||
|
}
|
||||||
|
if (normalized.startsWith("de")) {
|
||||||
|
return "de";
|
||||||
|
}
|
||||||
|
if (normalized.startsWith("fr")) {
|
||||||
|
return "fr";
|
||||||
|
}
|
||||||
|
return "it";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveRecipientName(CustomQuoteRequest request, String language) {
|
||||||
|
if (request.getName() != null && !request.getName().isBlank()) {
|
||||||
|
return request.getName().trim();
|
||||||
|
}
|
||||||
|
if (request.getContactPerson() != null && !request.getContactPerson().isBlank()) {
|
||||||
|
return request.getContactPerson().trim();
|
||||||
|
}
|
||||||
|
if (request.getCompanyName() != null && !request.getCompanyName().isBlank()) {
|
||||||
|
return request.getCompanyName().trim();
|
||||||
|
}
|
||||||
|
return switch (language) {
|
||||||
|
case "en" -> "customer";
|
||||||
|
case "de" -> "Kunde";
|
||||||
|
case "fr" -> "client";
|
||||||
|
default -> "cliente";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private String safeValue(String value) {
|
private String safeValue(String value) {
|
||||||
if (value == null || value.isBlank()) {
|
if (value == null || value.isBlank()) {
|
||||||
return "-";
|
return "-";
|
||||||
|
|||||||
@@ -301,6 +301,11 @@ public class OrderController {
|
|||||||
dto.setShippingCostChf(order.getShippingCostChf());
|
dto.setShippingCostChf(order.getShippingCostChf());
|
||||||
dto.setDiscountChf(order.getDiscountChf());
|
dto.setDiscountChf(order.getDiscountChf());
|
||||||
dto.setSubtotalChf(order.getSubtotalChf());
|
dto.setSubtotalChf(order.getSubtotalChf());
|
||||||
|
dto.setIsCadOrder(order.getIsCadOrder());
|
||||||
|
dto.setSourceRequestId(order.getSourceRequestId());
|
||||||
|
dto.setCadHours(order.getCadHours());
|
||||||
|
dto.setCadHourlyRateChf(order.getCadHourlyRateChf());
|
||||||
|
dto.setCadTotalChf(order.getCadTotalChf());
|
||||||
dto.setTotalChf(order.getTotalChf());
|
dto.setTotalChf(order.getTotalChf());
|
||||||
dto.setCreatedAt(order.getCreatedAt());
|
dto.setCreatedAt(order.getCreatedAt());
|
||||||
dto.setShippingSameAsBilling(order.getShippingSameAsBilling());
|
dto.setShippingSameAsBilling(order.getShippingSameAsBilling());
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.printcalculator.repository.QuoteLineItemRepository;
|
|||||||
import com.printcalculator.repository.QuoteSessionRepository;
|
import com.printcalculator.repository.QuoteSessionRepository;
|
||||||
import com.printcalculator.service.OrcaProfileResolver;
|
import com.printcalculator.service.OrcaProfileResolver;
|
||||||
import com.printcalculator.service.QuoteCalculator;
|
import com.printcalculator.service.QuoteCalculator;
|
||||||
|
import com.printcalculator.service.QuoteSessionTotalsService;
|
||||||
import com.printcalculator.service.SlicerService;
|
import com.printcalculator.service.SlicerService;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -42,6 +43,9 @@ import java.util.Optional;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.core.io.UrlResource;
|
import org.springframework.core.io.UrlResource;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/quote-sessions")
|
@RequestMapping("/api/quote-sessions")
|
||||||
@@ -59,6 +63,7 @@ public class QuoteSessionController {
|
|||||||
private final OrcaProfileResolver orcaProfileResolver;
|
private final OrcaProfileResolver orcaProfileResolver;
|
||||||
private final com.printcalculator.repository.PricingPolicyRepository pricingRepo;
|
private final com.printcalculator.repository.PricingPolicyRepository pricingRepo;
|
||||||
private final com.printcalculator.service.ClamAVService clamAVService;
|
private final com.printcalculator.service.ClamAVService clamAVService;
|
||||||
|
private final QuoteSessionTotalsService quoteSessionTotalsService;
|
||||||
|
|
||||||
public QuoteSessionController(QuoteSessionRepository sessionRepo,
|
public QuoteSessionController(QuoteSessionRepository sessionRepo,
|
||||||
QuoteLineItemRepository lineItemRepo,
|
QuoteLineItemRepository lineItemRepo,
|
||||||
@@ -69,7 +74,8 @@ public class QuoteSessionController {
|
|||||||
FilamentVariantRepository variantRepo,
|
FilamentVariantRepository variantRepo,
|
||||||
OrcaProfileResolver orcaProfileResolver,
|
OrcaProfileResolver orcaProfileResolver,
|
||||||
com.printcalculator.repository.PricingPolicyRepository pricingRepo,
|
com.printcalculator.repository.PricingPolicyRepository pricingRepo,
|
||||||
com.printcalculator.service.ClamAVService clamAVService) {
|
com.printcalculator.service.ClamAVService clamAVService,
|
||||||
|
QuoteSessionTotalsService quoteSessionTotalsService) {
|
||||||
this.sessionRepo = sessionRepo;
|
this.sessionRepo = sessionRepo;
|
||||||
this.lineItemRepo = lineItemRepo;
|
this.lineItemRepo = lineItemRepo;
|
||||||
this.slicerService = slicerService;
|
this.slicerService = slicerService;
|
||||||
@@ -80,6 +86,7 @@ public class QuoteSessionController {
|
|||||||
this.orcaProfileResolver = orcaProfileResolver;
|
this.orcaProfileResolver = orcaProfileResolver;
|
||||||
this.pricingRepo = pricingRepo;
|
this.pricingRepo = pricingRepo;
|
||||||
this.clamAVService = clamAVService;
|
this.clamAVService = clamAVService;
|
||||||
|
this.quoteSessionTotalsService = quoteSessionTotalsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Start a new empty session
|
// 1. Start a new empty session
|
||||||
@@ -121,6 +128,9 @@ public class QuoteSessionController {
|
|||||||
// Helper to add item
|
// Helper to add item
|
||||||
private QuoteLineItem addItemToSession(QuoteSession session, MultipartFile file, com.printcalculator.dto.PrintSettingsDto settings) throws IOException {
|
private QuoteLineItem addItemToSession(QuoteSession session, MultipartFile file, com.printcalculator.dto.PrintSettingsDto settings) throws IOException {
|
||||||
if (file.isEmpty()) throw new IllegalArgumentException("File is empty");
|
if (file.isEmpty()) throw new IllegalArgumentException("File is empty");
|
||||||
|
if ("CONVERTED".equals(session.getStatus())) {
|
||||||
|
throw new ResponseStatusException(BAD_REQUEST, "Cannot modify a converted session");
|
||||||
|
}
|
||||||
|
|
||||||
// Scan for virus
|
// Scan for virus
|
||||||
clamAVService.scan(file.getInputStream());
|
clamAVService.scan(file.getInputStream());
|
||||||
@@ -148,8 +158,14 @@ public class QuoteSessionController {
|
|||||||
|
|
||||||
Path convertedPersistentPath = null;
|
Path convertedPersistentPath = null;
|
||||||
try {
|
try {
|
||||||
// Apply Basic/Advanced Logic
|
boolean cadSession = "CAD_ACTIVE".equals(session.getStatus());
|
||||||
applyPrintSettings(settings);
|
|
||||||
|
// In CAD sessions, print settings are locked server-side.
|
||||||
|
if (cadSession) {
|
||||||
|
enforceCadPrintSettings(session, settings);
|
||||||
|
} else {
|
||||||
|
applyPrintSettings(settings);
|
||||||
|
}
|
||||||
|
|
||||||
BigDecimal nozzleDiameter = BigDecimal.valueOf(settings.getNozzleDiameter() != null ? settings.getNozzleDiameter() : 0.4);
|
BigDecimal nozzleDiameter = BigDecimal.valueOf(settings.getNozzleDiameter() != null ? settings.getNozzleDiameter() : 0.4);
|
||||||
|
|
||||||
@@ -159,14 +175,27 @@ public class QuoteSessionController {
|
|||||||
// Resolve selected filament variant
|
// Resolve selected filament variant
|
||||||
FilamentVariant selectedVariant = resolveFilamentVariant(settings);
|
FilamentVariant selectedVariant = resolveFilamentVariant(settings);
|
||||||
|
|
||||||
|
if (cadSession
|
||||||
|
&& session.getMaterialCode() != null
|
||||||
|
&& selectedVariant.getFilamentMaterialType() != null
|
||||||
|
&& selectedVariant.getFilamentMaterialType().getMaterialCode() != null) {
|
||||||
|
String lockedMaterial = normalizeRequestedMaterialCode(session.getMaterialCode());
|
||||||
|
String selectedMaterial = normalizeRequestedMaterialCode(selectedVariant.getFilamentMaterialType().getMaterialCode());
|
||||||
|
if (!lockedMaterial.equals(selectedMaterial)) {
|
||||||
|
throw new ResponseStatusException(BAD_REQUEST, "Selected filament does not match locked CAD material");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update session global settings from the most recent item added
|
// Update session global settings from the most recent item added
|
||||||
session.setMaterialCode(selectedVariant.getFilamentMaterialType().getMaterialCode());
|
if (!cadSession) {
|
||||||
session.setNozzleDiameterMm(nozzleDiameter);
|
session.setMaterialCode(selectedVariant.getFilamentMaterialType().getMaterialCode());
|
||||||
session.setLayerHeightMm(BigDecimal.valueOf(settings.getLayerHeight() != null ? settings.getLayerHeight() : 0.2));
|
session.setNozzleDiameterMm(nozzleDiameter);
|
||||||
session.setInfillPattern(settings.getInfillPattern());
|
session.setLayerHeightMm(BigDecimal.valueOf(settings.getLayerHeight() != null ? settings.getLayerHeight() : 0.2));
|
||||||
session.setInfillPercent(settings.getInfillDensity() != null ? settings.getInfillDensity().intValue() : 20);
|
session.setInfillPattern(settings.getInfillPattern());
|
||||||
session.setSupportsEnabled(settings.getSupportsEnabled() != null ? settings.getSupportsEnabled() : false);
|
session.setInfillPercent(settings.getInfillDensity() != null ? settings.getInfillDensity().intValue() : 20);
|
||||||
sessionRepo.save(session);
|
session.setSupportsEnabled(settings.getSupportsEnabled() != null ? settings.getSupportsEnabled() : false);
|
||||||
|
sessionRepo.save(session);
|
||||||
|
}
|
||||||
|
|
||||||
OrcaProfileResolver.ResolvedProfiles profiles = orcaProfileResolver.resolve(machine, nozzleDiameter, selectedVariant);
|
OrcaProfileResolver.ResolvedProfiles profiles = orcaProfileResolver.resolve(machine, nozzleDiameter, selectedVariant);
|
||||||
String machineProfile = profiles.machineProfileName();
|
String machineProfile = profiles.machineProfileName();
|
||||||
@@ -290,6 +319,16 @@ public class QuoteSessionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void enforceCadPrintSettings(QuoteSession session, com.printcalculator.dto.PrintSettingsDto settings) {
|
||||||
|
settings.setComplexityMode("ADVANCED");
|
||||||
|
settings.setMaterial(session.getMaterialCode() != null ? session.getMaterialCode() : "PLA");
|
||||||
|
settings.setNozzleDiameter(session.getNozzleDiameterMm() != null ? session.getNozzleDiameterMm().doubleValue() : 0.4);
|
||||||
|
settings.setLayerHeight(session.getLayerHeightMm() != null ? session.getLayerHeightMm().doubleValue() : 0.2);
|
||||||
|
settings.setInfillPattern(session.getInfillPattern() != null ? session.getInfillPattern() : "grid");
|
||||||
|
settings.setInfillDensity(session.getInfillPercent() != null ? session.getInfillPercent().doubleValue() : 20.0);
|
||||||
|
settings.setSupportsEnabled(Boolean.TRUE.equals(session.getSupportsEnabled()));
|
||||||
|
}
|
||||||
|
|
||||||
private PrinterMachine resolvePrinterMachine(Long printerMachineId) {
|
private PrinterMachine resolvePrinterMachine(Long printerMachineId) {
|
||||||
if (printerMachineId != null) {
|
if (printerMachineId != null) {
|
||||||
PrinterMachine selected = machineRepo.findById(printerMachineId)
|
PrinterMachine selected = machineRepo.findById(printerMachineId)
|
||||||
@@ -344,6 +383,32 @@ public class QuoteSessionController {
|
|||||||
.replaceAll("\\s+", " ");
|
.replaceAll("\\s+", " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int parsePositiveQuantity(Object raw) {
|
||||||
|
if (raw == null) {
|
||||||
|
throw new ResponseStatusException(BAD_REQUEST, "Quantity is required");
|
||||||
|
}
|
||||||
|
|
||||||
|
int quantity;
|
||||||
|
if (raw instanceof Number number) {
|
||||||
|
double numericValue = number.doubleValue();
|
||||||
|
if (!Double.isFinite(numericValue)) {
|
||||||
|
throw new ResponseStatusException(BAD_REQUEST, "Quantity must be a finite number");
|
||||||
|
}
|
||||||
|
quantity = (int) Math.floor(numericValue);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
quantity = Integer.parseInt(String.valueOf(raw).trim());
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
throw new ResponseStatusException(BAD_REQUEST, "Quantity must be an integer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quantity < 1) {
|
||||||
|
throw new ResponseStatusException(BAD_REQUEST, "Quantity must be >= 1");
|
||||||
|
}
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
// 3. Update Line Item
|
// 3. Update Line Item
|
||||||
@PatchMapping("/line-items/{lineItemId}")
|
@PatchMapping("/line-items/{lineItemId}")
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -354,11 +419,19 @@ public class QuoteSessionController {
|
|||||||
QuoteLineItem item = lineItemRepo.findById(lineItemId)
|
QuoteLineItem item = lineItemRepo.findById(lineItemId)
|
||||||
.orElseThrow(() -> new RuntimeException("Item not found"));
|
.orElseThrow(() -> new RuntimeException("Item not found"));
|
||||||
|
|
||||||
|
QuoteSession session = item.getQuoteSession();
|
||||||
|
if ("CONVERTED".equals(session.getStatus())) {
|
||||||
|
throw new ResponseStatusException(BAD_REQUEST, "Cannot modify a converted session");
|
||||||
|
}
|
||||||
|
|
||||||
if (updates.containsKey("quantity")) {
|
if (updates.containsKey("quantity")) {
|
||||||
item.setQuantity((Integer) updates.get("quantity"));
|
item.setQuantity(parsePositiveQuantity(updates.get("quantity")));
|
||||||
}
|
}
|
||||||
if (updates.containsKey("color_code")) {
|
if (updates.containsKey("color_code")) {
|
||||||
item.setColorCode((String) updates.get("color_code"));
|
Object colorValue = updates.get("color_code");
|
||||||
|
if (colorValue != null) {
|
||||||
|
item.setColorCode(String.valueOf(colorValue));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recalculate price if needed?
|
// Recalculate price if needed?
|
||||||
@@ -394,25 +467,7 @@ public class QuoteSessionController {
|
|||||||
.orElseThrow(() -> new RuntimeException("Session not found"));
|
.orElseThrow(() -> new RuntimeException("Session not found"));
|
||||||
|
|
||||||
List<QuoteLineItem> items = lineItemRepo.findByQuoteSessionId(id);
|
List<QuoteLineItem> items = lineItemRepo.findByQuoteSessionId(id);
|
||||||
|
QuoteSessionTotalsService.QuoteSessionTotals totals = quoteSessionTotalsService.compute(session, items);
|
||||||
// Calculate Totals and global session hours
|
|
||||||
BigDecimal itemsTotal = BigDecimal.ZERO;
|
|
||||||
BigDecimal totalSeconds = BigDecimal.ZERO;
|
|
||||||
|
|
||||||
for (QuoteLineItem item : items) {
|
|
||||||
BigDecimal lineTotal = item.getUnitPriceChf().multiply(BigDecimal.valueOf(item.getQuantity()));
|
|
||||||
itemsTotal = itemsTotal.add(lineTotal);
|
|
||||||
|
|
||||||
if (item.getPrintTimeSeconds() != null) {
|
|
||||||
totalSeconds = totalSeconds.add(BigDecimal.valueOf(item.getPrintTimeSeconds()).multiply(BigDecimal.valueOf(item.getQuantity())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal totalHours = totalSeconds.divide(BigDecimal.valueOf(3600), 4, RoundingMode.HALF_UP);
|
|
||||||
com.printcalculator.entity.PricingPolicy policy = pricingRepo.findFirstByIsActiveTrueOrderByValidFromDesc();
|
|
||||||
BigDecimal globalMachineCost = quoteCalculator.calculateSessionMachineCost(policy, totalHours);
|
|
||||||
|
|
||||||
itemsTotal = itemsTotal.add(globalMachineCost);
|
|
||||||
|
|
||||||
// Map items to DTO to embed distributed machine cost
|
// Map items to DTO to embed distributed machine cost
|
||||||
List<Map<String, Object>> itemsDto = new ArrayList<>();
|
List<Map<String, Object>> itemsDto = new ArrayList<>();
|
||||||
@@ -428,57 +483,28 @@ public class QuoteSessionController {
|
|||||||
dto.put("status", item.getStatus());
|
dto.put("status", item.getStatus());
|
||||||
dto.put("convertedStoredPath", extractConvertedStoredPath(item));
|
dto.put("convertedStoredPath", extractConvertedStoredPath(item));
|
||||||
|
|
||||||
BigDecimal unitPrice = item.getUnitPriceChf();
|
BigDecimal unitPrice = item.getUnitPriceChf() != null ? item.getUnitPriceChf() : BigDecimal.ZERO;
|
||||||
if (totalSeconds.compareTo(BigDecimal.ZERO) > 0 && item.getPrintTimeSeconds() != null) {
|
int quantity = item.getQuantity() != null && item.getQuantity() > 0 ? item.getQuantity() : 1;
|
||||||
BigDecimal itemSeconds = BigDecimal.valueOf(item.getPrintTimeSeconds()).multiply(BigDecimal.valueOf(item.getQuantity()));
|
if (totals.totalPrintSeconds().compareTo(BigDecimal.ZERO) > 0 && item.getPrintTimeSeconds() != null) {
|
||||||
BigDecimal share = itemSeconds.divide(totalSeconds, 8, RoundingMode.HALF_UP);
|
BigDecimal itemSeconds = BigDecimal.valueOf(item.getPrintTimeSeconds()).multiply(BigDecimal.valueOf(quantity));
|
||||||
BigDecimal itemMachineCost = globalMachineCost.multiply(share);
|
BigDecimal share = itemSeconds.divide(totals.totalPrintSeconds(), 8, RoundingMode.HALF_UP);
|
||||||
BigDecimal unitMachineCost = itemMachineCost.divide(BigDecimal.valueOf(item.getQuantity()), 2, RoundingMode.HALF_UP);
|
BigDecimal itemMachineCost = totals.globalMachineCostChf().multiply(share);
|
||||||
|
BigDecimal unitMachineCost = itemMachineCost.divide(BigDecimal.valueOf(quantity), 2, RoundingMode.HALF_UP);
|
||||||
unitPrice = unitPrice.add(unitMachineCost);
|
unitPrice = unitPrice.add(unitMachineCost);
|
||||||
}
|
}
|
||||||
dto.put("unitPriceChf", unitPrice);
|
dto.put("unitPriceChf", unitPrice);
|
||||||
itemsDto.add(dto);
|
itemsDto.add(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal setupFee = session.getSetupCostChf() != null ? session.getSetupCostChf() : BigDecimal.ZERO;
|
|
||||||
|
|
||||||
// Calculate shipping cost based on dimensions
|
|
||||||
boolean exceedsBaseSize = false;
|
|
||||||
for (QuoteLineItem item : items) {
|
|
||||||
BigDecimal x = item.getBoundingBoxXMm() != null ? item.getBoundingBoxXMm() : BigDecimal.ZERO;
|
|
||||||
BigDecimal y = item.getBoundingBoxYMm() != null ? item.getBoundingBoxYMm() : BigDecimal.ZERO;
|
|
||||||
BigDecimal z = item.getBoundingBoxZMm() != null ? item.getBoundingBoxZMm() : BigDecimal.ZERO;
|
|
||||||
|
|
||||||
BigDecimal[] dims = {x, y, z};
|
|
||||||
java.util.Arrays.sort(dims);
|
|
||||||
|
|
||||||
if (dims[2].compareTo(BigDecimal.valueOf(250.0)) > 0 ||
|
|
||||||
dims[1].compareTo(BigDecimal.valueOf(176.0)) > 0 ||
|
|
||||||
dims[0].compareTo(BigDecimal.valueOf(20.0)) > 0) {
|
|
||||||
exceedsBaseSize = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int totalQuantity = items.stream()
|
|
||||||
.mapToInt(i -> i.getQuantity() != null ? i.getQuantity() : 1)
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
BigDecimal shippingCostChf;
|
|
||||||
if (exceedsBaseSize) {
|
|
||||||
shippingCostChf = totalQuantity > 5 ? BigDecimal.valueOf(9.00) : BigDecimal.valueOf(4.00);
|
|
||||||
} else {
|
|
||||||
shippingCostChf = BigDecimal.valueOf(2.00);
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal grandTotal = itemsTotal.add(setupFee).add(shippingCostChf);
|
|
||||||
|
|
||||||
Map<String, Object> response = new HashMap<>();
|
Map<String, Object> response = new HashMap<>();
|
||||||
response.put("session", session);
|
response.put("session", session);
|
||||||
response.put("items", itemsDto);
|
response.put("items", itemsDto);
|
||||||
response.put("itemsTotalChf", itemsTotal); // Includes the base cost of all items + the global tiered machine cost
|
response.put("printItemsTotalChf", totals.printItemsTotalChf());
|
||||||
response.put("shippingCostChf", shippingCostChf);
|
response.put("cadTotalChf", totals.cadTotalChf());
|
||||||
response.put("globalMachineCostChf", globalMachineCost); // Provide it so frontend knows how much it was (optional now)
|
response.put("itemsTotalChf", totals.itemsTotalChf());
|
||||||
response.put("grandTotalChf", grandTotal);
|
response.put("shippingCostChf", totals.shippingCostChf());
|
||||||
|
response.put("globalMachineCostChf", totals.globalMachineCostChf());
|
||||||
|
response.put("grandTotalChf", totals.grandTotalChf());
|
||||||
|
|
||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.printcalculator.controller.admin;
|
|||||||
import com.printcalculator.dto.AdminContactRequestDto;
|
import com.printcalculator.dto.AdminContactRequestDto;
|
||||||
import com.printcalculator.dto.AdminContactRequestAttachmentDto;
|
import com.printcalculator.dto.AdminContactRequestAttachmentDto;
|
||||||
import com.printcalculator.dto.AdminContactRequestDetailDto;
|
import com.printcalculator.dto.AdminContactRequestDetailDto;
|
||||||
|
import com.printcalculator.dto.AdminCadInvoiceCreateRequest;
|
||||||
|
import com.printcalculator.dto.AdminCadInvoiceDto;
|
||||||
import com.printcalculator.dto.AdminFilamentStockDto;
|
import com.printcalculator.dto.AdminFilamentStockDto;
|
||||||
import com.printcalculator.dto.AdminQuoteSessionDto;
|
import com.printcalculator.dto.AdminQuoteSessionDto;
|
||||||
import com.printcalculator.dto.AdminUpdateContactRequestStatusRequest;
|
import com.printcalculator.dto.AdminUpdateContactRequestStatusRequest;
|
||||||
@@ -10,13 +12,18 @@ import com.printcalculator.entity.CustomQuoteRequest;
|
|||||||
import com.printcalculator.entity.CustomQuoteRequestAttachment;
|
import com.printcalculator.entity.CustomQuoteRequestAttachment;
|
||||||
import com.printcalculator.entity.FilamentVariant;
|
import com.printcalculator.entity.FilamentVariant;
|
||||||
import com.printcalculator.entity.FilamentVariantStockKg;
|
import com.printcalculator.entity.FilamentVariantStockKg;
|
||||||
|
import com.printcalculator.entity.Order;
|
||||||
|
import com.printcalculator.entity.QuoteLineItem;
|
||||||
import com.printcalculator.entity.QuoteSession;
|
import com.printcalculator.entity.QuoteSession;
|
||||||
import com.printcalculator.repository.CustomQuoteRequestAttachmentRepository;
|
import com.printcalculator.repository.CustomQuoteRequestAttachmentRepository;
|
||||||
import com.printcalculator.repository.CustomQuoteRequestRepository;
|
import com.printcalculator.repository.CustomQuoteRequestRepository;
|
||||||
import com.printcalculator.repository.FilamentVariantRepository;
|
import com.printcalculator.repository.FilamentVariantRepository;
|
||||||
import com.printcalculator.repository.FilamentVariantStockKgRepository;
|
import com.printcalculator.repository.FilamentVariantStockKgRepository;
|
||||||
import com.printcalculator.repository.OrderRepository;
|
import com.printcalculator.repository.OrderRepository;
|
||||||
|
import com.printcalculator.repository.PricingPolicyRepository;
|
||||||
|
import com.printcalculator.repository.QuoteLineItemRepository;
|
||||||
import com.printcalculator.repository.QuoteSessionRepository;
|
import com.printcalculator.repository.QuoteSessionRepository;
|
||||||
|
import com.printcalculator.service.QuoteSessionTotalsService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@@ -31,6 +38,7 @@ import org.springframework.web.bind.annotation.DeleteMapping;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PatchMapping;
|
import org.springframework.web.bind.annotation.PatchMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -39,6 +47,7 @@ import org.springframework.web.server.ResponseStatusException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -75,7 +84,10 @@ public class AdminOperationsController {
|
|||||||
private final CustomQuoteRequestRepository customQuoteRequestRepo;
|
private final CustomQuoteRequestRepository customQuoteRequestRepo;
|
||||||
private final CustomQuoteRequestAttachmentRepository customQuoteRequestAttachmentRepo;
|
private final CustomQuoteRequestAttachmentRepository customQuoteRequestAttachmentRepo;
|
||||||
private final QuoteSessionRepository quoteSessionRepo;
|
private final QuoteSessionRepository quoteSessionRepo;
|
||||||
|
private final QuoteLineItemRepository quoteLineItemRepo;
|
||||||
private final OrderRepository orderRepo;
|
private final OrderRepository orderRepo;
|
||||||
|
private final PricingPolicyRepository pricingRepo;
|
||||||
|
private final QuoteSessionTotalsService quoteSessionTotalsService;
|
||||||
|
|
||||||
public AdminOperationsController(
|
public AdminOperationsController(
|
||||||
FilamentVariantStockKgRepository filamentStockRepo,
|
FilamentVariantStockKgRepository filamentStockRepo,
|
||||||
@@ -83,14 +95,20 @@ public class AdminOperationsController {
|
|||||||
CustomQuoteRequestRepository customQuoteRequestRepo,
|
CustomQuoteRequestRepository customQuoteRequestRepo,
|
||||||
CustomQuoteRequestAttachmentRepository customQuoteRequestAttachmentRepo,
|
CustomQuoteRequestAttachmentRepository customQuoteRequestAttachmentRepo,
|
||||||
QuoteSessionRepository quoteSessionRepo,
|
QuoteSessionRepository quoteSessionRepo,
|
||||||
OrderRepository orderRepo
|
QuoteLineItemRepository quoteLineItemRepo,
|
||||||
|
OrderRepository orderRepo,
|
||||||
|
PricingPolicyRepository pricingRepo,
|
||||||
|
QuoteSessionTotalsService quoteSessionTotalsService
|
||||||
) {
|
) {
|
||||||
this.filamentStockRepo = filamentStockRepo;
|
this.filamentStockRepo = filamentStockRepo;
|
||||||
this.filamentVariantRepo = filamentVariantRepo;
|
this.filamentVariantRepo = filamentVariantRepo;
|
||||||
this.customQuoteRequestRepo = customQuoteRequestRepo;
|
this.customQuoteRequestRepo = customQuoteRequestRepo;
|
||||||
this.customQuoteRequestAttachmentRepo = customQuoteRequestAttachmentRepo;
|
this.customQuoteRequestAttachmentRepo = customQuoteRequestAttachmentRepo;
|
||||||
this.quoteSessionRepo = quoteSessionRepo;
|
this.quoteSessionRepo = quoteSessionRepo;
|
||||||
|
this.quoteLineItemRepo = quoteLineItemRepo;
|
||||||
this.orderRepo = orderRepo;
|
this.orderRepo = orderRepo;
|
||||||
|
this.pricingRepo = pricingRepo;
|
||||||
|
this.quoteSessionTotalsService = quoteSessionTotalsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/filament-stock")
|
@GetMapping("/filament-stock")
|
||||||
@@ -279,6 +297,83 @@ public class AdminOperationsController {
|
|||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/cad-invoices")
|
||||||
|
public ResponseEntity<List<AdminCadInvoiceDto>> getCadInvoices() {
|
||||||
|
List<AdminCadInvoiceDto> response = quoteSessionRepo.findByStatusInOrderByCreatedAtDesc(List.of("CAD_ACTIVE", "CONVERTED"))
|
||||||
|
.stream()
|
||||||
|
.filter(this::isCadSessionRecord)
|
||||||
|
.map(this::toCadInvoiceDto)
|
||||||
|
.toList();
|
||||||
|
return ResponseEntity.ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/cad-invoices")
|
||||||
|
@Transactional
|
||||||
|
public ResponseEntity<AdminCadInvoiceDto> createOrUpdateCadInvoice(
|
||||||
|
@RequestBody AdminCadInvoiceCreateRequest payload
|
||||||
|
) {
|
||||||
|
if (payload == null || payload.getCadHours() == null) {
|
||||||
|
throw new ResponseStatusException(BAD_REQUEST, "cadHours is required");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal cadHours = payload.getCadHours().setScale(2, RoundingMode.HALF_UP);
|
||||||
|
if (cadHours.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
throw new ResponseStatusException(BAD_REQUEST, "cadHours must be > 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal cadRate = payload.getCadHourlyRateChf();
|
||||||
|
if (cadRate == null || cadRate.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
var policy = pricingRepo.findFirstByIsActiveTrueOrderByValidFromDesc();
|
||||||
|
cadRate = policy != null && policy.getCadCostChfPerHour() != null
|
||||||
|
? policy.getCadCostChfPerHour()
|
||||||
|
: BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
cadRate = cadRate.setScale(2, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
|
QuoteSession session;
|
||||||
|
if (payload.getSessionId() != null) {
|
||||||
|
session = quoteSessionRepo.findById(payload.getSessionId())
|
||||||
|
.orElseThrow(() -> new ResponseStatusException(NOT_FOUND, "Session not found"));
|
||||||
|
} else {
|
||||||
|
session = new QuoteSession();
|
||||||
|
session.setStatus("CAD_ACTIVE");
|
||||||
|
session.setPricingVersion("v1");
|
||||||
|
session.setMaterialCode("PLA");
|
||||||
|
session.setNozzleDiameterMm(BigDecimal.valueOf(0.4));
|
||||||
|
session.setLayerHeightMm(BigDecimal.valueOf(0.2));
|
||||||
|
session.setInfillPattern("grid");
|
||||||
|
session.setInfillPercent(20);
|
||||||
|
session.setSupportsEnabled(false);
|
||||||
|
session.setSetupCostChf(BigDecimal.ZERO);
|
||||||
|
session.setCreatedAt(OffsetDateTime.now());
|
||||||
|
session.setExpiresAt(OffsetDateTime.now().plusDays(30));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("CONVERTED".equals(session.getStatus())) {
|
||||||
|
throw new ResponseStatusException(CONFLICT, "Session already converted to order");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload.getSourceRequestId() != null) {
|
||||||
|
if (!customQuoteRequestRepo.existsById(payload.getSourceRequestId())) {
|
||||||
|
throw new ResponseStatusException(NOT_FOUND, "Source request not found");
|
||||||
|
}
|
||||||
|
session.setSourceRequestId(payload.getSourceRequestId());
|
||||||
|
} else {
|
||||||
|
session.setSourceRequestId(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
session.setStatus("CAD_ACTIVE");
|
||||||
|
session.setCadHours(cadHours);
|
||||||
|
session.setCadHourlyRateChf(cadRate);
|
||||||
|
if (payload.getNotes() != null) {
|
||||||
|
String trimmedNotes = payload.getNotes().trim();
|
||||||
|
session.setNotes(trimmedNotes.isEmpty() ? null : trimmedNotes);
|
||||||
|
}
|
||||||
|
|
||||||
|
QuoteSession saved = quoteSessionRepo.save(session);
|
||||||
|
return ResponseEntity.ok(toCadInvoiceDto(saved));
|
||||||
|
}
|
||||||
|
|
||||||
@DeleteMapping("/sessions/{sessionId}")
|
@DeleteMapping("/sessions/{sessionId}")
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResponseEntity<Void> deleteQuoteSession(@PathVariable UUID sessionId) {
|
public ResponseEntity<Void> deleteQuoteSession(@PathVariable UUID sessionId) {
|
||||||
@@ -347,6 +442,48 @@ public class AdminOperationsController {
|
|||||||
dto.setCreatedAt(session.getCreatedAt());
|
dto.setCreatedAt(session.getCreatedAt());
|
||||||
dto.setExpiresAt(session.getExpiresAt());
|
dto.setExpiresAt(session.getExpiresAt());
|
||||||
dto.setConvertedOrderId(session.getConvertedOrderId());
|
dto.setConvertedOrderId(session.getConvertedOrderId());
|
||||||
|
dto.setSourceRequestId(session.getSourceRequestId());
|
||||||
|
dto.setCadHours(session.getCadHours());
|
||||||
|
dto.setCadHourlyRateChf(session.getCadHourlyRateChf());
|
||||||
|
dto.setCadTotalChf(quoteSessionTotalsService.calculateCadTotal(session));
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isCadSessionRecord(QuoteSession session) {
|
||||||
|
if ("CAD_ACTIVE".equals(session.getStatus())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!"CONVERTED".equals(session.getStatus())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
BigDecimal cadHours = session.getCadHours() != null ? session.getCadHours() : BigDecimal.ZERO;
|
||||||
|
return cadHours.compareTo(BigDecimal.ZERO) > 0 || session.getSourceRequestId() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AdminCadInvoiceDto toCadInvoiceDto(QuoteSession session) {
|
||||||
|
List<QuoteLineItem> items = quoteLineItemRepo.findByQuoteSessionId(session.getId());
|
||||||
|
QuoteSessionTotalsService.QuoteSessionTotals totals = quoteSessionTotalsService.compute(session, items);
|
||||||
|
|
||||||
|
AdminCadInvoiceDto dto = new AdminCadInvoiceDto();
|
||||||
|
dto.setSessionId(session.getId());
|
||||||
|
dto.setSessionStatus(session.getStatus());
|
||||||
|
dto.setSourceRequestId(session.getSourceRequestId());
|
||||||
|
dto.setCadHours(session.getCadHours() != null ? session.getCadHours() : BigDecimal.ZERO);
|
||||||
|
dto.setCadHourlyRateChf(session.getCadHourlyRateChf() != null ? session.getCadHourlyRateChf() : BigDecimal.ZERO);
|
||||||
|
dto.setCadTotalChf(totals.cadTotalChf());
|
||||||
|
dto.setPrintItemsTotalChf(totals.printItemsTotalChf());
|
||||||
|
dto.setSetupCostChf(totals.setupCostChf());
|
||||||
|
dto.setShippingCostChf(totals.shippingCostChf());
|
||||||
|
dto.setGrandTotalChf(totals.grandTotalChf());
|
||||||
|
dto.setConvertedOrderId(session.getConvertedOrderId());
|
||||||
|
dto.setCheckoutPath("/checkout/cad?session=" + session.getId());
|
||||||
|
dto.setNotes(session.getNotes());
|
||||||
|
dto.setCreatedAt(session.getCreatedAt());
|
||||||
|
|
||||||
|
if (session.getConvertedOrderId() != null) {
|
||||||
|
Order order = orderRepo.findById(session.getConvertedOrderId()).orElse(null);
|
||||||
|
dto.setConvertedOrderStatus(order != null ? order.getStatus() : null);
|
||||||
|
}
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -214,6 +214,11 @@ public class AdminOrderController {
|
|||||||
dto.setShippingCostChf(order.getShippingCostChf());
|
dto.setShippingCostChf(order.getShippingCostChf());
|
||||||
dto.setDiscountChf(order.getDiscountChf());
|
dto.setDiscountChf(order.getDiscountChf());
|
||||||
dto.setSubtotalChf(order.getSubtotalChf());
|
dto.setSubtotalChf(order.getSubtotalChf());
|
||||||
|
dto.setIsCadOrder(order.getIsCadOrder());
|
||||||
|
dto.setSourceRequestId(order.getSourceRequestId());
|
||||||
|
dto.setCadHours(order.getCadHours());
|
||||||
|
dto.setCadHourlyRateChf(order.getCadHourlyRateChf());
|
||||||
|
dto.setCadTotalChf(order.getCadTotalChf());
|
||||||
dto.setTotalChf(order.getTotalChf());
|
dto.setTotalChf(order.getTotalChf());
|
||||||
dto.setCreatedAt(order.getCreatedAt());
|
dto.setCreatedAt(order.getCreatedAt());
|
||||||
dto.setShippingSameAsBilling(order.getShippingSameAsBilling());
|
dto.setShippingSameAsBilling(order.getShippingSameAsBilling());
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.printcalculator.dto;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class AdminCadInvoiceCreateRequest {
|
||||||
|
private UUID sessionId;
|
||||||
|
private UUID sourceRequestId;
|
||||||
|
private BigDecimal cadHours;
|
||||||
|
private BigDecimal cadHourlyRateChf;
|
||||||
|
private String notes;
|
||||||
|
|
||||||
|
public UUID getSessionId() {
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSessionId(UUID sessionId) {
|
||||||
|
this.sessionId = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getSourceRequestId() {
|
||||||
|
return sourceRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceRequestId(UUID sourceRequestId) {
|
||||||
|
this.sourceRequestId = sourceRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadHours() {
|
||||||
|
return cadHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadHours(BigDecimal cadHours) {
|
||||||
|
this.cadHours = cadHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadHourlyRateChf() {
|
||||||
|
return cadHourlyRateChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadHourlyRateChf(BigDecimal cadHourlyRateChf) {
|
||||||
|
this.cadHourlyRateChf = cadHourlyRateChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotes() {
|
||||||
|
return notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotes(String notes) {
|
||||||
|
this.notes = notes;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
package com.printcalculator.dto;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class AdminCadInvoiceDto {
|
||||||
|
private UUID sessionId;
|
||||||
|
private String sessionStatus;
|
||||||
|
private UUID sourceRequestId;
|
||||||
|
private BigDecimal cadHours;
|
||||||
|
private BigDecimal cadHourlyRateChf;
|
||||||
|
private BigDecimal cadTotalChf;
|
||||||
|
private BigDecimal printItemsTotalChf;
|
||||||
|
private BigDecimal setupCostChf;
|
||||||
|
private BigDecimal shippingCostChf;
|
||||||
|
private BigDecimal grandTotalChf;
|
||||||
|
private UUID convertedOrderId;
|
||||||
|
private String convertedOrderStatus;
|
||||||
|
private String checkoutPath;
|
||||||
|
private String notes;
|
||||||
|
private OffsetDateTime createdAt;
|
||||||
|
|
||||||
|
public UUID getSessionId() {
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSessionId(UUID sessionId) {
|
||||||
|
this.sessionId = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSessionStatus() {
|
||||||
|
return sessionStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSessionStatus(String sessionStatus) {
|
||||||
|
this.sessionStatus = sessionStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getSourceRequestId() {
|
||||||
|
return sourceRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceRequestId(UUID sourceRequestId) {
|
||||||
|
this.sourceRequestId = sourceRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadHours() {
|
||||||
|
return cadHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadHours(BigDecimal cadHours) {
|
||||||
|
this.cadHours = cadHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadHourlyRateChf() {
|
||||||
|
return cadHourlyRateChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadHourlyRateChf(BigDecimal cadHourlyRateChf) {
|
||||||
|
this.cadHourlyRateChf = cadHourlyRateChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadTotalChf() {
|
||||||
|
return cadTotalChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadTotalChf(BigDecimal cadTotalChf) {
|
||||||
|
this.cadTotalChf = cadTotalChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getPrintItemsTotalChf() {
|
||||||
|
return printItemsTotalChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrintItemsTotalChf(BigDecimal printItemsTotalChf) {
|
||||||
|
this.printItemsTotalChf = printItemsTotalChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getSetupCostChf() {
|
||||||
|
return setupCostChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSetupCostChf(BigDecimal setupCostChf) {
|
||||||
|
this.setupCostChf = setupCostChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getShippingCostChf() {
|
||||||
|
return shippingCostChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShippingCostChf(BigDecimal shippingCostChf) {
|
||||||
|
this.shippingCostChf = shippingCostChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getGrandTotalChf() {
|
||||||
|
return grandTotalChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGrandTotalChf(BigDecimal grandTotalChf) {
|
||||||
|
this.grandTotalChf = grandTotalChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getConvertedOrderId() {
|
||||||
|
return convertedOrderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConvertedOrderId(UUID convertedOrderId) {
|
||||||
|
this.convertedOrderId = convertedOrderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConvertedOrderStatus() {
|
||||||
|
return convertedOrderStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConvertedOrderStatus(String convertedOrderStatus) {
|
||||||
|
this.convertedOrderStatus = convertedOrderStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCheckoutPath() {
|
||||||
|
return checkoutPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheckoutPath(String checkoutPath) {
|
||||||
|
this.checkoutPath = checkoutPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotes() {
|
||||||
|
return notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotes(String notes) {
|
||||||
|
this.notes = notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OffsetDateTime getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(OffsetDateTime createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.printcalculator.dto;
|
package com.printcalculator.dto;
|
||||||
|
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AdminQuoteSessionDto {
|
public class AdminQuoteSessionDto {
|
||||||
@@ -10,6 +11,10 @@ public class AdminQuoteSessionDto {
|
|||||||
private OffsetDateTime createdAt;
|
private OffsetDateTime createdAt;
|
||||||
private OffsetDateTime expiresAt;
|
private OffsetDateTime expiresAt;
|
||||||
private UUID convertedOrderId;
|
private UUID convertedOrderId;
|
||||||
|
private UUID sourceRequestId;
|
||||||
|
private BigDecimal cadHours;
|
||||||
|
private BigDecimal cadHourlyRateChf;
|
||||||
|
private BigDecimal cadTotalChf;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
@@ -58,4 +63,36 @@ public class AdminQuoteSessionDto {
|
|||||||
public void setConvertedOrderId(UUID convertedOrderId) {
|
public void setConvertedOrderId(UUID convertedOrderId) {
|
||||||
this.convertedOrderId = convertedOrderId;
|
this.convertedOrderId = convertedOrderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getSourceRequestId() {
|
||||||
|
return sourceRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceRequestId(UUID sourceRequestId) {
|
||||||
|
this.sourceRequestId = sourceRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadHours() {
|
||||||
|
return cadHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadHours(BigDecimal cadHours) {
|
||||||
|
this.cadHours = cadHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadHourlyRateChf() {
|
||||||
|
return cadHourlyRateChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadHourlyRateChf(BigDecimal cadHourlyRateChf) {
|
||||||
|
this.cadHourlyRateChf = cadHourlyRateChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadTotalChf() {
|
||||||
|
return cadTotalChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadTotalChf(BigDecimal cadTotalChf) {
|
||||||
|
this.cadTotalChf = cadTotalChf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ public class OrderDto {
|
|||||||
private BigDecimal shippingCostChf;
|
private BigDecimal shippingCostChf;
|
||||||
private BigDecimal discountChf;
|
private BigDecimal discountChf;
|
||||||
private BigDecimal subtotalChf;
|
private BigDecimal subtotalChf;
|
||||||
|
private Boolean isCadOrder;
|
||||||
|
private UUID sourceRequestId;
|
||||||
|
private BigDecimal cadHours;
|
||||||
|
private BigDecimal cadHourlyRateChf;
|
||||||
|
private BigDecimal cadTotalChf;
|
||||||
private BigDecimal totalChf;
|
private BigDecimal totalChf;
|
||||||
private OffsetDateTime createdAt;
|
private OffsetDateTime createdAt;
|
||||||
private String printMaterialCode;
|
private String printMaterialCode;
|
||||||
@@ -85,6 +90,21 @@ public class OrderDto {
|
|||||||
public BigDecimal getSubtotalChf() { return subtotalChf; }
|
public BigDecimal getSubtotalChf() { return subtotalChf; }
|
||||||
public void setSubtotalChf(BigDecimal subtotalChf) { this.subtotalChf = subtotalChf; }
|
public void setSubtotalChf(BigDecimal subtotalChf) { this.subtotalChf = subtotalChf; }
|
||||||
|
|
||||||
|
public Boolean getIsCadOrder() { return isCadOrder; }
|
||||||
|
public void setIsCadOrder(Boolean isCadOrder) { this.isCadOrder = isCadOrder; }
|
||||||
|
|
||||||
|
public UUID getSourceRequestId() { return sourceRequestId; }
|
||||||
|
public void setSourceRequestId(UUID sourceRequestId) { this.sourceRequestId = sourceRequestId; }
|
||||||
|
|
||||||
|
public BigDecimal getCadHours() { return cadHours; }
|
||||||
|
public void setCadHours(BigDecimal cadHours) { this.cadHours = cadHours; }
|
||||||
|
|
||||||
|
public BigDecimal getCadHourlyRateChf() { return cadHourlyRateChf; }
|
||||||
|
public void setCadHourlyRateChf(BigDecimal cadHourlyRateChf) { this.cadHourlyRateChf = cadHourlyRateChf; }
|
||||||
|
|
||||||
|
public BigDecimal getCadTotalChf() { return cadTotalChf; }
|
||||||
|
public void setCadTotalChf(BigDecimal cadTotalChf) { this.cadTotalChf = cadTotalChf; }
|
||||||
|
|
||||||
public BigDecimal getTotalChf() { return totalChf; }
|
public BigDecimal getTotalChf() { return totalChf; }
|
||||||
public void setTotalChf(BigDecimal totalChf) { this.totalChf = totalChf; }
|
public void setTotalChf(BigDecimal totalChf) { this.totalChf = totalChf; }
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import jakarta.validation.constraints.AssertTrue;
|
|||||||
public class QuoteRequestDto {
|
public class QuoteRequestDto {
|
||||||
private String requestType; // "PRINT_SERVICE" or "DESIGN_SERVICE"
|
private String requestType; // "PRINT_SERVICE" or "DESIGN_SERVICE"
|
||||||
private String customerType; // "PRIVATE" or "BUSINESS"
|
private String customerType; // "PRIVATE" or "BUSINESS"
|
||||||
|
private String language; // "it" | "en" | "de" | "fr"
|
||||||
private String email;
|
private String email;
|
||||||
private String phone;
|
private String phone;
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@@ -119,6 +119,23 @@ public class Order {
|
|||||||
@Column(name = "subtotal_chf", nullable = false, precision = 12, scale = 2)
|
@Column(name = "subtotal_chf", nullable = false, precision = 12, scale = 2)
|
||||||
private BigDecimal subtotalChf;
|
private BigDecimal subtotalChf;
|
||||||
|
|
||||||
|
@ColumnDefault("false")
|
||||||
|
@Column(name = "is_cad_order", nullable = false)
|
||||||
|
private Boolean isCadOrder;
|
||||||
|
|
||||||
|
@Column(name = "source_request_id")
|
||||||
|
private UUID sourceRequestId;
|
||||||
|
|
||||||
|
@Column(name = "cad_hours", precision = 10, scale = 2)
|
||||||
|
private BigDecimal cadHours;
|
||||||
|
|
||||||
|
@Column(name = "cad_hourly_rate_chf", precision = 10, scale = 2)
|
||||||
|
private BigDecimal cadHourlyRateChf;
|
||||||
|
|
||||||
|
@ColumnDefault("0.00")
|
||||||
|
@Column(name = "cad_total_chf", nullable = false, precision = 12, scale = 2)
|
||||||
|
private BigDecimal cadTotalChf;
|
||||||
|
|
||||||
@ColumnDefault("0.00")
|
@ColumnDefault("0.00")
|
||||||
@Column(name = "total_chf", nullable = false, precision = 12, scale = 2)
|
@Column(name = "total_chf", nullable = false, precision = 12, scale = 2)
|
||||||
private BigDecimal totalChf;
|
private BigDecimal totalChf;
|
||||||
@@ -400,6 +417,46 @@ public class Order {
|
|||||||
this.subtotalChf = subtotalChf;
|
this.subtotalChf = subtotalChf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getIsCadOrder() {
|
||||||
|
return isCadOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsCadOrder(Boolean isCadOrder) {
|
||||||
|
this.isCadOrder = isCadOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getSourceRequestId() {
|
||||||
|
return sourceRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceRequestId(UUID sourceRequestId) {
|
||||||
|
this.sourceRequestId = sourceRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadHours() {
|
||||||
|
return cadHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadHours(BigDecimal cadHours) {
|
||||||
|
this.cadHours = cadHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadHourlyRateChf() {
|
||||||
|
return cadHourlyRateChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadHourlyRateChf(BigDecimal cadHourlyRateChf) {
|
||||||
|
this.cadHourlyRateChf = cadHourlyRateChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadTotalChf() {
|
||||||
|
return cadTotalChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadTotalChf(BigDecimal cadTotalChf) {
|
||||||
|
this.cadTotalChf = cadTotalChf;
|
||||||
|
}
|
||||||
|
|
||||||
public BigDecimal getTotalChf() {
|
public BigDecimal getTotalChf() {
|
||||||
return totalChf;
|
return totalChf;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,15 @@ public class QuoteSession {
|
|||||||
@Column(name = "converted_order_id")
|
@Column(name = "converted_order_id")
|
||||||
private UUID convertedOrderId;
|
private UUID convertedOrderId;
|
||||||
|
|
||||||
|
@Column(name = "source_request_id")
|
||||||
|
private UUID sourceRequestId;
|
||||||
|
|
||||||
|
@Column(name = "cad_hours", precision = 10, scale = 2)
|
||||||
|
private BigDecimal cadHours;
|
||||||
|
|
||||||
|
@Column(name = "cad_hourly_rate_chf", precision = 10, scale = 2)
|
||||||
|
private BigDecimal cadHourlyRateChf;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -173,4 +182,28 @@ public class QuoteSession {
|
|||||||
this.convertedOrderId = convertedOrderId;
|
this.convertedOrderId = convertedOrderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getSourceRequestId() {
|
||||||
|
return sourceRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceRequestId(UUID sourceRequestId) {
|
||||||
|
this.sourceRequestId = sourceRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadHours() {
|
||||||
|
return cadHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadHours(BigDecimal cadHours) {
|
||||||
|
this.cadHours = cadHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCadHourlyRateChf() {
|
||||||
|
return cadHourlyRateChf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCadHourlyRateChf(BigDecimal cadHourlyRateChf) {
|
||||||
|
this.cadHourlyRateChf = cadHourlyRateChf;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,4 +8,6 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public interface QuoteSessionRepository extends JpaRepository<QuoteSession, UUID> {
|
public interface QuoteSessionRepository extends JpaRepository<QuoteSession, UUID> {
|
||||||
List<QuoteSession> findByCreatedAtBefore(java.time.OffsetDateTime cutoff);
|
List<QuoteSession> findByCreatedAtBefore(java.time.OffsetDateTime cutoff);
|
||||||
|
|
||||||
|
List<QuoteSession> findByStatusInOrderByCreatedAtDesc(List<String> statuses);
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,8 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
import com.printcalculator.entity.Order;
|
import com.printcalculator.entity.Order;
|
||||||
import com.printcalculator.entity.OrderItem;
|
import com.printcalculator.entity.OrderItem;
|
||||||
@@ -95,6 +97,17 @@ public class InvoicePdfRenderingService {
|
|||||||
return line;
|
return line;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (order.getCadTotalChf() != null && order.getCadTotalChf().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
BigDecimal cadHours = order.getCadHours() != null ? order.getCadHours() : BigDecimal.ZERO;
|
||||||
|
BigDecimal cadHourlyRate = order.getCadHourlyRateChf() != null ? order.getCadHourlyRateChf() : BigDecimal.ZERO;
|
||||||
|
Map<String, Object> cadLine = new HashMap<>();
|
||||||
|
cadLine.put("description", "Servizio CAD (" + formatCadHours(cadHours) + "h)");
|
||||||
|
cadLine.put("quantity", 1);
|
||||||
|
cadLine.put("unitPriceFormatted", String.format("CHF %.2f", cadHourlyRate));
|
||||||
|
cadLine.put("lineTotalFormatted", String.format("CHF %.2f", order.getCadTotalChf()));
|
||||||
|
invoiceLineItems.add(cadLine);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Object> setupLine = new HashMap<>();
|
Map<String, Object> setupLine = new HashMap<>();
|
||||||
setupLine.put("description", "Costo Setup");
|
setupLine.put("description", "Costo Setup");
|
||||||
setupLine.put("quantity", 1);
|
setupLine.put("quantity", 1);
|
||||||
@@ -140,4 +153,8 @@ public class InvoicePdfRenderingService {
|
|||||||
|
|
||||||
return generateInvoicePdfBytesFromTemplate(vars, qrBillSvg);
|
return generateInvoicePdfBytesFromTemplate(vars, qrBillSvg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String formatCadHours(BigDecimal hours) {
|
||||||
|
return hours.setScale(2, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.printcalculator.repository.OrderItemRepository;
|
|||||||
import com.printcalculator.repository.OrderRepository;
|
import com.printcalculator.repository.OrderRepository;
|
||||||
import com.printcalculator.repository.QuoteLineItemRepository;
|
import com.printcalculator.repository.QuoteLineItemRepository;
|
||||||
import com.printcalculator.repository.QuoteSessionRepository;
|
import com.printcalculator.repository.QuoteSessionRepository;
|
||||||
import com.printcalculator.repository.PricingPolicyRepository;
|
|
||||||
import com.printcalculator.event.OrderCreatedEvent;
|
import com.printcalculator.event.OrderCreatedEvent;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -35,8 +34,7 @@ public class OrderService {
|
|||||||
private final QrBillService qrBillService;
|
private final QrBillService qrBillService;
|
||||||
private final ApplicationEventPublisher eventPublisher;
|
private final ApplicationEventPublisher eventPublisher;
|
||||||
private final PaymentService paymentService;
|
private final PaymentService paymentService;
|
||||||
private final QuoteCalculator quoteCalculator;
|
private final QuoteSessionTotalsService quoteSessionTotalsService;
|
||||||
private final PricingPolicyRepository pricingRepo;
|
|
||||||
|
|
||||||
public OrderService(OrderRepository orderRepo,
|
public OrderService(OrderRepository orderRepo,
|
||||||
OrderItemRepository orderItemRepo,
|
OrderItemRepository orderItemRepo,
|
||||||
@@ -48,8 +46,7 @@ public class OrderService {
|
|||||||
QrBillService qrBillService,
|
QrBillService qrBillService,
|
||||||
ApplicationEventPublisher eventPublisher,
|
ApplicationEventPublisher eventPublisher,
|
||||||
PaymentService paymentService,
|
PaymentService paymentService,
|
||||||
QuoteCalculator quoteCalculator,
|
QuoteSessionTotalsService quoteSessionTotalsService) {
|
||||||
PricingPolicyRepository pricingRepo) {
|
|
||||||
this.orderRepo = orderRepo;
|
this.orderRepo = orderRepo;
|
||||||
this.orderItemRepo = orderItemRepo;
|
this.orderItemRepo = orderItemRepo;
|
||||||
this.quoteSessionRepo = quoteSessionRepo;
|
this.quoteSessionRepo = quoteSessionRepo;
|
||||||
@@ -60,8 +57,7 @@ public class OrderService {
|
|||||||
this.qrBillService = qrBillService;
|
this.qrBillService = qrBillService;
|
||||||
this.eventPublisher = eventPublisher;
|
this.eventPublisher = eventPublisher;
|
||||||
this.paymentService = paymentService;
|
this.paymentService = paymentService;
|
||||||
this.quoteCalculator = quoteCalculator;
|
this.quoteSessionTotalsService = quoteSessionTotalsService;
|
||||||
this.pricingRepo = pricingRepo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -148,60 +144,31 @@ public class OrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<QuoteLineItem> quoteItems = quoteLineItemRepo.findByQuoteSessionId(quoteSessionId);
|
List<QuoteLineItem> quoteItems = quoteLineItemRepo.findByQuoteSessionId(quoteSessionId);
|
||||||
|
QuoteSessionTotalsService.QuoteSessionTotals totals = quoteSessionTotalsService.compute(session, quoteItems);
|
||||||
|
BigDecimal cadTotal = totals.cadTotalChf();
|
||||||
|
|
||||||
BigDecimal subtotal = BigDecimal.ZERO;
|
BigDecimal subtotal = BigDecimal.ZERO;
|
||||||
order.setSubtotalChf(BigDecimal.ZERO);
|
order.setSubtotalChf(BigDecimal.ZERO);
|
||||||
order.setTotalChf(BigDecimal.ZERO);
|
order.setTotalChf(BigDecimal.ZERO);
|
||||||
order.setDiscountChf(BigDecimal.ZERO);
|
order.setDiscountChf(BigDecimal.ZERO);
|
||||||
order.setSetupCostChf(session.getSetupCostChf() != null ? session.getSetupCostChf() : BigDecimal.ZERO);
|
order.setSetupCostChf(session.getSetupCostChf() != null ? session.getSetupCostChf() : BigDecimal.ZERO);
|
||||||
|
order.setShippingCostChf(totals.shippingCostChf());
|
||||||
// Calculate shipping cost based on dimensions before initial save
|
order.setIsCadOrder(cadTotal.compareTo(BigDecimal.ZERO) > 0 || "CAD_ACTIVE".equals(session.getStatus()));
|
||||||
boolean exceedsBaseSize = false;
|
order.setSourceRequestId(session.getSourceRequestId());
|
||||||
for (QuoteLineItem item : quoteItems) {
|
order.setCadHours(session.getCadHours() != null ? session.getCadHours() : BigDecimal.ZERO);
|
||||||
BigDecimal x = item.getBoundingBoxXMm() != null ? item.getBoundingBoxXMm() : BigDecimal.ZERO;
|
order.setCadHourlyRateChf(session.getCadHourlyRateChf() != null ? session.getCadHourlyRateChf() : BigDecimal.ZERO);
|
||||||
BigDecimal y = item.getBoundingBoxYMm() != null ? item.getBoundingBoxYMm() : BigDecimal.ZERO;
|
order.setCadTotalChf(cadTotal);
|
||||||
BigDecimal z = item.getBoundingBoxZMm() != null ? item.getBoundingBoxZMm() : BigDecimal.ZERO;
|
|
||||||
|
|
||||||
BigDecimal[] dims = {x, y, z};
|
|
||||||
java.util.Arrays.sort(dims);
|
|
||||||
|
|
||||||
if (dims[2].compareTo(BigDecimal.valueOf(250.0)) > 0 ||
|
|
||||||
dims[1].compareTo(BigDecimal.valueOf(176.0)) > 0 ||
|
|
||||||
dims[0].compareTo(BigDecimal.valueOf(20.0)) > 0) {
|
|
||||||
exceedsBaseSize = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int totalQuantity = quoteItems.stream()
|
|
||||||
.mapToInt(i -> i.getQuantity() != null ? i.getQuantity() : 1)
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
if (exceedsBaseSize) {
|
|
||||||
order.setShippingCostChf(totalQuantity > 5 ? BigDecimal.valueOf(9.00) : BigDecimal.valueOf(4.00));
|
|
||||||
} else {
|
|
||||||
order.setShippingCostChf(BigDecimal.valueOf(2.00));
|
|
||||||
}
|
|
||||||
|
|
||||||
order = orderRepo.save(order);
|
order = orderRepo.save(order);
|
||||||
|
|
||||||
List<OrderItem> savedItems = new ArrayList<>();
|
List<OrderItem> savedItems = new ArrayList<>();
|
||||||
|
|
||||||
// Calculate global machine cost upfront
|
|
||||||
BigDecimal totalSeconds = BigDecimal.ZERO;
|
|
||||||
for (QuoteLineItem qItem : quoteItems) {
|
|
||||||
if (qItem.getPrintTimeSeconds() != null) {
|
|
||||||
totalSeconds = totalSeconds.add(BigDecimal.valueOf(qItem.getPrintTimeSeconds()).multiply(BigDecimal.valueOf(qItem.getQuantity())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BigDecimal totalHours = totalSeconds.divide(BigDecimal.valueOf(3600), 4, RoundingMode.HALF_UP);
|
|
||||||
PricingPolicy policy = pricingRepo.findFirstByIsActiveTrueOrderByValidFromDesc();
|
|
||||||
BigDecimal globalMachineCost = quoteCalculator.calculateSessionMachineCost(policy, totalHours);
|
|
||||||
|
|
||||||
for (QuoteLineItem qItem : quoteItems) {
|
for (QuoteLineItem qItem : quoteItems) {
|
||||||
OrderItem oItem = new OrderItem();
|
OrderItem oItem = new OrderItem();
|
||||||
oItem.setOrder(order);
|
oItem.setOrder(order);
|
||||||
oItem.setOriginalFilename(qItem.getOriginalFilename());
|
oItem.setOriginalFilename(qItem.getOriginalFilename());
|
||||||
oItem.setQuantity(qItem.getQuantity());
|
int quantity = qItem.getQuantity() != null && qItem.getQuantity() > 0 ? qItem.getQuantity() : 1;
|
||||||
|
oItem.setQuantity(quantity);
|
||||||
oItem.setColorCode(qItem.getColorCode());
|
oItem.setColorCode(qItem.getColorCode());
|
||||||
oItem.setFilamentVariant(qItem.getFilamentVariant());
|
oItem.setFilamentVariant(qItem.getFilamentVariant());
|
||||||
if (qItem.getFilamentVariant() != null
|
if (qItem.getFilamentVariant() != null
|
||||||
@@ -212,17 +179,17 @@ public class OrderService {
|
|||||||
oItem.setMaterialCode(session.getMaterialCode());
|
oItem.setMaterialCode(session.getMaterialCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal distributedUnitPrice = qItem.getUnitPriceChf();
|
BigDecimal distributedUnitPrice = qItem.getUnitPriceChf() != null ? qItem.getUnitPriceChf() : BigDecimal.ZERO;
|
||||||
if (totalSeconds.compareTo(BigDecimal.ZERO) > 0 && qItem.getPrintTimeSeconds() != null) {
|
if (totals.totalPrintSeconds().compareTo(BigDecimal.ZERO) > 0 && qItem.getPrintTimeSeconds() != null) {
|
||||||
BigDecimal itemSeconds = BigDecimal.valueOf(qItem.getPrintTimeSeconds()).multiply(BigDecimal.valueOf(qItem.getQuantity()));
|
BigDecimal itemSeconds = BigDecimal.valueOf(qItem.getPrintTimeSeconds()).multiply(BigDecimal.valueOf(quantity));
|
||||||
BigDecimal share = itemSeconds.divide(totalSeconds, 8, RoundingMode.HALF_UP);
|
BigDecimal share = itemSeconds.divide(totals.totalPrintSeconds(), 8, RoundingMode.HALF_UP);
|
||||||
BigDecimal itemMachineCost = globalMachineCost.multiply(share);
|
BigDecimal itemMachineCost = totals.globalMachineCostChf().multiply(share);
|
||||||
BigDecimal unitMachineCost = itemMachineCost.divide(BigDecimal.valueOf(qItem.getQuantity()), 2, RoundingMode.HALF_UP);
|
BigDecimal unitMachineCost = itemMachineCost.divide(BigDecimal.valueOf(quantity), 2, RoundingMode.HALF_UP);
|
||||||
distributedUnitPrice = distributedUnitPrice.add(unitMachineCost);
|
distributedUnitPrice = distributedUnitPrice.add(unitMachineCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
oItem.setUnitPriceChf(distributedUnitPrice);
|
oItem.setUnitPriceChf(distributedUnitPrice);
|
||||||
oItem.setLineTotalChf(distributedUnitPrice.multiply(BigDecimal.valueOf(qItem.getQuantity())));
|
oItem.setLineTotalChf(distributedUnitPrice.multiply(BigDecimal.valueOf(quantity)));
|
||||||
oItem.setPrintTimeSeconds(qItem.getPrintTimeSeconds());
|
oItem.setPrintTimeSeconds(qItem.getPrintTimeSeconds());
|
||||||
oItem.setMaterialGrams(qItem.getMaterialGrams());
|
oItem.setMaterialGrams(qItem.getMaterialGrams());
|
||||||
oItem.setBoundingBoxXMm(qItem.getBoundingBoxXMm());
|
oItem.setBoundingBoxXMm(qItem.getBoundingBoxXMm());
|
||||||
@@ -260,9 +227,12 @@ public class OrderService {
|
|||||||
subtotal = subtotal.add(oItem.getLineTotalChf());
|
subtotal = subtotal.add(oItem.getLineTotalChf());
|
||||||
}
|
}
|
||||||
|
|
||||||
order.setSubtotalChf(subtotal);
|
order.setSubtotalChf(subtotal.add(cadTotal));
|
||||||
|
|
||||||
BigDecimal total = subtotal.add(order.getSetupCostChf()).add(order.getShippingCostChf()).subtract(order.getDiscountChf() != null ? order.getDiscountChf() : BigDecimal.ZERO);
|
BigDecimal total = order.getSubtotalChf()
|
||||||
|
.add(order.getSetupCostChf())
|
||||||
|
.add(order.getShippingCostChf())
|
||||||
|
.subtract(order.getDiscountChf() != null ? order.getDiscountChf() : BigDecimal.ZERO);
|
||||||
order.setTotalChf(total);
|
order.setTotalChf(total);
|
||||||
|
|
||||||
session.setConvertedOrderId(order.getId());
|
session.setConvertedOrderId(order.getId());
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package com.printcalculator.service;
|
||||||
|
|
||||||
|
import com.printcalculator.entity.PricingPolicy;
|
||||||
|
import com.printcalculator.entity.QuoteLineItem;
|
||||||
|
import com.printcalculator.entity.QuoteSession;
|
||||||
|
import com.printcalculator.repository.PricingPolicyRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class QuoteSessionTotalsService {
|
||||||
|
private final PricingPolicyRepository pricingRepo;
|
||||||
|
private final QuoteCalculator quoteCalculator;
|
||||||
|
|
||||||
|
public QuoteSessionTotalsService(PricingPolicyRepository pricingRepo, QuoteCalculator quoteCalculator) {
|
||||||
|
this.pricingRepo = pricingRepo;
|
||||||
|
this.quoteCalculator = quoteCalculator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuoteSessionTotals compute(QuoteSession session, List<QuoteLineItem> items) {
|
||||||
|
BigDecimal printItemsBaseTotal = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalSeconds = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
for (QuoteLineItem item : items) {
|
||||||
|
int quantity = normalizeQuantity(item.getQuantity());
|
||||||
|
BigDecimal unitPrice = item.getUnitPriceChf() != null ? item.getUnitPriceChf() : BigDecimal.ZERO;
|
||||||
|
printItemsBaseTotal = printItemsBaseTotal.add(unitPrice.multiply(BigDecimal.valueOf(quantity)));
|
||||||
|
|
||||||
|
if (item.getPrintTimeSeconds() != null && item.getPrintTimeSeconds() > 0) {
|
||||||
|
totalSeconds = totalSeconds.add(BigDecimal.valueOf(item.getPrintTimeSeconds()).multiply(BigDecimal.valueOf(quantity)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal totalHours = totalSeconds.divide(BigDecimal.valueOf(3600), 4, RoundingMode.HALF_UP);
|
||||||
|
PricingPolicy policy = pricingRepo.findFirstByIsActiveTrueOrderByValidFromDesc();
|
||||||
|
BigDecimal globalMachineCost = quoteCalculator.calculateSessionMachineCost(policy, totalHours);
|
||||||
|
BigDecimal printItemsTotal = printItemsBaseTotal.add(globalMachineCost);
|
||||||
|
|
||||||
|
BigDecimal cadTotal = calculateCadTotal(session);
|
||||||
|
BigDecimal itemsTotal = printItemsTotal.add(cadTotal);
|
||||||
|
|
||||||
|
BigDecimal setupFee = session.getSetupCostChf() != null ? session.getSetupCostChf() : BigDecimal.ZERO;
|
||||||
|
BigDecimal shippingCost = calculateShippingCost(items);
|
||||||
|
BigDecimal grandTotal = itemsTotal.add(setupFee).add(shippingCost);
|
||||||
|
|
||||||
|
return new QuoteSessionTotals(
|
||||||
|
printItemsTotal,
|
||||||
|
globalMachineCost,
|
||||||
|
cadTotal,
|
||||||
|
itemsTotal,
|
||||||
|
setupFee,
|
||||||
|
shippingCost,
|
||||||
|
grandTotal,
|
||||||
|
totalSeconds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal calculateCadTotal(QuoteSession session) {
|
||||||
|
if (session == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
BigDecimal cadHours = session.getCadHours() != null ? session.getCadHours() : BigDecimal.ZERO;
|
||||||
|
BigDecimal cadRate = session.getCadHourlyRateChf() != null ? session.getCadHourlyRateChf() : BigDecimal.ZERO;
|
||||||
|
if (cadHours.compareTo(BigDecimal.ZERO) <= 0 || cadRate.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
return cadHours.multiply(cadRate).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal calculateShippingCost(List<QuoteLineItem> items) {
|
||||||
|
if (items == null || items.isEmpty()) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean exceedsBaseSize = false;
|
||||||
|
for (QuoteLineItem item : items) {
|
||||||
|
BigDecimal x = item.getBoundingBoxXMm() != null ? item.getBoundingBoxXMm() : BigDecimal.ZERO;
|
||||||
|
BigDecimal y = item.getBoundingBoxYMm() != null ? item.getBoundingBoxYMm() : BigDecimal.ZERO;
|
||||||
|
BigDecimal z = item.getBoundingBoxZMm() != null ? item.getBoundingBoxZMm() : BigDecimal.ZERO;
|
||||||
|
|
||||||
|
BigDecimal[] dims = {x, y, z};
|
||||||
|
Arrays.sort(dims);
|
||||||
|
|
||||||
|
if (dims[2].compareTo(BigDecimal.valueOf(250.0)) > 0
|
||||||
|
|| dims[1].compareTo(BigDecimal.valueOf(176.0)) > 0
|
||||||
|
|| dims[0].compareTo(BigDecimal.valueOf(20.0)) > 0) {
|
||||||
|
exceedsBaseSize = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalQuantity = items.stream().mapToInt(i -> normalizeQuantity(i.getQuantity())).sum();
|
||||||
|
if (totalQuantity <= 0) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exceedsBaseSize) {
|
||||||
|
return totalQuantity > 5 ? BigDecimal.valueOf(9.00) : BigDecimal.valueOf(4.00);
|
||||||
|
}
|
||||||
|
return BigDecimal.valueOf(2.00);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int normalizeQuantity(Integer quantity) {
|
||||||
|
if (quantity == null || quantity < 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public record QuoteSessionTotals(
|
||||||
|
BigDecimal printItemsTotalChf,
|
||||||
|
BigDecimal globalMachineCostChf,
|
||||||
|
BigDecimal cadTotalChf,
|
||||||
|
BigDecimal itemsTotalChf,
|
||||||
|
BigDecimal setupCostChf,
|
||||||
|
BigDecimal shippingCostChf,
|
||||||
|
BigDecimal grandTotalChf,
|
||||||
|
BigDecimal totalPrintSeconds
|
||||||
|
) {}
|
||||||
|
}
|
||||||
@@ -45,9 +45,8 @@ public class SessionCleanupService {
|
|||||||
// "rimangono in memoria... cancella quelle vecchie di 7 giorni".
|
// "rimangono in memoria... cancella quelle vecchie di 7 giorni".
|
||||||
// Implementation plan said: status != 'ORDERED'.
|
// Implementation plan said: status != 'ORDERED'.
|
||||||
|
|
||||||
// User specified statuses: ACTIVE, EXPIRED, CONVERTED.
|
// CAD_ACTIVE sessions are managed manually from back-office and must be preserved.
|
||||||
// We should NOT delete sessions that have been converted to an order.
|
if ("CONVERTED".equals(session.getStatus()) || "CAD_ACTIVE".equals(session.getStatus())) {
|
||||||
if ("CONVERTED".equals(session.getStatus())) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ app.mail.admin.enabled=${APP_MAIL_ADMIN_ENABLED:true}
|
|||||||
app.mail.admin.address=${APP_MAIL_ADMIN_ADDRESS:admin@printcalculator.local}
|
app.mail.admin.address=${APP_MAIL_ADMIN_ADDRESS:admin@printcalculator.local}
|
||||||
app.mail.contact-request.admin.enabled=${APP_MAIL_CONTACT_REQUEST_ADMIN_ENABLED:true}
|
app.mail.contact-request.admin.enabled=${APP_MAIL_CONTACT_REQUEST_ADMIN_ENABLED:true}
|
||||||
app.mail.contact-request.admin.address=${APP_MAIL_CONTACT_REQUEST_ADMIN_ADDRESS:infog@3d-fab.ch}
|
app.mail.contact-request.admin.address=${APP_MAIL_CONTACT_REQUEST_ADMIN_ADDRESS:infog@3d-fab.ch}
|
||||||
|
app.mail.contact-request.customer.enabled=${APP_MAIL_CONTACT_REQUEST_CUSTOMER_ENABLED:true}
|
||||||
app.frontend.base-url=${APP_FRONTEND_BASE_URL:http://localhost:4200}
|
app.frontend.base-url=${APP_FRONTEND_BASE_URL:http://localhost:4200}
|
||||||
|
|
||||||
# Admin back-office authentication
|
# Admin back-office authentication
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title th:text="${emailTitle}">Contact request received</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
max-width: 640px;
|
||||||
|
margin: 20px auto;
|
||||||
|
background-color: #ffffff;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin-top: 0;
|
||||||
|
color: #222222;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin-top: 18px;
|
||||||
|
color: #222222;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
color: #444444;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
border-bottom: 1px solid #eeeeee;
|
||||||
|
padding: 10px 6px;
|
||||||
|
color: #333333;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
width: 35%;
|
||||||
|
color: #222222;
|
||||||
|
background: #fafafa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
margin-top: 24px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #888888;
|
||||||
|
border-top: 1px solid #eeeeee;
|
||||||
|
padding-top: 12px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1 th:text="${headlineText}">We received your contact request</h1>
|
||||||
|
<p th:text="${greetingText}">Hi customer,</p>
|
||||||
|
<p th:text="${introText}">Thank you for contacting us. Our team will reply as soon as possible.</p>
|
||||||
|
<p>
|
||||||
|
<strong th:text="${requestIdHintText}">Please keep this request ID for future order references:</strong>
|
||||||
|
<span th:text="${requestId}">00000000-0000-0000-0000-000000000000</span>
|
||||||
|
</p>
|
||||||
|
<h2 th:text="${detailsTitleText}">Request details</h2>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelRequestId}">Request ID</th>
|
||||||
|
<td th:text="${requestId}">00000000-0000-0000-0000-000000000000</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelDate}">Date</th>
|
||||||
|
<td th:text="${createdAt}">2026-03-03T10:00:00Z</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelRequestType}">Request type</th>
|
||||||
|
<td th:text="${requestType}">custom</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelCustomerType}">Customer type</th>
|
||||||
|
<td th:text="${customerType}">PRIVATE</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelName}">Name</th>
|
||||||
|
<td th:text="${name}">Mario Rossi</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelCompany}">Company</th>
|
||||||
|
<td th:text="${companyName}">3D Fab SA</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelContactPerson}">Contact person</th>
|
||||||
|
<td th:text="${contactPerson}">Mario Rossi</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelEmail}">Email</th>
|
||||||
|
<td th:text="${email}">cliente@example.com</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelPhone}">Phone</th>
|
||||||
|
<td th:text="${phone}">+41 00 000 00 00</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelMessage}">Message</th>
|
||||||
|
<td th:text="${message}">Testo richiesta cliente...</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th th:text="${labelAttachments}">Attachments</th>
|
||||||
|
<td th:text="${attachmentsCount}">0</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p th:text="${supportText}">If you need help, reply to this email.</p>
|
||||||
|
|
||||||
|
<div class="footer">
|
||||||
|
<p>© <span th:text="${currentYear}">2026</span> <span th:text="${footerText}">Automated request-receipt confirmation from 3D-Fab.</span></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.printcalculator.service;
|
||||||
|
|
||||||
|
import com.printcalculator.entity.PricingPolicy;
|
||||||
|
import com.printcalculator.entity.QuoteLineItem;
|
||||||
|
import com.printcalculator.entity.QuoteSession;
|
||||||
|
import com.printcalculator.repository.PricingPolicyRepository;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
class QuoteSessionTotalsServiceTest {
|
||||||
|
private PricingPolicyRepository pricingRepo;
|
||||||
|
private QuoteCalculator quoteCalculator;
|
||||||
|
private QuoteSessionTotalsService service;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
pricingRepo = mock(PricingPolicyRepository.class);
|
||||||
|
quoteCalculator = mock(QuoteCalculator.class);
|
||||||
|
service = new QuoteSessionTotalsService(pricingRepo, quoteCalculator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void compute_WithCadOnlySession_ShouldIncludeCadAndNoShipping() {
|
||||||
|
QuoteSession session = new QuoteSession();
|
||||||
|
session.setSetupCostChf(BigDecimal.ZERO);
|
||||||
|
session.setCadHours(BigDecimal.valueOf(2));
|
||||||
|
session.setCadHourlyRateChf(BigDecimal.valueOf(75));
|
||||||
|
|
||||||
|
PricingPolicy policy = new PricingPolicy();
|
||||||
|
when(pricingRepo.findFirstByIsActiveTrueOrderByValidFromDesc()).thenReturn(policy);
|
||||||
|
when(quoteCalculator.calculateSessionMachineCost(eq(policy), any(BigDecimal.class))).thenReturn(BigDecimal.ZERO);
|
||||||
|
|
||||||
|
QuoteSessionTotalsService.QuoteSessionTotals totals = service.compute(session, List.of());
|
||||||
|
|
||||||
|
assertAmountEquals("150.00", totals.cadTotalChf());
|
||||||
|
assertAmountEquals("0.00", totals.shippingCostChf());
|
||||||
|
assertAmountEquals("150.00", totals.itemsTotalChf());
|
||||||
|
assertAmountEquals("150.00", totals.grandTotalChf());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void compute_WithPrintItemAndCad_ShouldSumEverything() {
|
||||||
|
QuoteSession session = new QuoteSession();
|
||||||
|
session.setSetupCostChf(new BigDecimal("5.00"));
|
||||||
|
session.setCadHours(new BigDecimal("1.50"));
|
||||||
|
session.setCadHourlyRateChf(new BigDecimal("60.00"));
|
||||||
|
|
||||||
|
QuoteLineItem item = new QuoteLineItem();
|
||||||
|
item.setQuantity(2);
|
||||||
|
item.setUnitPriceChf(new BigDecimal("10.00"));
|
||||||
|
item.setPrintTimeSeconds(3600);
|
||||||
|
item.setBoundingBoxXMm(new BigDecimal("10"));
|
||||||
|
item.setBoundingBoxYMm(new BigDecimal("10"));
|
||||||
|
item.setBoundingBoxZMm(new BigDecimal("10"));
|
||||||
|
|
||||||
|
PricingPolicy policy = new PricingPolicy();
|
||||||
|
when(pricingRepo.findFirstByIsActiveTrueOrderByValidFromDesc()).thenReturn(policy);
|
||||||
|
when(quoteCalculator.calculateSessionMachineCost(policy, new BigDecimal("2.0000")))
|
||||||
|
.thenReturn(new BigDecimal("3.00"));
|
||||||
|
|
||||||
|
QuoteSessionTotalsService.QuoteSessionTotals totals = service.compute(session, List.of(item));
|
||||||
|
|
||||||
|
assertAmountEquals("23.00", totals.printItemsTotalChf());
|
||||||
|
assertAmountEquals("90.00", totals.cadTotalChf());
|
||||||
|
assertAmountEquals("113.00", totals.itemsTotalChf());
|
||||||
|
assertAmountEquals("2.00", totals.shippingCostChf());
|
||||||
|
assertAmountEquals("120.00", totals.grandTotalChf());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertAmountEquals(String expected, BigDecimal actual) {
|
||||||
|
assertTrue(new BigDecimal(expected).compareTo(actual) == 0,
|
||||||
|
"Expected " + expected + " but got " + actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
61
db.sql
61
db.sql
@@ -599,7 +599,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS ux_customers_email
|
|||||||
CREATE TABLE IF NOT EXISTS quote_sessions
|
CREATE TABLE IF NOT EXISTS quote_sessions
|
||||||
(
|
(
|
||||||
quote_session_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
quote_session_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
status text NOT NULL CHECK (status IN ('ACTIVE', 'EXPIRED', 'CONVERTED')),
|
status text NOT NULL CHECK (status IN ('ACTIVE', 'CAD_ACTIVE', 'EXPIRED', 'CONVERTED')),
|
||||||
pricing_version text NOT NULL,
|
pricing_version text NOT NULL,
|
||||||
|
|
||||||
-- Parametri "globali" (dalla tua UI avanzata)
|
-- Parametri "globali" (dalla tua UI avanzata)
|
||||||
@@ -612,6 +612,9 @@ CREATE TABLE IF NOT EXISTS quote_sessions
|
|||||||
notes text,
|
notes text,
|
||||||
|
|
||||||
setup_cost_chf numeric(12, 2) NOT NULL DEFAULT 0.00,
|
setup_cost_chf numeric(12, 2) NOT NULL DEFAULT 0.00,
|
||||||
|
source_request_id uuid,
|
||||||
|
cad_hours numeric(10, 2),
|
||||||
|
cad_hourly_rate_chf numeric(10, 2),
|
||||||
|
|
||||||
created_at timestamptz NOT NULL DEFAULT now(),
|
created_at timestamptz NOT NULL DEFAULT now(),
|
||||||
expires_at timestamptz NOT NULL,
|
expires_at timestamptz NOT NULL,
|
||||||
@@ -624,6 +627,25 @@ CREATE INDEX IF NOT EXISTS ix_quote_sessions_status
|
|||||||
CREATE INDEX IF NOT EXISTS ix_quote_sessions_expires_at
|
CREATE INDEX IF NOT EXISTS ix_quote_sessions_expires_at
|
||||||
ON quote_sessions (expires_at);
|
ON quote_sessions (expires_at);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS ix_quote_sessions_source_request
|
||||||
|
ON quote_sessions (source_request_id);
|
||||||
|
|
||||||
|
ALTER TABLE quote_sessions
|
||||||
|
ADD COLUMN IF NOT EXISTS source_request_id uuid;
|
||||||
|
|
||||||
|
ALTER TABLE quote_sessions
|
||||||
|
ADD COLUMN IF NOT EXISTS cad_hours numeric(10, 2);
|
||||||
|
|
||||||
|
ALTER TABLE quote_sessions
|
||||||
|
ADD COLUMN IF NOT EXISTS cad_hourly_rate_chf numeric(10, 2);
|
||||||
|
|
||||||
|
ALTER TABLE quote_sessions
|
||||||
|
DROP CONSTRAINT IF EXISTS quote_sessions_status_check;
|
||||||
|
|
||||||
|
ALTER TABLE quote_sessions
|
||||||
|
ADD CONSTRAINT quote_sessions_status_check
|
||||||
|
CHECK (status IN ('ACTIVE', 'CAD_ACTIVE', 'EXPIRED', 'CONVERTED'));
|
||||||
|
|
||||||
-- =========================
|
-- =========================
|
||||||
-- QUOTE LINE ITEMS (1 file = 1 riga)
|
-- QUOTE LINE ITEMS (1 file = 1 riga)
|
||||||
-- =========================
|
-- =========================
|
||||||
@@ -676,6 +698,7 @@ CREATE TABLE IF NOT EXISTS orders
|
|||||||
(
|
(
|
||||||
order_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
order_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
source_quote_session_id uuid REFERENCES quote_sessions (quote_session_id),
|
source_quote_session_id uuid REFERENCES quote_sessions (quote_session_id),
|
||||||
|
source_request_id uuid,
|
||||||
|
|
||||||
status text NOT NULL CHECK (status IN (
|
status text NOT NULL CHECK (status IN (
|
||||||
'PENDING_PAYMENT', 'PAID', 'IN_PRODUCTION',
|
'PENDING_PAYMENT', 'PAID', 'IN_PRODUCTION',
|
||||||
@@ -717,6 +740,10 @@ CREATE TABLE IF NOT EXISTS orders
|
|||||||
discount_chf numeric(12, 2) NOT NULL DEFAULT 0.00,
|
discount_chf numeric(12, 2) NOT NULL DEFAULT 0.00,
|
||||||
|
|
||||||
subtotal_chf numeric(12, 2) NOT NULL DEFAULT 0.00,
|
subtotal_chf numeric(12, 2) NOT NULL DEFAULT 0.00,
|
||||||
|
is_cad_order boolean NOT NULL DEFAULT false,
|
||||||
|
cad_hours numeric(10, 2),
|
||||||
|
cad_hourly_rate_chf numeric(10, 2),
|
||||||
|
cad_total_chf numeric(12, 2) NOT NULL DEFAULT 0.00,
|
||||||
total_chf numeric(12, 2) NOT NULL DEFAULT 0.00,
|
total_chf numeric(12, 2) NOT NULL DEFAULT 0.00,
|
||||||
|
|
||||||
created_at timestamptz NOT NULL DEFAULT now(),
|
created_at timestamptz NOT NULL DEFAULT now(),
|
||||||
@@ -730,6 +757,24 @@ CREATE INDEX IF NOT EXISTS ix_orders_status
|
|||||||
CREATE INDEX IF NOT EXISTS ix_orders_customer_email
|
CREATE INDEX IF NOT EXISTS ix_orders_customer_email
|
||||||
ON orders (lower(customer_email));
|
ON orders (lower(customer_email));
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS ix_orders_source_request
|
||||||
|
ON orders (source_request_id);
|
||||||
|
|
||||||
|
ALTER TABLE orders
|
||||||
|
ADD COLUMN IF NOT EXISTS source_request_id uuid;
|
||||||
|
|
||||||
|
ALTER TABLE orders
|
||||||
|
ADD COLUMN IF NOT EXISTS is_cad_order boolean NOT NULL DEFAULT false;
|
||||||
|
|
||||||
|
ALTER TABLE orders
|
||||||
|
ADD COLUMN IF NOT EXISTS cad_hours numeric(10, 2);
|
||||||
|
|
||||||
|
ALTER TABLE orders
|
||||||
|
ADD COLUMN IF NOT EXISTS cad_hourly_rate_chf numeric(10, 2);
|
||||||
|
|
||||||
|
ALTER TABLE orders
|
||||||
|
ADD COLUMN IF NOT EXISTS cad_total_chf numeric(12, 2) NOT NULL DEFAULT 0.00;
|
||||||
|
|
||||||
-- =========================
|
-- =========================
|
||||||
-- ORDER ITEMS (1 file 3D = 1 riga, file salvato su disco)
|
-- ORDER ITEMS (1 file 3D = 1 riga, file salvato su disco)
|
||||||
-- =========================
|
-- =========================
|
||||||
@@ -849,3 +894,17 @@ CREATE TABLE IF NOT EXISTS custom_quote_request_attachments
|
|||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS ix_custom_quote_attachments_request
|
CREATE INDEX IF NOT EXISTS ix_custom_quote_attachments_request
|
||||||
ON custom_quote_request_attachments (request_id);
|
ON custom_quote_request_attachments (request_id);
|
||||||
|
|
||||||
|
ALTER TABLE quote_sessions
|
||||||
|
DROP CONSTRAINT IF EXISTS fk_quote_sessions_source_request;
|
||||||
|
|
||||||
|
ALTER TABLE quote_sessions
|
||||||
|
ADD CONSTRAINT fk_quote_sessions_source_request
|
||||||
|
FOREIGN KEY (source_request_id) REFERENCES custom_quote_requests (request_id);
|
||||||
|
|
||||||
|
ALTER TABLE orders
|
||||||
|
DROP CONSTRAINT IF EXISTS fk_orders_source_request;
|
||||||
|
|
||||||
|
ALTER TABLE orders
|
||||||
|
ADD CONSTRAINT fk_orders_source_request
|
||||||
|
FOREIGN KEY (source_request_id) REFERENCES custom_quote_requests (request_id);
|
||||||
|
|||||||
@@ -28,6 +28,13 @@ const appChildRoutes: Routes = [
|
|||||||
loadChildren: () =>
|
loadChildren: () =>
|
||||||
import('./features/contact/contact.routes').then((m) => m.CONTACT_ROUTES),
|
import('./features/contact/contact.routes').then((m) => m.CONTACT_ROUTES),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'checkout/cad',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('./features/checkout/checkout.component').then(
|
||||||
|
(m) => m.CheckoutComponent,
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'checkout',
|
path: 'checkout',
|
||||||
loadComponent: () =>
|
loadComponent: () =>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<div class="icon-placeholder">
|
<div class="icon-placeholder" routerLink="/admin">
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="20"
|
width="20"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
|
|||||||
import { RouterLink, RouterLinkActive } from '@angular/router';
|
import { RouterLink, RouterLinkActive } from '@angular/router';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { LanguageService } from '../services/language.service';
|
import { LanguageService } from '../services/language.service';
|
||||||
|
import { routes } from '../../app.routes';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-navbar',
|
selector: 'app-navbar',
|
||||||
@@ -37,4 +38,6 @@ export class NavbarComponent {
|
|||||||
closeMenu() {
|
closeMenu() {
|
||||||
this.isMenuOpen = false;
|
this.isMenuOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected readonly routes = routes;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { environment } from '../../../environments/environment';
|
|||||||
export interface QuoteRequestDto {
|
export interface QuoteRequestDto {
|
||||||
requestType: string;
|
requestType: string;
|
||||||
customerType: string;
|
customerType: string;
|
||||||
|
language?: 'it' | 'en' | 'de' | 'fr';
|
||||||
email: string;
|
email: string;
|
||||||
phone?: string;
|
phone?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type PassionId =
|
|||||||
| 'woodworking'
|
| 'woodworking'
|
||||||
| 'van-life'
|
| 'van-life'
|
||||||
| 'coffee'
|
| 'coffee'
|
||||||
|
| 'cooking'
|
||||||
| 'software-development';
|
| 'software-development';
|
||||||
|
|
||||||
interface PassionChip {
|
interface PassionChip {
|
||||||
@@ -50,6 +51,7 @@ export class AboutPageComponent {
|
|||||||
{ id: 'snowboard', labelKey: 'ABOUT.PASSION_SNOWBOARD' },
|
{ id: 'snowboard', labelKey: 'ABOUT.PASSION_SNOWBOARD' },
|
||||||
{ id: 'van-life', labelKey: 'ABOUT.PASSION_VAN_LIFE' },
|
{ id: 'van-life', labelKey: 'ABOUT.PASSION_VAN_LIFE' },
|
||||||
{ id: 'self-hosting', labelKey: 'ABOUT.PASSION_SELF_HOSTING' },
|
{ id: 'self-hosting', labelKey: 'ABOUT.PASSION_SELF_HOSTING' },
|
||||||
|
{ id: 'cooking', labelKey: 'ABOUT.PASSION_COOKING' },
|
||||||
{
|
{
|
||||||
id: 'snowboard-instructor',
|
id: 'snowboard-instructor',
|
||||||
labelKey: 'ABOUT.PASSION_SNOWBOARD_INSTRUCTOR',
|
labelKey: 'ABOUT.PASSION_SNOWBOARD_INSTRUCTOR',
|
||||||
@@ -67,6 +69,7 @@ export class AboutPageComponent {
|
|||||||
'print-3d',
|
'print-3d',
|
||||||
'travel',
|
'travel',
|
||||||
'coffee',
|
'coffee',
|
||||||
|
'cooking',
|
||||||
'software-development',
|
'software-development',
|
||||||
],
|
],
|
||||||
matteo: [
|
matteo: [
|
||||||
|
|||||||
@@ -50,6 +50,13 @@ export const ADMIN_ROUTES: Routes = [
|
|||||||
(m) => m.AdminSessionsComponent,
|
(m) => m.AdminSessionsComponent,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'cad-invoices',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('./pages/admin-cad-invoices.component').then(
|
||||||
|
(m) => m.AdminCadInvoicesComponent,
|
||||||
|
),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,149 @@
|
|||||||
|
<section class="cad-page">
|
||||||
|
<header class="page-header">
|
||||||
|
<div>
|
||||||
|
<h1>Fatture CAD</h1>
|
||||||
|
<p>
|
||||||
|
Crea un checkout CAD partendo da una sessione esistente (opzionale) e
|
||||||
|
gestisci lo stato fino all'ordine.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" (click)="loadCadInvoices()" [disabled]="loading">
|
||||||
|
Aggiorna
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<p class="error" *ngIf="errorMessage">{{ errorMessage }}</p>
|
||||||
|
<p class="success" *ngIf="successMessage">{{ successMessage }}</p>
|
||||||
|
|
||||||
|
<section class="create-box">
|
||||||
|
<h2>Crea nuova fattura CAD</h2>
|
||||||
|
<div class="form-grid">
|
||||||
|
<label>
|
||||||
|
<span>ID Sessione (opzionale)</span>
|
||||||
|
<input
|
||||||
|
[(ngModel)]="form.sessionId"
|
||||||
|
placeholder="UUID sessione quote"
|
||||||
|
type="text"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span>ID Richiesta Contatto (opzionale)</span>
|
||||||
|
<input
|
||||||
|
[(ngModel)]="form.sourceRequestId"
|
||||||
|
placeholder="UUID richiesta contatto"
|
||||||
|
type="text"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span>Ore CAD</span>
|
||||||
|
<input [(ngModel)]="form.cadHours" min="0.1" step="0.1" type="number" />
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span>Tariffa CAD CHF/h (opzionale)</span>
|
||||||
|
<input
|
||||||
|
[(ngModel)]="form.cadHourlyRateChf"
|
||||||
|
placeholder="Se vuoto usa pricing policy attiva"
|
||||||
|
min="0"
|
||||||
|
step="0.05"
|
||||||
|
type="number"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label class="notes-field">
|
||||||
|
<span>Nota (opzionale)</span>
|
||||||
|
<textarea
|
||||||
|
[(ngModel)]="form.notes"
|
||||||
|
placeholder="Nota visibile nel checkout CAD (es. dettagli lavorazione)"
|
||||||
|
rows="3"
|
||||||
|
></textarea>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="create-actions">
|
||||||
|
<button type="button" (click)="createCadInvoice()" [disabled]="creating">
|
||||||
|
{{ creating ? "Creazione..." : "Crea link checkout CAD" }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="table-wrap" *ngIf="!loading; else loadingTpl">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Sessione</th>
|
||||||
|
<th>Richiesta</th>
|
||||||
|
<th>Ore CAD</th>
|
||||||
|
<th>Tariffa</th>
|
||||||
|
<th>Totale CAD</th>
|
||||||
|
<th>Totale ordine</th>
|
||||||
|
<th>Stato sessione</th>
|
||||||
|
<th>Nota</th>
|
||||||
|
<th>Ordine</th>
|
||||||
|
<th>Azioni</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let row of invoices">
|
||||||
|
<td [title]="row.sessionId" [appCopyOnClick]="row.sessionId">
|
||||||
|
{{ row.sessionId | slice: 0 : 8 }}
|
||||||
|
</td>
|
||||||
|
<td
|
||||||
|
[title]="row.sourceRequestId || ''"
|
||||||
|
[appCopyOnClick]="row.sourceRequestId"
|
||||||
|
>
|
||||||
|
{{ row.sourceRequestId || "-" }}
|
||||||
|
</td>
|
||||||
|
<td>{{ row.cadHours }}</td>
|
||||||
|
<td>{{ row.cadHourlyRateChf | currency: "CHF" }}</td>
|
||||||
|
<td>{{ row.cadTotalChf | currency: "CHF" }}</td>
|
||||||
|
<td>{{ row.grandTotalChf | currency: "CHF" }}</td>
|
||||||
|
<td>{{ row.sessionStatus }}</td>
|
||||||
|
<td class="notes-cell" [title]="row.notes || ''">
|
||||||
|
{{ row.notes || "-" }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span
|
||||||
|
*ngIf="row.convertedOrderId; else noOrder"
|
||||||
|
[title]="row.convertedOrderId || ''"
|
||||||
|
[appCopyOnClick]="row.convertedOrderId"
|
||||||
|
>
|
||||||
|
{{ row.convertedOrderId | slice: 0 : 8 }} ({{
|
||||||
|
row.convertedOrderStatus || "-"
|
||||||
|
}})
|
||||||
|
</span>
|
||||||
|
<ng-template #noOrder>-</ng-template>
|
||||||
|
</td>
|
||||||
|
<td class="actions">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="ghost"
|
||||||
|
(click)="openCheckout(row.checkoutPath)"
|
||||||
|
>
|
||||||
|
Apri checkout
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="ghost"
|
||||||
|
(click)="copyCheckout(row.checkoutPath)"
|
||||||
|
>
|
||||||
|
Copia link
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="ghost"
|
||||||
|
*ngIf="row.convertedOrderId"
|
||||||
|
(click)="downloadInvoice(row.convertedOrderId)"
|
||||||
|
>
|
||||||
|
Scarica fattura
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr *ngIf="invoices.length === 0">
|
||||||
|
<td colspan="10">Nessuna fattura CAD trovata.</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<ng-template #loadingTpl>
|
||||||
|
<p>Caricamento fatture CAD...</p>
|
||||||
|
</ng-template>
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
.cad-page {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: var(--space-4);
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-header h1 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-header p {
|
||||||
|
margin: var(--space-2) 0 0;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
border: 0;
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
padding: var(--space-2) var(--space-4);
|
||||||
|
background: var(--color-brand);
|
||||||
|
color: var(--color-neutral-900);
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
opacity: 0.65;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.create-box {
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
background: var(--color-bg-card);
|
||||||
|
padding: var(--space-4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.create-box h2 {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: var(--space-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid label {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid span {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid input {
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
padding: var(--space-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notes-field {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid textarea {
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
padding: var(--space-2);
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
.create-actions {
|
||||||
|
margin-top: var(--space-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-wrap {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
min-width: 1100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
padding: var(--space-2);
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notes-cell {
|
||||||
|
max-width: 280px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-2);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ghost {
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
color: var(--color-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
color: var(--color-danger-500);
|
||||||
|
}
|
||||||
|
|
||||||
|
.success {
|
||||||
|
color: var(--color-success-500);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 880px) {
|
||||||
|
.page-header {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { Component, OnInit, inject } from '@angular/core';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import {
|
||||||
|
AdminCadInvoice,
|
||||||
|
AdminOperationsService,
|
||||||
|
} from '../services/admin-operations.service';
|
||||||
|
import { AdminOrdersService } from '../services/admin-orders.service';
|
||||||
|
import { CopyOnClickDirective } from '../../../shared/directives/copy-on-click.directive';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-admin-cad-invoices',
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, FormsModule, CopyOnClickDirective],
|
||||||
|
templateUrl: './admin-cad-invoices.component.html',
|
||||||
|
styleUrl: './admin-cad-invoices.component.scss',
|
||||||
|
})
|
||||||
|
export class AdminCadInvoicesComponent implements OnInit {
|
||||||
|
private readonly adminOperationsService = inject(AdminOperationsService);
|
||||||
|
private readonly adminOrdersService = inject(AdminOrdersService);
|
||||||
|
|
||||||
|
invoices: AdminCadInvoice[] = [];
|
||||||
|
loading = false;
|
||||||
|
creating = false;
|
||||||
|
errorMessage: string | null = null;
|
||||||
|
successMessage: string | null = null;
|
||||||
|
|
||||||
|
form = {
|
||||||
|
sessionId: '',
|
||||||
|
sourceRequestId: '',
|
||||||
|
cadHours: 1,
|
||||||
|
cadHourlyRateChf: '',
|
||||||
|
notes: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.loadCadInvoices();
|
||||||
|
}
|
||||||
|
|
||||||
|
loadCadInvoices(): void {
|
||||||
|
this.loading = true;
|
||||||
|
this.errorMessage = null;
|
||||||
|
this.adminOperationsService.listCadInvoices().subscribe({
|
||||||
|
next: (rows) => {
|
||||||
|
this.invoices = rows;
|
||||||
|
this.loading = false;
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
this.loading = false;
|
||||||
|
this.errorMessage = 'Impossibile caricare le fatture CAD.';
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createCadInvoice(): void {
|
||||||
|
if (this.creating) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cadHours = Number(this.form.cadHours);
|
||||||
|
if (!Number.isFinite(cadHours) || cadHours <= 0) {
|
||||||
|
this.errorMessage = 'Inserisci ore CAD valide (> 0).';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.creating = true;
|
||||||
|
this.errorMessage = null;
|
||||||
|
this.successMessage = null;
|
||||||
|
|
||||||
|
let payload: {
|
||||||
|
sessionId?: string;
|
||||||
|
sourceRequestId?: string;
|
||||||
|
cadHours: number;
|
||||||
|
cadHourlyRateChf?: number;
|
||||||
|
notes?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const sessionIdRaw = String(this.form.sessionId ?? '').trim();
|
||||||
|
const sourceRequestIdRaw = String(this.form.sourceRequestId ?? '').trim();
|
||||||
|
const cadRateRaw = String(this.form.cadHourlyRateChf ?? '').trim();
|
||||||
|
const notesRaw = String(this.form.notes ?? '').trim();
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
sessionId: sessionIdRaw || undefined,
|
||||||
|
sourceRequestId: sourceRequestIdRaw || undefined,
|
||||||
|
cadHours,
|
||||||
|
cadHourlyRateChf:
|
||||||
|
cadRateRaw.length > 0 && Number.isFinite(Number(cadRateRaw))
|
||||||
|
? Number(cadRateRaw)
|
||||||
|
: undefined,
|
||||||
|
notes: notesRaw.length > 0 ? notesRaw : undefined,
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
this.creating = false;
|
||||||
|
this.errorMessage = 'Valori form non validi.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.adminOperationsService.createCadInvoice(payload).subscribe({
|
||||||
|
next: (created) => {
|
||||||
|
this.creating = false;
|
||||||
|
this.successMessage = `Fattura CAD pronta. Sessione: ${created.sessionId}`;
|
||||||
|
this.loadCadInvoices();
|
||||||
|
},
|
||||||
|
error: (err) => {
|
||||||
|
this.creating = false;
|
||||||
|
this.errorMessage =
|
||||||
|
err?.error?.message || 'Creazione fattura CAD non riuscita.';
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
openCheckout(path: string): void {
|
||||||
|
const url = this.toCheckoutUrl(path);
|
||||||
|
window.open(url, '_blank');
|
||||||
|
}
|
||||||
|
|
||||||
|
copyCheckout(path: string): void {
|
||||||
|
const url = this.toCheckoutUrl(path);
|
||||||
|
navigator.clipboard?.writeText(url);
|
||||||
|
this.successMessage = 'Link checkout CAD copiato negli appunti.';
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadInvoice(orderId?: string): void {
|
||||||
|
if (!orderId) return;
|
||||||
|
this.adminOrdersService.downloadOrderInvoice(orderId).subscribe({
|
||||||
|
next: (blob) => {
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = `fattura-cad-${orderId}.pdf`;
|
||||||
|
a.click();
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
this.errorMessage = 'Download fattura non riuscito.';
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private toCheckoutUrl(path: string): string {
|
||||||
|
const safePath = path.startsWith('/') ? path : `/${path}`;
|
||||||
|
const lang = this.resolveLang();
|
||||||
|
return `${window.location.origin}/${lang}${safePath}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private resolveLang(): string {
|
||||||
|
const firstSegment = window.location.pathname
|
||||||
|
.split('/')
|
||||||
|
.filter(Boolean)
|
||||||
|
.shift();
|
||||||
|
if (firstSegment && ['it', 'en', 'de', 'fr'].includes(firstSegment)) {
|
||||||
|
return firstSegment;
|
||||||
|
}
|
||||||
|
return 'it';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,7 +76,12 @@
|
|||||||
<div>
|
<div>
|
||||||
<h3>Dettaglio richiesta</h3>
|
<h3>Dettaglio richiesta</h3>
|
||||||
<p class="request-id">
|
<p class="request-id">
|
||||||
<span>ID</span><code>{{ selectedRequest.id }}</code>
|
<span>ID</span>
|
||||||
|
<code
|
||||||
|
[title]="selectedRequest.id"
|
||||||
|
[appCopyOnClick]="selectedRequest.id"
|
||||||
|
>{{ selectedRequest.id }}</code
|
||||||
|
>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-chips">
|
<div class="detail-chips">
|
||||||
|
|||||||
@@ -199,18 +199,20 @@ tbody tr.selected {
|
|||||||
.request-id {
|
.request-id {
|
||||||
margin: var(--space-2) 0 0;
|
margin: var(--space-2) 0 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: flex-start;
|
||||||
|
flex-wrap: wrap;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
color: var(--color-text-muted);
|
color: var(--color-text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
.request-id code {
|
.request-id code {
|
||||||
display: inline-block;
|
display: block;
|
||||||
max-width: 260px;
|
max-width: 100%;
|
||||||
overflow: hidden;
|
overflow: visible;
|
||||||
text-overflow: ellipsis;
|
text-overflow: clip;
|
||||||
white-space: nowrap;
|
white-space: normal;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
color: var(--color-text);
|
color: var(--color-text);
|
||||||
background: var(--color-neutral-100);
|
background: var(--color-neutral-100);
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ import {
|
|||||||
AdminContactRequestDetail,
|
AdminContactRequestDetail,
|
||||||
AdminOperationsService,
|
AdminOperationsService,
|
||||||
} from '../services/admin-operations.service';
|
} from '../services/admin-operations.service';
|
||||||
|
import { CopyOnClickDirective } from '../../../shared/directives/copy-on-click.directive';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-admin-contact-requests',
|
selector: 'app-admin-contact-requests',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, FormsModule],
|
imports: [CommonModule, FormsModule, CopyOnClickDirective],
|
||||||
templateUrl: './admin-contact-requests.component.html',
|
templateUrl: './admin-contact-requests.component.html',
|
||||||
styleUrl: './admin-contact-requests.component.scss',
|
styleUrl: './admin-contact-requests.component.scss',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -97,7 +97,12 @@
|
|||||||
<div class="detail-header">
|
<div class="detail-header">
|
||||||
<h2>Dettaglio ordine {{ selectedOrder.orderNumber }}</h2>
|
<h2>Dettaglio ordine {{ selectedOrder.orderNumber }}</h2>
|
||||||
<p class="order-uuid">
|
<p class="order-uuid">
|
||||||
UUID: <code>{{ selectedOrder.id }}</code>
|
UUID:
|
||||||
|
<code
|
||||||
|
[title]="selectedOrder.id"
|
||||||
|
[appCopyOnClick]="selectedOrder.id"
|
||||||
|
>{{ selectedOrder.id }}</code
|
||||||
|
>
|
||||||
</p>
|
</p>
|
||||||
<p *ngIf="detailLoading">Caricamento dettaglio...</p>
|
<p *ngIf="detailLoading">Caricamento dettaglio...</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import {
|
|||||||
AdminOrder,
|
AdminOrder,
|
||||||
AdminOrdersService,
|
AdminOrdersService,
|
||||||
} from '../services/admin-orders.service';
|
} from '../services/admin-orders.service';
|
||||||
|
import { CopyOnClickDirective } from '../../../shared/directives/copy-on-click.directive';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-admin-dashboard',
|
selector: 'app-admin-dashboard',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, FormsModule],
|
imports: [CommonModule, FormsModule, CopyOnClickDirective],
|
||||||
templateUrl: './admin-dashboard.component.html',
|
templateUrl: './admin-dashboard.component.html',
|
||||||
styleUrl: './admin-dashboard.component.scss',
|
styleUrl: './admin-dashboard.component.scss',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,12 +33,23 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<ng-container *ngFor="let session of sessions">
|
<ng-container *ngFor="let session of sessions">
|
||||||
<tr>
|
<tr>
|
||||||
<td [title]="session.id">{{ session.id | slice: 0 : 8 }}</td>
|
<td [title]="session.id" [appCopyOnClick]="session.id">
|
||||||
|
{{ session.id | slice: 0 : 8 }}
|
||||||
|
</td>
|
||||||
<td>{{ session.createdAt | date: "short" }}</td>
|
<td>{{ session.createdAt | date: "short" }}</td>
|
||||||
<td>{{ session.expiresAt | date: "short" }}</td>
|
<td>{{ session.expiresAt | date: "short" }}</td>
|
||||||
<td>{{ session.materialCode }}</td>
|
<td>{{ session.materialCode }}</td>
|
||||||
<td>{{ session.status }}</td>
|
<td>{{ session.status }}</td>
|
||||||
<td>{{ session.convertedOrderId || "-" }}</td>
|
<td
|
||||||
|
[title]="session.convertedOrderId || ''"
|
||||||
|
[appCopyOnClick]="session.convertedOrderId"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
session.convertedOrderId
|
||||||
|
? (session.convertedOrderId | slice: 0 : 8)
|
||||||
|
: "-"
|
||||||
|
}}
|
||||||
|
</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -78,6 +89,15 @@
|
|||||||
"
|
"
|
||||||
class="detail-box"
|
class="detail-box"
|
||||||
>
|
>
|
||||||
|
<div class="detail-session-id">
|
||||||
|
<strong>UUID sessione:</strong>
|
||||||
|
<code
|
||||||
|
[title]="detail.session.id"
|
||||||
|
[appCopyOnClick]="detail.session.id"
|
||||||
|
>{{ detail.session.id }}</code
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="detail-summary">
|
<div class="detail-summary">
|
||||||
<div>
|
<div>
|
||||||
<strong>Elementi:</strong> {{ detail.items.length }}
|
<strong>Elementi:</strong> {{ detail.items.length }}
|
||||||
|
|||||||
@@ -103,6 +103,22 @@ td {
|
|||||||
padding: var(--space-4);
|
padding: var(--space-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.detail-session-id {
|
||||||
|
margin-bottom: var(--space-3);
|
||||||
|
display: grid;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-session-id code {
|
||||||
|
display: block;
|
||||||
|
max-width: 100%;
|
||||||
|
padding: var(--space-2);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
background: var(--color-neutral-100);
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
.detail-summary {
|
.detail-summary {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import {
|
|||||||
AdminQuoteSession,
|
AdminQuoteSession,
|
||||||
AdminQuoteSessionDetail,
|
AdminQuoteSessionDetail,
|
||||||
} from '../services/admin-operations.service';
|
} from '../services/admin-operations.service';
|
||||||
|
import { CopyOnClickDirective } from '../../../shared/directives/copy-on-click.directive';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-admin-sessions',
|
selector: 'app-admin-sessions',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule],
|
imports: [CommonModule, CopyOnClickDirective],
|
||||||
templateUrl: './admin-sessions.component.html',
|
templateUrl: './admin-sessions.component.html',
|
||||||
styleUrl: './admin-sessions.component.scss',
|
styleUrl: './admin-sessions.component.scss',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
>Richieste contatto</a
|
>Richieste contatto</a
|
||||||
>
|
>
|
||||||
<a routerLink="sessions" routerLinkActive="active">Sessioni</a>
|
<a routerLink="sessions" routerLinkActive="active">Sessioni</a>
|
||||||
|
<a routerLink="cad-invoices" routerLinkActive="active">Fatture CAD</a>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,10 @@ export interface AdminQuoteSession {
|
|||||||
createdAt: string;
|
createdAt: string;
|
||||||
expiresAt: string;
|
expiresAt: string;
|
||||||
convertedOrderId?: string;
|
convertedOrderId?: string;
|
||||||
|
sourceRequestId?: string;
|
||||||
|
cadHours?: number;
|
||||||
|
cadHourlyRateChf?: number;
|
||||||
|
cadTotalChf?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminQuoteSessionDetailItem {
|
export interface AdminQuoteSessionDetailItem {
|
||||||
@@ -136,14 +140,45 @@ export interface AdminQuoteSessionDetail {
|
|||||||
setupCostChf?: number;
|
setupCostChf?: number;
|
||||||
supportsEnabled?: boolean;
|
supportsEnabled?: boolean;
|
||||||
notes?: string;
|
notes?: string;
|
||||||
|
sourceRequestId?: string;
|
||||||
|
cadHours?: number;
|
||||||
|
cadHourlyRateChf?: number;
|
||||||
};
|
};
|
||||||
items: AdminQuoteSessionDetailItem[];
|
items: AdminQuoteSessionDetailItem[];
|
||||||
|
printItemsTotalChf: number;
|
||||||
|
cadTotalChf: number;
|
||||||
itemsTotalChf: number;
|
itemsTotalChf: number;
|
||||||
shippingCostChf: number;
|
shippingCostChf: number;
|
||||||
globalMachineCostChf: number;
|
globalMachineCostChf: number;
|
||||||
grandTotalChf: number;
|
grandTotalChf: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AdminCreateCadInvoicePayload {
|
||||||
|
sessionId?: string;
|
||||||
|
sourceRequestId?: string;
|
||||||
|
cadHours: number;
|
||||||
|
cadHourlyRateChf?: number;
|
||||||
|
notes?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminCadInvoice {
|
||||||
|
sessionId: string;
|
||||||
|
sessionStatus: string;
|
||||||
|
sourceRequestId?: string;
|
||||||
|
cadHours: number;
|
||||||
|
cadHourlyRateChf: number;
|
||||||
|
cadTotalChf: number;
|
||||||
|
printItemsTotalChf: number;
|
||||||
|
setupCostChf: number;
|
||||||
|
shippingCostChf: number;
|
||||||
|
grandTotalChf: number;
|
||||||
|
convertedOrderId?: string;
|
||||||
|
convertedOrderStatus?: string;
|
||||||
|
checkoutPath: string;
|
||||||
|
notes?: string;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
@@ -279,4 +314,20 @@ export class AdminOperationsService {
|
|||||||
{ withCredentials: true },
|
{ withCredentials: true },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listCadInvoices(): Observable<AdminCadInvoice[]> {
|
||||||
|
return this.http.get<AdminCadInvoice[]>(`${this.baseUrl}/cad-invoices`, {
|
||||||
|
withCredentials: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createCadInvoice(
|
||||||
|
payload: AdminCreateCadInvoicePayload,
|
||||||
|
): Observable<AdminCadInvoice> {
|
||||||
|
return this.http.post<AdminCadInvoice>(
|
||||||
|
`${this.baseUrl}/cad-invoices`,
|
||||||
|
payload,
|
||||||
|
{ withCredentials: true },
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ export interface AdminOrder {
|
|||||||
customerEmail: string;
|
customerEmail: string;
|
||||||
totalChf: number;
|
totalChf: number;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
isCadOrder?: boolean;
|
||||||
|
sourceRequestId?: string;
|
||||||
|
cadHours?: number;
|
||||||
|
cadHourlyRateChf?: number;
|
||||||
|
cadTotalChf?: number;
|
||||||
printMaterialCode?: string;
|
printMaterialCode?: string;
|
||||||
printNozzleDiameterMm?: number;
|
printNozzleDiameterMm?: number;
|
||||||
printLayerHeightMm?: number;
|
printLayerHeightMm?: number;
|
||||||
|
|||||||
@@ -23,14 +23,16 @@
|
|||||||
<div
|
<div
|
||||||
class="mode-option"
|
class="mode-option"
|
||||||
[class.active]="mode() === 'easy'"
|
[class.active]="mode() === 'easy'"
|
||||||
(click)="mode.set('easy')"
|
[class.disabled]="cadSessionLocked()"
|
||||||
|
(click)="!cadSessionLocked() && mode.set('easy')"
|
||||||
>
|
>
|
||||||
{{ "CALC.MODE_EASY" | translate }}
|
{{ "CALC.MODE_EASY" | translate }}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="mode-option"
|
class="mode-option"
|
||||||
[class.active]="mode() === 'advanced'"
|
[class.active]="mode() === 'advanced'"
|
||||||
(click)="mode.set('advanced')"
|
[class.disabled]="cadSessionLocked()"
|
||||||
|
(click)="!cadSessionLocked() && mode.set('advanced')"
|
||||||
>
|
>
|
||||||
{{ "CALC.MODE_ADVANCED" | translate }}
|
{{ "CALC.MODE_ADVANCED" | translate }}
|
||||||
</div>
|
</div>
|
||||||
@@ -39,6 +41,7 @@
|
|||||||
<app-upload-form
|
<app-upload-form
|
||||||
#uploadForm
|
#uploadForm
|
||||||
[mode]="mode()"
|
[mode]="mode()"
|
||||||
|
[lockedSettings]="cadSessionLocked()"
|
||||||
[loading]="loading()"
|
[loading]="loading()"
|
||||||
[uploadProgress]="uploadProgress()"
|
[uploadProgress]="uploadProgress()"
|
||||||
(submitRequest)="onCalculate($event)"
|
(submitRequest)="onCalculate($event)"
|
||||||
|
|||||||
@@ -80,6 +80,11 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.benefits {
|
.benefits {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export class CalculatorPageComponent implements OnInit {
|
|||||||
loading = signal(false);
|
loading = signal(false);
|
||||||
uploadProgress = signal(0);
|
uploadProgress = signal(0);
|
||||||
result = signal<QuoteResult | null>(null);
|
result = signal<QuoteResult | null>(null);
|
||||||
|
cadSessionLocked = signal(false);
|
||||||
error = signal<boolean>(false);
|
error = signal<boolean>(false);
|
||||||
errorKey = signal<string>('CALC.ERROR_GENERIC');
|
errorKey = signal<string>('CALC.ERROR_GENERIC');
|
||||||
isZeroQuoteError = computed(
|
isZeroQuoteError = computed(
|
||||||
@@ -100,6 +101,8 @@ export class CalculatorPageComponent implements OnInit {
|
|||||||
this.error.set(false);
|
this.error.set(false);
|
||||||
this.errorKey.set('CALC.ERROR_GENERIC');
|
this.errorKey.set('CALC.ERROR_GENERIC');
|
||||||
this.result.set(result);
|
this.result.set(result);
|
||||||
|
const isCadSession = data?.session?.status === 'CAD_ACTIVE';
|
||||||
|
this.cadSessionLocked.set(isCadSession);
|
||||||
this.step.set('quote');
|
this.step.set('quote');
|
||||||
|
|
||||||
// 2. Determine Mode (Heuristic)
|
// 2. Determine Mode (Heuristic)
|
||||||
@@ -206,6 +209,7 @@ export class CalculatorPageComponent implements OnInit {
|
|||||||
this.error.set(false);
|
this.error.set(false);
|
||||||
this.errorKey.set('CALC.ERROR_GENERIC');
|
this.errorKey.set('CALC.ERROR_GENERIC');
|
||||||
this.result.set(null);
|
this.result.set(null);
|
||||||
|
this.cadSessionLocked.set(false);
|
||||||
this.orderSuccess.set(false);
|
this.orderSuccess.set(false);
|
||||||
|
|
||||||
// Auto-scroll on mobile to make analysis visible
|
// Auto-scroll on mobile to make analysis visible
|
||||||
@@ -270,10 +274,12 @@ export class CalculatorPageComponent implements OnInit {
|
|||||||
onProceed() {
|
onProceed() {
|
||||||
const res = this.result();
|
const res = this.result();
|
||||||
if (res && res.sessionId) {
|
if (res && res.sessionId) {
|
||||||
this.router.navigate(
|
const segments = this.cadSessionLocked()
|
||||||
['/', this.languageService.selectedLang(), 'checkout'],
|
? ['/', this.languageService.selectedLang(), 'checkout', 'cad']
|
||||||
{ queryParams: { session: res.sessionId } },
|
: ['/', this.languageService.selectedLang(), 'checkout'];
|
||||||
);
|
this.router.navigate(segments, {
|
||||||
|
queryParams: { session: res.sessionId },
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
console.error('No session ID found in quote result');
|
console.error('No session ID found in quote result');
|
||||||
// Fallback or error handling
|
// Fallback or error handling
|
||||||
@@ -343,6 +349,7 @@ export class CalculatorPageComponent implements OnInit {
|
|||||||
onNewQuote() {
|
onNewQuote() {
|
||||||
this.step.set('upload');
|
this.step.set('upload');
|
||||||
this.result.set(null);
|
this.result.set(null);
|
||||||
|
this.cadSessionLocked.set(false);
|
||||||
this.orderSuccess.set(false);
|
this.orderSuccess.set(false);
|
||||||
this.mode.set('easy'); // Reset to default
|
this.mode.set('easy'); // Reset to default
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,12 @@
|
|||||||
: { cost: (result().setupCost | currency: result().currency) }
|
: { cost: (result().setupCost | currency: result().currency) }
|
||||||
}}</small
|
}}</small
|
||||||
><br />
|
><br />
|
||||||
|
@if ((result().cadTotal || 0) > 0) {
|
||||||
|
<small class="shipping-note" style="color: #666">
|
||||||
|
Servizio CAD: {{ result().cadTotal | currency: result().currency }}
|
||||||
|
</small>
|
||||||
|
<br />
|
||||||
|
}
|
||||||
<small class="shipping-note" style="color: #666">{{
|
<small class="shipping-note" style="color: #666">{{
|
||||||
"CALC.SHIPPING_NOTE" | translate
|
"CALC.SHIPPING_NOTE" | translate
|
||||||
}}</small>
|
}}</small>
|
||||||
|
|||||||
@@ -120,8 +120,9 @@ export class QuoteResultComponent implements OnDestroy {
|
|||||||
totals = computed(() => {
|
totals = computed(() => {
|
||||||
const currentItems = this.items();
|
const currentItems = this.items();
|
||||||
const setup = this.result().setupCost;
|
const setup = this.result().setupCost;
|
||||||
|
const cad = this.result().cadTotal || 0;
|
||||||
|
|
||||||
let price = setup;
|
let price = setup + cad;
|
||||||
let time = 0;
|
let time = 0;
|
||||||
let weight = 0;
|
let weight = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
|
@if (lockedSettings()) {
|
||||||
|
<p class="upload-privacy-note">
|
||||||
|
Parametri stampa bloccati per sessione CAD: materiale, nozzle, layer,
|
||||||
|
infill e supporti sono definiti dal back-office.
|
||||||
|
</p>
|
||||||
|
}
|
||||||
<app-select
|
<app-select
|
||||||
formControlName="material"
|
formControlName="material"
|
||||||
[label]="'CALC.MATERIAL' | translate"
|
[label]="'CALC.MATERIAL' | translate"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
signal,
|
signal,
|
||||||
OnInit,
|
OnInit,
|
||||||
inject,
|
inject,
|
||||||
|
effect,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import {
|
import {
|
||||||
@@ -57,6 +58,7 @@ interface FormItem {
|
|||||||
})
|
})
|
||||||
export class UploadFormComponent implements OnInit {
|
export class UploadFormComponent implements OnInit {
|
||||||
mode = input<'easy' | 'advanced'>('easy');
|
mode = input<'easy' | 'advanced'>('easy');
|
||||||
|
lockedSettings = input<boolean>(false);
|
||||||
loading = input<boolean>(false);
|
loading = input<boolean>(false);
|
||||||
uploadProgress = input<number>(0);
|
uploadProgress = input<number>(0);
|
||||||
submitRequest = output<QuoteRequest>();
|
submitRequest = output<QuoteRequest>();
|
||||||
@@ -139,6 +141,10 @@ export class UploadFormComponent implements OnInit {
|
|||||||
if (this.mode() !== 'easy' || this.isPatchingSettings) return;
|
if (this.mode() !== 'easy' || this.isPatchingSettings) return;
|
||||||
this.applyAdvancedPresetFromQuality(quality);
|
this.applyAdvancedPresetFromQuality(quality);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
effect(() => {
|
||||||
|
this.applySettingsLock(this.lockedSettings());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private applyAdvancedPresetFromQuality(quality: string | null | undefined) {
|
private applyAdvancedPresetFromQuality(quality: string | null | undefined) {
|
||||||
@@ -520,7 +526,7 @@ export class UploadFormComponent implements OnInit {
|
|||||||
this.form.value,
|
this.form.value,
|
||||||
);
|
);
|
||||||
this.submitRequest.emit({
|
this.submitRequest.emit({
|
||||||
...this.form.value,
|
...this.form.getRawValue(),
|
||||||
items: this.items(), // Pass the items array explicitly AFTER form value to prevent overwrite
|
items: this.items(), // Pass the items array explicitly AFTER form value to prevent overwrite
|
||||||
mode: this.mode(),
|
mode: this.mode(),
|
||||||
});
|
});
|
||||||
@@ -554,4 +560,26 @@ export class UploadFormComponent implements OnInit {
|
|||||||
private normalizeFileName(fileName: string): string {
|
private normalizeFileName(fileName: string): string {
|
||||||
return (fileName || '').split(/[\\/]/).pop()?.trim().toLowerCase() ?? '';
|
return (fileName || '').split(/[\\/]/).pop()?.trim().toLowerCase() ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private applySettingsLock(locked: boolean): void {
|
||||||
|
const controlsToLock = [
|
||||||
|
'material',
|
||||||
|
'quality',
|
||||||
|
'nozzleDiameter',
|
||||||
|
'infillPattern',
|
||||||
|
'layerHeight',
|
||||||
|
'infillDensity',
|
||||||
|
'supportEnabled',
|
||||||
|
];
|
||||||
|
|
||||||
|
controlsToLock.forEach((name) => {
|
||||||
|
const control = this.form.get(name);
|
||||||
|
if (!control) return;
|
||||||
|
if (locked) {
|
||||||
|
control.disable({ emitEvent: false });
|
||||||
|
} else {
|
||||||
|
control.enable({ emitEvent: false });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ export interface QuoteResult {
|
|||||||
items: QuoteItem[];
|
items: QuoteItem[];
|
||||||
setupCost: number;
|
setupCost: number;
|
||||||
globalMachineCost: number;
|
globalMachineCost: number;
|
||||||
|
cadHours?: number;
|
||||||
|
cadTotal?: number;
|
||||||
currency: string;
|
currency: string;
|
||||||
totalPrice: number;
|
totalPrice: number;
|
||||||
totalTimeHours: number;
|
totalTimeHours: number;
|
||||||
@@ -463,6 +465,8 @@ export class QuoteEstimatorService {
|
|||||||
})),
|
})),
|
||||||
setupCost: session.setupCostChf || 0,
|
setupCost: session.setupCostChf || 0,
|
||||||
globalMachineCost: sessionData.globalMachineCostChf || 0,
|
globalMachineCost: sessionData.globalMachineCostChf || 0,
|
||||||
|
cadHours: session.cadHours || 0,
|
||||||
|
cadTotal: sessionData.cadTotalChf || 0,
|
||||||
currency: 'CHF', // Fixed for now
|
currency: 'CHF', // Fixed for now
|
||||||
totalPrice:
|
totalPrice:
|
||||||
(sessionData.itemsTotalChf || 0) +
|
(sessionData.itemsTotalChf || 0) +
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
<div class="checkout-page">
|
<div class="checkout-page">
|
||||||
<div class="container hero">
|
<div class="container hero">
|
||||||
<h1 class="section-title">{{ "CHECKOUT.TITLE" | translate }}</h1>
|
<h1 class="section-title">{{ "CHECKOUT.TITLE" | translate }}</h1>
|
||||||
|
<p class="cad-subtitle" *ngIf="isCadSession()">
|
||||||
|
Servizio CAD
|
||||||
|
<ng-container *ngIf="cadRequestId()">
|
||||||
|
riferito alla richiesta contatto #{{ cadRequestId() }}
|
||||||
|
</ng-container>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -260,6 +266,17 @@
|
|||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="summary-item cad-summary-item" *ngIf="cadTotal() > 0">
|
||||||
|
<div class="item-details">
|
||||||
|
<span class="item-name">Servizio CAD</span>
|
||||||
|
<div class="item-specs-sub">{{ cadHours() }}h</div>
|
||||||
|
</div>
|
||||||
|
<div class="item-price">
|
||||||
|
<span class="item-total-price">
|
||||||
|
{{ cadTotal() | currency: "CHF" }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="summary-totals" *ngIf="quoteSession() as session">
|
<div class="summary-totals" *ngIf="quoteSession() as session">
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cad-subtitle {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
.checkout-layout {
|
.checkout-layout {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 420px;
|
grid-template-columns: 1fr 420px;
|
||||||
@@ -260,6 +265,13 @@ app-toggle-selector.user-type-selector-compact {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cad-summary-item {
|
||||||
|
background: var(--color-neutral-100);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
padding-left: var(--space-3);
|
||||||
|
padding-right: var(--space-3);
|
||||||
|
}
|
||||||
|
|
||||||
.summary-totals {
|
.summary-totals {
|
||||||
background: var(--color-neutral-100);
|
background: var(--color-neutral-100);
|
||||||
padding: var(--space-4);
|
padding: var(--space-4);
|
||||||
|
|||||||
@@ -162,6 +162,22 @@ export class CheckoutComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isCadSession(): boolean {
|
||||||
|
return this.quoteSession()?.session?.status === 'CAD_ACTIVE';
|
||||||
|
}
|
||||||
|
|
||||||
|
cadRequestId(): string | null {
|
||||||
|
return this.quoteSession()?.session?.sourceRequestId ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
cadHours(): number {
|
||||||
|
return this.quoteSession()?.session?.cadHours ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cadTotal(): number {
|
||||||
|
return this.quoteSession()?.cadTotalChf ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
if (this.checkoutForm.invalid) {
|
if (this.checkoutForm.invalid) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { AppInputComponent } from '../../../../shared/components/app-input/app-i
|
|||||||
import { AppButtonComponent } from '../../../../shared/components/app-button/app-button.component';
|
import { AppButtonComponent } from '../../../../shared/components/app-button/app-button.component';
|
||||||
import { QuoteEstimatorService } from '../../../calculator/services/quote-estimator.service';
|
import { QuoteEstimatorService } from '../../../calculator/services/quote-estimator.service';
|
||||||
import { QuoteRequestService } from '../../../../core/services/quote-request.service';
|
import { QuoteRequestService } from '../../../../core/services/quote-request.service';
|
||||||
|
import { LanguageService } from '../../../../core/services/language.service';
|
||||||
|
|
||||||
interface FilePreview {
|
interface FilePreview {
|
||||||
file: File;
|
file: File;
|
||||||
@@ -53,6 +54,7 @@ export class ContactFormComponent implements OnDestroy {
|
|||||||
];
|
];
|
||||||
|
|
||||||
private quoteRequestService = inject(QuoteRequestService);
|
private quoteRequestService = inject(QuoteRequestService);
|
||||||
|
private languageService = inject(LanguageService);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
@@ -257,6 +259,7 @@ export class ContactFormComponent implements OnDestroy {
|
|||||||
const requestDto: any = {
|
const requestDto: any = {
|
||||||
requestType: formVal.requestType,
|
requestType: formVal.requestType,
|
||||||
customerType: isCompany ? 'BUSINESS' : 'PRIVATE',
|
customerType: isCompany ? 'BUSINESS' : 'PRIVATE',
|
||||||
|
language: this.languageService.selectedLang(),
|
||||||
email: formVal.email,
|
email: formVal.email,
|
||||||
phone: formVal.phone,
|
phone: formVal.phone,
|
||||||
message: formVal.message,
|
message: formVal.message,
|
||||||
|
|||||||
@@ -205,10 +205,10 @@
|
|||||||
gap: var(--space-3);
|
gap: var(--space-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
.capabilities {
|
.section.capabilities {
|
||||||
position: relative;
|
position: relative;
|
||||||
border-bottom: 1px solid var(--color-border);
|
border-bottom: 1px solid var(--color-border);
|
||||||
padding-top: 3rem;
|
padding-top: 4.5rem;
|
||||||
}
|
}
|
||||||
.capabilities-bg {
|
.capabilities-bg {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@@ -198,6 +198,10 @@
|
|||||||
<span>{{ "PAYMENT.SUBTOTAL" | translate }}</span>
|
<span>{{ "PAYMENT.SUBTOTAL" | translate }}</span>
|
||||||
<span>{{ o.subtotalChf | currency: "CHF" }}</span>
|
<span>{{ o.subtotalChf | currency: "CHF" }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="total-row" *ngIf="o.cadTotalChf > 0">
|
||||||
|
<span>Servizio CAD ({{ o.cadHours || 0 }}h)</span>
|
||||||
|
<span>{{ o.cadTotalChf | currency: "CHF" }}</span>
|
||||||
|
</div>
|
||||||
<div class="total-row">
|
<div class="total-row">
|
||||||
<span>{{ "PAYMENT.SHIPPING" | translate }}</span>
|
<span>{{ "PAYMENT.SHIPPING" | translate }}</span>
|
||||||
<span>{{ o.shippingCostChf | currency: "CHF" }}</span>
|
<span>{{ o.shippingCostChf | currency: "CHF" }}</span>
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import { Directive, HostBinding, HostListener, Input } from '@angular/core';
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: '[appCopyOnClick]',
|
||||||
|
standalone: true,
|
||||||
|
})
|
||||||
|
export class CopyOnClickDirective {
|
||||||
|
@Input('appCopyOnClick') value: string | null | undefined;
|
||||||
|
|
||||||
|
@HostBinding('style.cursor') readonly cursor = 'pointer';
|
||||||
|
|
||||||
|
@HostListener('click', ['$event'])
|
||||||
|
onClick(event: MouseEvent): void {
|
||||||
|
const text = (this.value ?? '').trim();
|
||||||
|
if (!text) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.stopPropagation();
|
||||||
|
void this.copy(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async copy(text: string): Promise<void> {
|
||||||
|
if (navigator.clipboard?.writeText) {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(text);
|
||||||
|
return;
|
||||||
|
} catch {
|
||||||
|
// Fallback below for browsers/environments that block clipboard API.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const textarea = document.createElement('textarea');
|
||||||
|
textarea.value = text;
|
||||||
|
textarea.style.position = 'fixed';
|
||||||
|
textarea.style.opacity = '0';
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.select();
|
||||||
|
try {
|
||||||
|
document.execCommand('copy');
|
||||||
|
} finally {
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -149,6 +149,7 @@
|
|||||||
"PASSION_WOODWORKING": "Holzbearbeitung",
|
"PASSION_WOODWORKING": "Holzbearbeitung",
|
||||||
"PASSION_VAN_LIFE": "Van Life",
|
"PASSION_VAN_LIFE": "Van Life",
|
||||||
"PASSION_COFFEE": "Kaffee",
|
"PASSION_COFFEE": "Kaffee",
|
||||||
|
"PASSION_COOKING": "Kochen",
|
||||||
"PASSION_SOFTWARE_DEVELOPMENT": "Softwareentwicklung",
|
"PASSION_SOFTWARE_DEVELOPMENT": "Softwareentwicklung",
|
||||||
"SERVICES_TITLE": "Hauptleistungen",
|
"SERVICES_TITLE": "Hauptleistungen",
|
||||||
"TARGET_TITLE": "Für wen",
|
"TARGET_TITLE": "Für wen",
|
||||||
@@ -471,8 +472,8 @@
|
|||||||
"FOUNDER_IMAGE_ALT_1": "Gründer - Foto 1",
|
"FOUNDER_IMAGE_ALT_1": "Gründer - Foto 1",
|
||||||
"FOUNDER_IMAGE_ALT_2": "Gründer - Foto 2",
|
"FOUNDER_IMAGE_ALT_2": "Gründer - Foto 2",
|
||||||
"HERO_EYEBROW": "Technischer 3D-Druck für Unternehmen, Freelancer und Maker",
|
"HERO_EYEBROW": "Technischer 3D-Druck für Unternehmen, Freelancer und Maker",
|
||||||
"HERO_TITLE": "Preis und Lieferzeit in wenigen Sekunden.<br>Von der 3D-Datei zum fertigen Teil.",
|
"HERO_TITLE": "3D-Druckservice.<br>Von der Datei zum fertigen Teil.",
|
||||||
"HERO_LEAD": "Der fortschrittlichste Rechner für Ihre 3D-Drucke: maximale Präzision und keine Überraschungen.",
|
"HERO_LEAD": "Mit dem fortschrittlichsten Rechner für Ihre 3D-Drucke: absolute Präzision und keine Überraschungen.",
|
||||||
"HERO_SUBTITLE": "Wir bieten auch CAD-Services für individuelle Teile an!",
|
"HERO_SUBTITLE": "Wir bieten auch CAD-Services für individuelle Teile an!",
|
||||||
"BTN_CALCULATE": "Angebot berechnen",
|
"BTN_CALCULATE": "Angebot berechnen",
|
||||||
"BTN_SHOP": "Zum Shop",
|
"BTN_SHOP": "Zum Shop",
|
||||||
|
|||||||
@@ -149,6 +149,7 @@
|
|||||||
"PASSION_WOODWORKING": "Woodworking",
|
"PASSION_WOODWORKING": "Woodworking",
|
||||||
"PASSION_VAN_LIFE": "Van life",
|
"PASSION_VAN_LIFE": "Van life",
|
||||||
"PASSION_COFFEE": "Coffee",
|
"PASSION_COFFEE": "Coffee",
|
||||||
|
"PASSION_COOKING": "Cooking",
|
||||||
"PASSION_SOFTWARE_DEVELOPMENT": "Software development",
|
"PASSION_SOFTWARE_DEVELOPMENT": "Software development",
|
||||||
"SERVICES_TITLE": "Main Services",
|
"SERVICES_TITLE": "Main Services",
|
||||||
"TARGET_TITLE": "Who is it for",
|
"TARGET_TITLE": "Who is it for",
|
||||||
@@ -471,8 +472,8 @@
|
|||||||
"FOUNDER_IMAGE_ALT_1": "Founder - photo 1",
|
"FOUNDER_IMAGE_ALT_1": "Founder - photo 1",
|
||||||
"FOUNDER_IMAGE_ALT_2": "Founder - photo 2",
|
"FOUNDER_IMAGE_ALT_2": "Founder - photo 2",
|
||||||
"HERO_EYEBROW": "Technical 3D printing for businesses, freelancers and makers",
|
"HERO_EYEBROW": "Technical 3D printing for businesses, freelancers and makers",
|
||||||
"HERO_TITLE": "Price and lead time in a few seconds.<br>From 3D file to finished part.",
|
"HERO_TITLE": "3D printing service.<br>From file to finished part.",
|
||||||
"HERO_LEAD": "The most advanced calculator for your 3D prints: total precision and zero surprises.",
|
"HERO_LEAD": "With the most advanced calculator for your 3D prints: absolute precision and zero surprises.",
|
||||||
"HERO_SUBTITLE": "We also offer CAD services for custom parts!",
|
"HERO_SUBTITLE": "We also offer CAD services for custom parts!",
|
||||||
"BTN_CALCULATE": "Calculate Quote",
|
"BTN_CALCULATE": "Calculate Quote",
|
||||||
"BTN_SHOP": "Go to shop",
|
"BTN_SHOP": "Go to shop",
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
},
|
},
|
||||||
"HOME": {
|
"HOME": {
|
||||||
"HERO_EYEBROW": "Impression 3D technique pour entreprises, freelances et makers",
|
"HERO_EYEBROW": "Impression 3D technique pour entreprises, freelances et makers",
|
||||||
"HERO_TITLE": "Prix et délais en quelques secondes.<br>Du fichier 3D à la pièce finie.",
|
"HERO_TITLE": "Service d'impression 3D.<br>Du fichier à la pièce finie.",
|
||||||
"HERO_LEAD": "Le calculateur le plus avancé pour vos impressions 3D : précision totale et zéro surprise.",
|
"HERO_LEAD": "Avec le calculateur le plus avancé pour vos impressions 3D : précision absolue et zéro surprise.",
|
||||||
"HERO_SUBTITLE": "Nous proposons aussi des services CAD pour des pièces personnalisées !",
|
"HERO_SUBTITLE": "Nous proposons aussi des services CAD pour des pièces personnalisées !",
|
||||||
"BTN_CALCULATE": "Calculer un devis",
|
"BTN_CALCULATE": "Calculer un devis",
|
||||||
"BTN_SHOP": "Aller à la boutique",
|
"BTN_SHOP": "Aller à la boutique",
|
||||||
@@ -206,6 +206,7 @@
|
|||||||
"PASSION_WOODWORKING": "Travail du bois",
|
"PASSION_WOODWORKING": "Travail du bois",
|
||||||
"PASSION_VAN_LIFE": "Van life",
|
"PASSION_VAN_LIFE": "Van life",
|
||||||
"PASSION_COFFEE": "Café",
|
"PASSION_COFFEE": "Café",
|
||||||
|
"PASSION_COOKING": "Cuisine",
|
||||||
"PASSION_SOFTWARE_DEVELOPMENT": "Développement logiciel",
|
"PASSION_SOFTWARE_DEVELOPMENT": "Développement logiciel",
|
||||||
"SERVICES_TITLE": "Services principaux",
|
"SERVICES_TITLE": "Services principaux",
|
||||||
"TARGET_TITLE": "Pour qui",
|
"TARGET_TITLE": "Pour qui",
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
},
|
},
|
||||||
"HOME": {
|
"HOME": {
|
||||||
"HERO_EYEBROW": "Stampa 3D tecnica per aziende, freelance e maker",
|
"HERO_EYEBROW": "Stampa 3D tecnica per aziende, freelance e maker",
|
||||||
"HERO_TITLE": "Prezzo e tempi in pochi secondi.<br>Dal file 3D al pezzo finito.",
|
"HERO_TITLE": "Servizio di stampa 3D.<br>Dal file al pezzo finito.",
|
||||||
"HERO_LEAD": "Il calcolatore più avanzato per le tue stampe 3D: precisione assoluta e zero sorprese.",
|
"HERO_LEAD": "Con il calcolatore più avanzato per le tue stampe 3D: precisione assoluta e zero sorprese.",
|
||||||
"HERO_SUBTITLE": "Offriamo anche servizi di CAD per pezzi personalizzati!",
|
"HERO_SUBTITLE": "Offriamo anche servizi di CAD per pezzi personalizzati!",
|
||||||
"BTN_CALCULATE": "Calcola Preventivo",
|
"BTN_CALCULATE": "Calcola Preventivo",
|
||||||
"BTN_SHOP": "Vai allo shop",
|
"BTN_SHOP": "Vai allo shop",
|
||||||
@@ -206,6 +206,7 @@
|
|||||||
"PASSION_WOODWORKING": "Lavorazione del legno",
|
"PASSION_WOODWORKING": "Lavorazione del legno",
|
||||||
"PASSION_VAN_LIFE": "Van life",
|
"PASSION_VAN_LIFE": "Van life",
|
||||||
"PASSION_COFFEE": "Caffè",
|
"PASSION_COFFEE": "Caffè",
|
||||||
|
"PASSION_COOKING": "Cucina",
|
||||||
"PASSION_SOFTWARE_DEVELOPMENT": "Sviluppo software",
|
"PASSION_SOFTWARE_DEVELOPMENT": "Sviluppo software",
|
||||||
"SERVICES_TITLE": "Servizi principali",
|
"SERVICES_TITLE": "Servizi principali",
|
||||||
"TARGET_TITLE": "Per chi è",
|
"TARGET_TITLE": "Per chi è",
|
||||||
|
|||||||
Reference in New Issue
Block a user