feat(createClaim): disallow claim creation for a ticket delivered more than seven days ago
Refs: 3278
This commit is contained in:
parent
c101bbb6be
commit
8c5f0d3019
|
@ -212,5 +212,6 @@
|
|||
"You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito",
|
||||
"You can't change the credit set to zero from a manager": "No puedes cambiar el cŕedito establecido a cero por un gerente",
|
||||
"The PDF document does not exists": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'",
|
||||
"The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos"
|
||||
"The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
|
||||
"You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días"
|
||||
}
|
|
@ -57,8 +57,14 @@ module.exports = Self => {
|
|||
}
|
||||
}, myOptions);
|
||||
|
||||
const landedPlusWeek = new Date(ticket.landed);
|
||||
landedPlusWeek.setDate(landedPlusWeek.getDate() + 7);
|
||||
const isClaimable = landedPlusWeek >= new Date();
|
||||
|
||||
if (ticket.isDeleted)
|
||||
throw new UserError(`You can't create a claim for a removed ticket`);
|
||||
if (!isClaimable)
|
||||
throw new UserError(`You can't create a claim from a ticket delivered more than seven days ago`);
|
||||
|
||||
const newClaim = await Self.create({
|
||||
ticketFk: ticketId,
|
||||
|
|
|
@ -469,7 +469,8 @@
|
|||
</vn-item>
|
||||
<vn-item translate
|
||||
name="claim"
|
||||
ng-click="$ctrl.createClaim()">
|
||||
ng-click="$ctrl.createClaim()"
|
||||
ng-if="$ctrl.isClaimable">
|
||||
Add claim
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
|
|
|
@ -35,6 +35,16 @@ class Controller extends Section {
|
|||
return ticketState && ticketState.state.code;
|
||||
}
|
||||
|
||||
get isClaimable() {
|
||||
if (this.ticket) {
|
||||
const landedPlusWeek = new Date(this.ticket.landed);
|
||||
landedPlusWeek.setDate(landedPlusWeek.getDate() + 7);
|
||||
|
||||
return landedPlusWeek >= new Date();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
getSaleTotal(sale) {
|
||||
if (sale.quantity == null || sale.price == null)
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue