This commit is contained in:
Joan Sanchez 2019-01-23 14:53:16 +01:00
commit 747b593c90
14 changed files with 64 additions and 46 deletions

View File

@ -1,5 +1,5 @@
<vn-horizontal>
<vn-one>{{::$ctrl.item.name}}</vn-one>
<vn-one>{{::$ctrl.title}}</vn-one>
<vn-auto>
<section
class="inline-tag ellipsize"

View File

@ -49,6 +49,7 @@ ngModule.component('vnFetchedTags', {
controller: FetchedTags,
bindings: {
maxLength: '<',
item: '<'
item: '<',
title: '<'
}
});

View File

@ -81,7 +81,7 @@
</a>
</vn-vertical>
<!-- Add Lines Dialog -->
<vn-dialog vn-id="add-sales" class="modalForm">
<vn-dialog vn-id="add-sales" class="modal-form">
<tpl-body>
<vn-horizontal pad-medium class="header">
<h5><span translate>Claimable sales from ticket</span> {{$ctrl.claim.ticketFk}}</h5>

View File

@ -1,6 +1,6 @@
<vn-dialog
vn-id="dialog"
class="modalForm"
class="modal-form"
on-open="$ctrl.getPossibleStowaways()">
<tpl-body>
<vn-horizontal pad-medium class="header">

View File

@ -1,5 +1,5 @@
<vn-dialog
class="modalForm"
class="modal-form"
vn-id="dialog">
<tpl-body>
<vn-horizontal pad-medium class="header">

View File

@ -1,6 +1,6 @@
@import 'colors';
vn-dialog.modalForm {
vn-dialog.modal-form {
vn-horizontal.header{
background-color: $main-01;
h5{

View File

@ -27,7 +27,6 @@ module.exports = Self => {
{relation: 'client'}
]
});
let clientFk = address.clientFk;
if (address.client().isFreezed)
throw new UserError(`You can't create an order for a frozen client`);
@ -38,12 +37,6 @@ module.exports = Self => {
if (!address.client().isTaxDataChecked)
throw new UserError(`You can't create an order for a client that doesn't has tax data verified`);
let query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`;
let clientDebt = await Self.rawSql(query, [clientFk]);
if (address.client().credit - clientDebt[0].debt <= 0)
throw new UserError(`You can't create an order for a client that has a debt`);
query = `CALL vn.orderListCreate(?, ?, ?, ?);`;
[result] = await Self.rawSql(query, [
params.landed,

View File

@ -44,21 +44,6 @@ describe('order new()', () => {
expect(error).toEqual(new UserError(`You can't create an order for a client that doesn't has tax data verified`));
});
it('should throw an error if the client isnt frozen and is active, has data checked but has a debt', async() => {
let error;
let params = {
addressFk: 123,
landed: new Date()
};
await app.models.Order.new(params)
.catch(e => {
error = e;
});
expect(error).toEqual(new UserError(`You can't create an order for a client that has a debt`));
});
it('should create a new order for the user with id 105 when all conditions are met', async() => {
let params = {
landed: new Date(),

View File

@ -4,5 +4,8 @@
},
"OrderRow": {
"dataSource": "vn"
},
"OrderTicket": {
"dataSource": "vn"
}
}

View File

@ -0,0 +1,31 @@
{
"name": "OrderTicket",
"base": "VnModel",
"options": {
"mysql": {
"table": "orderTicket"
}
},
"properties": {
"orderFk": {
"id": true,
"type": "Number"
},
"ticketFk": {
"id": true,
"type": "Number"
}
},
"relations": {
"ticket": {
"type": "belongsTo",
"model": "Ticket",
"foreignKey": "ticketFk"
},
"order": {
"type": "belongsTo",
"model": "Order",
"foreignKey": "orderFk"
}
}
}

View File

@ -111,13 +111,13 @@ module.exports = Self => {
teamIds = [worker && worker.id];
}
if (ctx.args && ctx.args.mine || ctx.args.myTeam)
if (ctx.args && (ctx.args.mine || ctx.args.myTeam))
ctx.args.teamIds = teamIds;
let orderTickets = [];
if (ctx.args && ctx.args.orderFk) {
let ticketsToSearch = await Self.app.models.OrderTickets.find({where: {orderFk: filter.orderFk}});
let ticketsToSearch = await Self.app.models.OrderTicket.find({where: {orderFk: ctx.args.orderFk}});
ticketsToSearch.forEach(ticket => {
orderTickets.push(ticket.ticketFk);
});

View File

@ -2,32 +2,37 @@ import ngModule from '../module';
import './style.scss';
export default class Controller {
constructor($scope, $state) {
constructor($scope, $state, $stateparams) {
this.$ = $scope;
this.$stateparams = $stateparams;
this.$state = $state;
this.selectedTicket = null;
this.moreOptions = [
{callback: this.goToTurns, name: 'Turns', always: true},
];
let today = new Date();
let offset = today.getTimezoneOffset() * 60000;
today.setHours(0, 0, 0, 0);
today.setTime(today.getTime() - offset);
if (!$state && !$stateparams) {
let today = new Date();
let offset = today.getTimezoneOffset() * 60000;
today.setHours(0, 0, 0, 0);
today.setTime(today.getTime() - offset);
let tomorrow = new Date(today);
tomorrow.setHours(23, 59, 59, 999);
tomorrow.setTime(tomorrow.getTime() - offset);
let tomorrow = new Date(today);
tomorrow.setHours(23, 59, 59, 999);
tomorrow.setTime(tomorrow.getTime() - offset);
let sixDays = new Date(today);
sixDays.setDate(today.getDate() + 6);
sixDays.setHours(23, 59, 59, 999);
sixDays.setTime(sixDays.getTime() - offset);
this.filter = {mine: true, from: today, to: sixDays};
let sixDays = new Date(today);
sixDays.setDate(today.getDate() + 6);
sixDays.setHours(23, 59, 59, 999);
sixDays.setTime(sixDays.getTime() - offset);
this.filter = {mine: true, from: today, to: sixDays};
}
}
$postLink() {
this.onSearch(this.filter);
if (this.filter)
this.onSearch(this.filter);
}
onSearch(params) {

View File

@ -102,7 +102,7 @@
{{::sale.itemFk | zeroFill:6}}
</span>
</vn-td>
<vn-td><vn-fetched-tags max-length="6" item="sale.tags"/></vn-td>
<vn-td><vn-fetched-tags max-length="6" item="sale.tags" title="sale.concept"/></vn-td>
<vn-td ng-if="!$ctrl.isEditable" number>{{sale.quantity}}</vn-td>
<vn-td ng-if="$ctrl.isEditable" number>
<vn-textfield

View File

@ -88,7 +88,7 @@
{{sale.itemFk | zeroFill:6}}
</span>
</td>
<td><vn-fetched-tags max-length="6" item="sale.item"/></td>
<td><vn-fetched-tags max-length="6" item="sale.item" title="sale.concept"/></td>
<td number>{{::sale.quantity}}</td>
<td number>{{::sale.price | currency:'€':2}}</td>
<td number>{{::sale.discount}} %</td>