master #1367
|
@ -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
|
||||||
|
|
|
@ -32,45 +32,66 @@ 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;
|
||||||
|
|
||||||
const decodedParams = JSON.parse(
|
try {
|
||||||
base64url.decode(merchantParameters, 'utf8'));
|
const decodedParams = JSON.parse(
|
||||||
const params = {};
|
base64url.decode(merchantParameters, 'utf8'));
|
||||||
|
const params = {};
|
||||||
|
|
||||||
for (const param in decodedParams)
|
for (const param in decodedParams)
|
||||||
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)
|
||||||
|
throw new UserError('Order id not provided');
|
||||||
|
|
||||||
if (!orderId)
|
transaction = await Self.findById(orderId, {fields: ['id']});
|
||||||
throw new UserError('Order id not found');
|
if (!transaction)
|
||||||
if (!merchantId)
|
throw new UserError('Order not found');
|
||||||
throw new UserError('Mechant id not found');
|
|
||||||
|
|
||||||
const merchant = await $.TpvMerchant.findById(merchantId, {
|
await transaction.updateAttributes({
|
||||||
fields: ['id', 'secretKey']
|
merchantParameters,
|
||||||
});
|
signature,
|
||||||
|
signatureVersion,
|
||||||
|
});
|
||||||
|
|
||||||
const base64hmac = Self.createSignature(
|
const merchantId = parseInt(params['Ds_MerchantCode']);
|
||||||
orderId,
|
if (!merchantId)
|
||||||
merchant.secretKey,
|
throw new UserError('Merchant id not provided');
|
||||||
merchantParameters
|
|
||||||
);
|
|
||||||
|
|
||||||
if (base64hmac !== base64url.toBase64(signature))
|
const merchant = await $.TpvMerchant.findById(merchantId, {
|
||||||
throw new UserError('Invalid signature');
|
fields: ['id', 'secretKey']
|
||||||
|
});
|
||||||
|
if (!merchant)
|
||||||
|
throw new UserError('Merchant not found');
|
||||||
|
|
||||||
await Self.rawSql(
|
const base64hmac = Self.createSignature(
|
||||||
'CALL hedera.tpvTransaction_confirm(?, ?, ?, ?, ?, ?)', [
|
|
||||||
params['Ds_Amount'],
|
|
||||||
orderId,
|
orderId,
|
||||||
merchantId,
|
merchant.secretKey,
|
||||||
params['Ds_Currency'],
|
merchantParameters
|
||||||
params['Ds_Response'],
|
);
|
||||||
params['Ds_ErrorCode']
|
|
||||||
]);
|
|
||||||
|
|
||||||
return true;
|
if (base64hmac !== base64url.toBase64(signature))
|
||||||
|
throw new UserError('Invalid signature');
|
||||||
|
|
||||||
|
await Self.rawSql(
|
||||||
|
'CALL hedera.tpvTransaction_confirm(?, ?, ?, ?, ?, ?)', [
|
||||||
|
params['Ds_Amount'],
|
||||||
|
orderId,
|
||||||
|
merchantId,
|
||||||
|
params['Ds_Currency'],
|
||||||
|
params['Ds_Response'],
|
||||||
|
params['Ds_ErrorCode']
|
||||||
|
]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
if (transaction)
|
||||||
|
await transaction.updateAttribute('responseError', err.message);
|
||||||
|
else
|
||||||
|
console.error(err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -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 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
description="$ctrl.invoiceOut.ref"
|
description="$ctrl.invoiceOut.ref"
|
||||||
summary="$ctrl.$.summary">
|
summary="$ctrl.$.summary">
|
||||||
<slot-dot-menu>
|
<slot-dot-menu>
|
||||||
<vn-invoice-out-descriptor-menu
|
<vn-invoice-out-descriptor-menu
|
||||||
invoice-out="$ctrl.invoiceOut"
|
invoice-out="$ctrl.invoiceOut"
|
||||||
parent-reload="$ctrl.reload()"
|
parent-reload="$ctrl.reload()"
|
||||||
/>
|
/>
|
||||||
|
@ -11,23 +11,23 @@
|
||||||
<slot-body>
|
<slot-body>
|
||||||
<div class="attributes">
|
<div class="attributes">
|
||||||
<vn-label-value
|
<vn-label-value
|
||||||
label="Date"
|
label="Date"
|
||||||
value="{{$ctrl.invoiceOut.issued | date: 'dd/MM/yyyy'}}">
|
value="{{$ctrl.invoiceOut.issued | date: 'dd/MM/yyyy'}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value
|
<vn-label-value
|
||||||
label="Import"
|
label="Import"
|
||||||
value="{{$ctrl.invoiceOut.amount | currency: 'EUR': 2}}">
|
value="{{$ctrl.invoiceOut.amount | currency: 'EUR': 2}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value
|
<vn-label-value
|
||||||
label="Client">
|
label="Client">
|
||||||
<span
|
<span
|
||||||
ng-click="clientDescriptor.show($event, $ctrl.invoiceOut.client.id)"
|
ng-click="clientDescriptor.show($event, $ctrl.invoiceOut.client.id)"
|
||||||
class="link">
|
class="link">
|
||||||
{{$ctrl.invoiceOut.client.name}}
|
{{$ctrl.invoiceOut.client.name}}
|
||||||
</span>
|
</span>
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value
|
<vn-label-value
|
||||||
label="Company"
|
label="Company"
|
||||||
value="{{$ctrl.invoiceOut.company.code}}">
|
value="{{$ctrl.invoiceOut.company.code}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
</div>
|
</div>
|
||||||
|
@ -53,4 +53,7 @@
|
||||||
</vn-descriptor-content>
|
</vn-descriptor-content>
|
||||||
<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>
|
||||||
|
|
|
@ -33,16 +33,16 @@
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
<vn-tr ng-repeat="waste in detail.lines" class="clickable vn-tr"
|
<a ng-repeat="waste in detail.lines" class="clickable vn-tr"
|
||||||
ui-sref="item.waste.detail({buyer: waste.buyer, family: waste.family})"
|
ui-sref="item.waste.detail({buyer: waste.buyer, family: waste.family})"
|
||||||
ng-class="{'hidden': !$ctrl.wasteConfig[detail.buyer].hidden}">
|
ng-show="$ctrl.wasteConfig[detail.buyer].hidden">
|
||||||
<vn-td></vn-td>
|
<vn-td></vn-td>
|
||||||
<vn-td>{{::waste.family}}</vn-td>
|
<vn-td>{{::waste.family}}</vn-td>
|
||||||
<vn-td number>{{::(waste.percentage / 100) | percentage: 2}}</vn-td>
|
<vn-td number>{{::(waste.percentage / 100) | percentage: 2}}</vn-td>
|
||||||
<vn-td number>{{::waste.dwindle | currency: 'EUR'}}</vn-td>
|
<vn-td number>{{::waste.dwindle | currency: 'EUR'}}</vn-td>
|
||||||
<vn-td number>{{::waste.total | currency: 'EUR'}}</vn-td>
|
<vn-td number>{{::waste.total | currency: 'EUR'}}</vn-td>
|
||||||
<vn-td shrink></vn-td>
|
<vn-td shrink></vn-td>
|
||||||
</vn-tr>
|
</a>
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
|
|
@ -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
|
||||||
WHERE io.ref = ?
|
JOIN invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk
|
||||||
|
WHERE io.ref = ?
|
||||||
|
|
Loading…
Reference in New Issue