Ticket summary. #213
This commit is contained in:
parent
f95a2f646b
commit
5e09df1c9d
|
@ -1,5 +1,6 @@
|
||||||
import ngModule from '../../module';
|
import ngModule from '../../module';
|
||||||
import Component from '../../lib/component';
|
import Component from '../../lib/component';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
ngModule.component('vnLabelValue', {
|
ngModule.component('vnLabelValue', {
|
||||||
template: require('../label-value/label-value.html'),
|
template: require('../label-value/label-value.html'),
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
vn-label-value {
|
||||||
|
& vn-label {
|
||||||
|
color: #9b9b9b
|
||||||
|
}
|
||||||
|
|
||||||
|
& span {
|
||||||
|
color: #222222
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-auto>
|
</vn-auto>
|
||||||
<vn-one margin-medium>
|
<vn-one margin-medium>
|
||||||
<vn-vertical>
|
<vn-vertical name="basicData">
|
||||||
<h5 translate>Basic data</h5>
|
<h5 translate>Basic data</h5>
|
||||||
<vn-label-value label="Name"
|
<vn-label-value label="Name"
|
||||||
value="{{$ctrl.item.name}}">
|
value="{{$ctrl.item.name}}">
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
<vn-one margin-medium>
|
<vn-one margin-medium>
|
||||||
<vn-vertical>
|
<vn-vertical name="tax">
|
||||||
<h5 translate>Tax</h5>
|
<h5 translate>Tax</h5>
|
||||||
<vn-label-value label="{{tax.country.country}}" ng-repeat="tax in $ctrl.taxes track by $index"
|
<vn-label-value label="{{tax.country.country}}" ng-repeat="tax in $ctrl.taxes track by $index"
|
||||||
value="{{tax.taxClass.description}}">
|
value="{{tax.taxClass.description}}">
|
||||||
|
@ -50,21 +50,23 @@
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-one margin-medium>
|
<vn-one margin-medium>
|
||||||
<h5 translate>Tags</h5>
|
<vn-vertical name="tags">
|
||||||
<vn-label-value label="{{tag.tag.name}}" ng-repeat="tag in $ctrl.tags track by tag.id"
|
<h5 translate>Tags</h5>
|
||||||
value="{{tag.value}}">
|
<vn-label-value label="{{tag.tag.name}}" ng-repeat="tag in $ctrl.tags track by tag.id"
|
||||||
</vn-label-value>
|
value="{{tag.value}}">
|
||||||
|
</vn-label-value>
|
||||||
|
</vn-vertical>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
<vn-one margin-medium>
|
<vn-one margin-medium>
|
||||||
<vn-vertical>
|
<vn-vertical name="niche">
|
||||||
<h5 translate>Nicho</h5>
|
<h5 translate>Niche</h5>
|
||||||
<vn-label-value label="{{niche.warehouse.name}}" ng-repeat="niche in $ctrl.niches track by $index"
|
<vn-label-value label="{{niche.warehouse.name}}" ng-repeat="niche in $ctrl.niches track by $index"
|
||||||
value="{{niche.code}}">
|
value="{{niche.code}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
<vn-one margin-medium>
|
<vn-one margin-medium>
|
||||||
<vn-vertical>
|
<vn-vertical name="botanical">
|
||||||
<h5 translate>Botanical</h5>
|
<h5 translate>Botanical</h5>
|
||||||
<vn-label-value label="Botanical"
|
<vn-label-value label="Botanical"
|
||||||
value="{{$ctrl.item.botanical.botanical}}">
|
value="{{$ctrl.item.botanical.botanical}}">
|
||||||
|
@ -78,7 +80,7 @@
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
<vn-one margin-medium>
|
<vn-one margin-medium>
|
||||||
<vn-vertical>
|
<vn-vertical name="barcode">
|
||||||
<h5 translate>Barcode</h5>
|
<h5 translate>Barcode</h5>
|
||||||
<p ng-repeat="barcode in $ctrl.barcodes track by $index">
|
<p ng-repeat="barcode in $ctrl.barcodes track by $index">
|
||||||
<b>{{barcode.code}}</b>
|
<b>{{barcode.code}}</b>
|
||||||
|
|
|
@ -132,11 +132,6 @@ button {
|
||||||
@extend .vn-clickable;
|
@extend .vn-clickable;
|
||||||
}
|
}
|
||||||
|
|
||||||
vn-label {
|
|
||||||
font-size: .9em;
|
|
||||||
color: #c4c4c4
|
|
||||||
}
|
|
||||||
|
|
||||||
vn-button-bar {
|
vn-button-bar {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: $margin-small;
|
margin-top: $margin-small;
|
||||||
|
|
|
@ -48,3 +48,5 @@ Tracking: Revisión
|
||||||
Volume: Volumen
|
Volume: Volumen
|
||||||
Warehouse: Almacén
|
Warehouse: Almacén
|
||||||
Worker: Trabajador
|
Worker: Trabajador
|
||||||
|
Package size: Bultos
|
||||||
|
VAT: IVA
|
|
@ -46,7 +46,7 @@
|
||||||
<vn-one class="ticketSummary__taxes">
|
<vn-one class="ticketSummary__taxes">
|
||||||
<section>
|
<section>
|
||||||
<p><vn-label translate>Subtotal</vn-label> {{$ctrl.summary.subTotal | currency:' €':2}}</p>
|
<p><vn-label translate>Subtotal</vn-label> {{$ctrl.summary.subTotal | currency:' €':2}}</p>
|
||||||
<p><vn-label translate>BAT</vn-label> {{$ctrl.summary.totalTax | currency:' €':2}}</p>
|
<p><vn-label translate>VAT</vn-label> {{$ctrl.summary.totalTax | currency:' €':2}}</p>
|
||||||
<p><vn-label><strong>Total</strong></vn-label> <strong>{{$ctrl.summary.total | currency:' €':2}}</strong></p>
|
<p><vn-label><strong>Total</strong></vn-label> <strong>{{$ctrl.summary.total | currency:' €':2}}</strong></p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('getTaxes', {
|
||||||
|
description: 'Returns ticket taxes',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'ticket id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'number',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/getTaxes`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getTaxes = async ticketFk => {
|
||||||
|
let query = `CALL vn.ticketGetTaxAdd(?)`;
|
||||||
|
let [taxes] = await Self.rawSql(query, [ticketFk]);
|
||||||
|
|
||||||
|
return taxes;
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,28 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('getTotal', {
|
||||||
|
description: 'Returns the total of a ticket',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'ticket id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'number',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/getTotal`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getTotal = async ticketFk => {
|
||||||
|
let query = `SELECT vn.ticketGetTotal(?) AS amount`;
|
||||||
|
let [total] = await Self.rawSql(query, [ticketFk]);
|
||||||
|
|
||||||
|
return total.amount ? total.amount : 0.00;
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,18 @@
|
||||||
|
const getTaxes = require('../get-taxes');
|
||||||
|
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||||
|
const model = {
|
||||||
|
remoteMethod: () => {}
|
||||||
|
};
|
||||||
|
|
||||||
|
rawSql(model);
|
||||||
|
getTaxes(model);
|
||||||
|
|
||||||
|
describe('ticket getTaxes()', () => {
|
||||||
|
it('should call the getTaxes method', done => {
|
||||||
|
model.getTaxes(1)
|
||||||
|
.then(response => {
|
||||||
|
expect(response[0].tax).toEqual(1.05);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,26 @@
|
||||||
|
const getTotal = require('../get-total');
|
||||||
|
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||||
|
const model = {
|
||||||
|
remoteMethod: () => {}
|
||||||
|
};
|
||||||
|
|
||||||
|
rawSql(model);
|
||||||
|
getTotal(model);
|
||||||
|
|
||||||
|
describe('ticket getTotal()', () => {
|
||||||
|
it('should call the getTotal method and return the response', done => {
|
||||||
|
model.getTotal(1)
|
||||||
|
.then(response => {
|
||||||
|
expect(response).toEqual(11.55);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should call the getTotal method and return zero if doesn't have lines`, done => {
|
||||||
|
model.getTotal(13)
|
||||||
|
.then(response => {
|
||||||
|
expect(response).toEqual(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,22 @@
|
||||||
|
/* let Jasmine = require('jasmine');
|
||||||
|
const {getTicketData} = require('../summary');
|
||||||
|
|
||||||
|
const summary = require('../summary');
|
||||||
|
const model = {
|
||||||
|
remoteMethod: () => {}
|
||||||
|
};
|
||||||
|
|
||||||
|
summary(model);
|
||||||
|
|
||||||
|
fdescribe('ticket summary()', () => {
|
||||||
|
describe('getTicketData()', () => {
|
||||||
|
it('should sum all sales price', done => {
|
||||||
|
let result = getTicketData(model, 1);
|
||||||
|
|
||||||
|
expect(result).toEqual("pepinillos");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
*/
|
|
@ -22,8 +22,10 @@ module.exports = Self => {
|
||||||
Self.summary = async ticketFk => {
|
Self.summary = async ticketFk => {
|
||||||
let models = Self.app.models;
|
let models = Self.app.models;
|
||||||
let summaryObj = await getTicketData(Self, ticketFk);
|
let summaryObj = await getTicketData(Self, ticketFk);
|
||||||
|
|
||||||
summaryObj.sales = await getSales(models.Sale, ticketFk);
|
summaryObj.sales = await getSales(models.Sale, ticketFk);
|
||||||
|
summaryObj.subTotal = getSubTotal(summaryObj.sales);
|
||||||
|
summaryObj.totalTax = await getTotalTax(models.Ticket, ticketFk);
|
||||||
|
summaryObj.total = await models.Ticket.getTotal(ticketFk);
|
||||||
|
|
||||||
return summaryObj;
|
return summaryObj;
|
||||||
};
|
};
|
||||||
|
@ -95,26 +97,30 @@ module.exports = Self => {
|
||||||
},
|
},
|
||||||
fields: ['itemFk', 'name']
|
fields: ['itemFk', 'name']
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'isChecked',
|
|
||||||
scope: {
|
|
||||||
fields: ['isChecked']
|
|
||||||
}
|
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
return await Sale.find(filter);
|
return await Sale.find(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* async function getRecoveries(recovery, clientId) {
|
function getSubTotal(sales) {
|
||||||
let filter = {
|
let subTotal = 0.00;
|
||||||
where: {
|
|
||||||
and: [{clientFk: clientId}, {or: [{finished: null}, {finished: {gt: Date.now()}}]}]
|
|
||||||
},
|
|
||||||
limit: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
return await recovery.findOne(filter);
|
sales.forEach(sale => {
|
||||||
} */
|
subTotal+= sale.quantity * sale.price;
|
||||||
|
});
|
||||||
|
|
||||||
|
return subTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getTotalTax(ticket, ticketFk) {
|
||||||
|
let totalTax = 0.00;
|
||||||
|
let taxes = await ticket.getTaxes(ticketFk);
|
||||||
|
|
||||||
|
taxes.forEach(tax => {
|
||||||
|
totalTax += tax.tax;
|
||||||
|
});
|
||||||
|
|
||||||
|
return totalTax;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,4 +4,6 @@ module.exports = function(Self) {
|
||||||
require('../methods/ticket/filter')(Self);
|
require('../methods/ticket/filter')(Self);
|
||||||
require('../methods/ticket/get-volume')(Self);
|
require('../methods/ticket/get-volume')(Self);
|
||||||
require('../methods/ticket/summary')(Self);
|
require('../methods/ticket/summary')(Self);
|
||||||
|
require('../methods/ticket/get-total')(Self);
|
||||||
|
require('../methods/ticket/get-taxes')(Self);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue