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