First commit (wating to add alerts in budget)
This commit is contained in:
@@ -17,10 +17,7 @@
|
||||
*/
|
||||
package com.axelor.apps.base.service;
|
||||
|
||||
|
||||
|
||||
public interface ConvertNumberToFrenchWordsService {
|
||||
|
||||
public String convert(long number);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,202 +16,203 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.axelor.apps.base.service;
|
||||
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class ConvertNumberToFrenchWordsServiceImpl implements ConvertNumberToFrenchWordsService {
|
||||
|
||||
private final String[] dizaineNames = { "", //
|
||||
"", //
|
||||
"vingt", //
|
||||
"trente", //
|
||||
"quarante", //
|
||||
"cinquante", //
|
||||
"soixante", //
|
||||
"soixante", //
|
||||
"quatre-vingt", //
|
||||
"quatre-vingt" //
|
||||
};
|
||||
private final String[] dizaineNames = {
|
||||
"", //
|
||||
"", //
|
||||
"vingt", //
|
||||
"trente", //
|
||||
"quarante", //
|
||||
"cinquante", //
|
||||
"soixante", //
|
||||
"soixante", //
|
||||
"quatre-vingt", //
|
||||
"quatre-vingt" //
|
||||
};
|
||||
|
||||
private final String[] uniteNames1 = { "", //
|
||||
"un", //
|
||||
"deux", //
|
||||
"trois", //
|
||||
"quatre", //
|
||||
"cinq", //
|
||||
"six", //
|
||||
"sept", //
|
||||
"huit", //
|
||||
"neuf", //
|
||||
"dix", //
|
||||
"onze", //
|
||||
"douze", //
|
||||
"treize", //
|
||||
"quatorze", //
|
||||
"quinze", //
|
||||
"seize", //
|
||||
"dix-sept", //
|
||||
"dix-huit", //
|
||||
"dix-neuf" //
|
||||
};
|
||||
private final String[] uniteNames1 = {
|
||||
"", //
|
||||
"un", //
|
||||
"deux", //
|
||||
"trois", //
|
||||
"quatre", //
|
||||
"cinq", //
|
||||
"six", //
|
||||
"sept", //
|
||||
"huit", //
|
||||
"neuf", //
|
||||
"dix", //
|
||||
"onze", //
|
||||
"douze", //
|
||||
"treize", //
|
||||
"quatorze", //
|
||||
"quinze", //
|
||||
"seize", //
|
||||
"dix-sept", //
|
||||
"dix-huit", //
|
||||
"dix-neuf" //
|
||||
};
|
||||
|
||||
private final String[] uniteNames2 = { "", //
|
||||
"", //
|
||||
"deux", //
|
||||
"trois", //
|
||||
"quatre", //
|
||||
"cinq", //
|
||||
"six", //
|
||||
"sept", //
|
||||
"huit", //
|
||||
"neuf", //
|
||||
"dix" //
|
||||
};
|
||||
private final String[] uniteNames2 = {
|
||||
"", //
|
||||
"", //
|
||||
"deux", //
|
||||
"trois", //
|
||||
"quatre", //
|
||||
"cinq", //
|
||||
"six", //
|
||||
"sept", //
|
||||
"huit", //
|
||||
"neuf", //
|
||||
"dix" //
|
||||
};
|
||||
|
||||
|
||||
private String convertZeroToHundred(int number) {
|
||||
|
||||
private String convertZeroToHundred(int number) {
|
||||
int laDizaine = number / 10;
|
||||
int lUnite = number % 10;
|
||||
String resultat = "";
|
||||
|
||||
int laDizaine = number / 10;
|
||||
int lUnite = number % 10;
|
||||
String resultat = "";
|
||||
|
||||
switch (laDizaine) {
|
||||
switch (laDizaine) {
|
||||
case 1:
|
||||
case 7:
|
||||
case 9:
|
||||
lUnite = lUnite + 10;
|
||||
break;
|
||||
lUnite = lUnite + 10;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
String laLiaison = "";
|
||||
if (laDizaine > 1) {
|
||||
laLiaison = "-";
|
||||
}
|
||||
switch (lUnite) {
|
||||
String laLiaison = "";
|
||||
if (laDizaine > 1) {
|
||||
laLiaison = "-";
|
||||
}
|
||||
switch (lUnite) {
|
||||
case 0:
|
||||
laLiaison = "";
|
||||
break;
|
||||
laLiaison = "";
|
||||
break;
|
||||
case 1:
|
||||
if (laDizaine == 8) {
|
||||
laLiaison = "-";
|
||||
} else {
|
||||
laLiaison = " et ";
|
||||
}
|
||||
break;
|
||||
if (laDizaine == 8) {
|
||||
laLiaison = "-";
|
||||
} else {
|
||||
laLiaison = " et ";
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
if (laDizaine == 7) {
|
||||
laLiaison = " et ";
|
||||
}
|
||||
break;
|
||||
if (laDizaine == 7) {
|
||||
laLiaison = " et ";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
// dizaines en lettres
|
||||
switch (laDizaine) {
|
||||
// dizaines en lettres
|
||||
switch (laDizaine) {
|
||||
case 0:
|
||||
resultat = uniteNames1[lUnite];
|
||||
break;
|
||||
resultat = uniteNames1[lUnite];
|
||||
break;
|
||||
case 8:
|
||||
if (lUnite == 0) {
|
||||
resultat = dizaineNames[laDizaine];
|
||||
} else {
|
||||
resultat = dizaineNames[laDizaine] + laLiaison + uniteNames1[lUnite];
|
||||
}
|
||||
break;
|
||||
if (lUnite == 0) {
|
||||
resultat = dizaineNames[laDizaine];
|
||||
} else {
|
||||
resultat = dizaineNames[laDizaine] + laLiaison + uniteNames1[lUnite];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
resultat = dizaineNames[laDizaine] + laLiaison + uniteNames1[lUnite];
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
resultat = dizaineNames[laDizaine] + laLiaison + uniteNames1[lUnite];
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
|
||||
private String convertLessThanOneThousand(int number) {
|
||||
private String convertLessThanOneThousand(int number) {
|
||||
|
||||
int lesCentaines = number / 100;
|
||||
int leReste = number % 100;
|
||||
String sReste = convertZeroToHundred(leReste);
|
||||
int lesCentaines = number / 100;
|
||||
int leReste = number % 100;
|
||||
String sReste = convertZeroToHundred(leReste);
|
||||
|
||||
String resultat;
|
||||
switch (lesCentaines) {
|
||||
String resultat;
|
||||
switch (lesCentaines) {
|
||||
case 0:
|
||||
resultat = sReste;
|
||||
break;
|
||||
resultat = sReste;
|
||||
break;
|
||||
case 1:
|
||||
if (leReste > 0) {
|
||||
resultat = "cent " + sReste;
|
||||
} else {
|
||||
resultat = "cent";
|
||||
}
|
||||
break;
|
||||
if (leReste > 0) {
|
||||
resultat = "cent " + sReste;
|
||||
} else {
|
||||
resultat = "cent";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (leReste > 0) {
|
||||
resultat = uniteNames2[lesCentaines] + " cent " + sReste;
|
||||
} else {
|
||||
resultat = uniteNames2[lesCentaines] + " cents";
|
||||
}
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
if (leReste > 0) {
|
||||
resultat = uniteNames2[lesCentaines] + " cent " + sReste;
|
||||
} else {
|
||||
resultat = uniteNames2[lesCentaines] + " cents";
|
||||
}
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public String convert(long number) {
|
||||
if (number == 0) {
|
||||
return "zero";
|
||||
}
|
||||
public String convert(long number) {
|
||||
if (number == 0) {
|
||||
return "zero";
|
||||
}
|
||||
|
||||
String snumber = Long.toString(number);
|
||||
String mask = "000000000000";
|
||||
DecimalFormat df = new DecimalFormat(mask);
|
||||
snumber = df.format(number);
|
||||
String snumber = Long.toString(number);
|
||||
String mask = "000000000000";
|
||||
DecimalFormat df = new DecimalFormat(mask);
|
||||
snumber = df.format(number);
|
||||
|
||||
int lesMilliards = Integer.parseInt(snumber.substring(0, 3));
|
||||
int lesMillions = Integer.parseInt(snumber.substring(3, 6));
|
||||
int lesCentMille = Integer.parseInt(snumber.substring(6, 9));
|
||||
int lesMille = Integer.parseInt(snumber.substring(9, 12));
|
||||
int lesMilliards = Integer.parseInt(snumber.substring(0, 3));
|
||||
int lesMillions = Integer.parseInt(snumber.substring(3, 6));
|
||||
int lesCentMille = Integer.parseInt(snumber.substring(6, 9));
|
||||
int lesMille = Integer.parseInt(snumber.substring(9, 12));
|
||||
|
||||
String tradMilliards;
|
||||
switch (lesMilliards) {
|
||||
String tradMilliards;
|
||||
switch (lesMilliards) {
|
||||
case 0:
|
||||
tradMilliards = "";
|
||||
break;
|
||||
tradMilliards = "";
|
||||
break;
|
||||
case 1:
|
||||
tradMilliards = convertLessThanOneThousand(lesMilliards) + " milliard ";
|
||||
break;
|
||||
tradMilliards = convertLessThanOneThousand(lesMilliards) + " milliard ";
|
||||
break;
|
||||
default:
|
||||
tradMilliards = convertLessThanOneThousand(lesMilliards) + " milliards ";
|
||||
}
|
||||
String resultat = tradMilliards;
|
||||
tradMilliards = convertLessThanOneThousand(lesMilliards) + " milliards ";
|
||||
}
|
||||
String resultat = tradMilliards;
|
||||
|
||||
String tradMillions;
|
||||
switch (lesMillions) {
|
||||
String tradMillions;
|
||||
switch (lesMillions) {
|
||||
case 0:
|
||||
tradMillions = "";
|
||||
break;
|
||||
tradMillions = "";
|
||||
break;
|
||||
case 1:
|
||||
tradMillions = convertLessThanOneThousand(lesMillions) + " million ";
|
||||
break;
|
||||
tradMillions = convertLessThanOneThousand(lesMillions) + " million ";
|
||||
break;
|
||||
default:
|
||||
tradMillions = convertLessThanOneThousand(lesMillions) + " millions ";
|
||||
}
|
||||
resultat = resultat + tradMillions;
|
||||
tradMillions = convertLessThanOneThousand(lesMillions) + " millions ";
|
||||
}
|
||||
resultat = resultat + tradMillions;
|
||||
|
||||
String tradCentMille;
|
||||
switch (lesCentMille) {
|
||||
String tradCentMille;
|
||||
switch (lesCentMille) {
|
||||
case 0:
|
||||
tradCentMille = "";
|
||||
break;
|
||||
tradCentMille = "";
|
||||
break;
|
||||
case 1:
|
||||
tradCentMille = "mille ";
|
||||
break;
|
||||
tradCentMille = "mille ";
|
||||
break;
|
||||
default:
|
||||
tradCentMille = convertLessThanOneThousand(lesCentMille) + " mille ";
|
||||
}
|
||||
resultat = resultat + tradCentMille;
|
||||
tradCentMille = convertLessThanOneThousand(lesCentMille) + " mille ";
|
||||
}
|
||||
resultat = resultat + tradCentMille;
|
||||
|
||||
String tradMille;
|
||||
tradMille = convertLessThanOneThousand(lesMille);
|
||||
resultat = resultat + tradMille;
|
||||
String tradMille;
|
||||
tradMille = convertLessThanOneThousand(lesMille);
|
||||
resultat = resultat + tradMille;
|
||||
|
||||
return resultat;
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.axelor.apps.base.db.repo.SequenceRepository;
|
||||
import com.axelor.apps.base.exceptions.IExceptionMessage;
|
||||
import com.axelor.apps.base.service.administration.SequenceService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.base.service.BarcodeGeneratorService;
|
||||
import com.axelor.apps.message.db.EmailAddress;
|
||||
import com.axelor.common.StringUtils;
|
||||
import com.axelor.db.JPA;
|
||||
@@ -42,15 +41,14 @@ import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.meta.MetaFiles;
|
||||
import com.axelor.meta.db.MetaFile;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import com.axelor.meta.MetaFiles;
|
||||
import com.axelor.meta.db.MetaFile;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.validation.ValidationException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
@@ -61,6 +59,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Singleton;
|
||||
import javax.validation.ValidationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -71,7 +70,7 @@ public class PartnerServiceImpl implements PartnerService {
|
||||
|
||||
protected PartnerRepository partnerRepo;
|
||||
protected AppBaseService appBaseService;
|
||||
|
||||
|
||||
@Inject protected BarcodeGeneratorService barcodeGeneratorService;
|
||||
@Inject private MetaFiles metaFiles;
|
||||
|
||||
@@ -171,7 +170,7 @@ public class PartnerServiceImpl implements PartnerService {
|
||||
|
||||
this.setPartnerFullName(partner);
|
||||
this.setCompanyStr(partner);
|
||||
this.setPartnerBarCodeSeq(partner);
|
||||
this.setPartnerBarCodeSeq(partner);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -709,30 +708,29 @@ public class PartnerServiceImpl implements PartnerService {
|
||||
}
|
||||
return partnerQuery.fetchOne();
|
||||
}
|
||||
|
||||
|
||||
public void setPartnerBarCodeSeq(Partner partner) {
|
||||
if (partner.getBarCodeSeq() == null) {
|
||||
try {
|
||||
boolean addPadding = false;
|
||||
InputStream inStream = null;
|
||||
|
||||
inStream =
|
||||
barcodeGeneratorService.createBarCode(
|
||||
partner.getPartnerSeq(),
|
||||
appBaseService.getAppBase().getBarcodeTypeConfigPartnerSeq(),
|
||||
addPadding);
|
||||
|
||||
if (inStream != null) {
|
||||
MetaFile barcodeFile =
|
||||
metaFiles.upload(inStream, String.format("PartnerBarCodeSeq%d.png",partner.getId()));
|
||||
partner.setBarCodeSeq(barcodeFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AxelorException e) {
|
||||
throw new ValidationException(e.getMessage());
|
||||
|
||||
public void setPartnerBarCodeSeq(Partner partner) {
|
||||
if (partner.getBarCodeSeq() == null) {
|
||||
try {
|
||||
boolean addPadding = false;
|
||||
InputStream inStream = null;
|
||||
|
||||
inStream =
|
||||
barcodeGeneratorService.createBarCode(
|
||||
partner.getPartnerSeq(),
|
||||
appBaseService.getAppBase().getBarcodeTypeConfigPartnerSeq(),
|
||||
addPadding);
|
||||
|
||||
if (inStream != null) {
|
||||
MetaFile barcodeFile =
|
||||
metaFiles.upload(inStream, String.format("PartnerBarCodeSeq%d.png", partner.getId()));
|
||||
partner.setBarCodeSeq(barcodeFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AxelorException e) {
|
||||
throw new ValidationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,32 +338,30 @@ public class UserServiceImpl implements UserService {
|
||||
Boolean sendEmailUponPasswordChange = user.getSendEmailUponPasswordChange();
|
||||
Boolean sendEmailUponAccountCreation = user.getSendEmailUponAccountCreation();
|
||||
|
||||
if(!sendEmailUponPasswordChange && !sendEmailUponAccountCreation){
|
||||
if (!sendEmailUponPasswordChange && !sendEmailUponAccountCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(sendEmailUponPasswordChange){
|
||||
if (sendEmailUponPasswordChange) {
|
||||
|
||||
if (user.equals(AuthUtils.getUser())) {
|
||||
if (user.equals(AuthUtils.getUser())) {
|
||||
logger.debug("User {} changed own password.", user.getCode());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
|
||||
Template template = appBase.getPasswordChangedTemplate();
|
||||
AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
|
||||
Template template = appBase.getPasswordChangedTemplate();
|
||||
|
||||
if (template == null) {
|
||||
throw new AxelorException(
|
||||
appBase,
|
||||
TraceBackRepository.CATEGORY_NO_VALUE,
|
||||
I18n.get("Template for changed password is missing."));
|
||||
}
|
||||
if (template == null) {
|
||||
throw new AxelorException(
|
||||
appBase,
|
||||
TraceBackRepository.CATEGORY_NO_VALUE,
|
||||
I18n.get("Template for changed password is missing."));
|
||||
}
|
||||
|
||||
TemplateMessageService templateMessageService = Beans.get(TemplateMessageService.class);
|
||||
templateMessageService.generateAndSendMessage(user, template);
|
||||
}
|
||||
|
||||
else if(sendEmailUponAccountCreation){
|
||||
TemplateMessageService templateMessageService = Beans.get(TemplateMessageService.class);
|
||||
templateMessageService.generateAndSendMessage(user, template);
|
||||
} else if (sendEmailUponAccountCreation) {
|
||||
user.setSendEmailUponAccountCreation(false);
|
||||
AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
|
||||
Template template = appBase.getAccountCreationTemplate();
|
||||
|
||||
@@ -17,20 +17,6 @@
|
||||
*/
|
||||
package com.axelor.apps.base.web;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import wslite.json.JSONException;
|
||||
import wslite.json.JSONObject;
|
||||
|
||||
import org.apache.batik.util.io.StringDecoder;
|
||||
|
||||
import com.axelor.app.AppSettings;
|
||||
import com.axelor.apps.base.db.AppBase;
|
||||
import com.axelor.apps.base.exceptions.IExceptionMessage;
|
||||
@@ -48,13 +34,22 @@ import com.axelor.meta.schema.actions.ActionView;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import wslite.json.JSONException;
|
||||
import wslite.json.JSONObject;
|
||||
|
||||
@Singleton
|
||||
public class AppBaseController {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** */
|
||||
private static final String localhost = "127.0.0.1";
|
||||
|
||||
public void exportObjects(ActionRequest request, ActionResponse response) {
|
||||
@@ -133,41 +128,47 @@ public class AppBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@CallMethod
|
||||
public void execWhatsApp(String username,String message,String url,String id,String enc) throws IOException, ClassNotFoundException {
|
||||
|
||||
try{
|
||||
public void execWhatsApp(String username, String message, String url, String id, String enc)
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
try {
|
||||
String uri = Beans.get(AppBaseService.class).getAppBase().getWhatsAppURL();
|
||||
|
||||
String fullUrl = uri + "/"+ url + "/" + id;
|
||||
Socket socket = new Socket(localhost, 6060);
|
||||
// String data = "{\"username\" : \"" + username + "\",\"url\": \""+ fullUrl +"\",\"message\":\""+ message +"\"}";
|
||||
String data = username + "***"+ fullUrl +"***"+ message;
|
||||
String fullUrl = uri + "/" + url + "/" + id;
|
||||
Socket socket = new Socket(localhost, 6060);
|
||||
// String data = "{\"username\" : \"" + username + "\",\"url\": \""+ fullUrl
|
||||
// +"\",\"message\":\""+ message +"\"}";
|
||||
String data = username + "***" + fullUrl + "***" + message;
|
||||
|
||||
DataOutputStream dout=new DataOutputStream(socket.getOutputStream());
|
||||
DataOutputStream dout = new DataOutputStream(socket.getOutputStream());
|
||||
DataInputStream in = new DataInputStream(socket.getInputStream());
|
||||
|
||||
dout.write(data.getBytes("UTF8"));
|
||||
|
||||
String msg=(String)in.readUTF();
|
||||
|
||||
if( msg == "message_received"){
|
||||
String msg = (String) in.readUTF();
|
||||
|
||||
if (msg == "message_received") {
|
||||
dout.flush();
|
||||
dout.close();
|
||||
// socket.close();
|
||||
System.out.println("Message: " + msg);
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@CallMethod
|
||||
public void execWhatsApp2(String username,String message,String url,String id,String enc) throws IOException, ClassNotFoundException {
|
||||
String args[] = { "python", "/Users\\Bachir.souldi.SOPHAL\\Desktop\\dev\\whatsapp_erp\\index.py" , message, url , id };
|
||||
public void execWhatsApp2(String username, String message, String url, String id, String enc)
|
||||
throws IOException, ClassNotFoundException {
|
||||
String args[] = {
|
||||
"python",
|
||||
"/Users\\Bachir.souldi.SOPHAL\\Desktop\\dev\\whatsapp_erp\\index.py",
|
||||
message,
|
||||
url,
|
||||
id
|
||||
};
|
||||
Process p = Runtime.getRuntime().exec(args);
|
||||
// BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
}
|
||||
@@ -235,5 +236,4 @@ public class AppBaseController {
|
||||
return null; // Handle error appropriately
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ import com.axelor.inject.Beans;
|
||||
import com.axelor.meta.schema.actions.ActionView;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.axelor.rpc.Context;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.inject.Singleton;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.axelor.rpc.Context;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class ProductController {
|
||||
@@ -139,20 +139,20 @@ public class ProductController {
|
||||
public void printProductQrCodes(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
try {
|
||||
|
||||
|
||||
Context context = request.getContext();
|
||||
Long id = 1L;
|
||||
Integer typeSelect = Integer.parseInt(context.get("printingTypeSelect").toString());
|
||||
|
||||
Integer typeSelect = Integer.parseInt(context.get("printingTypeSelect").toString());
|
||||
|
||||
switch (typeSelect) {
|
||||
case 1:
|
||||
id = new Long((Integer) ((Map) context.get("product")).get("id"));
|
||||
id = new Long((Integer) ((Map) context.get("product")).get("id"));
|
||||
break;
|
||||
case 2:
|
||||
id = new Long((Integer) ((Map) request.getContext().get("stockLocation")).get("id"));
|
||||
id = new Long((Integer) ((Map) request.getContext().get("stockLocation")).get("id"));
|
||||
break;
|
||||
case 3:
|
||||
id = ((FamilleProduit) request.getContext().get("familleProduit")).getId();
|
||||
id = ((FamilleProduit) request.getContext().get("familleProduit")).getId();
|
||||
break;
|
||||
default:
|
||||
id = 0L;
|
||||
@@ -166,7 +166,7 @@ public class ProductController {
|
||||
.addParam("typeSelect", typeSelect)
|
||||
.addParam("productId", id)
|
||||
.addParam("stockLocation", id)
|
||||
.addParam("familleProduit",id)
|
||||
.addParam("familleProduit", id)
|
||||
.generate()
|
||||
.getFileLink();
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
<!-- From contact -->
|
||||
<one-to-one name="emailAddress" ref="com.axelor.apps.message.db.EmailAddress" title="Email"/>
|
||||
<one-to-one name="emailAddressCC1" ref="com.axelor.apps.message.db.EmailAddress" title="Email CC1"/>
|
||||
<one-to-one name="emailAddressCC2" ref="com.axelor.apps.message.db.EmailAddress" title="Email CC2"/>
|
||||
<string name="fax" title="Fax"/>
|
||||
<string name="fixedPhone" title="Fixed phone"/>
|
||||
<string name="mobilePhone" title="Mobile phone"/>
|
||||
|
||||
@@ -148,6 +148,9 @@
|
||||
<decimal name="ug" title="UG" />
|
||||
|
||||
<boolean name="isDangerousProduct" title="Is dangerous" />
|
||||
|
||||
|
||||
<many-to-one name="coaSpec" ref="com.axelor.meta.db.MetaFile" />
|
||||
|
||||
<finder-method name="findByCode" using="code" cacheable="true" />
|
||||
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="base" package="com.axelor.apps.base.db" />
|
||||
|
||||
<entity name="ProductInventory" lang="java">
|
||||
|
||||
<string name="name" title="Name" required="true" initParam="true"
|
||||
translatable="true" />
|
||||
<string name="serialNumber" title="Serial Nbr"/>
|
||||
<string name="code" title="Code" initParam="true" namecolumn="true" unique="true"/>
|
||||
|
||||
<string name="description" large="true" title="Description"
|
||||
initParam="true" translatable="true" />
|
||||
<string name="internalDescription" large="true" title="Internal description"
|
||||
initParam="true" />
|
||||
<many-to-one name="picture" ref="com.axelor.meta.db.MetaFile"
|
||||
initParam="true" />
|
||||
|
||||
<many-to-one name="familleProduit" ref="FamilleProduit"
|
||||
title="Product category" massUpdate="true" /><!--sophal-->
|
||||
<many-to-one name="sousFamilleProduit" ref="FamilleProduit"
|
||||
title="Product category" massUpdate="true" /><!--sophal-->
|
||||
<many-to-one name="sousSousFamilleProduit" ref="FamilleProduit"
|
||||
title="Product category" massUpdate="true" /><!--sophal-->
|
||||
|
||||
<many-to-one name="productCategory" ref="ProductCategory"
|
||||
title="Product category" initParam="true" massUpdate="true" />
|
||||
|
||||
<string name="unitCodeSelect" title="Unit Code"
|
||||
selection="product.unit.code.select" massUpdate="true"/><!--sophal-->
|
||||
<boolean name="codeCreated" title="code Created By Systeme" default="true"/><!--sophal-->
|
||||
<many-to-one name="productFamily" ref="ProductFamily"
|
||||
title="Accounting family" initParam="true" massUpdate="true"/>
|
||||
<many-to-one name="unit" ref="Unit" title="Unit"
|
||||
initParam="true" massUpdate="true" />
|
||||
|
||||
<integer name="saleSupplySelect" title="Sale supply default method on sale order"
|
||||
selection="product.sale.supply.select" initParam="true" massUpdate="true"/>
|
||||
|
||||
<string name="productTypeSelect" title="Type" required="true"
|
||||
selection="product.product.type.select" initParam="true" massUpdate="true"/>
|
||||
<string name="procurementMethodSelect" title="Procurement method"
|
||||
selection="product.procurement.method.select" initParam="true" />
|
||||
<boolean name="isPrototype" title="Prototype" />
|
||||
<boolean name="isUnrenewed" title="Unrenewed"/>
|
||||
<integer name="productSubTypeSelect" title="Product Subtype"
|
||||
selection="product.sub.type.product.select" />
|
||||
<integer name="inventoryTypeSelect" title="Inventory type"
|
||||
selection="product.inventory.type.select" />
|
||||
|
||||
<decimal name="salePrice" title="Sale price W.T." precision="20"
|
||||
scale="10" massUpdate="true" />
|
||||
<many-to-one name="saleCurrency" ref="com.axelor.apps.base.db.Currency"
|
||||
title="Sale currency" initParam="true" />
|
||||
<decimal name="purchasePrice" title="Purchase price W.T."
|
||||
precision="20" scale="10" massUpdate="true" />
|
||||
<many-to-one name="purchaseCurrency" ref="com.axelor.apps.base.db.Currency"
|
||||
title="Purchase / Cost currency" initParam="true" />
|
||||
<boolean name="autoUpdateSalePrice" default="false"
|
||||
title="Update sale price from cost price" />
|
||||
|
||||
<decimal name="costPrice" title="Cost price" precision="20"
|
||||
scale="10" massUpdate="true" />
|
||||
|
||||
<decimal name="managPriceCoef" title="Management coef." />
|
||||
<decimal name="shippingCoef" title="Shipping Coef." />
|
||||
<boolean name="defShipCoefByPartner" title="Define the shipping coef by partner" />
|
||||
|
||||
<date name="startDate" title="Product launch Date" initParam="true" />
|
||||
<date name="endDate" title="Product pulled off market Date"
|
||||
initParam="true" />
|
||||
|
||||
<boolean name="hasWarranty" title="Warranty" />
|
||||
<boolean name="isPerishable" title="Perishable" />
|
||||
<integer name="warrantyNbrOfMonths" title="Warranty length (in months)" />
|
||||
<integer name="perishableNbrOfMonths" title="Time before expiry (in months)" />
|
||||
<boolean name="checkExpirationDateAtStockMoveRealization" />
|
||||
|
||||
<many-to-one name="productVariantConfig"
|
||||
ref="com.axelor.apps.base.db.ProductVariantConfig" />
|
||||
<many-to-one name="productVariant" ref="com.axelor.apps.base.db.ProductVariant" />
|
||||
<many-to-one name="parentProduct" ref="com.axelor.apps.base.db.Product"
|
||||
title="Parent product" />
|
||||
<boolean name="isModel" title="Is model" />
|
||||
<boolean name="manageVariantPrice" default="false"
|
||||
title="Manage prices for product variants" />
|
||||
|
||||
<many-to-one name="defaultSupplierPartner" ref="com.axelor.apps.base.db.Partner"
|
||||
title="Default supplier" />
|
||||
|
||||
|
||||
<integer name="versionSelect" title="Version"
|
||||
selection="base.product.version.select" />
|
||||
|
||||
<boolean name="sellable" title="Sellable" default="true" />
|
||||
<boolean name="purchasable" title="Purchasable" default="true" />
|
||||
<boolean name="inAti" title="In ATI" />
|
||||
|
||||
<integer name="costTypeSelect" title="Cost type"
|
||||
selection="base.product.cost.type.select" default="1" />
|
||||
|
||||
<integer name="supplierDeliveryTime" title="Supplier delivery time (days)" />
|
||||
|
||||
<many-to-one name="barCode" title="Barcode"
|
||||
ref="com.axelor.meta.db.MetaFile" />
|
||||
<many-to-one name="barcodeTypeConfig" title="Barcode Type" ref="com.axelor.apps.base.db.BarcodeTypeConfig"/>
|
||||
<string name="fullName" title="Full name" translatable="true" />
|
||||
|
||||
|
||||
<many-to-one name="massUnit" ref="com.axelor.apps.base.db.Unit"
|
||||
title="Unit of mass" />
|
||||
<decimal name="grossMass" title="Gross mass" precision="20" scale="3" />
|
||||
<decimal name="netMass" title="Net mass" precision="20" scale="3" />
|
||||
|
||||
<many-to-one name="lengthUnit" ref="com.axelor.apps.base.db.Unit"
|
||||
title="Unit of length" />
|
||||
<decimal name="length" title="Length" default="0" />
|
||||
<decimal name="width" title="Width" default="0" />
|
||||
<decimal name="height" title="Height" default="0" />
|
||||
<decimal name="diameter" title="Diameter" />
|
||||
<decimal name="articleVolume" title="Article volume" />
|
||||
<decimal name="economicManufOrderQty" title="Economic manuf. qty"/>
|
||||
|
||||
<boolean name="isShippingCostsProduct" title="Is shipping costs product"/>
|
||||
|
||||
|
||||
<boolean name="allowToForceSaleQty" title="Allow to force sales quantities"/>
|
||||
|
||||
|
||||
<boolean name="allowToForcePurchaseQty" title="Allow to force purchases quantities"/>
|
||||
|
||||
<decimal name="ppa" title="PPA" />
|
||||
<decimal name="shp" title="SHP" />
|
||||
<decimal name="pvg" title="PVG" />
|
||||
<decimal name="stklim" title="Stklim" />
|
||||
<decimal name="ug" title="UG" />
|
||||
|
||||
<boolean name="isDangerousProduct" title="Is dangerous" />
|
||||
|
||||
|
||||
<many-to-one name="coaSpec" ref="com.axelor.meta.db.MetaFile" />
|
||||
|
||||
<finder-method name="findByCode" using="code" cacheable="true" />
|
||||
|
||||
<extra-code>
|
||||
<![CDATA[
|
||||
// PRODUCT TYPE SELECT
|
||||
public static final String PRODUCT_TYPE_SERVICE = "service";
|
||||
public static final String PRODUCT_TYPE_STORABLE = "storable";
|
||||
public static final String PRODUCT_TYPE_PACK = "pack";
|
||||
|
||||
// SALE SUPPLY SELECT
|
||||
public static final int SALE_SUPPLY_FROM_STOCK = 1;
|
||||
public static final int SALE_SUPPLY_PURCHASE = 2;
|
||||
public static final int SALE_SUPPLY_PRODUCE = 3;
|
||||
|
||||
public static final String PROCUREMENT_METHOD_BUY = "buy";
|
||||
public static final String PROCUREMENT_METHOD_PRODUCE = "produce";
|
||||
public static final String PROCUREMENT_METHOD_BUYANDPRODUCE = "buyAndProduce";
|
||||
|
||||
public static final int COST_TYPE_STANDARD = 1;
|
||||
public static final int COST_TYPE_LAST_PURCHASE_PRICE = 2;
|
||||
public static final int COST_TYPE_AVERAGE_PRICE = 3;
|
||||
public static final int COST_TYPE_LAST_PRODUCTION_PRICE = 4;
|
||||
|
||||
// PRODUCT SUB-TYPE SELECT
|
||||
public static final int PRODUCT_SUB_TYPE_FINISHED_PRODUCT = 1;
|
||||
public static final int PRODUCT_SUB_TYPE_SEMI_FINISHED_PRODUCT = 2;
|
||||
public static final int PRODUCT_SUB_TYPE_COMPONENT = 3;
|
||||
]]>
|
||||
</extra-code>
|
||||
|
||||
<track on="UPDATE">
|
||||
<field name="productCategory" />
|
||||
<field name="productFamily" />
|
||||
<field name="saleSupplySelect" />
|
||||
<field name="sellable" />
|
||||
<field name="salePrice" />
|
||||
<field name="saleCurrency" />
|
||||
<field name="unit" />
|
||||
<field name="startDate" />
|
||||
<field name="endDate" />
|
||||
<field name="purchasable" />
|
||||
<field name="purchasePrice" />
|
||||
<field name="defaultSupplierPartner" />
|
||||
<field name="purchaseCurrency" />
|
||||
<field name="supplierDeliveryTime" />
|
||||
<field name="costPrice" />
|
||||
<field name="managPriceCoef" />
|
||||
<field name="costTypeSelect" />
|
||||
<field name="hasWarranty" />
|
||||
<field name="warrantyNbrOfMonths" />
|
||||
<field name="isPerishable" />
|
||||
<field name="perishableNbrOfMonths" />
|
||||
<field name="ppa" />
|
||||
<field name="pvg" />
|
||||
<field name="shp" />
|
||||
<field name="stklim" />
|
||||
<field name="ug" />
|
||||
<message if="true" on="UPDATE">Product updated</message>
|
||||
</track>
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -21,35 +21,21 @@ import com.axelor.app.AxelorModule;
|
||||
import com.axelor.apps.base.module.AdminModule;
|
||||
import com.axelor.apps.base.module.BaseModule;
|
||||
import com.axelor.apps.base.service.user.UserService;
|
||||
import com.axelor.apps.base.test.UserServiceTest.MyModule;
|
||||
import com.axelor.apps.message.module.MessageModule;
|
||||
import com.axelor.apps.tool.module.ToolModule;
|
||||
import com.axelor.auth.db.User;
|
||||
import com.axelor.auth.db.repo.UserRepository;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.test.GuiceModules;
|
||||
import com.axelor.test.GuiceRunner;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.persist.Transactional;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
||||
@RunWith(GuiceRunner.class)
|
||||
@GuiceModules({UserServiceTest.MyModule.class})
|
||||
@@ -58,7 +44,6 @@ public class UserServiceTest {
|
||||
static UserService userService;
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
||||
public static class MyModule extends AxelorModule {
|
||||
|
||||
@Override
|
||||
@@ -78,14 +63,13 @@ public class UserServiceTest {
|
||||
|
||||
@Inject UserRepository injector;
|
||||
|
||||
|
||||
// public void test() {
|
||||
// assertNotNull(injector.find(1L));
|
||||
// assertNotNull(injector.find(1L));
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testMatchPasswordPatternUpperLowerDigit() {
|
||||
Assert.assertTrue(userService.matchPasswordPattern("Axelor123"));
|
||||
Assert.assertTrue(userService.matchPasswordPattern("5"));
|
||||
Assert.assertTrue(userService.matchPasswordPattern("123Axelor"));
|
||||
Assert.assertTrue(userService.matchPasswordPattern("axelor123A"));
|
||||
}
|
||||
@@ -125,19 +109,19 @@ public class UserServiceTest {
|
||||
Assert.assertFalse(userService.matchPasswordPattern("axelor123456"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void findUser() throws AxelorException {
|
||||
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("testUnitManager");
|
||||
EntityManager entityManager = entityManagerFactory.createEntityManager();
|
||||
// EntityManagerFactory entityManagerFactory =
|
||||
// Persistence.createEntityManagerFactory("testUnitManager");
|
||||
// EntityManager entityManager = entityManagerFactory.createEntityManager();
|
||||
|
||||
// Student student = new Student("Ramesh", "Fadatare", "rameshfadatare@javaguides.com");
|
||||
// Object partner = entityManager.createNativeQuery("select u from base_partner u where u.id = 1",Partner.class).getSingleResult();
|
||||
// Object partner = entityManager.createNativeQuery("select u from base_partner u where u.id =
|
||||
// 1",Partner.class).getSingleResult();
|
||||
|
||||
// log.debug("data *******************************"+ partner.toString());
|
||||
entityManager.close();
|
||||
entityManagerFactory.close();
|
||||
|
||||
// entityManager.close();
|
||||
// entityManagerFactory.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user