creating new customer settings if required
This commit is contained in:
@@ -488,6 +488,7 @@ public class DocumentApi extends BaseHandler implements DocumentService {
|
||||
String currency = company.currency();
|
||||
String sep = company.decimalSeparator();
|
||||
var settings = db.getCustomerSettings(companyId.longValue(),type,customer.id());
|
||||
if (settings == null) settings = CustomerSettings.empty();
|
||||
var companySettings = db.getCompanySettings(companyId.longValue(),type);
|
||||
var nextNumber = companySettings.nextDocId();
|
||||
String lastHead = settings.header();
|
||||
|
||||
@@ -285,12 +285,11 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
CustomerSettings settings = null;
|
||||
if (rs.next()) settings = CustomerSettings.of(rs);
|
||||
rs.close();
|
||||
if (settings != null) return settings;
|
||||
|
||||
return settings;
|
||||
} catch (SQLException e) {
|
||||
LOG.log(WARNING,"Failed to load customer settings (company: {0}, document type: {1}",companyId, docType.name(),e);
|
||||
throw new UmbrellaException(500,"Failed to load customer settings (company: {0}, document type: {1}",companyId, docType.name());
|
||||
}
|
||||
throw new UmbrellaException(500,"Failed to load customer settings (company: {0}, document type: {1}",companyId, docType.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,10 @@ public record CustomerSettings(String header, String footer, String mailText) im
|
||||
return new CustomerSettings(header,footer,mailText);
|
||||
}
|
||||
|
||||
public static CustomerSettings empty() {
|
||||
return new CustomerSettings("","","");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(FIELD_FOOTER,footer,FIELD_HEAD,header,CONTENT,mailText);
|
||||
|
||||
Reference in New Issue
Block a user