1368 - First sale refactor
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
356c1a7b45
commit
d4c78b46c1
|
@ -29,7 +29,7 @@ module.exports = Self => {
|
|||
order: 'priority',
|
||||
include: [
|
||||
{
|
||||
relation: 'state',
|
||||
relation: 'ticketState',
|
||||
scope: {
|
||||
fields: ['id', 'stateFk'],
|
||||
include: [{relation: 'state'}]
|
||||
|
|
|
@ -38,7 +38,6 @@ module.exports = Self => {
|
|||
let highestDate = new Date(ship.shipped.getTime());
|
||||
highestDate.setHours(23, 59, 59);
|
||||
|
||||
|
||||
let possibleStowaways = await models.Ticket.find({
|
||||
where: {
|
||||
id: {neq: ticketFk},
|
||||
|
@ -53,7 +52,7 @@ module.exports = Self => {
|
|||
include: [
|
||||
{relation: 'agencyMode'},
|
||||
{relation: 'warehouse'},
|
||||
{relation: 'state',
|
||||
{relation: 'ticketState',
|
||||
scope: {
|
||||
fields: ['stateFk'],
|
||||
include: {
|
||||
|
|
|
@ -90,7 +90,7 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
}, {
|
||||
relation: 'state',
|
||||
relation: 'ticketState',
|
||||
scope: {
|
||||
fields: ['stateFk'],
|
||||
include: {
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
"model": "TicketObservation",
|
||||
"foreignKey": "ticketFk"
|
||||
},
|
||||
"state": {
|
||||
"ticketState": {
|
||||
"type": "hasOne",
|
||||
"model": "TicketState",
|
||||
"foreignKey": "ticketFk"
|
||||
|
|
|
@ -45,7 +45,7 @@ class Controller extends ModuleCard {
|
|||
},
|
||||
},
|
||||
}, {
|
||||
relation: 'state',
|
||||
relation: 'ticketState',
|
||||
scope: {
|
||||
fields: ['stateFk'],
|
||||
include: {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<vn-td>{{ticket.landed | date: 'dd/MM/yyyy'}}</vn-td>
|
||||
<vn-td>{{ticket.agencyMode.name}}</vn-td>
|
||||
<vn-td>{{ticket.warehouse.name}}</vn-td>
|
||||
<vn-td>{{ticket.state.state.name}}</vn-td>
|
||||
<vn-td>{{ticket.ticketState.state.name}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
<div class="attributes">
|
||||
<vn-label-value
|
||||
label="State"
|
||||
value="{{$ctrl.ticket.state.state.name}}">
|
||||
value="{{$ctrl.ticket.ticketState.state.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Sales person"
|
||||
|
|
|
@ -211,7 +211,7 @@ class Controller extends Descriptor {
|
|||
}
|
||||
}
|
||||
}, {
|
||||
relation: 'state',
|
||||
relation: 'ticketState',
|
||||
scope: {
|
||||
fields: ['stateFk'],
|
||||
include: {
|
||||
|
|
|
@ -58,6 +58,8 @@ class Controller extends Component {
|
|||
const query = `Tickets/${this.$params.id}/updateDiscount`;
|
||||
this.$http.post(query, params).then(() => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
console.log(this.edit[0].sale);
|
||||
this.edit[0].sale.price = 277;
|
||||
this.clearDiscount();
|
||||
modified = false;
|
||||
}).catch(e => {
|
||||
|
|
|
@ -12,19 +12,19 @@
|
|||
<vn-horizontal class="header">
|
||||
<vn-tool-bar class="vn-mb-md">
|
||||
<vn-button
|
||||
disabled="!$ctrl.isEditable"
|
||||
disabled="!$ctrl.isEditable || $ctrl.ticketState == 'OK'"
|
||||
label="Ok"
|
||||
vn-http-click="$ctrl.onStateOkClick()"
|
||||
vn-http-click="$ctrl.changeState('OK')"
|
||||
vn-tooltip="Change ticket state to 'Ok'">
|
||||
</vn-button>
|
||||
<vn-button-menu
|
||||
disabled="!$ctrl.isEditable"
|
||||
label="State"
|
||||
value-field="id"
|
||||
value-field="code"
|
||||
url="States/editableStates"
|
||||
on-change="$ctrl.onStateChange(value)">
|
||||
on-change="$ctrl.changeState(value)">
|
||||
</vn-button-menu>
|
||||
<vn-button-menu
|
||||
<!-- <vn-button-menu
|
||||
ng-show="$ctrl.isChecked"
|
||||
vn-id="more-button"
|
||||
label="More"
|
||||
|
@ -33,15 +33,20 @@
|
|||
translate-fields="['name']"
|
||||
on-change="$ctrl.onMoreChange(value)"
|
||||
on-open="$ctrl.onMoreOpen()">
|
||||
</vn-button-menu>
|
||||
</vn-button-menu> -->
|
||||
<vn-button icon="keyboard_arrow_down"
|
||||
label="More"
|
||||
ng-click="moreOptions.show($event)"
|
||||
ng-show="$ctrl.hasCheckedLines()">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
disabled="!$ctrl.isChecked || !$ctrl.isEditable"
|
||||
disabled="!$ctrl.hasCheckedLines() || !$ctrl.isEditable"
|
||||
ng-click="deleteLines.show()"
|
||||
vn-tooltip="Remove lines"
|
||||
icon="delete">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
disabled="!$ctrl.isChecked || !$ctrl.isEditable"
|
||||
disabled="!$ctrl.hasCheckedLines() || !$ctrl.isEditable"
|
||||
ng-click="$ctrl.showTransferPopover($event)"
|
||||
vn-tooltip="Transfer lines"
|
||||
icon="call_split">
|
||||
|
@ -80,14 +85,13 @@
|
|||
</vn-td>
|
||||
<vn-td shrink>
|
||||
<a ui-sref="claim.card.basicData({id: sale.claim.claimFk})">
|
||||
<vn-icon
|
||||
<vn-icon icon="icon-claims"
|
||||
ng-show="sale.claim.claimFk"
|
||||
icon="icon-claims"
|
||||
vn-tooltip="{{::$ctrl.$t('Claim')}}: {{::sale.claim.claimFk}}">
|
||||
</vn-icon>
|
||||
</a>
|
||||
<vn-icon
|
||||
ng-show="sale.visible < 0 || sale.available < 0"
|
||||
ng-show="::(sale.visible < 0 || sale.available < 0)"
|
||||
color-main
|
||||
icon="warning"
|
||||
vn-tooltip="Visible: {{::sale.visible || 0}} <br> {{::$ctrl.$t('Available')}}: {{::sale.available || 0}}">
|
||||
|
@ -117,7 +121,7 @@
|
|||
show-field="name"
|
||||
value-field="id"
|
||||
search-function="$ctrl.itemSearchFunc($search)"
|
||||
on-change="$ctrl.onChangeQuantity(sale)"
|
||||
on-change="$ctrl.changeQuantity(sale)"
|
||||
order="id DESC"
|
||||
tabindex="1">
|
||||
<tpl-item>
|
||||
|
@ -131,14 +135,14 @@
|
|||
<vn-input-number class="dense"
|
||||
vn-focus
|
||||
ng-model="sale.quantity"
|
||||
on-change="$ctrl.onChangeQuantity(sale)">
|
||||
on-change="$ctrl.changeQuantity(sale)">
|
||||
</vn-input-number>
|
||||
</field>
|
||||
</vn-td-editable>
|
||||
<vn-td ng-if="!sale.id" number>
|
||||
<vn-input-number
|
||||
ng-model="sale.quantity"
|
||||
on-change="$ctrl.onChangeQuantity(sale)"
|
||||
on-change="$ctrl.changeQuantity(sale)"
|
||||
tabindex="2">
|
||||
</vn-input-number>
|
||||
</vn-td>
|
||||
|
@ -152,23 +156,23 @@
|
|||
</vn-fetched-tags>
|
||||
</text>
|
||||
<field>
|
||||
<vn-textfield class="dense"
|
||||
<vn-textfield class="dense" vn-focus
|
||||
vn-id="concept"
|
||||
ng-model="sale.concept"
|
||||
on-change="$ctrl.updateConcept(sale)">
|
||||
on-change="$ctrl.changeConcept(sale)">
|
||||
</vn-textfield>
|
||||
</field>
|
||||
</vn-td-editable>
|
||||
<vn-td number>
|
||||
<span ng-class="{'link': $ctrl.isEditable}"
|
||||
title="{{$ctrl.isEditable ? 'Edit price' : ''}}"
|
||||
translate-attr="{title: $ctrl.isEditable ? 'Edit price' : ''}"
|
||||
ng-click="$ctrl.showEditPricePopover($event, sale)">
|
||||
{{sale.price | currency: 'EUR':2}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number>
|
||||
<span ng-class="{'link': !$ctrl.isLocked}"
|
||||
title="{{!$ctrl.isLocked ? 'Edit discount' : ''}}"
|
||||
translate-attr="{title: !$ctrl.isLocked ? 'Edit discount' : ''}"
|
||||
ng-click="$ctrl.showEditDiscountPopover($event, sale)"
|
||||
ng-if="sale.id">
|
||||
{{(sale.discount / 100) | percentage}}
|
||||
|
@ -206,60 +210,106 @@
|
|||
ticket-fk="$ctrl.ticket.id">
|
||||
</vn-item-descriptor-popover>
|
||||
|
||||
<!-- Edit Price Popover -->
|
||||
<!-- Price Popover -->
|
||||
<vn-popover
|
||||
vn-id="edit-price-popover"
|
||||
on-open="$ctrl.getManaSalespersonMana()"
|
||||
on-close="$ctrl.mana = null">
|
||||
on-open="$ctrl.getMana()"
|
||||
on-close="$ctrl.edit = null">
|
||||
<div class="edit-price">
|
||||
<vn-spinner
|
||||
ng-if="$ctrl.mana == null"
|
||||
style="padding: 1em;"
|
||||
<vn-spinner class="vn-pa-xs"
|
||||
ng-if="$ctrl.edit.mana == null"
|
||||
enable="true">
|
||||
</vn-spinner>
|
||||
<div ng-if="$ctrl.mana != null">
|
||||
<div ng-if="$ctrl.edit.mana != null">
|
||||
<section class="header vn-pa-md">
|
||||
<h5>MANÁ: {{$ctrl.mana | currency: 'EUR':0}}</h5>
|
||||
<h5>MANÁ: {{$ctrl.edit.mana | currency: 'EUR': 0}}</h5>
|
||||
</section>
|
||||
<div class="vn-pa-md">
|
||||
<vn-input-number
|
||||
vn-focus
|
||||
label="Price"
|
||||
ng-model="$ctrl.newPrice"
|
||||
ng-model="$ctrl.edit.price"
|
||||
step="0.01"
|
||||
on-change="$ctrl.updatePrice()"
|
||||
suffix="€">
|
||||
</vn-input-number>
|
||||
<div class="simulator">
|
||||
<p class="simulatorTitle" translate>New price</p>
|
||||
<p>{{$ctrl.newPrice | currency: 'EUR':2}}</p>
|
||||
<p>
|
||||
<strong>{{$ctrl.getNewPrice() | currency: 'EUR': 2}}</strong>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</vn-popover>
|
||||
|
||||
<!-- Edit Popover -->
|
||||
<!-- Discount popover -->
|
||||
<vn-popover
|
||||
vn-id="edit-popover"
|
||||
on-open="$ctrl.getManaSalespersonMana()"
|
||||
on-close="$ctrl.mana = null">
|
||||
vn-id="editDiscount"
|
||||
on-open="$ctrl.getMana()"
|
||||
on-close="$ctrl.edit = null">
|
||||
<div class="edit-price">
|
||||
<vn-spinner
|
||||
ng-if="$ctrl.mana == null"
|
||||
style="padding: 1em;"
|
||||
<vn-spinner class="vn-pa-xs"
|
||||
ng-if="$ctrl.edit.mana == null"
|
||||
enable="true">
|
||||
</vn-spinner>
|
||||
<vn-ticket-sale-edit-discount
|
||||
ng-if="$ctrl.mana != null"
|
||||
mana="$ctrl.mana"
|
||||
<div ng-if="$ctrl.edit.mana != null">
|
||||
<section class="header vn-pa-md">
|
||||
<h5>Mana: {{$ctrl.edit.mana | currency: 'EUR':0}}</h5>
|
||||
</section>
|
||||
<div class="vn-pa-md">
|
||||
<vn-input-number
|
||||
vn-focus
|
||||
label="Discount"
|
||||
ng-model="$ctrl.edit.discount"
|
||||
on-change="$ctrl.changeDiscount()"
|
||||
suffix="%">
|
||||
</vn-input-number>
|
||||
<div class="simulator">
|
||||
<p class="simulatorTitle" translate>New price</p>
|
||||
<p>
|
||||
<strong>{{$ctrl.getNewPrice() | currency: 'EUR': 2}}</strong>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <vn-ticket-sale-edit-discount
|
||||
ng-if="$ctrl.edit.mana != null"
|
||||
mana="$ctrl.edit.mana"
|
||||
bulk="false"
|
||||
edit="$ctrl.edit"
|
||||
on-hide="$ctrl.hideEditPopover()">
|
||||
</vn-ticket-sale-edit-discount>
|
||||
</vn-ticket-sale-edit-discount> -->
|
||||
</div>
|
||||
</vn-popover>
|
||||
|
||||
<!-- Multiple discount dialog -->
|
||||
<vn-dialog vn-id="editDiscountDialog"
|
||||
on-open="$ctrl.getMana()"
|
||||
on-close="$ctrl.edit = null"
|
||||
message="Edit discount">
|
||||
<tpl-body>
|
||||
<vn-spinner class="vn-pa-xs"
|
||||
ng-if="$ctrl.edit.mana == null"
|
||||
enable="true">
|
||||
</vn-spinner>
|
||||
<div ng-if="$ctrl.edit.mana != null">
|
||||
<div class="vn-pa-md">
|
||||
<vn-input-number vn-focus
|
||||
label="Discount"
|
||||
ng-model="$ctrl.edit.discount"
|
||||
on-change="$ctrl.changeMultipleDiscount()"
|
||||
suffix="%">
|
||||
</vn-input-number>
|
||||
</div>
|
||||
<section class="header vn-pa-md">
|
||||
<span>Mana: <strong>{{$ctrl.edit.mana | currency: 'EUR': 0}}</strong></span>
|
||||
</section>
|
||||
</div>
|
||||
</tpl-body>
|
||||
</vn-dialog>
|
||||
|
||||
<!-- Transfer Popover -->
|
||||
<vn-popover vn-id="transfer">
|
||||
<div class="vn-pa-md transfer">
|
||||
|
@ -306,10 +356,10 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th number>Id</th>
|
||||
<th number>Shipped</th>
|
||||
<th number>Agency</th>
|
||||
<th number>Warehouse</th>
|
||||
<th number>Address</th>
|
||||
<th number translate>Shipped</th>
|
||||
<th number translate>Agency</th>
|
||||
<th number translate>Warehouse</th>
|
||||
<th number translate>Address</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -352,28 +402,6 @@
|
|||
</div>
|
||||
</vn-popover>
|
||||
|
||||
<!-- Edit Dialog -->
|
||||
<vn-dialog
|
||||
vn-id="editDialog"
|
||||
class="edit"
|
||||
on-open="$ctrl.getManaSalespersonMana()"
|
||||
on-close="$ctrl.mana = null">
|
||||
<tpl-body>
|
||||
<vn-spinner
|
||||
ng-if="$ctrl.mana == null"
|
||||
style="padding: 1em;"
|
||||
enable="true">
|
||||
</vn-spinner>
|
||||
<vn-ticket-sale-edit-discount
|
||||
ng-if="$ctrl.mana != null"
|
||||
mana="$ctrl.mana"
|
||||
bulk="true"
|
||||
edit="$ctrl.edit"
|
||||
on-hide="$ctrl.hideEditDialog()">
|
||||
</vn-ticket-sale-edit-discount>
|
||||
</tpl-body>
|
||||
</vn-dialog>
|
||||
|
||||
<!-- SMS Dialog -->
|
||||
<vn-ticket-sms
|
||||
vn-id="sms"
|
||||
|
@ -393,3 +421,33 @@
|
|||
message="This ticket is now empty"
|
||||
on-response="$ctrl.transferSales($ctrl.transfer.ticketId, $response)">
|
||||
</vn-confirm>
|
||||
|
||||
<vn-menu vn-id="moreOptions">
|
||||
<vn-item translate
|
||||
ng-click="$ctrl.showSMSDialog()">
|
||||
Send shortage SMS
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-click="$ctrl.calculateSalePrice()"
|
||||
ng-if="$ctrl.isEditable && $ctrl.hasOneSaleSelected()">
|
||||
Recalculate price
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-click="$ctrl.showEditDiscountDialog($event)">
|
||||
Update discount
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-click="$ctrl.createClaim()">
|
||||
Add claim
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-click="$ctrl.markAsReserved()"
|
||||
ng-if="$ctrl.isEditable">
|
||||
Mark as reserved
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-click="$ctrl.unmarkAsReserved()"
|
||||
ng-if="$ctrl.isEditable && $ctrl.hasReserves()">
|
||||
Unmark as reserved
|
||||
</vn-item>
|
||||
</vn-menu>
|
|
@ -5,8 +5,8 @@ import './style.scss';
|
|||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.edit = {};
|
||||
this.moreOptions = [
|
||||
// this.edit = {};
|
||||
/* this.moreOptions = [
|
||||
{
|
||||
name: 'Send shortage SMS',
|
||||
callback: this.showSMSDialog
|
||||
|
@ -30,7 +30,7 @@ class Controller extends Section {
|
|||
callback: this.calculateSalePrice,
|
||||
show: () => this.hasOneSaleSelected()
|
||||
},
|
||||
];
|
||||
]; */
|
||||
this._sales = [];
|
||||
}
|
||||
|
||||
|
@ -53,13 +53,19 @@ class Controller extends Section {
|
|||
this.refreshTotal();
|
||||
}
|
||||
|
||||
get editedPrice() {
|
||||
/* get editedPrice() {
|
||||
return this._editedPrice;
|
||||
}
|
||||
|
||||
set editedPrice(value) {
|
||||
this._editedPrice = value;
|
||||
this.updateNewPrice();
|
||||
} */
|
||||
|
||||
get ticketState() {
|
||||
if (!this.ticket) return null;
|
||||
|
||||
return this.ticket.ticketState.state.code;
|
||||
}
|
||||
|
||||
refreshTotal() {
|
||||
|
@ -93,7 +99,7 @@ class Controller extends Section {
|
|||
return this.subtotal + this.VAT;
|
||||
}
|
||||
|
||||
onMoreOpen() {
|
||||
/* onMoreOpen() {
|
||||
let options = this.moreOptions.filter(option => {
|
||||
const hasShowProperty = Object.hasOwnProperty.call(option, 'show');
|
||||
const shouldShow = !hasShowProperty || option.show === true ||
|
||||
|
@ -106,16 +112,16 @@ class Controller extends Section {
|
|||
|
||||
onMoreChange(callback) {
|
||||
callback.call(this);
|
||||
}
|
||||
} */
|
||||
|
||||
get isChecked() {
|
||||
/* get isChecked() {
|
||||
if (this.sales) {
|
||||
for (let instance of this.sales)
|
||||
if (instance.checked) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} */
|
||||
|
||||
/**
|
||||
* Returns checked instances
|
||||
|
@ -130,6 +136,34 @@ class Controller extends Section {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total of checked instances
|
||||
*
|
||||
* @return {Number} Total checked instances
|
||||
*/
|
||||
checkedLinesCount() {
|
||||
const checkedLines = this.checkedLines();
|
||||
if (checkedLines)
|
||||
return checkedLines.length;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
hasCheckedLines() {
|
||||
const checkedLines = this.checkedLines();
|
||||
|
||||
if (checkedLines)
|
||||
return checkedLines.length > 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
hasOneSaleSelected() {
|
||||
if (this.checkedLinesCount() === 1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new instances
|
||||
*
|
||||
|
@ -160,22 +194,11 @@ class Controller extends Section {
|
|||
return indexes;
|
||||
}
|
||||
|
||||
firstCheckedLine() {
|
||||
/* firstCheckedLine() {
|
||||
const checkedLines = this.checkedLines();
|
||||
if (checkedLines)
|
||||
return checkedLines[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total of checked instances
|
||||
*
|
||||
* @return {Number} Total checked instances
|
||||
*/
|
||||
totalCheckedLines() {
|
||||
const checkedLines = this.checkedLines();
|
||||
if (checkedLines)
|
||||
return checkedLines.length;
|
||||
}
|
||||
} */
|
||||
|
||||
removeCheckedLines() {
|
||||
const sales = this.checkedLines();
|
||||
|
@ -191,19 +214,19 @@ class Controller extends Section {
|
|||
this.refreshTotal();
|
||||
}
|
||||
|
||||
onStateOkClick() {
|
||||
/* onStateOkClick() {
|
||||
let filter = {where: {code: 'OK'}, fields: ['id']};
|
||||
let json = encodeURIComponent(JSON.stringify(filter));
|
||||
return this.$http.get(`States?filter=${json}`).then(res => {
|
||||
this.onStateChange(res.data[0].id);
|
||||
this.changeState(res.data[0].id);
|
||||
});
|
||||
}
|
||||
|
||||
onStateChange(value) {
|
||||
let params = {ticketFk: this.$state.params.id, stateFk: value};
|
||||
*/
|
||||
changeState(value) {
|
||||
let params = {ticketFk: this.$params.id, code: value};
|
||||
this.$http.post('TicketTrackings/changeState', params).then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.card.reload();
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
}).finally(() => {
|
||||
if (this.newInstances().length === 0)
|
||||
this.$.watcher.updateOriginalData();
|
||||
|
@ -223,7 +246,7 @@ class Controller extends Section {
|
|||
let query = `Sales/removes`;
|
||||
this.$http.post(query, params).then(() => {
|
||||
this.removeCheckedLines();
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -258,58 +281,51 @@ class Controller extends Section {
|
|||
this.$.watcher.updateOriginalData();
|
||||
|
||||
const query = `tickets/${this.ticket.id}/transferSales`;
|
||||
this.$http.post(query, params).then(res => {
|
||||
this.goToTicket(res.data.id);
|
||||
});
|
||||
this.$http.post(query, params)
|
||||
.then(res => this.$state.go('ticket.card.sale', {id: res.data.id}));
|
||||
}
|
||||
|
||||
createClaim() {
|
||||
const claim = {
|
||||
const sales = this.checkedLines();
|
||||
const params = {
|
||||
claim: {
|
||||
ticketFk: this.ticket.id,
|
||||
clientFk: this.ticket.clientFk,
|
||||
ticketCreated: this.ticket.shipped
|
||||
},
|
||||
sales: sales
|
||||
};
|
||||
const sales = this.checkedLines();
|
||||
|
||||
if (this.newInstances().length === 0)
|
||||
this.$.watcher.updateOriginalData();
|
||||
|
||||
this.$http.post(`Claims/createFromSales`, {claim: claim, sales: sales}).then(res => {
|
||||
this.$state.go('claim.card.basicData', {id: res.data.id});
|
||||
});
|
||||
this.$http.post(`Claims/createFromSales`, params)
|
||||
.then(res => this.$state.go('claim.card.basicData', {id: res.data.id}));
|
||||
}
|
||||
|
||||
goToTicket(ticketId) {
|
||||
this.$state.go('ticket.card.sale', {id: ticketId});
|
||||
}
|
||||
|
||||
// Slesperson Mana
|
||||
getManaSalespersonMana() {
|
||||
this.$http.get(`Tickets/${this.$state.params.id}/getSalesPersonMana`).then(res => {
|
||||
this.mana = res.data;
|
||||
});
|
||||
getMana() {
|
||||
this.$http.get(`Tickets/${this.$params.id}/getSalesPersonMana`)
|
||||
.then(res => this.edit.mana = res.data);
|
||||
}
|
||||
|
||||
showEditPricePopover(event, sale) {
|
||||
if (!this.isEditable) return;
|
||||
this.sale = sale;
|
||||
this.newPrice = this.sale.price;
|
||||
|
||||
this.edit = {
|
||||
ticketFk: this.ticket.id,
|
||||
id: sale.id,
|
||||
quantity: sale.quantity
|
||||
price: sale.price,
|
||||
sale: sale
|
||||
};
|
||||
this.$.editPricePopover.parent = event.target;
|
||||
this.$.editPricePopover.show();
|
||||
this.$.editPricePopover.show(event);
|
||||
}
|
||||
|
||||
updatePrice() {
|
||||
if (this.newPrice && this.newPrice != this.sale.price) {
|
||||
const query = `Sales/${this.edit.id}/updatePrice`;
|
||||
this.$http.post(query, {newPrice: this.newPrice}).then(res => {
|
||||
this.sale.price = res.data.price;
|
||||
const sale = this.edit.sale;
|
||||
if (this.edit.price != sale.price) {
|
||||
const query = `Sales/${sale.id}/updatePrice`;
|
||||
this.$http.post(query, {newPrice: this.edit.price}).then(res => {
|
||||
sale.price = res.data.price;
|
||||
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
}).finally(() => {
|
||||
if (this.newInstances().length === 0)
|
||||
this.$.watcher.updateOriginalData();
|
||||
|
@ -319,26 +335,93 @@ class Controller extends Section {
|
|||
this.$.editPricePopover.hide();
|
||||
}
|
||||
|
||||
updateNewPrice() {
|
||||
/* updateNewPrice() {
|
||||
this.newPrice = this.sale.quantity * this.newPrice - ((this.sale.discount * (this.sale.quantity * this.newPrice)) / 100);
|
||||
}
|
||||
|
||||
*/
|
||||
showEditDiscountPopover(event, sale) {
|
||||
if (this.isLocked) return;
|
||||
|
||||
this.sale = sale;
|
||||
this.edit = [{
|
||||
ticketFk: this.ticket.id,
|
||||
id: sale.id,
|
||||
quantity: sale.quantity,
|
||||
price: sale.price,
|
||||
discount: sale.discount
|
||||
}];
|
||||
this.$.editPopover.parent = event.target;
|
||||
this.$.editPopover.show();
|
||||
this.edit = {
|
||||
discount: sale.discount,
|
||||
sale: sale
|
||||
};
|
||||
|
||||
this.$.editDiscount.show(event);
|
||||
}
|
||||
|
||||
showEditDialog() {
|
||||
showEditDiscountDialog(event) {
|
||||
if (this.isLocked) return;
|
||||
|
||||
this.edit = {
|
||||
discount: null,
|
||||
sales: this.checkedLines()
|
||||
};
|
||||
|
||||
this.$.editDiscountDialog.show(event);
|
||||
}
|
||||
|
||||
changeDiscount() {
|
||||
const sale = this.edit.sale;
|
||||
if (this.edit.discount != sale.discount)
|
||||
this.updateDiscount([sale]);
|
||||
|
||||
this.$.editDiscount.hide();
|
||||
}
|
||||
|
||||
changeMultipleDiscount() {
|
||||
const sales = this.edit.sales;
|
||||
const hasChanges = sales.some(sale => {
|
||||
return sale.discount != this.edit.discount;
|
||||
});
|
||||
|
||||
console.log(hasChanges);
|
||||
|
||||
if (hasChanges)
|
||||
this.updateDiscount(sales);
|
||||
|
||||
this.$.editDiscountDialog.hide();
|
||||
}
|
||||
|
||||
updateDiscount(sales) {
|
||||
const saleIds = sales.map(sale => {
|
||||
return sale.id;
|
||||
});
|
||||
|
||||
const params = {salesIds: saleIds, newDiscount: this.edit.discount};
|
||||
const query = `Tickets/${this.$params.id}/updateDiscount`;
|
||||
this.$http.post(query, params).then(() => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
|
||||
for (let sale of sales)
|
||||
sale.discount = this.edit.discount;
|
||||
}).catch(e => {
|
||||
this.vnApp.showError(e.message);
|
||||
});
|
||||
}
|
||||
|
||||
getNewPrice() {
|
||||
if (this.edit) {
|
||||
const sale = this.edit.sale;
|
||||
let newDiscount = sale.discount;
|
||||
let newPrice = this.edit.price || sale.price;
|
||||
|
||||
if (this.edit.discount != null)
|
||||
newDiscount = this.edit.discount;
|
||||
|
||||
if (this.edit.price != null)
|
||||
newPrice = this.edit.price;
|
||||
|
||||
const price = sale.quantity * newPrice;
|
||||
const discount = (newDiscount * price) / 100;
|
||||
|
||||
return price - discount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* showEditDialog() {
|
||||
this.edit = this.checkedLines();
|
||||
this.$.editDialog.show();
|
||||
}
|
||||
|
@ -351,6 +434,12 @@ class Controller extends Section {
|
|||
hideEditPopover() {
|
||||
this.$.model.refresh();
|
||||
this.$.editPopover.hide();
|
||||
} */
|
||||
|
||||
hasReserves() {
|
||||
return this.sales.some(sale => {
|
||||
return sale.reserved == true;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -395,7 +484,7 @@ class Controller extends Section {
|
|||
const path = this.$state.href('order.card.catalog', {id: res.data});
|
||||
window.open(path, '_blank');
|
||||
|
||||
this.vnApp.showSuccess(this.$translate.instant('Order created'));
|
||||
this.vnApp.showSuccess(this.$t('Order created'));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -417,7 +506,7 @@ class Controller extends Section {
|
|||
this.newSMS = {
|
||||
destinationFk: this.ticket.clientFk,
|
||||
destination: phone,
|
||||
message: this.$translate.instant('Product not available', params)
|
||||
message: this.$t('Product not available', params)
|
||||
};
|
||||
this.$.sms.open();
|
||||
}
|
||||
|
@ -433,7 +522,7 @@ class Controller extends Section {
|
|||
* Creates a new sale if it's a new instance
|
||||
* Updates the sale quantity for existing instance
|
||||
*/
|
||||
onChangeQuantity(sale) {
|
||||
changeQuantity(sale) {
|
||||
if (!sale.quantity) return;
|
||||
|
||||
if (!sale.id)
|
||||
|
@ -443,13 +532,13 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
/*
|
||||
* Updates a sale quantity
|
||||
* Changes a sale quantity
|
||||
*/
|
||||
updateQuantity(sale) {
|
||||
const data = {quantity: parseInt(sale.quantity)};
|
||||
const data = {quantity: sale.quantity};
|
||||
const query = `Sales/${sale.id}/updateQuantity`;
|
||||
this.$http.post(query, data).then(() => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
}).catch(e => {
|
||||
this.$.model.refresh();
|
||||
throw e;
|
||||
|
@ -460,13 +549,13 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
/*
|
||||
* Updates a sale concept
|
||||
* Changes a sale concept
|
||||
*/
|
||||
updateConcept(sale) {
|
||||
changeConcept(sale) {
|
||||
const data = {newConcept: sale.concept};
|
||||
const query = `Sales/${sale.id}/updateConcept`;
|
||||
this.$http.post(query, data).then(() => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
}).catch(e => {
|
||||
this.$.model.refresh();
|
||||
throw e;
|
||||
|
@ -499,7 +588,7 @@ class Controller extends Section {
|
|||
sale.price = newSale.price;
|
||||
sale.item = newSale.item;
|
||||
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
}).finally(() => {
|
||||
if (this.newInstances().length === 0)
|
||||
this.$.watcher.updateOriginalData();
|
||||
|
@ -518,17 +607,11 @@ class Controller extends Section {
|
|||
});
|
||||
}
|
||||
|
||||
hasOneSaleSelected() {
|
||||
if (this.totalCheckedLines() === 1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
calculateSalePrice() {
|
||||
const sale = this.checkedLines()[0];
|
||||
const query = `Sales/${sale.id}/recalculatePrice`;
|
||||
this.$http.post(query).then(res => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.$.model.refresh();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-label-value label="State"
|
||||
value="{{$ctrl.summary.state.state.name}}">
|
||||
value="{{$ctrl.summary.ticketState.state.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Salesperson"
|
||||
value="{{$ctrl.summary.client.salesPerson.user.nickname}}">
|
||||
|
|
|
@ -31,7 +31,7 @@ class Controller extends Section {
|
|||
|
||||
get isEditable() {
|
||||
try {
|
||||
return !this.ticket.state.state.alertLevel;
|
||||
return !this.ticket.ticketState.state.alertLevel;
|
||||
} catch (e) {}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -10740,7 +10740,8 @@
|
|||
},
|
||||
"yargs-parser": {
|
||||
"version": "13.1.1",
|
||||
"resolved": "",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz",
|
||||
"integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"camelcase": "^5.0.0",
|
||||
|
|
Loading…
Reference in New Issue