Ticket packages, moved Item model to loopback service
This commit is contained in:
parent
34a0c37797
commit
af2fca3879
|
@ -1,53 +1,29 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class ClientSummary {
|
||||
class Controller {
|
||||
|
||||
constructor($http) {
|
||||
this.$http = $http;
|
||||
}
|
||||
|
||||
set client(value) {
|
||||
if (!value)
|
||||
$onChanges() {
|
||||
if (!this.client || !this.client.id)
|
||||
return;
|
||||
|
||||
this.getSummary();
|
||||
this.getGreuse();
|
||||
this.getRecoveries();
|
||||
}
|
||||
|
||||
getSummary() {
|
||||
let filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'account',
|
||||
scope: {
|
||||
fields: ['name', 'active']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'salesPerson',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'country',
|
||||
scope: {
|
||||
fields: ['country']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'province',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'contactChannel',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'payMethod',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
{relation: 'account', scope: {fields: ['name', 'active']}},
|
||||
{relation: 'salesPerson', scope: {fields: ['name']}},
|
||||
{relation: 'country', scope: {fields: ['country']}},
|
||||
{relation: 'province', scope: {fields: ['name']}},
|
||||
{relation: 'contactChannel', scope: {fields: ['name']}},
|
||||
{relation: 'payMethod', scope: {fields: ['name']}},
|
||||
{
|
||||
relation: 'addresses',
|
||||
scope: {
|
||||
|
@ -57,43 +33,46 @@ class ClientSummary {
|
|||
}
|
||||
]
|
||||
};
|
||||
filter = encodeURIComponent(JSON.stringify(filter));
|
||||
|
||||
let clientSummary = `/client/api/Clients/${value.id}?filter=${JSON.stringify(filter)}`;
|
||||
|
||||
this.$http.get(encodeURIComponent(clientSummary)).then(res => {
|
||||
let query = `/client/api/Clients/${this.client.id}?filter=${filter}`;
|
||||
this.$http.get(query).then(res => {
|
||||
if (res.data) {
|
||||
this.summary = res.data;
|
||||
this.address = res.data.addresses[0];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let greugeSum = `/client/api/Greuges/${value.id}/sumAmount`;
|
||||
|
||||
this.$http.get(encodeURIComponent(greugeSum)).then(res => {
|
||||
getGreuse() {
|
||||
let query = `/client/api/Greuges/${this.client.id}/sumAmount`;
|
||||
this.$http.get(query).then(res => {
|
||||
if (res.data)
|
||||
this.greuge = res.data;
|
||||
});
|
||||
}
|
||||
|
||||
let recoveryFilter = {
|
||||
getRecoveries() {
|
||||
let filter = {
|
||||
where: {
|
||||
and: [{clientFk: value.id}, {or: [{finished: null}, {finished: {gt: Date.now()}}]}]
|
||||
and: [{clientFk: this.client.id}, {or: [{finished: null}, {finished: {gt: Date.now()}}]}]
|
||||
},
|
||||
limit: 1
|
||||
};
|
||||
filter = encodeURIComponent(JSON.stringify(filter));
|
||||
|
||||
let recovery = `/client/api/Recoveries?filter=${JSON.stringify(recoveryFilter)}`;
|
||||
|
||||
this.$http.get(encodeURIComponent(recovery)).then(res => {
|
||||
let query = `/client/api/Recoveries?filter=${filter}`;
|
||||
this.$http.get(query).then(res => {
|
||||
if (res.data)
|
||||
this.recovery = res.data[0];
|
||||
});
|
||||
}
|
||||
}
|
||||
ClientSummary.$inject = ['$http'];
|
||||
Controller.$inject = ['$http'];
|
||||
|
||||
ngModule.component('vnClientSummary', {
|
||||
template: require('./client-summary.html'),
|
||||
controller: ClientSummary,
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
client: '<'
|
||||
}
|
||||
|
|
|
@ -45,6 +45,24 @@
|
|||
"description": "Basic data",
|
||||
"icon": "settings"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url" : "/package",
|
||||
"abstract": true,
|
||||
"state": "ticket.card.package",
|
||||
"component": "ui-view"
|
||||
},
|
||||
{
|
||||
"url": "/list",
|
||||
"state": "ticket.card.package.list",
|
||||
"component": "vn-ticket-package-list",
|
||||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
},
|
||||
"menu": {
|
||||
"description": "Packages",
|
||||
"icon": "icon-bucket"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<mg-ajax
|
||||
path="/ticket/api/Tickets/{{index.params.id}}/packages"
|
||||
options="mgIndex">
|
||||
</mg-ajax>
|
||||
|
||||
<vn-card pad-large>
|
||||
<vn-title>Packages</vn-title>
|
||||
<vn-one>
|
||||
<vn-horizontal ng-repeat="package in index.model track by package.id">
|
||||
<vn-autocomplete vn-one
|
||||
margin-large-right
|
||||
url="/ticket/api/Packagings/listPackaging"
|
||||
label="Package"
|
||||
show-field="name"
|
||||
value-field="packagingFk"
|
||||
field="package.packagingFk">
|
||||
<tpl-item>{{id}} : {{name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
margin-large-right
|
||||
label="Quantity"
|
||||
model="package.quantity">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
margin-large-right
|
||||
label="Added"
|
||||
model="package.created | date: 'dd/MM/yyyy'"
|
||||
disabled="true"
|
||||
ng-readonly="true">
|
||||
</vn-textfield>
|
||||
<vn-auto pad-medium-top>
|
||||
<vn-icon
|
||||
pointer
|
||||
medium-grey
|
||||
vn-tooltip="Remove package"
|
||||
tooltip-position = "left"
|
||||
icon="remove_circle_outline"
|
||||
ng-click="$ctrl.removePackage($index)">
|
||||
</vn-icon>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<vn-icon
|
||||
pointer
|
||||
margin-medium-left
|
||||
vn-tooltip="Add package"
|
||||
tooltip-position = "right"
|
||||
orange
|
||||
icon="add_circle"
|
||||
ng-click="$ctrl.addPackage()">
|
||||
</vn-icon>
|
||||
</vn-one>
|
||||
</vn-card>
|
|
@ -0,0 +1,19 @@
|
|||
import ngModule from '../../module';
|
||||
|
||||
class Controller {
|
||||
|
||||
construct($http, $scope) {
|
||||
this.$http = $http;
|
||||
this.$ = $scope;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$http', '$scope'];
|
||||
|
||||
ngModule.component('vnTicketPackageList', {
|
||||
template: require('./package-list.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
ticket: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,6 @@
|
|||
Packages: Embalajes
|
||||
Package: Embalaje
|
||||
Quantity: Cantidad
|
||||
Added: Añadido
|
||||
Add package: Añadir embalaje
|
||||
Remove package: Quitar embalaje
|
|
@ -5,3 +5,4 @@ import './create/ticket-create';
|
|||
import './card/ticket-card';
|
||||
import './summary/ticket-summary';
|
||||
import './data/ticket-data';
|
||||
import './package/list/package-list';
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/item/crudItemBarcodes.js')(Self);
|
||||
require('../methods/item-barcode/crudItemBarcodes.js')(Self);
|
||||
};
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/item/getLog.js')(Self);
|
||||
require('../methods/item-log/getLog.js')(Self);
|
||||
};
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/item/crudItemNiches.js')(Self);
|
||||
require('../methods/item-niche/crudItemNiches.js')(Self);
|
||||
};
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/item/crudItemTags.js')(Self);
|
||||
require('../methods/item-tag/crudItemTags.js')(Self);
|
||||
};
|
||||
|
|
|
@ -1,22 +1,4 @@
|
|||
{
|
||||
"Item": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ItemType": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Ink": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Origin": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Producer": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Intrastat": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"TaxClass": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -26,9 +8,6 @@
|
|||
"TaxType": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Expence": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ItemTag": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -7,5 +7,8 @@
|
|||
"El método de pago seleccionado requiere que se especifique el IBAN": "El método de pago seleccionado requiere que se especifique el IBAN",
|
||||
"can't be blank": "can't be blank",
|
||||
"DNI Incorrecto": "DNI Incorrecto",
|
||||
"Ya existe un usuario con ese nombre": "Ya existe un usuario con ese nombre"
|
||||
"Ya existe un usuario con ese nombre": "Ya existe un usuario con ese nombre",
|
||||
"ValidationError: The `Item` instance is not valid. Details: `originFk` Cannot be blank (value: undefined).": "ValidationError: The `Item` instance is not valid. Details: `originFk` Cannot be blank (value: undefined).",
|
||||
"Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`vn2008`.`Articles`, CONSTRAINT `Articles_ibfk_5` FOREIGN KEY (`tipo_id`) REFERENCES `Tipos` (`tipo_id`) ON UPDATE CASCADE)": "Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`vn2008`.`Articles`, CONSTRAINT `Articles_ibfk_5` FOREIGN KEY (`tipo_id`) REFERENCES `Tipos` (`tipo_id`) ON UPDATE CASCADE)",
|
||||
"Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`vn2008`.`Articles`, CONSTRAINT `expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `Gastos` (`Id_Gasto`) ON UPDATE CASCADE)": "Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`vn2008`.`Articles`, CONSTRAINT `expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `Gastos` (`Id_Gasto`) ON UPDATE CASCADE)"
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
var UserError = require('../../../../loopback/common/helpers').UserError;
|
||||
var UserError = require('../../helpers').UserError;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('clone', {
|
||||
|
@ -27,7 +27,7 @@ module.exports = Self => {
|
|||
id: itemId
|
||||
},
|
||||
include: [
|
||||
{relation: "itemTag", scope: {order: "priority ASC", include: {relation: "tag"}}}
|
||||
{relation: 'itemTag', scope: {order: 'priority ASC', include: {relation: 'tag'}}}
|
||||
]
|
||||
};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
let UserError = require('../../../loopback/common/helpers').UserError;
|
||||
let UserError = require('../helpers').UserError;
|
||||
|
||||
module.exports = function(Self) {
|
||||
require('../methods/item/filter.js')(Self);
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "Specie",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "specie"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"specie_id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"latin_species_name": {
|
||||
"type": "String"
|
||||
},
|
||||
"entry_date": {
|
||||
"type": "date"
|
||||
},
|
||||
"expiry_date": {
|
||||
"type": "date"
|
||||
},
|
||||
"change_date_time": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"genus": {
|
||||
"type": "belongsTo",
|
||||
"model": "Genus",
|
||||
"foreignKey": "genus_id"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -71,6 +71,11 @@
|
|||
"model": "AgencyMode",
|
||||
"foreignKey": "agencyModeFk",
|
||||
"required": true
|
||||
},
|
||||
"packages": {
|
||||
"type": "hasMany",
|
||||
"model": "TicketPackaging",
|
||||
"foreignKey": "ticketFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,5 +68,26 @@
|
|||
},
|
||||
"TicketState":{
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Item": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Origin": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ItemType": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Expence": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Ink": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Intrastat": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Producer": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('listPackaging', {
|
||||
description: 'Returns all packages including item',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'filter',
|
||||
type: 'Object',
|
||||
required: false,
|
||||
description: 'Filter defining where and paginated data',
|
||||
http: {source: 'query'}
|
||||
}],
|
||||
returns: {
|
||||
type: ["Object"],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/listPackaging`,
|
||||
verb: 'get'
|
||||
}
|
||||
});
|
||||
|
||||
Self.listPackaging = async filter => {
|
||||
let where = '';
|
||||
let limit = '';
|
||||
let order = '';
|
||||
let params;
|
||||
|
||||
if (filter) {
|
||||
let connector = Self.dataSource.connector;
|
||||
if (filter.where) {
|
||||
if (filter.where.packagingFk) {
|
||||
where = 'WHERE p.id = ?';
|
||||
params = [filter.where.packagingFk];
|
||||
} else {
|
||||
let search = filter.where.name.regexp;
|
||||
where = 'WHERE i.id REGEXP ? OR i.name REGEXP ?';
|
||||
params = [search, search];
|
||||
}
|
||||
}
|
||||
|
||||
limit = connector._buildLimit(null, filter.limit, filter.offset);
|
||||
order = connector.buildOrderBy('Item', filter.order);
|
||||
}
|
||||
|
||||
let query = `SELECT i.name, i.id, p.id packagingFk FROM
|
||||
item i JOIN packaging p ON i.id = p.itemFk ${where} ${order} ${limit}`;
|
||||
return await Self.rawSql(query, params);
|
||||
};
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/packaging/listPackaging')(Self);
|
||||
};
|
|
@ -9,7 +9,7 @@
|
|||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "Number",
|
||||
"type": "String",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"volume": {
|
||||
|
|
Loading…
Reference in New Issue