refs #4734 refactor: variables definindas
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2023-07-18 07:56:44 +02:00
parent 112d7a84e3
commit 834e4b3723
4 changed files with 37 additions and 57 deletions

View File

@ -24,7 +24,7 @@ module.exports = Self => {
const models = Self.app.models;
const viaexpressConfig = await models.ViaexpressConfig.findOne({
fields: ['clientViaexpress', 'userViaexpress', 'passwordViaexpress', 'defaultWeight', 'deliveryType']
fields: ['client', 'user', 'password', 'defaultWeight', 'deliveryType']
});
const expedition = await models.Expedition.findOne({
@ -107,36 +107,16 @@ module.exports = Self => {
]
});
const shipped = expedition.ticket().shipped;
const ticket = expedition.ticket();
const sender = ticket.company().client();
const shipped = ticket.shipped.toISOString();
const data = {
defaultWeight: viaexpressConfig.defaultWeight,
date: shipped.toISOString(), // const date = new Date().toISOString();
deliveryType: viaexpressConfig.deliveryType,
senderName: expedition.ticket().company().client().socialName,
senderStreet: expedition.ticket().company().client().defaultAddress().street,
senderPostalCode: expedition.ticket().company().client().defaultAddress().postalCode,
senderCity: expedition.ticket().company().client().defaultAddress().city,
senderProvince: expedition.ticket().company().client().defaultAddress().province().name,
senderPhone: expedition.ticket().company().client().defaultAddress().mobile
|| expedition.ticket().company().client().defaultAddress().phone
|| expedition.ticket().company().client().mobile
|| expedition.ticket().company().client().phone,
senderEmail: expedition.ticket().company().client().email,
receiverName: expedition.ticket().address().nickname,
receiverStreet: expedition.ticket().address().street,
receiverPostalCode: expedition.ticket().address().postalCode,
receiverCity: expedition.ticket().address().city,
receiverProvince: expedition.ticket().address().province().name,
receiverPhone: expedition.ticket().address().mobile
|| expedition.ticket().address().phone
|| expedition.ticket().client().mobile
|| expedition.ticket().client().phone,
receiverEmail: expedition.ticket().client().email,
receiverCountry: expedition.ticket().address().province().country().code,
clientViaexpress: viaexpressConfig.clientViaexpress,
userViaexpress: viaexpressConfig.userViaexpress,
passwordViaexpress: viaexpressConfig.passwordViaexpress
viaexpressConfig,
sender,
senderAddress: sender.defaultAddress(),
client: ticket.client(),
address: ticket.address(),
shipped
};
const template = fs.readFileSync(__dirname + '/template.ejs', 'utf-8');

View File

@ -3,12 +3,12 @@
<soap12:Body>
<PutExpedicionInternacional xmlns="http://82.223.6.71:82">
<ObjetoEnvio>
<Peso><%= defaultWeight %></Peso>
<Peso><%= viaexpressConfig.defaultWeight %></Peso>
<Bultos>1</Bultos>
<Reembolso>0</Reembolso>
<Fecha><%= date %></Fecha>
<Fecha><%= shipped %></Fecha>
<ConRetorno>0</ConRetorno>
<Tipo><%= deliveryType %></Tipo>
<Tipo><%= viaexpressConfig.deliveryType %></Tipo>
<Debidos>0</Debidos>
<Asegurado>0</Asegurado>
<Imprimir>0</Imprimir>
@ -20,31 +20,31 @@
<TextoAgencia></TextoAgencia>
<Terminal></Terminal>
<ObjetoRemitente>
<RazonSocial><%= senderName %></RazonSocial>
<Domicilio><%= senderStreet %></Domicilio>
<Cpostal><%= senderPostalCode %></Cpostal>
<Poblacion><%= senderCity %></Poblacion>
<Provincia><%= senderProvince %></Provincia>
<RazonSocial><%= sender.socialName %></RazonSocial>
<Domicilio><%= senderAddress.street %></Domicilio>
<Cpostal><%= senderAddress.postalCode %></Cpostal>
<Poblacion><%= senderAddress.city %></Poblacion>
<Provincia><%= senderAddress.province().name %></Provincia>
<Contacto></Contacto>
<Telefono><%= senderPhone %></Telefono>
<Email><%= senderEmail %></Email>
<Telefono><%= senderAddress.mobile || senderAddress.phone || sender.mobile || sender.phone %></Telefono>
<Email><%= sender.email %></Email>
</ObjetoRemitente>
<ObjetoDestinatario>
<RazonSocial><%= receiverName %></RazonSocial>
<Domicilio><%= receiverStreet %></Domicilio>
<Cpostal><%= receiverPostalCode %></Cpostal>
<Poblacion><%= receiverCity %></Poblacion>
<RazonSocial><%= address.nickname %></RazonSocial>
<Domicilio><%= address.street %></Domicilio>
<Cpostal><%= address.postalCode %></Cpostal>
<Poblacion><%= address.city %></Poblacion>
<Municipio></Municipio>
<Provincia><%= receiverProvince %></Provincia>
<Provincia><%= address.province().name %></Provincia>
<Contacto></Contacto>
<Telefono><%= receiverPhone %></Telefono>
<Email><%= receiverEmail %></Email>
<Pais><%= receiverCountry %></Pais>
<Telefono><%= address.mobile || address.phone || client.mobile || client.phone %></Telefono>
<Email><%= client.email %></Email>
<Pais><%= address.province().country().code %></Pais>
</ObjetoDestinatario>
<ObjetoLogin>
<IdCliente><%= clientViaexpress %></IdCliente>
<Usuario><%= userViaexpress %></Usuario>
<Password><%= passwordViaexpress %></Password>
<IdCliente><%= viaexpressConfig.client %></IdCliente>
<Usuario><%= viaexpressConfig.user %></Usuario>
<Password><%= viaexpressConfig.password %></Password>
</ObjetoLogin>
</ObjetoEnvio>
</PutExpedicionInternacional>

View File

@ -15,13 +15,13 @@
"type": "string",
"required": true
},
"clientViaexpress": {
"client": {
"type": "string"
},
"userViaexpress": {
"user": {
"type": "string"
},
"passwordViaexpress": {
"password": {
"type": "string"
},
"defaultWeight": {

View File

@ -1,9 +1,9 @@
CREATE TABLE `vn`.`viaexpressConfig` (
id int auto_increment NOT NULL,
url varchar(100) NOT NULL,
clientViaexpress varchar(100) NOT NULL,
userViaexpress varchar(100) NOT NULL,
passwordViaexpress varchar(100) NOT NULL,
client varchar(100) NOT NULL,
user varchar(100) NOT NULL,
password varchar(100) NOT NULL,
defaultWeight decimal(10,2) NOT NULL,
deliveryType varchar(5) NOT NULL,
CONSTRAINT viaexpressConfig_PK PRIMARY KEY (id)