#390 Crear nuevo tipo de textfield
This commit is contained in:
parent
ef9b72b78c
commit
13e9b53a73
|
@ -5,7 +5,7 @@
|
|||
<vn-textfield
|
||||
label="Discount"
|
||||
model="$ctrl.newDiscount"
|
||||
type="number"
|
||||
type="text"
|
||||
on-change="$ctrl.updateDiscount()">
|
||||
<t-right-icons>
|
||||
<span class="filter">%</span>
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
</th>
|
||||
<th></th>
|
||||
<th style="text-align: center" translate>Item</th>
|
||||
<th translate>Id</th>
|
||||
<th number translate>Id</th>
|
||||
<th style="text-align: center" translate>Description</th>
|
||||
<th number translate>Quantity</th>
|
||||
<th number translate>Price</th>
|
||||
|
@ -73,6 +73,7 @@
|
|||
<td style="text-align: center">
|
||||
<img
|
||||
ng-src="//verdnatura.es/vn-image-data/catalog/50x50/{{sale.image}}"
|
||||
zoom-image="//verdnatura.es/vn-image-data/catalog/900x900/{{sale.image}}"
|
||||
on-error-src/>
|
||||
</td>
|
||||
<td
|
||||
|
@ -88,7 +89,7 @@
|
|||
<vn-textfield
|
||||
model="sale.quantity"
|
||||
on-change="$ctrl.updateQuantity(sale.id,sale.quantity)"
|
||||
unclearable="true">
|
||||
type="text">
|
||||
</vn-textfield>
|
||||
</td>
|
||||
<td number
|
||||
|
@ -196,7 +197,7 @@
|
|||
<vn-textfield
|
||||
label="Price"
|
||||
model="$ctrl.editedPrice"
|
||||
type="number"
|
||||
type="text"
|
||||
on-change="$ctrl.updatePrice()">
|
||||
<t-right-icons>
|
||||
<span class="filter">€</span>
|
||||
|
|
|
@ -20,6 +20,9 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.updateDiscount = async params => {
|
||||
if (isNAN(params.editLines[0].discount))
|
||||
throw new Error(`The value should be a number`);
|
||||
|
||||
let model = Self.app.models;
|
||||
let thisTicketIsEditable = await model.Ticket.isEditable(params.editLines[0].ticketFk);
|
||||
|
||||
|
@ -37,14 +40,10 @@ module.exports = Self => {
|
|||
}
|
||||
}],
|
||||
fields: ['id', 'clientFk']
|
||||
}).catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
let componentToUse;
|
||||
let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'}).catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'});
|
||||
|
||||
if (usesMana)
|
||||
componentToUse = 37;
|
||||
|
@ -52,23 +51,15 @@ module.exports = Self => {
|
|||
componentToUse = 34;
|
||||
|
||||
for (let i = 0; i < params.editLines.length; i++) {
|
||||
let currentLine = await model.Sale.findOne({where: {id: params.editLines[i].id}, fields: 'price'}).catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
let currentLine = await model.Sale.findOne({where: {id: params.editLines[i].id}, fields: 'price'});
|
||||
let value = (-currentLine.price * params.editLines[i].discount / 100);
|
||||
await model.SaleComponent.upsert({saleFk: params.editLines[i].id, value: value, componentFk: componentToUse}).catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
await model.SaleComponent.upsert({saleFk: params.editLines[i].id, value: value, componentFk: componentToUse});
|
||||
|
||||
await model.Sale.update({id: params.editLines[i].id}, {discount: params.editLines[i].discount}).catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
await model.Sale.update({id: params.editLines[i].id}, {discount: params.editLines[i].discount});
|
||||
}
|
||||
|
||||
query = `
|
||||
call vn.manaSpellersRequery(?)`;
|
||||
await Self.rawSql(query, [ticket[0].client().salesPersonFk]).catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
await Self.rawSql(query, [ticket[0].client().salesPersonFk]);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -20,6 +20,8 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.updatePrice = async params => {
|
||||
if (isNAN(params.price))
|
||||
throw new Error(`The value should be a number`);
|
||||
if (!params.price) params.price = 0;
|
||||
let model = Self.app.models;
|
||||
let thisTicketIsEditable = await model.Ticket.isEditable(params.ticketFk);
|
||||
|
|
Loading…
Reference in New Issue