Merge
This commit is contained in:
commit
2951a737a7
|
@ -4,7 +4,7 @@
|
|||
<vn-title vn-one>Addresses</vn-title>
|
||||
<vn-horizontal ng-repeat="address in index.model.items track by address.id" class="pad-medium-top" style="align-items: center;">
|
||||
<vn-one border-radius class="pad-small border-solid"
|
||||
ng-class="{'bg-dark-item': address.isDefaultAddress,'bg-opacity-item': !address.isActive && !address.isDefaultAddress}">
|
||||
ng-class="{'bg-main': address.isDefaultAddress,'bg-opacity-item': !address.isActive && !address.isDefaultAddress}">
|
||||
<vn-horizontal style="align-items: center;">
|
||||
<vn-none pad-medium-h>
|
||||
<i class="material-icons"
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<vn-card pad-large>
|
||||
<vn-title vn-one>Contract credit insurance</vn-title>
|
||||
<vn-horizontal ng-repeat="classification in $ctrl.classifications track by classification.id" class="pad-medium-top" style="align-items: center;">
|
||||
<vn-one border-radius class="pad-small border-solid" ng-class="{'bg-dark-item': !classification.finished,'bg-opacity-item': classification.finished}">
|
||||
<vn-one border-radius class="pad-small border-solid" ng-class="{'bg-main': !classification.finished,'bg-opacity-item': classification.finished}">
|
||||
<vn-horizontal style="align-items: center;">
|
||||
<vn-none pad-medium-h style="color:#FFA410;">
|
||||
<vn-none pad-medium-h orange>
|
||||
<i class="material-icons pointer"
|
||||
ng-if="!classification.finished"
|
||||
vn-tooltip="Close contract"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@import "colors";
|
||||
|
||||
vn-grid-header {
|
||||
border-bottom: 3px solid $main-header;
|
||||
border-bottom: 3px solid $lines;
|
||||
font-weight: bold;
|
||||
.orderly{
|
||||
text-align: center;
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
}
|
||||
}
|
||||
& > thead, & > tbody {
|
||||
border-bottom: 3px solid $main-header;
|
||||
border-bottom: 3px solid $lines;
|
||||
}
|
||||
& > tbody > tr {
|
||||
border-bottom: 1px solid $main-header;
|
||||
border-bottom: 1px solid $lines;
|
||||
transition: background-color 200ms ease-in-out;
|
||||
|
||||
&.clickable {
|
||||
|
|
|
@ -109,6 +109,18 @@
|
|||
"params": {
|
||||
"item": "$ctrl.item"
|
||||
}
|
||||
}, {
|
||||
"url" : "/diary",
|
||||
"state": "item.card.diary",
|
||||
"component": "vn-item-diary",
|
||||
"params": {
|
||||
"item": "$ctrl.item"
|
||||
},
|
||||
"menu": {
|
||||
"description": "Diary",
|
||||
"icon": "icon-transaction"
|
||||
},
|
||||
"acl": ["employee"]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<vn-vertical>
|
||||
<vn-card pad-large>
|
||||
<vn-vertical>
|
||||
<vn-title>Item diary</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-focus
|
||||
url="/item/api/Warehouses"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
initial-data="$ctrl.warehouseFk"
|
||||
field="$ctrl.warehouseFk"
|
||||
label="Select warehouse">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<table class="vn-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th number translate>Date</th>
|
||||
<th number translate>State</th>
|
||||
<th number translate>Origin</th>
|
||||
<th number translate>Reference</th>
|
||||
<th style="text-align: center" translate>Name</th>
|
||||
<th number translate>In</th>
|
||||
<th number translate>Out</th>
|
||||
<th number translate>Balance</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="diary in $ctrl.diary">
|
||||
<td number>{{diary.date | date:'dd/MM/yyyy HH:mm' }}</td>
|
||||
<td number>{{diary.alertLevel | dashIfEmpty}}</td>
|
||||
<td number>{{diary.origin | dashIfEmpty}}</td>
|
||||
<td number>{{diary.reference | dashIfEmpty}}</td>
|
||||
<td style="text-align: center">{{diary.name | dashIfEmpty}}</td>
|
||||
<td number>{{diary.in | dashIfEmpty}}</td>
|
||||
<td number>{{diary.out | dashIfEmpty}}</td>
|
||||
<td number>{{diary.balance | dashIfEmpty}}</td>
|
||||
</tr>
|
||||
<tr ng-if="$ctrl.diary.length === 0" class="list list-element">
|
||||
<td colspan="8" style="text-align: center" translate>No results</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-paging margin-large-top vn-one index="$ctrl.diary" total="$ctrl.diary.count"></vn-paging>
|
||||
<!-- <vn-auto-paging margin-large-top vn-one index="index" total="index.model.count" items="$ctrl.instances"></vn-auto-paging> -->
|
||||
</vn-vertical>
|
|
@ -0,0 +1,38 @@
|
|||
import ngModule from '../module';
|
||||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($scope, $http) {
|
||||
this.$ = $scope;
|
||||
this.$http = $http;
|
||||
this.diary = [];
|
||||
}
|
||||
|
||||
set warehouseFk(value) {
|
||||
this._getItemDiary(value);
|
||||
this._warehouseFk = value;
|
||||
}
|
||||
|
||||
get warehouseFk() {
|
||||
return this._warehouseFk;
|
||||
}
|
||||
|
||||
_getItemDiary(warehouse) {
|
||||
if (warehouse == null)
|
||||
return;
|
||||
let params = {itemFk: this.item.id, warehouseFk: warehouse};
|
||||
this.$http.get(`/item/api/Items/getDiary?params=${JSON.stringify(params)}`).then(res => {
|
||||
this.diary = res.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$http'];
|
||||
|
||||
ngModule.component('vnItemDiary', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
item: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,42 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Item', () => {
|
||||
describe('Component vnItemDiary', () => {
|
||||
let $componentController;
|
||||
let $scope;
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('item');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
|
||||
$componentController = _$componentController_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
$scope = $rootScope.$new();
|
||||
controller = $componentController('vnItemDiary', {$scope: $scope});
|
||||
controller.item = {id: 3};
|
||||
}));
|
||||
|
||||
describe('set warehouseFk()', () => {
|
||||
it(`should call _getItemDiary() with 2 and set warehouseFk`, () => {
|
||||
spyOn(controller, '_getItemDiary');
|
||||
controller.warehouseFk = 2;
|
||||
|
||||
expect(controller._getItemDiary).toHaveBeenCalledWith(2);
|
||||
expect(controller.warehouseFk).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('_getItemDiary()', () => {
|
||||
it(`should make a request to get the diary hwen is called with a number`, () => {
|
||||
$httpBackend.whenGET('/item/api/Items/getDiary?params={"itemFk":3,"warehouseFk":2}').respond({data: 'item'});
|
||||
$httpBackend.expectGET('/item/api/Items/getDiary?params={"itemFk":3,"warehouseFk":2}');
|
||||
controller._getItemDiary(2);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
vn-item-diary {
|
||||
& vn-horizontal {
|
||||
justify-content: center;
|
||||
}
|
||||
& vn-autocomplete > div{
|
||||
width: 400px;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ export * from './module';
|
|||
import './index';
|
||||
import './filter-item-list';
|
||||
import './search-panel';
|
||||
import './diary';
|
||||
import './create';
|
||||
import './card';
|
||||
import './descriptor';
|
||||
|
|
|
@ -29,10 +29,16 @@ Value: Valor
|
|||
Priority: Prioridad
|
||||
Item tax: Tasas del artículo
|
||||
Country: País
|
||||
Select warehouse: Selecione almacén
|
||||
Class: Clase
|
||||
Item niches: Nichos del artículo
|
||||
Item diary: Registro de compra-venta
|
||||
Diary: Registro
|
||||
Warehouse: Almacén
|
||||
Code: Código
|
||||
State: Estado
|
||||
In: Entrada
|
||||
Out: Salida
|
||||
Botanical: Botánico
|
||||
Species: Especie
|
||||
Add tag: Añadir etiqueta
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
show-field="name"
|
||||
value-field="id"
|
||||
field="$ctrl.filter.warehouseFk"
|
||||
url="/production/api/Warehouses/production"
|
||||
url="/production/api/Warehouses"
|
||||
on-change = "$ctrl.onChangeWareHouse(item)"
|
||||
label="Store">
|
||||
</vn-autocomplete>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
show-field="name"
|
||||
value-field="id"
|
||||
field="$ctrl.filter.warehouseFk"
|
||||
url="/production/api/Warehouses/production"
|
||||
url="/production/api/Warehouses"
|
||||
on-change = "$ctrl.onChangeWareHouse(item)"
|
||||
label="Store">
|
||||
</vn-autocomplete>
|
||||
|
|
|
@ -10,6 +10,7 @@ $main-01-03: rgba($main-01, 0.3);
|
|||
$main-02: #a3d131;
|
||||
$main-02-05: rgba($main-02, 0.5);
|
||||
$main-02-03: rgba($main-02, 0.3);
|
||||
$lines: #9b9b9b;
|
||||
|
||||
$color-green: #a3d131;
|
||||
$color-orange: #f7931e;
|
||||
|
|
|
@ -64,7 +64,7 @@ html [vn-center], .vn-center{
|
|||
|
||||
.list-element{
|
||||
padding: 8px 0 0 0;
|
||||
border-bottom: 1px solid $main-header;
|
||||
border-bottom: 1px solid $lines;
|
||||
i {
|
||||
color: $main-01;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ html [vn-center], .vn-center{
|
|||
}
|
||||
.list-footer{
|
||||
font-family: vn-font-bold;
|
||||
border-top: 3px solid $main-header;
|
||||
border-top: 3px solid $lines;
|
||||
}
|
||||
.list-element.warning{
|
||||
background-color: $color-medium-orange;
|
||||
|
|
|
@ -5,31 +5,50 @@
|
|||
<vn-title>Sale</vn-title>
|
||||
<vn-tool-bar margin-medium-bottom>
|
||||
<vn-button
|
||||
disabled="$ctrl.ticket.tracking.state.alertLevel != 0"
|
||||
disabled="!$ctrl.isEditable"
|
||||
label="Ok"
|
||||
ng-click="$ctrl.onStateOkClick()">
|
||||
</vn-button>
|
||||
<vn-icon-menu
|
||||
disabled="$ctrl.ticket.tracking.state.alertLevel != 0"
|
||||
disabled="!$ctrl.isEditable"
|
||||
label="State"
|
||||
url="/ticket/api/States/alertLevelIs0"
|
||||
on-change="$ctrl.onStateChange(value)">
|
||||
</vn-icon-menu>
|
||||
<vn-icon-menu
|
||||
label="More"
|
||||
show-filter="false"
|
||||
value-field="callback"
|
||||
data="::$ctrl.moreOptions"
|
||||
translate-fields="['name']"
|
||||
on-change="$ctrl.onMoreChange(value)">
|
||||
</vn-icon-menu>
|
||||
<vn-button
|
||||
disabled="!$ctrl.isChecked"
|
||||
disabled="!$ctrl.isChecked || !$ctrl.isEditable"
|
||||
ng-click="$ctrl.onRemoveLinesClick()"
|
||||
vn-tooltip="Remove lines"
|
||||
tooltip-position="up"
|
||||
icon="delete">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
disabled="!$ctrl.isChecked || !$ctrl.isEditable"
|
||||
ng-click="$ctrl.showTransferPopover($event);"
|
||||
vn-tooltip="Transfer lines"
|
||||
tooltip-position="right"
|
||||
icon="call_split">
|
||||
</vn-button>
|
||||
</vn-tool-bar>
|
||||
<table class="vn-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th number>
|
||||
<vn-multi-check data="index.model.instances"></vn-multi-check>
|
||||
<vn-multi-check
|
||||
data="index.model.instances"
|
||||
disabled="!$ctrl.isEditable">
|
||||
</vn-multi-check>
|
||||
</th>
|
||||
<th number translate>Item</th>
|
||||
<th translate>Description</th>
|
||||
<th translate style="text-align:center">Description</th>
|
||||
<th number translate>Quantity</th>
|
||||
<th number translate>Price</th>
|
||||
<th number translate>Discount</th>
|
||||
|
@ -39,7 +58,10 @@
|
|||
<tbody>
|
||||
<tr ng-repeat="sale in index.model.instances track by sale.id">
|
||||
<td number>
|
||||
<vn-check field="sale.checked"></vn-check>
|
||||
<vn-check
|
||||
field="sale.checked"
|
||||
disabled="!$ctrl.isEditable">
|
||||
</vn-check>
|
||||
</td>
|
||||
<td
|
||||
pointer
|
||||
|
@ -48,10 +70,27 @@
|
|||
{{::sale.itemFk}}
|
||||
</td>
|
||||
<td><vn-fetched-tags sale="sale"/></td>
|
||||
<td number>{{::sale.quantity}}</td>
|
||||
<td number>{{::sale.price | currency:'€':2}}</td>
|
||||
<td number>{{::sale.discount}} %</td>
|
||||
<td number>{{::sale.quantity * sale.price | currency:'€':2}}</td>
|
||||
<td number>{{sale.quantity}}</td>
|
||||
<!--<td ng-if="$ctrl.ticket.tracking.state.alertLevel == 0">
|
||||
<vn-textfield
|
||||
model="sale.quantity"
|
||||
type="number"
|
||||
ng-blur="updateLine()">
|
||||
</vn-textfield>
|
||||
</td>-->
|
||||
<td number>{{sale.price | currency:'€':2}}</td>
|
||||
<td number>{{sale.discount}} %</td>
|
||||
<td number>{{sale.quantity * sale.price | currency:'€':2}}</td>
|
||||
<!--<td number>
|
||||
<vn-icon-button
|
||||
ng-if="$ctrl.ticket.tracking.state.alertLevel == 0"
|
||||
pointer
|
||||
vn-tooltip="Add note"
|
||||
tooltip-position="left"
|
||||
icon="mode_edit"
|
||||
ng-click="$ctrl.showEditPopover($event, sale)">
|
||||
</vn-icon-button>
|
||||
</td>-->
|
||||
</tr>
|
||||
<tr ng-if="index.model.count === 0" class="list list-element">
|
||||
<td colspan="6" style="text-align: center" translate>No results</td>
|
||||
|
@ -61,6 +100,135 @@
|
|||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging>
|
||||
<!-- <vn-auto-paging vn-one margin-large-top index="index" total="index.model.count" items="index.model.instances"></vn-auto-paging> -->
|
||||
<vn-item-descriptor-popover vn-id="descriptor"></vn-item-descriptor-popover>
|
||||
<vn-item-descriptor-popover vn-id="descriptor">
|
||||
</vn-item-descriptor-popover>
|
||||
|
||||
<!-- Create Ticket Dialog -->
|
||||
<!-- <vn-ticket-create-dialog
|
||||
vn-id="newTicket"
|
||||
callback="$ctrl.moveLines(res)"
|
||||
ticket="$ctrl.ticket">
|
||||
</vn-ticket-create-dialog>
|
||||
-->
|
||||
<!-- Add Turn Dialog -->
|
||||
<vn-dialog class="dialog-summary"
|
||||
vn-id="addTurn">
|
||||
<tpl-body>
|
||||
<div>
|
||||
<h5 style="text-align: center">
|
||||
<span translate>In which day you want to add the ticket?</span>
|
||||
</h5>
|
||||
<vn-tool-bar margin-medium-top>
|
||||
<vn-button
|
||||
label="Monday"
|
||||
ng-click="$ctrl.addTurn(0)">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Tuesday"
|
||||
ng-click="$ctrl.addTurn(1)">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Wednesday"
|
||||
ng-click="$ctrl.addTurn(2)">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Thursday"
|
||||
ng-click="$ctrl.addTurn(3)">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Friday"
|
||||
ng-click="$ctrl.addTurn(4)">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Saturday"
|
||||
ng-click="$ctrl.addTurn(5)">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Sunday"
|
||||
ng-click="$ctrl.addTurn(6)">
|
||||
</vn-button>
|
||||
</vn-tool-bar>
|
||||
</div>
|
||||
</tpl-body>
|
||||
</vn-dialog>
|
||||
|
||||
<!-- Edit Popover -->
|
||||
<vn-popover class="edit" vn-id="edit">
|
||||
<vn-horizontal pad-medium class="header">
|
||||
<h5>MANÁ: {{$ctrl.workerMana}}</h5>
|
||||
</vn-horizontal>
|
||||
<div pad-medium>
|
||||
<h5>{{$ctrl.client.name}}</h5>
|
||||
<vn-textfield
|
||||
label="Quantity"
|
||||
model="$ctrl.edit.quantity"
|
||||
type="number">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
label="Price"
|
||||
model="$ctrl.edit.price"
|
||||
type="number">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
label="Discount"
|
||||
model="$ctrl.edit.discount"
|
||||
type="number">
|
||||
</vn-textfield>
|
||||
<vn-button
|
||||
label="Save"
|
||||
ng-click="$ctrl.updateLine()">
|
||||
</vn-button>
|
||||
</div>
|
||||
</vn-popover>
|
||||
|
||||
<!-- Transfer Popover -->
|
||||
<vn-popover class="transfer" vn-id="transfer">
|
||||
<div pad-medium>
|
||||
<table class="vn-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th number translate>ID</th>
|
||||
<th number translate>F. envio</th>
|
||||
<th number translate>Agencia</th>
|
||||
<th number translate>Almacen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-if="$ctrl.lastThreeTickets.length === 0" ><td colspan="4" style="text-align: center" translate>No results</td></tr>
|
||||
<tr
|
||||
class="clickable"
|
||||
ng-repeat="ticket in $ctrl.lastThreeTickets track by ticket.id"
|
||||
ng-click="$ctrl.moveLines(ticket.id)">
|
||||
<td number>{{::ticket.id}}</td>
|
||||
<td number>{{::ticket.shipped | date: 'dd/MM/yyyy HH:mm'}}</td>
|
||||
<td number>{{::ticket.agencyName}}</td>
|
||||
<td number>{{::ticket.warehouseName}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
label="Move to ticket"
|
||||
model="$ctrl.moveToTicketFk"
|
||||
type="number">
|
||||
</vn-textfield>
|
||||
<vn-icon-button
|
||||
pointer
|
||||
icon="arrow_forward_ios"
|
||||
ng-click="$ctrl.moveLines($ctrl.moveToTicketFk)">
|
||||
</vn-icon-button>
|
||||
</vn-horizontal>
|
||||
<!-- <vn-button
|
||||
pointer
|
||||
label="New ticket"
|
||||
ng-click="$ctrl.showticketCreate()">
|
||||
</vn-button> -->
|
||||
</div>
|
||||
</vn-popover>
|
||||
</vn-vertical>
|
||||
<vn-confirm
|
||||
vn-id="deleteConfirmation"
|
||||
on-response="$ctrl.returnDeleteTicketDialog(response)"
|
||||
question="You are going to delete this ticket"
|
||||
message="Continue anyway?">
|
||||
</vn-confirm>
|
||||
|
|
|
@ -1,13 +1,29 @@
|
|||
import ngModule from '../module';
|
||||
import FilterTicketList from '../filter-ticket-list';
|
||||
import './style.scss';
|
||||
|
||||
class Controller extends FilterTicketList {
|
||||
constructor($scope, $timeout, $stateParams, $http) {
|
||||
constructor($scope, $timeout, $stateParams, $http, $state, vnApp) {
|
||||
super($scope, $timeout, $stateParams);
|
||||
this.$ = $scope;
|
||||
this.vnApp = vnApp;
|
||||
this.$timeout = $timeout;
|
||||
this.onOrder('itemFk', 'ASC');
|
||||
this.$state = $stateParams;
|
||||
this.$http = $http;
|
||||
this.deletable = false;
|
||||
this.moreOptions = [
|
||||
{callback: this.showAddTurnDialog, name: "Add turn"},
|
||||
{callback: this.showDeleteTicketDialog, name: "Delete ticket"}
|
||||
];
|
||||
}
|
||||
|
||||
get isEditable() {
|
||||
try {
|
||||
return !this.ticket.tracking.state.alertLevel;
|
||||
} catch (e) {}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
get isChecked() {
|
||||
|
@ -20,6 +36,22 @@ class Controller extends FilterTicketList {
|
|||
return false;
|
||||
}
|
||||
|
||||
getCheckedLines() {
|
||||
let lines = [];
|
||||
let data = this.$.index.model.instances;
|
||||
if (data)
|
||||
for (let i = 0; i < data.length; i++)
|
||||
if (data[i].checked)
|
||||
lines.push({id: data[i].id, instance: i});
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
onMoreChange(callback) {
|
||||
callback.call(this);
|
||||
}
|
||||
|
||||
// Change State
|
||||
onStateOkClick() {
|
||||
let filter = {where: {code: "OK"}, fields: ["id"]};
|
||||
let json = encodeURIComponent(JSON.stringify(filter));
|
||||
|
@ -30,41 +62,153 @@ class Controller extends FilterTicketList {
|
|||
|
||||
onStateChange(value) {
|
||||
let params = {ticketFk: this.$state.params.id, stateFk: value};
|
||||
this.$http.post(`/ticket/api/TicketTrackings`, params).then(() => {
|
||||
this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => {
|
||||
this.card.reload();
|
||||
this.vnApp.showMessage(this.translate.instant('Data saved'));
|
||||
});
|
||||
}
|
||||
|
||||
onRemoveLinesClick() {
|
||||
let lines = {
|
||||
delete: []
|
||||
};
|
||||
let data = this.$.index.model.instances;
|
||||
if (data)
|
||||
for (let i = 0; i < data.length;) {
|
||||
if (data[i].checked) {
|
||||
lines.delete.push(data[i].id);
|
||||
data.splice(i, 1);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
let query = `/ticket/api/Sales/crudSale`;
|
||||
this.$http.post(query, lines);
|
||||
// Add Turn
|
||||
showAddTurnDialog() {
|
||||
this.$.addTurn.show();
|
||||
}
|
||||
|
||||
addTurn(day) {
|
||||
let params = {ticketFk: this.$state.params.id, weekDay: day};
|
||||
this.$http.patch(`/ticket/api/TicketWeeklies`, params).then(() => {
|
||||
this.$.addTurn.hide();
|
||||
});
|
||||
}
|
||||
|
||||
// Delete Ticket
|
||||
showDeleteTicketDialog() {
|
||||
this.$.deleteConfirmation.show();
|
||||
}
|
||||
|
||||
returnDeleteTicketDialog(response) {
|
||||
if (response === 'ACCEPT')
|
||||
this.deleteTicket();
|
||||
}
|
||||
|
||||
deleteTicket() {
|
||||
let params = {id: this.$state.params.id};
|
||||
this.$http.post(`/ticket/api/Tickets/deleted`, params).then(() => {
|
||||
this.$state.go('ticket.list');
|
||||
});
|
||||
}
|
||||
|
||||
// Remove Lines
|
||||
onRemoveLinesClick() {
|
||||
let sales = this.getCheckedLines();
|
||||
let params = {sales: sales, actualTicketFk: this.ticket.id};
|
||||
let query = `/ticket/api/Sales/removes`;
|
||||
this.$http.post(query, params).then(() => {
|
||||
this.removeInstances(sales);
|
||||
});
|
||||
}
|
||||
|
||||
// Move Lines
|
||||
showTransferPopover(event) {
|
||||
let filter = {clientFk: this.ticket.clientFk, ticketFk: this.ticket.id};
|
||||
let json = encodeURIComponent(JSON.stringify(filter));
|
||||
this.$http.get(`/ticket/api/Tickets/threeLastActive?filter=${json}`).then(res => {
|
||||
this.lastThreeTickets = res.data;
|
||||
});
|
||||
this.$.transfer.parent = event.target;
|
||||
this.$.transfer.show();
|
||||
}
|
||||
|
||||
moveLines(ticketID) {
|
||||
let sales = this.getCheckedLines();
|
||||
|
||||
let params = {sales: sales, newTicketFk: ticketID, actualTicketFk: this.ticket.id};
|
||||
this.$http.post(`/ticket/api/Sales/moveToTicket`, params).then(() => {
|
||||
this.goToTicket(ticketID);
|
||||
});
|
||||
}
|
||||
|
||||
/* newTicket() {
|
||||
let params = [this.ticket.clientFk, this.ticket.warehouseFk, this.ticket.companyFk, this.ticket.addressFk, this.ticket.agencyModeFk, null];
|
||||
this.$http.post(`/ticket/api/Tickets/create`, params).then(res => {
|
||||
console.log(res);
|
||||
});
|
||||
}*/
|
||||
|
||||
goToTicket(ticketID) {
|
||||
this.$state.go("ticket.card.sale", {id: ticketID});
|
||||
}
|
||||
|
||||
removeInstances(instances) {
|
||||
for (let i = instances.length - 1; i >= 0; i--) {
|
||||
this.$.index.model.instances.splice(instances[i].instance, 1);
|
||||
}
|
||||
}
|
||||
// Item Descriptor
|
||||
showDescriptor(event, itemFk) {
|
||||
this.$.descriptor.itemFk = itemFk;
|
||||
this.$.descriptor.parent = event.target;
|
||||
this.$.descriptor.show();
|
||||
}
|
||||
|
||||
onDescriptorLoad() {
|
||||
this.$.popover.relocate();
|
||||
}
|
||||
|
||||
// Ticket Create
|
||||
showticketCreate() {
|
||||
console.log(this);
|
||||
this.$.newTicket.show();
|
||||
}
|
||||
|
||||
onResponse(response) {
|
||||
if (response === 'ACCEPT') {
|
||||
let newTicketID = this.$.newTicket.dialog.createTicket();
|
||||
console.log(newTicketID);
|
||||
}
|
||||
}
|
||||
// Edit Line
|
||||
_getworkerMana() {
|
||||
this.$http.get(`/api/WorkerManas/getCurrentWorkerMana`).then(res => {
|
||||
this.workerMana = res.data[0].mana;
|
||||
});
|
||||
}
|
||||
|
||||
showEditPopover(event, sale) {
|
||||
this.sale = sale;
|
||||
this.edit = {
|
||||
id: sale.id,
|
||||
quantity: sale.quantity,
|
||||
price: sale.price,
|
||||
discount: sale.discount
|
||||
};
|
||||
this.$.edit.parent = event.target;
|
||||
this._getworkerMana();
|
||||
this.$.edit.show();
|
||||
}
|
||||
|
||||
updateLine() {
|
||||
if (this.edit.quantity != this.sale.quantity) {
|
||||
this.$http.post(`/ticket/api/Sales/updateQuantity`, {id: this.edit.id, quantity: this.edit.quantity}).then(() => {
|
||||
this.sale.quantity = this.edit.quantity;
|
||||
});
|
||||
}
|
||||
|
||||
if (this.edit.price != this.sale.price) {
|
||||
this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.edit.price}).then(() => {
|
||||
this.sale.price = this.edit.price;
|
||||
});
|
||||
}
|
||||
|
||||
if (this.edit.discount != this.sale.discount) {
|
||||
this.$http.post(`/ticket/api/Sales/updateDiscount`, {id: this.edit.id, discount: this.edit.discount}).then(() => {
|
||||
this.sale.discount = this.edit.discount;
|
||||
});
|
||||
}
|
||||
this.$.edit.hide();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$timeout', '$state', '$http'];
|
||||
Controller.$inject = ['$scope', '$timeout', '$state', '$http', 'vnApp'];
|
||||
|
||||
ngModule.component('vnTicketSale', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Ticket', () => {
|
||||
xdescribe('Ticket', () => {
|
||||
describe('Component vnTicketSale', () => {
|
||||
let $componentController;
|
||||
let controller;
|
||||
|
@ -57,7 +57,7 @@ describe('Ticket', () => {
|
|||
|
||||
describe('onStateChange()', () => {
|
||||
it('should perform a post and then call a function', () => {
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketTrackings`).respond();
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketTrackings/changeState`).respond();
|
||||
controller.card = {reload: () => {}};
|
||||
controller.onStateChange(3);
|
||||
$httpBackend.flush();
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
@import "colors";
|
||||
|
||||
vn-popover.edit {
|
||||
|
||||
& div.popover{
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
& vn-horizontal.header{
|
||||
background-color: $main-01;
|
||||
text-align: center;
|
||||
|
||||
& h5{
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vn-ticket-sale{
|
||||
& tr .mdl-textfield{
|
||||
width: inherit;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
vn-popover.transfer{
|
||||
& table {
|
||||
min-width: 650px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
& i {
|
||||
padding-top: 0.2em;
|
||||
font-size: 1.8em;
|
||||
}
|
||||
}
|
||||
|
||||
vn-dialog.ticket-create{
|
||||
& vn-button[label=Cancel]{
|
||||
display: none;
|
||||
}
|
||||
& vn-card.vn-ticket-create{
|
||||
padding: 0!important;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> install/dump
|
|||
echo USE `vn`; >> install/dump/03-dumpedFixtures.sql
|
||||
mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc >> install/dump/03-dumpedFixtures.sql
|
||||
echo USE `vn2008`; >> install/dump/03-dumpedFixtures.sql
|
||||
mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas>> install/dump/03-dumpedFixtures.sql
|
||||
mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas container>> install/dump/03-dumpedFixtures.sql
|
||||
echo USE `bi`; >> install/dump/03-dumpedFixtures.sql
|
||||
mysqldump --defaults-file=connect.ini --no-create-info bi tarifa_componentes tarifa_componentes_series >> install/dump/03-dumpedFixtures.sql
|
||||
echo USE `cache`; >> install/dump/03-dumpedFixtures.sql
|
||||
|
|
|
@ -7,7 +7,7 @@ mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> install/dump
|
|||
echo "USE \`vn\`;" >> install/dump/03-dumpedFixtures.sql
|
||||
mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc >> install/dump/03-dumpedFixtures.sql
|
||||
echo "USE \`vn2008\`;" >> install/dump/03-dumpedFixtures.sql
|
||||
mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas>> install/dump/03-dumpedFixtures.sql
|
||||
mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas container>> install/dump/03-dumpedFixtures.sql
|
||||
echo "USE \`bi\`;" >> install/dump/03-dumpedFixtures.sql
|
||||
mysqldump --defaults-file=connect.ini --no-create-info bi tarifa_componentes tarifa_componentes_series >> install/dump/03-dumpedFixtures.sql
|
||||
echo "USE \`cache\`;" >> install/dump/03-dumpedFixtures.sql
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
USE `vn`;
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `buy` AS
|
||||
SELECT
|
||||
`c`.`Id_Compra` AS `id`,
|
||||
`c`.`Id_Entrada` AS `entryFk`,
|
||||
`c`.`Id_Article` AS `itemFk`,
|
||||
`c`.`Costefijo` AS `buyingValue`,
|
||||
`c`.`Cantidad` AS `quantity`,
|
||||
`c`.`Id_Cubo` AS `packageFk`,
|
||||
`c`.`Etiquetas` AS `stickers`,
|
||||
`c`.`Portefijo` AS `freightValue`,
|
||||
`c`.`Embalajefijo` AS `packageValue`,
|
||||
`c`.`Comisionfija` AS `comissionValue`,
|
||||
`c`.`Packing` AS `packing`,
|
||||
`c`.`grouping` AS `grouping`,
|
||||
`c`.`caja` AS `groupingMode`,
|
||||
`c`.`Nicho` AS `location`,
|
||||
`c`.`Tarifa1` AS `price1`,
|
||||
`c`.`Tarifa2` AS `price2`,
|
||||
`c`.`Tarifa3` AS `price3`,
|
||||
`c`.`PVP` AS `minPrice`,
|
||||
`c`.`Productor` AS `producer`,
|
||||
`c`.`Vida` AS `printedStickers`,
|
||||
`c`.`punteo` AS `isChecked`,
|
||||
`c`.`buy_edi_id` AS `ektFk`,
|
||||
`c`.`Novincular` AS `isIgnored`
|
||||
FROM
|
||||
`vn2008`.`Compres` `c`;
|
|
@ -0,0 +1,45 @@
|
|||
USE `edi`;
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `edi`.`ekt` AS
|
||||
SELECT
|
||||
`vn2008`.`buy_edi`.`id` AS `id`,
|
||||
`vn2008`.`buy_edi`.`barcode` AS `barcode`,
|
||||
`vn2008`.`buy_edi`.`entry_year` AS `entry_year`,
|
||||
`vn2008`.`buy_edi`.`delivery_number` AS `delivery_number`,
|
||||
`vn2008`.`buy_edi`.`fec` AS `fec`,
|
||||
`vn2008`.`buy_edi`.`hor` AS `hor`,
|
||||
`vn2008`.`buy_edi`.`now` AS `now`,
|
||||
`vn2008`.`buy_edi`.`ptj` AS `ptj`,
|
||||
`vn2008`.`buy_edi`.`ref` AS `ref`,
|
||||
`vn2008`.`buy_edi`.`item` AS `item`,
|
||||
`vn2008`.`buy_edi`.`pac` AS `pac`,
|
||||
`vn2008`.`buy_edi`.`qty` AS `qty`,
|
||||
`vn2008`.`buy_edi`.`ori` AS `ori`,
|
||||
`vn2008`.`buy_edi`.`cat` AS `cat`,
|
||||
`vn2008`.`buy_edi`.`agj` AS `agj`,
|
||||
`vn2008`.`buy_edi`.`kop` AS `kop`,
|
||||
`vn2008`.`buy_edi`.`ptd` AS `ptd`,
|
||||
`vn2008`.`buy_edi`.`sub` AS `sub`,
|
||||
`vn2008`.`buy_edi`.`pro` AS `pro`,
|
||||
`vn2008`.`buy_edi`.`pri` AS `pri`,
|
||||
`vn2008`.`buy_edi`.`package` AS `package`,
|
||||
`vn2008`.`buy_edi`.`auction` AS `auction`,
|
||||
`vn2008`.`buy_edi`.`klo` AS `klo`,
|
||||
`vn2008`.`buy_edi`.`k01` AS `k01`,
|
||||
`vn2008`.`buy_edi`.`k02` AS `k02`,
|
||||
`vn2008`.`buy_edi`.`k03` AS `k03`,
|
||||
`vn2008`.`buy_edi`.`k04` AS `k04`,
|
||||
`vn2008`.`buy_edi`.`s1` AS `s1`,
|
||||
`vn2008`.`buy_edi`.`s2` AS `s2`,
|
||||
`vn2008`.`buy_edi`.`s3` AS `s3`,
|
||||
`vn2008`.`buy_edi`.`s4` AS `s4`,
|
||||
`vn2008`.`buy_edi`.`s5` AS `s5`,
|
||||
`vn2008`.`buy_edi`.`s6` AS `s6`,
|
||||
`vn2008`.`buy_edi`.`ok` AS `ok`,
|
||||
`vn2008`.`buy_edi`.`trolley_id` AS `trolley_id`,
|
||||
`vn2008`.`buy_edi`.`scanned` AS `scanned`
|
||||
FROM
|
||||
`vn2008`.`buy_edi`;
|
|
@ -0,0 +1,40 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `itemLastEntries`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `itemLastEntries`(vItem INT, vDays DATE)
|
||||
BEGIN
|
||||
SELECT
|
||||
w.id AS warehouseFk,
|
||||
tr.landed,
|
||||
b.entryFk,
|
||||
b.isIgnored,
|
||||
b.price2,
|
||||
b.price3,
|
||||
b.stickers,
|
||||
b.packing,
|
||||
b.grouping,
|
||||
i.stems,
|
||||
b.quantity,
|
||||
b.buyingValue,
|
||||
b.packageFk ,
|
||||
s.id AS supplierFk
|
||||
FROM itemType it
|
||||
RIGHT JOIN (entry e
|
||||
LEFT JOIN supplier s ON s.id = e.supplierFk
|
||||
RIGHT JOIN buy b ON b.entryFk = e.id
|
||||
LEFT JOIN item i ON i.id = b.itemFk
|
||||
LEFT JOIN ink ON ink.id = i.inkFk
|
||||
LEFT JOIN travel tr ON tr.id = e.travelFk
|
||||
LEFT JOIN warehouse w ON w.id = tr.warehouseInFk
|
||||
LEFT JOIN origin o ON o.id = i.originFk
|
||||
) ON it.id = i.typeFk
|
||||
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
|
||||
WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND CURDATE()
|
||||
ORDER BY tr.landed DESC , b.id DESC;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `ticketComponentMakeUpdate`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentMakeUpdate`(
|
||||
vTicketFk INT,
|
||||
vClientFk INT,
|
||||
vAgencyModeFk INT,
|
||||
vAddressFk INT,
|
||||
vWarehouseFk INT,
|
||||
vShipped DATETIME,
|
||||
vLanded DATE,
|
||||
vIsDeleted BOOLEAN,
|
||||
vHasToBeUnrouted BOOLEAN,
|
||||
vOption INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula los componentes de un ticket
|
||||
* y los actualiza con los nuevos datos.
|
||||
*
|
||||
* @param vTicketFk Id del ticket
|
||||
* @param vClientFk Id del cliente
|
||||
* @param vAgencyModeFk Id del tipo de agencia
|
||||
* @param vAddressFk Id del consignatario
|
||||
* @param vWarehouseFk Id del almacén
|
||||
* @param vShipped Fecha de salida
|
||||
* @param vLanded Fecha de llegada
|
||||
* @param vIsDeleted Marcado como eliminado
|
||||
* @param vHasToBeUnrouted Marcado para sacar de ruta
|
||||
* @param vOption Id de la acción ticketUpdateAction
|
||||
*/
|
||||
|
||||
CALL vn.ticketComponentPreview (vTicketFk, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk);
|
||||
CALL vn.ticketComponentUpdate (
|
||||
vTicketFk,
|
||||
vClientFk,
|
||||
vAgencyModeFk,
|
||||
vAddressFk,
|
||||
vWarehouseFk,
|
||||
vShipped,
|
||||
vLanded,
|
||||
vIsDeleted,
|
||||
vHasToBeUnrouted,
|
||||
vOption
|
||||
);
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.ticketComponent,
|
||||
tmp.ticketComponentPrice;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `ticketComponentPreview`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentPreview`(
|
||||
vTicketFk INT,
|
||||
vDate DATE,
|
||||
vAddressFk INT,
|
||||
vAgencyModeFk INT,
|
||||
vWarehouseFk SMALLINT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve un listado previo de
|
||||
* componentes para un ticket
|
||||
*
|
||||
* @param vTicketFk Id del ticket
|
||||
* @param vDate Fecha de envÃo
|
||||
* @param vAddressFk Id del consignatario
|
||||
* @param vAgencyModeFk Id del modo de agencia
|
||||
* @param vWarehouseFk Id del almacén
|
||||
*/
|
||||
DECLARE vAgencyFk INT;
|
||||
DECLARE vShipped DATE;
|
||||
DECLARE vBuyOrderItem INT DEFAULT 100;
|
||||
|
||||
SELECT agencyFk INTO vAgencyFk
|
||||
FROM agencyMode
|
||||
WHERE id = vAgencyModeFk;
|
||||
|
||||
CALL agencyHourOffer(vDate, vAddressFk, vAgencyFk);
|
||||
|
||||
SELECT shipped INTO vShipped
|
||||
FROM tmp.agencyHourOffer
|
||||
WHERE warehouseFk = vWarehouseFK;
|
||||
|
||||
CALL buyUltimate(vWarehouseFK, vShipped);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
||||
CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY (
|
||||
SELECT
|
||||
vWarehouseFK AS warehouseFk,
|
||||
NULL AS available,
|
||||
s.itemFk,
|
||||
bu.buyFk
|
||||
FROM sale s
|
||||
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||
WHERE s.ticketFk = vTicketFk
|
||||
AND s.itemFk != vBuyOrderItem
|
||||
GROUP BY bu.warehouseFk, bu.itemFk);
|
||||
|
||||
CALL ticketComponentCalculate(vAddressFk, vAgencyModeFk);
|
||||
|
||||
REPLACE INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
|
||||
SELECT t.warehouseFk, s.itemFk, sc.componentFk, sc.value
|
||||
FROM saleComponent sc
|
||||
JOIN sale s ON s.id = sc.saleFk
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN componentRate cr ON cr.id = sc.componentFk
|
||||
WHERE s.ticketFk = vTicketFk AND NOT cr.isRenewable;
|
||||
|
||||
SET @shipped = vShipped;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.agencyHourOffer,
|
||||
tmp.buyUltimate,
|
||||
tmp.ticketLot;
|
||||
|
||||
IF IFNULL(vShipped, CURDATE() - 1) < CURDATE() THEN
|
||||
CALL util.throw('NO_AGENCY_AVAILABLE');
|
||||
END IF;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
|
@ -1,55 +0,0 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `ticketComponentPriceDifference`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentPriceDifference`(
|
||||
vTicketFk INT,
|
||||
vDate DATE,
|
||||
vAddressFk INT,
|
||||
vAgencyModeFk INT,
|
||||
vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve las diferencias de precio
|
||||
* de los movimientos de un ticket.
|
||||
*
|
||||
* @param vTicketFk Id del ticket
|
||||
* @param vDate Fecha de envÃo
|
||||
* @param vAddressFk Id del consignatario
|
||||
* @param vAgencyModeFk Id del modo de agencia
|
||||
* @param vWarehouseFk Id del almacén
|
||||
*/
|
||||
CALL vn.ticketComponentPreview(vTicketFk, vDate, vAddressFk, vAgencyModeFk, vWarehouseFk);
|
||||
|
||||
SELECT
|
||||
s.itemFk,
|
||||
i.name,
|
||||
i.size,
|
||||
i.category,
|
||||
IFNULL(s.quantity, 0) AS quantity,
|
||||
IFNULL(s.price, 0) AS price,
|
||||
ROUND(SUM(tc.cost), 4) AS newPrice,
|
||||
s.quantity * (s.price - ROUND(SUM(cost), 4)) difference,
|
||||
s.id AS saleFk
|
||||
FROM sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
LEFT JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk
|
||||
AND tc.warehouseFk = t.warehouseFk
|
||||
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
AND sc.componentFk = tc.componentFk
|
||||
LEFT JOIN componentRate cr ON cr.id = tc.componentFk
|
||||
WHERE
|
||||
t.id = vTicketFk
|
||||
AND IF(sc.componentFk IS NULL
|
||||
AND cr.classRate IS NOT NULL, FALSE, TRUE)
|
||||
GROUP BY s.id ORDER BY s.id;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.ticketComponent,
|
||||
tmp.ticketComponentPrice;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
USE `vn`;
|
||||
DROP procedure IF EXISTS `ticketComponentUpdate`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentUpdate`(
|
||||
vTicketFk INT,
|
||||
vClientFk INT,
|
||||
vAgencyModeFk INT,
|
||||
vAddressFk INT,
|
||||
vWarehouseFk INT,
|
||||
vShipped DATETIME,
|
||||
vLanded DATE,
|
||||
vIsDeleted BOOLEAN,
|
||||
vHasToBeUnrouted BOOLEAN,
|
||||
vOption INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Actualiza un ticket y sus componentes
|
||||
* con los nuevos datos.
|
||||
*
|
||||
* @param vTicketFk Id del ticket
|
||||
* @param vClientFk Id del cliente
|
||||
* @param vAgencyModeFk Id del tipo de agencia
|
||||
* @param vAddressFk Id del consignatario
|
||||
* @param vWarehouseFk Id del almacén
|
||||
* @param vShipped Fecha de salida
|
||||
* @param vLanded Fecha de llegada
|
||||
* @param vIsDeleted Marcado como eliminado
|
||||
* @param vHasToBeUnrouted Marcado para sacar de ruta
|
||||
* @param vOption Id de la acción ticketUpdateAction
|
||||
*/
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
UPDATE ticket t
|
||||
SET
|
||||
t.clientFk = vClientFk,
|
||||
t.agencyModeFk = vAgencyModeFk,
|
||||
t.addressFk = vAddressFk,
|
||||
t.warehouseFk = vWarehouseFk,
|
||||
t.landed = vLanded,
|
||||
t.shipped = vShipped,
|
||||
t.isDeleted = vIsDeleted
|
||||
WHERE
|
||||
t.id = vTicketFk;
|
||||
|
||||
IF vHasToBeUnrouted THEN
|
||||
UPDATE ticket t SET t.routeFk = NULL
|
||||
WHERE t.id = vTicketFk;
|
||||
END IF;
|
||||
|
||||
IF vOption <> 8 THEN
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
|
||||
CREATE TEMPORARY TABLE tmp.sale
|
||||
(PRIMARY KEY (saleFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT id AS saleFk, vWarehouseFk warehouseFk
|
||||
FROM sale s WHERE s.ticketFk = vTicketFk;
|
||||
|
||||
CALL ticketComponentUpdateSale (vOption);
|
||||
|
||||
DROP TEMPORARY TABLE tmp.sale;
|
||||
END IF;
|
||||
COMMIT;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -328,16 +328,16 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
|
|||
|
||||
INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `created`)
|
||||
VALUES
|
||||
(1, 1, 1, 5, CURDATE()),
|
||||
(2, 2, 2, 5, CURDATE()),
|
||||
(3, 3, 3, 5, CURDATE()),
|
||||
(4, 4, 1, 5, CURDATE()),
|
||||
(5, 5, 2, 18, CURDATE()),
|
||||
(6, 6, 3, 18, CURDATE()),
|
||||
(7, 7, 1, 18, CURDATE()),
|
||||
(8, 8, 2, 19, CURDATE()),
|
||||
(9, 9, 3, 19, CURDATE()),
|
||||
(10, 10, 3, 19, CURDATE()),
|
||||
(1, 1, 13, 5, CURDATE()),
|
||||
(2, 2, 15, 5, CURDATE()),
|
||||
(3, 3, 16, 5, CURDATE()),
|
||||
(4, 4, 13, 5, CURDATE()),
|
||||
(5, 5, 15, 18, CURDATE()),
|
||||
(6, 6, 16, 18, CURDATE()),
|
||||
(7, 7, 13, 18, CURDATE()),
|
||||
(8, 8, 15, 19, CURDATE()),
|
||||
(9, 9, 16, 19, CURDATE()),
|
||||
(10, 10, 13, 19, CURDATE()),
|
||||
(11, 11, 3, 19, CURDATE()),
|
||||
(12, 12, 3, 19, CURDATE()),
|
||||
(13, 13, 3, 19, CURDATE()),
|
||||
|
@ -346,9 +346,9 @@ INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `crea
|
|||
(16, 16, 1, 19, CURDATE()),
|
||||
(17, 17, 1, 19, CURDATE()),
|
||||
(18, 18, 1, 19, CURDATE()),
|
||||
(19, 19, 1, 19, CURDATE()),
|
||||
(20, 20, 1, 19, CURDATE()),
|
||||
(21, 21, 1, 19, CURDATE());
|
||||
(19, 19, 13, 19, CURDATE()),
|
||||
(20, 20, 15, 19, CURDATE()),
|
||||
(21, 21, 16, 19, CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`)
|
||||
VALUES
|
||||
|
@ -631,12 +631,12 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
|
|||
( 4, 4),
|
||||
( 5, 6);
|
||||
|
||||
INSERT INTO `vn`.`travel`(`id`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`)
|
||||
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`)
|
||||
VALUES
|
||||
( 1, CURDATE(), 1, 2, 1, 100.00, 1000),
|
||||
( 2, CURDATE(), 1, 2, 1, 150, 2000),
|
||||
( 3, CURDATE(), 1, 2, 1, 0.00, 0.00),
|
||||
( 4, CURDATE(), 1, 2, 1, 50.00, 500);
|
||||
( 1, CURDATE(), CURDATE(), 1, 2, 1, 100.00, 1000),
|
||||
( 2, CURDATE(), CURDATE(), 1, 2, 1, 150, 2000),
|
||||
( 3, CURDATE(), CURDATE(), 1, 2, 1, 0.00, 0.00),
|
||||
( 4, CURDATE(), CURDATE(), 1, 2, 1, 50.00, 500);
|
||||
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`)
|
||||
VALUES
|
||||
|
@ -675,3 +675,13 @@ INSERT INTO `bi`.`claims_ratio`(`id_Cliente`, `Consumo`, `Reclamaciones`, `Ratio
|
|||
( 102, 1000, 2.00, 0.01, 0.05, 1.00),
|
||||
( 103, 2000, 0.00, 0.00, 0.02, 1.00),
|
||||
( 104, 2500, 150.00, 0.02, 0.10, 1.00);
|
||||
|
||||
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packageFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`,`minPrice`,`producer`,`printedStickers`,`isChecked`,`isIgnored`)
|
||||
VALUES
|
||||
(1, 1, 1, 2.5, 4, 1, 1, 0.350, 0.050, 0.000, 1, 1, 1, NULL, 1.50, 1.25, 1.30, 2.00, NULL, 0, 1, 0),
|
||||
(2, 2, 2, 5, 2, 1, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 2, 1.00, 1.30, 2.00, NULL, 0, 1, 0),
|
||||
(3, 3, 3, 10, 1, 1, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 2.50, 1.00, 2.50, 2.00, NULL, 0, 1, 0);
|
||||
|
||||
INSERT INTO `vn2008`.`tblContadores`(`id`,`FechaInventario`)
|
||||
VALUES
|
||||
(1,CURDATE());
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"name": "Warehouse",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "warehouse",
|
||||
"database": "vn"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "String",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -47,9 +47,10 @@ module.exports = Self => {
|
|||
FROM vn.itemBotanical ib WHERE itemFk = ?`;
|
||||
promises.push(Self.rawSql(createBotanical, [newItem.id, origin.id]));
|
||||
|
||||
let createTags = `INSERT INTO vn.itemTag (itemFk, tagFk, value, priority)
|
||||
SELECT ?, tagFk, value, priority
|
||||
FROM vn.itemTag WHERE itemFk = ?`;
|
||||
let createTags = `INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT ?, i.tagFk, i.value,i.priority
|
||||
FROM vn.itemTag i WHERE i.itemFk = ?
|
||||
ON DUPLICATE KEY UPDATE value = i.value, priority = i.priority`;
|
||||
promises.push(Self.rawSql(createTags, [newItem.id, origin.id]));
|
||||
|
||||
let createTax = `REPLACE INTO vn.itemTaxCountry (itemFk, countryFk, taxClassFk)
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getDiary', {
|
||||
description: 'Returns the ',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'params',
|
||||
type: 'object',
|
||||
description: 'itemFk, warehouseFk'
|
||||
}],
|
||||
returns: {
|
||||
arg: 'diary',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getDiary`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getDiary = async params => {
|
||||
let [diary] = await Self.rawSql(`CALL vn.itemDiary(?, ?)`, [params.itemFk, params.warehouseFk]);
|
||||
return diary;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,35 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('moveToTicket', {
|
||||
description: 'Change the state of a ticket',
|
||||
accessType: '',
|
||||
accepts: [{
|
||||
arg: 'params',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: '[sales IDs], newTicketFk, actualTicketFk',
|
||||
http: {source: 'body'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'string',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/moveToTicket`,
|
||||
verb: 'post'
|
||||
}
|
||||
});
|
||||
|
||||
Self.moveToTicket = async params => {
|
||||
let thisTicketIsEditable = await Self.app.models.Ticket.isEditable(params.actualTicketFk);
|
||||
if (!thisTicketIsEditable)
|
||||
throw new Error(`The sales of this ticket can't be modified`);
|
||||
|
||||
let newTicketIsEditable = await Self.app.models.Ticket.isEditable(params.newTicketFk);
|
||||
if (!newTicketIsEditable)
|
||||
throw new Error(`The sales of this ticket can't be modified`);
|
||||
|
||||
for (let i = 0; i < params.sales.length; i++) {
|
||||
await Self.app.models.Sale.update({id: params.sales[i].id}, {ticketFk: params.newTicketFk});
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,31 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('removes', {
|
||||
description: 'Change the state of a ticket',
|
||||
accessType: '',
|
||||
accepts: [{
|
||||
arg: 'params',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: '[sales IDs], actualTicketFk',
|
||||
http: {source: 'body'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'string',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/removes`,
|
||||
verb: 'post'
|
||||
}
|
||||
});
|
||||
|
||||
Self.removes = async params => {
|
||||
let thisTicketIsEditable = await Self.app.models.Ticket.isEditable(params.actualTicketFk);
|
||||
if (!thisTicketIsEditable)
|
||||
throw new Error(`The sales of this ticket can't be modified`);
|
||||
|
||||
for (let i = 0; i < params.sales.length; i++) {
|
||||
await Self.app.models.Sale.destroyById(params.sales[i].id);
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,25 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('deleted', {
|
||||
description: 'Sets the isDeleted value of a ticket to 1',
|
||||
accessType: '',
|
||||
accepts: [{
|
||||
arg: 'ticketFk',
|
||||
type: 'Object',
|
||||
required: true,
|
||||
description: 'TicketFk',
|
||||
http: {source: 'body'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'string',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/deleted`,
|
||||
verb: 'post'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deleted = async params => {
|
||||
return await Self.app.models.Ticket.update({id: params.id}, {isDeleted: '1'});
|
||||
};
|
||||
};
|
|
@ -21,7 +21,7 @@ module.exports = Self => {
|
|||
|
||||
Self.isEditable = async ticketFk => {
|
||||
let state = await Self.app.models.TicketState.findOne({where: {ticketFk: ticketFk}, fields: 'alertLevel'});
|
||||
|
||||
return state != null && state.alertLevel == 0;
|
||||
let exists = await Self.app.models.Ticket.findOne({where: {id: ticketFk}, fields: 'isDeleted'});
|
||||
return (exists && state == null && exists.isDeleted == 0) || (exists.isDeleted == 0 && state.alertLevel == 0);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('threeLastActive', {
|
||||
description: 'Returns the last three tickets of a client that have the alertLevel at 0 and the shiped day is gt today',
|
||||
accessType: '',
|
||||
accepts: [{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'client id, ticketFk'
|
||||
}],
|
||||
returns: {
|
||||
type: [this.modelName],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/threeLastActive`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.threeLastActive = async filter => {
|
||||
console.log(filter);
|
||||
let query = `
|
||||
SELECT t.id,t.shipped,a.name AS agencyName,w.name AS warehouseName
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketState ts ON t.id = ts.ticketFk
|
||||
JOIN vn.agencyMode a ON t.agencyModeFk = a.id
|
||||
JOIN vn.warehouse w ON t.warehouseFk = w.id
|
||||
WHERE t.shipped > CURDATE() AND t.clientFk = ? AND ts.alertLevel = 0 AND t.id <> ?
|
||||
ORDER BY t.shipped
|
||||
LIMIT 3`;
|
||||
let result = await Self.rawSql(query, [filter.clientFk, filter.ticketFk]);
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -3,6 +3,7 @@ let UserError = require('../helpers').UserError;
|
|||
module.exports = Self => {
|
||||
require('../methods/item/clone')(Self);
|
||||
require('../methods/item/updateTaxes')(Self);
|
||||
require('../methods/item/getDiary')(Self);
|
||||
|
||||
Self.validatesPresenceOf('name', {message: 'Cannot be blank'});
|
||||
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});
|
||||
|
|
|
@ -3,4 +3,9 @@ module.exports = Self => {
|
|||
require('../methods/sale/saleComponentFilter')(Self);
|
||||
require('../methods/sale/priceDifference')(Self);
|
||||
require('../methods/sale/crudSale')(Self);
|
||||
require('../methods/sale/moveToTicket')(Self);
|
||||
require('../methods/sale/removes')(Self);
|
||||
// require('../methods/sale/updateDiscount')(Self);
|
||||
// require('../methods/sale/updatePrice')(Self);
|
||||
// require('../methods/sale/updateQuantity')(Self);
|
||||
};
|
||||
|
|
|
@ -7,4 +7,8 @@ module.exports = Self => {
|
|||
require('../methods/ticket/getTotal')(Self);
|
||||
require('../methods/ticket/getTaxes')(Self);
|
||||
require('../methods/ticket/componentUpdate')(Self);
|
||||
// require('../methods/ticket/create')(Self);
|
||||
require('../methods/ticket/isEditable')(Self);
|
||||
require('../methods/ticket/threeLastActive')(Self);
|
||||
require('../methods/ticket/deleted')(Self);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue