Merge branch 'dev' into 5090-renameGoLabel
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2023-03-08 09:47:47 +00:00
commit 63694f4478
6 changed files with 88 additions and 53 deletions

View File

@ -12,6 +12,9 @@ services:
placement: placement:
constraints: constraints:
- node.role == worker - node.role == worker
resources:
limits:
memory: 1G
back: back:
image: registry.verdnatura.es/salix-back:${BRANCH_NAME:?} image: registry.verdnatura.es/salix-back:${BRANCH_NAME:?}
build: . build: .
@ -38,6 +41,9 @@ services:
placement: placement:
constraints: constraints:
- node.role == worker - node.role == worker
resources:
limits:
memory: 4G
configs: configs:
datasources: datasources:
external: true external: true

View File

@ -32,7 +32,9 @@ module.exports = Self => {
Self.confirm = async(signatureVersion, merchantParameters, signature) => { Self.confirm = async(signatureVersion, merchantParameters, signature) => {
const $ = Self.app.models; const $ = Self.app.models;
let transaction;
try {
const decodedParams = JSON.parse( const decodedParams = JSON.parse(
base64url.decode(merchantParameters, 'utf8')); base64url.decode(merchantParameters, 'utf8'));
const params = {}; const params = {};
@ -41,16 +43,28 @@ module.exports = Self => {
params[param] = decodeURIComponent(decodedParams[param]); params[param] = decodeURIComponent(decodedParams[param]);
const orderId = params['Ds_Order']; const orderId = params['Ds_Order'];
const merchantId = parseInt(params['Ds_MerchantCode']);
if (!orderId) if (!orderId)
throw new UserError('Order id not found'); throw new UserError('Order id not provided');
transaction = await Self.findById(orderId, {fields: ['id']});
if (!transaction)
throw new UserError('Order not found');
await transaction.updateAttributes({
merchantParameters,
signature,
signatureVersion,
});
const merchantId = parseInt(params['Ds_MerchantCode']);
if (!merchantId) if (!merchantId)
throw new UserError('Mechant id not found'); throw new UserError('Merchant id not provided');
const merchant = await $.TpvMerchant.findById(merchantId, { const merchant = await $.TpvMerchant.findById(merchantId, {
fields: ['id', 'secretKey'] fields: ['id', 'secretKey']
}); });
if (!merchant)
throw new UserError('Merchant not found');
const base64hmac = Self.createSignature( const base64hmac = Self.createSignature(
orderId, orderId,
@ -72,5 +86,12 @@ module.exports = Self => {
]); ]);
return true; return true;
} catch (err) {
if (transaction)
await transaction.updateAttribute('responseError', err.message);
else
console.error(err);
throw err;
}
}; };
}; };

View File

@ -35,6 +35,18 @@
}, },
"created": { "created": {
"type": "date" "type": "date"
},
"merchantParameters": {
"type": "string"
},
"signature": {
"type": "string"
},
"signatureVersion": {
"type": "string"
},
"responseError": {
"type": "string"
} }
}, },
"relations": { "relations": {
@ -45,4 +57,3 @@
} }
} }
} }

View File

@ -54,3 +54,6 @@
<vn-popup vn-id="summary"> <vn-popup vn-id="summary">
<vn-invoice-out-summary invoice-out="$ctrl.invoiceOut"></vn-invoice-out-summary> <vn-invoice-out-summary invoice-out="$ctrl.invoiceOut"></vn-invoice-out-summary>
</vn-popup> </vn-popup>
<vn-client-descriptor-popover
vn-id="clientDescriptor">
</vn-client-descriptor-popover>

View File

@ -59,17 +59,10 @@ module.exports = Self => {
} }
const writeStream = fs.createWriteStream(filePath); const writeStream = fs.createWriteStream(filePath);
writeStream.on('open', () => { writeStream.on('open', () => response.pipe(writeStream));
response.pipe(writeStream); writeStream.on('error', async error =>
}); await errorHandler(image.itemFk, error, filePath));
writeStream.on('finish', writeStream.end());
writeStream.on('error', async error => {
await errorHandler(image.itemFk, error, filePath);
});
writeStream.on('finish', async function() {
writeStream.end();
});
writeStream.on('close', async function() { writeStream.on('close', async function() {
try { try {

View File

@ -1,10 +1,11 @@
SELECT SELECT
io.amount, io2.amount,
io.ref, io2.ref,
io.issued, io2.issued,
ict.description ict.description
FROM invoiceOut io FROM invoiceOut io
JOIN invoiceCorrection ic ON ic.correctingFk = io.id JOIN invoiceCorrection ic ON ic.correctingFk = io.id
JOIN invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk JOIN invoiceOut io2 ON io2.id = ic.correctedFk
LEFT JOIN ticket t ON t.refFk = io.ref LEFT JOIN ticket t ON t.refFk = io.ref
JOIN invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk
WHERE io.ref = ? WHERE io.ref = ?