Merge branch 'dev' into 2873-create-supplier-beneficiary
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
0abb8f2d5f
|
@ -159,7 +159,6 @@ describe('Client Edit fiscalData path', () => {
|
|||
});
|
||||
|
||||
it('should propagate the Equalization tax changes', async() => {
|
||||
await page.waitForTimeout(1000);
|
||||
await page.waitToClick(selectors.globalItems.acceptButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
|
|
|
@ -81,7 +81,6 @@ describe('Client Add address path', () => {
|
|||
});
|
||||
|
||||
it(`should confirm the new address exists and it's the default one`, async() => {
|
||||
await page.waitForTimeout(2000); // needs more than a single second to load the section
|
||||
const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
|
||||
|
||||
expect(result).toContain('320 Park Avenue New York');
|
||||
|
|
|
@ -52,7 +52,6 @@ describe('User config', () => {
|
|||
|
||||
it('should open the user config form to check the settings', async() => {
|
||||
await page.waitToClick(selectors.globalItems.userMenuButton);
|
||||
await page.waitForTimeout(1000);
|
||||
let expectedLocalWarehouse = await page
|
||||
.expectPropertyValue(selectors.globalItems.userLocalWarehouse, 'value', '');
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ describe('Client contacts', () => {
|
|||
});
|
||||
|
||||
it('should delete de contact', async() => {
|
||||
await page.waitForTimeout(3000);
|
||||
await page.waitToClick(selectors.clientContacts.deleteFirstPhone);
|
||||
await page.waitToClick(selectors.clientContacts.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
|
|
@ -20,7 +20,6 @@ describe('Client credit insurance path', () => {
|
|||
});
|
||||
|
||||
it('should open the create a new credit contract form', async() => {
|
||||
await page.waitForTimeout(1000);
|
||||
await page.waitToClick(selectors.clientCreditInsurance.addNewContract);
|
||||
await page.waitForState('client.card.creditInsurance.create');
|
||||
});
|
||||
|
|
|
@ -45,8 +45,7 @@ describe('Item Edit basic data path', () => {
|
|||
await page.waitToClick(selectors.itemBasicData.newIntrastatButton);
|
||||
await page.write(selectors.itemBasicData.newIntrastatId, '588420239');
|
||||
await page.write(selectors.itemBasicData.newIntrastatDescription, 'Tropical Flowers');
|
||||
await page.waitToClick(selectors.itemBasicData.acceptIntrastatButton); // this popover obscures the rest of the form for aprox 2 seconds
|
||||
await page.waitForTimeout(2000);
|
||||
await page.waitToClick(selectors.itemBasicData.acceptIntrastatButton);
|
||||
await page.waitForTextInField(selectors.itemBasicData.intrastat, 'Tropical Flowers');
|
||||
let newcode = await page.waitToGetProperty(selectors.itemBasicData.intrastat, 'value');
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ describe('Item index path', () => {
|
|||
});
|
||||
|
||||
it('should mark all unchecked boxes to leave the index as it was', async() => {
|
||||
await page.waitForTimeout(500); // otherwise the snackbar doesnt appear some times.
|
||||
await page.waitToClick(selectors.itemsIndex.fieldsToShowButton);
|
||||
await page.waitToClick(selectors.itemsIndex.idCheckbox);
|
||||
await page.waitToClick(selectors.itemsIndex.stemsCheckbox);
|
||||
|
|
|
@ -45,7 +45,6 @@ describe('Item fixed prices path', () => {
|
|||
await page.writeOnEditableTD(selectors.itemFixedPrice.fourthMinPrice, '5');
|
||||
await page.pickDate(selectors.itemFixedPrice.fourthStarted, now);
|
||||
await page.pickDate(selectors.itemFixedPrice.fourthEnded, now);
|
||||
await page.waitForTimeout(1000);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
|
|
|
@ -143,7 +143,6 @@ describe('Ticket Edit sale path', () => {
|
|||
});
|
||||
|
||||
it('should remove 1 from the first sale quantity', async() => {
|
||||
await page.waitForTimeout(500);
|
||||
await page.waitToClick(selectors.ticketSales.firstSaleQuantityCell);
|
||||
await page.waitForSelector(selectors.ticketSales.firstSaleQuantity);
|
||||
await page.type(selectors.ticketSales.firstSaleQuantity, '9\u000d');
|
||||
|
@ -225,16 +224,12 @@ describe('Ticket Edit sale path', () => {
|
|||
it('should search for a ticket then access to the sales section', async() => {
|
||||
await page.accessToSearchResult('16');
|
||||
await page.accessToSection('ticket.card.sale');
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
it('should select the third sale and delete it', async() => {
|
||||
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
|
||||
await page.waitForTimeout(2000);
|
||||
await page.waitToClick(selectors.ticketSales.deleteSaleButton);
|
||||
await page.waitForTimeout(2000);
|
||||
await page.waitToClick(selectors.globalItems.acceptButton);
|
||||
await page.waitForTimeout(2000);
|
||||
await page.waitForSpinnerLoad();
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ describe('Ticket Create new tracking state path', () => {
|
|||
});
|
||||
|
||||
it(`should attemp to create an state for which salesPerson doesn't have permissions`, async() => {
|
||||
await page.waitForTimeout(1500);
|
||||
await page.autocompleteSearch(selectors.createStateView.state, 'Encajado');
|
||||
await page.waitToClick(selectors.createStateView.saveStateButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
|
|
@ -51,7 +51,6 @@ describe('Ticket Edit basic data path', () => {
|
|||
|
||||
it(`should edit the ticket agency then check there are no zones for it`, async() => {
|
||||
await page.autocompleteSearch(selectors.ticketBasicData.agency, 'Super-Man delivery');
|
||||
await page.waitForTimeout(1000);
|
||||
let emptyZone = await page
|
||||
.expectPropertyValue(selectors.ticketBasicData.zone, 'value', '');
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ describe('Ticket purchase request path', () => {
|
|||
});
|
||||
|
||||
it('should add a new request', async() => {
|
||||
await page.waitForTimeout(500);
|
||||
await page.waitToClick(selectors.ticketRequests.addRequestButton);
|
||||
await page.write(selectors.ticketRequests.descriptionInput, 'New stuff');
|
||||
await page.write(selectors.ticketRequests.quantity, '9');
|
||||
|
|
|
@ -42,7 +42,6 @@ describe('Ticket create path', () => {
|
|||
|
||||
it('should again open the new ticket form', async() => {
|
||||
await page.waitToClick(selectors.globalItems.returnToModuleIndexButton);
|
||||
await page.waitForTimeout(500);
|
||||
await page.waitToClick(selectors.ticketsIndex.newTicketButton);
|
||||
await page.waitForState('ticket.create');
|
||||
});
|
||||
|
|
|
@ -25,10 +25,6 @@ describe('Claim action path', () => {
|
|||
});
|
||||
|
||||
it('should import the second importable ticket', async() => {
|
||||
// the animation adding the header element for the claimed total
|
||||
// obscures somehow other elements for about 2 seconds
|
||||
await page.waitForTimeout(3000);
|
||||
|
||||
await page.waitToClick(selectors.claimAction.importTicketButton);
|
||||
await page.waitToClick(selectors.claimAction.secondImportableTicket);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
|
|
@ -8,7 +8,6 @@ describe('Order summary path', () => {
|
|||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('employee', 'order');
|
||||
await page.waitForTimeout(2000);
|
||||
await page.accessToSearchResult('16');
|
||||
});
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ describe('Route create path', () => {
|
|||
|
||||
describe('as employee', () => {
|
||||
it('should click on the add new route button and open the creation form', async() => {
|
||||
await page.waitForTimeout(500);
|
||||
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
|
||||
await page.waitForState('route.create');
|
||||
});
|
||||
|
@ -74,7 +73,6 @@ describe('Route create path', () => {
|
|||
});
|
||||
|
||||
it(`should clone the first route`, async() => {
|
||||
await page.waitForTimeout(1000); // needs time for the index to show all items
|
||||
await page.waitToClick(selectors.routeIndex.firstRouteCheckbox);
|
||||
await page.waitToClick(selectors.routeIndex.cloneButton);
|
||||
await page.waitToClick(selectors.routeIndex.submitClonationButton);
|
||||
|
|
|
@ -44,7 +44,6 @@ describe('Travel basic data path', () => {
|
|||
it('should now edit the whole form then save', async() => {
|
||||
await page.clearInput(selectors.travelBasicData.reference);
|
||||
await page.write(selectors.travelBasicData.reference, 'new reference!');
|
||||
await page.waitForTimeout(2000);
|
||||
await page.autocompleteSearch(selectors.travelBasicData.agency, 'Entanglement');
|
||||
await page.autocompleteSearch(selectors.travelBasicData.outputWarehouse, 'Warehouse Three');
|
||||
await page.autocompleteSearch(selectors.travelBasicData.inputWarehouse, 'Warehouse Four');
|
||||
|
|
|
@ -22,7 +22,6 @@ describe('Travel extra community path', () => {
|
|||
await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelReference, 'edited reference');
|
||||
await page.waitForSpinnerLoad();
|
||||
await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelLockedKg, '1500');
|
||||
await page.waitForTimeout(1000);
|
||||
});
|
||||
|
||||
it('should reload the index and confirm the reference and locked kg were edited', async() => {
|
||||
|
|
|
@ -17,7 +17,6 @@ describe('Entry lastest buys path', () => {
|
|||
|
||||
it('should access the latest buys seccion and search not seeing the edit buys button yet', async() => {
|
||||
await page.waitToClick(selectors.entryLatestBuys.latestBuysSectionButton);
|
||||
await page.waitForTimeout(250);
|
||||
await page.waitToClick(selectors.globalItems.searchButton);
|
||||
await page.waitForSelector(selectors.entryLatestBuys.editBuysButton, {visible: false});
|
||||
});
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
label="Save">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
disabled="watcher.dataChanged()"
|
||||
label="Test connection"
|
||||
ng-click="$ctrl.onTestConection()">
|
||||
</vn-button>
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
on-error-src/>
|
||||
</div>
|
||||
<div class="description">
|
||||
<h3>
|
||||
<h3 class="link"
|
||||
ng-click="itemDescriptor.show($event, item.id)">
|
||||
{{::item.name}}
|
||||
</h3>
|
||||
<h4 class="ellipsize">
|
||||
|
@ -65,3 +66,6 @@
|
|||
vn-id="pricesPopover"
|
||||
order="$ctrl.order">
|
||||
</vn-order-prices-popover>
|
||||
<vn-item-descriptor-popover
|
||||
vn-id="itemDescriptor">
|
||||
</vn-item-descriptor-popover>
|
|
@ -1,75 +1,52 @@
|
|||
<default>
|
||||
<vn-descriptor-content
|
||||
module="item"
|
||||
description="$ctrl.item.name"
|
||||
descriptor="$ctrl"
|
||||
class="vn-order-prices-popover">
|
||||
<slot-body>
|
||||
<div class="attributes">
|
||||
<vn-label-value
|
||||
label="Buyer"
|
||||
value="{{$ctrl.item.firstName}} {{$ctrl.item.lastName}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
ng-repeat="tag in $ctrl.tags"
|
||||
label="{{::tag.tag.name}}"
|
||||
value="{{::tag.value}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
<div class="quicklinks">
|
||||
<vn-quick-link
|
||||
tooltip="Diary"
|
||||
state="['item.card.diary', {id: $ctrl.id}]"
|
||||
icon="icon-transaction">
|
||||
</vn-quick-link>
|
||||
</div>
|
||||
</slot-body>
|
||||
<slot-after>
|
||||
<form name="form" class="prices">
|
||||
<vn-table>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="price in $ctrl.prices">
|
||||
<vn-td shrink class="warehouse">
|
||||
<span
|
||||
class="ellipsize text"
|
||||
title="{{::price.warehouse}}">
|
||||
{{::price.warehouse}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number expand>
|
||||
<div>
|
||||
<span
|
||||
ng-click="$ctrl.addQuantity(price)"
|
||||
class="link unselectable">{{::price.grouping}}</span>
|
||||
<span> x {{::price.price | currency: 'EUR': 2}}</span>
|
||||
</div>
|
||||
<div class="price-kg" ng-show="::price.priceKg">
|
||||
{{price.priceKg | currency: 'EUR'}}/Kg
|
||||
</div>
|
||||
</vn-td>
|
||||
<vn-td shrink>
|
||||
<vn-input-number
|
||||
min="0"
|
||||
name="quantity"
|
||||
ng-model="price.quantity"
|
||||
step="price.grouping"
|
||||
on-change="$ctrl.validate()"
|
||||
class="dense">
|
||||
</vn-input-number>
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
<div class="footer vn-pa-md">
|
||||
<div class="error">
|
||||
<span translate>Wrong quantity</span>
|
||||
<form name="form" class="prices">
|
||||
<vn-table>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="price in $ctrl.prices">
|
||||
<vn-td class="warehouse" expand>
|
||||
<span
|
||||
class="text"
|
||||
title="{{::price.warehouse}}">
|
||||
{{::price.warehouse}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number expand>
|
||||
<div>
|
||||
<span
|
||||
ng-click="$ctrl.addQuantity(price)"
|
||||
class="link unselectable">{{::price.grouping}}</span>
|
||||
<span> x {{::price.price | currency: 'EUR': 2}}</span>
|
||||
</div>
|
||||
<vn-submit
|
||||
label="Save"
|
||||
ng-click="$ctrl.submit()">
|
||||
</vn-submit>
|
||||
</div>
|
||||
</form>
|
||||
</slot-after>
|
||||
</vn-descriptor-content>
|
||||
<div class="price-kg" ng-show="::price.priceKg">
|
||||
{{::price.priceKg | currency: 'EUR'}}/Kg
|
||||
</div>
|
||||
</vn-td>
|
||||
<vn-td shrink>
|
||||
<!-- Focus first element -->
|
||||
<vn-input-number ng-if="$index === 0"
|
||||
min="0"
|
||||
name="quantity"
|
||||
ng-model="price.quantity"
|
||||
step="price.grouping"
|
||||
class="dense"
|
||||
vn-focus>
|
||||
</vn-input-number>
|
||||
<vn-input-number ng-if="$index > 0"
|
||||
min="0"
|
||||
name="quantity"
|
||||
ng-model="price.quantity"
|
||||
step="price.grouping"
|
||||
class="dense">
|
||||
</vn-input-number>
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
<div class="footer vn-pa-md">
|
||||
<vn-submit
|
||||
label="Add"
|
||||
ng-click="$ctrl.submit()">
|
||||
</vn-submit>
|
||||
</div>
|
||||
</form>
|
||||
</default>
|
||||
|
|
|
@ -11,34 +11,18 @@ class Controller extends Popover {
|
|||
set prices(value) {
|
||||
this._prices = value;
|
||||
if (value && value[0].grouping)
|
||||
this.calculateTotal();
|
||||
this.getTotalQuantity();
|
||||
}
|
||||
|
||||
get prices() {
|
||||
return this._prices;
|
||||
}
|
||||
|
||||
getTags() {
|
||||
const filter = {
|
||||
where: {
|
||||
itemFk: this.id,
|
||||
priority: {gte: 4}
|
||||
},
|
||||
order: 'priority ASC',
|
||||
include: {relation: 'tag'}
|
||||
};
|
||||
this.$http.get(`ItemTags`, {filter})
|
||||
.then(res => {
|
||||
this.tags = res.data;
|
||||
this.$.$applyAsync(() => this.relocate());
|
||||
});
|
||||
}
|
||||
|
||||
show(parent, item) {
|
||||
this.item = JSON.parse(JSON.stringify(item));
|
||||
this.id = item.id;
|
||||
this.prices = this.item.prices;
|
||||
this.getTags();
|
||||
|
||||
super.show(parent);
|
||||
}
|
||||
|
||||
|
@ -47,67 +31,74 @@ class Controller extends Popover {
|
|||
this.item = {};
|
||||
this.tags = {};
|
||||
this._prices = {};
|
||||
this.total = 0;
|
||||
this.totalQuantity = 0;
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
calculateMax() {
|
||||
this.max = this.item.available - this.total;
|
||||
}
|
||||
|
||||
calculateTotal() {
|
||||
this.total = 0;
|
||||
|
||||
this.prices.forEach(price => {
|
||||
getTotalQuantity() {
|
||||
let total = 0;
|
||||
for (let price of this.prices) {
|
||||
if (!price.quantity) price.quantity = 0;
|
||||
this.total += price.quantity;
|
||||
});
|
||||
this.calculateMax();
|
||||
total += price.quantity;
|
||||
}
|
||||
|
||||
this.totalQuantity = total;
|
||||
this.maxQuantity = this.item.available - total;
|
||||
}
|
||||
|
||||
addQuantity(price) {
|
||||
if (this.total + price.grouping <= this.max)
|
||||
this.getTotalQuantity();
|
||||
const quantity = this.totalQuantity + price.grouping;
|
||||
if (quantity <= this.maxQuantity)
|
||||
price.quantity += price.grouping;
|
||||
}
|
||||
|
||||
getFilledLines() {
|
||||
const filledLines = [];
|
||||
let match;
|
||||
this.prices.forEach(price => {
|
||||
getGroupings() {
|
||||
const filledRows = [];
|
||||
for (let price of this.prices) {
|
||||
if (price.quantity && price.quantity > 0) {
|
||||
match = filledLines.find(element => {
|
||||
return element.warehouseFk == price.warehouseFk;
|
||||
const priceMatch = filledRows.find(row => {
|
||||
return row.warehouseFk == price.warehouseFk;
|
||||
});
|
||||
|
||||
if (!match) {
|
||||
filledLines.push(Object.assign({}, price));
|
||||
return;
|
||||
}
|
||||
match.quantity += price.quantity;
|
||||
if (!priceMatch)
|
||||
filledRows.push(Object.assign({}, price));
|
||||
else priceMatch.quantity += price.quantity;
|
||||
}
|
||||
});
|
||||
return filledLines;
|
||||
}
|
||||
|
||||
return filledRows;
|
||||
}
|
||||
|
||||
submit() {
|
||||
this.calculateTotal();
|
||||
const filledLines = this.getFilledLines();
|
||||
const filledRows = this.getGroupings();
|
||||
|
||||
if (filledLines.length <= 0) {
|
||||
this.vnApp.showError(this.$t('First you must add some quantity'));
|
||||
return;
|
||||
try {
|
||||
const hasValidGropings = filledRows.some(row =>
|
||||
row.quantity % row.grouping == 0
|
||||
);
|
||||
|
||||
if (filledRows.length <= 0)
|
||||
throw new Error('First you must add some quantity');
|
||||
|
||||
if (!hasValidGropings)
|
||||
throw new Error(`The amounts doesn't match with the grouping`);
|
||||
|
||||
const params = {
|
||||
orderFk: this.order.id,
|
||||
items: filledRows
|
||||
};
|
||||
this.$http.post(`OrderRows/addToOrder`, params)
|
||||
.then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.hide();
|
||||
if (this.card) this.card.reload();
|
||||
});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$t(e.message));
|
||||
return false;
|
||||
}
|
||||
|
||||
const params = {
|
||||
orderFk: this.order.id,
|
||||
items: filledLines
|
||||
};
|
||||
this.$http.post(`OrderRows/addToOrder`, params)
|
||||
.then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.hide();
|
||||
if (this.card) this.card.reload();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,171 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Order', () => {
|
||||
describe('Component vnOrderPricesPopover', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let orderId = 16;
|
||||
|
||||
beforeEach(ngModule('order'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
const $scope = $rootScope.$new();
|
||||
const $element = angular.element('<vn-order-prices-popover></vn-order-prices-popover>');
|
||||
const $transclude = {
|
||||
$$boundTransclude: {
|
||||
$$slots: []
|
||||
}
|
||||
};
|
||||
controller = $componentController('vnOrderPricesPopover', {$element, $scope, $transclude});
|
||||
controller._prices = [
|
||||
{warehouseFk: 1, grouping: 10, quantity: 0},
|
||||
{warehouseFk: 1, grouping: 100, quantity: 100}
|
||||
];
|
||||
controller.item = {available: 1000};
|
||||
controller.order = {id: orderId};
|
||||
}));
|
||||
|
||||
describe('prices() setter', () => {
|
||||
it('should call to the getTotalQuantity() method', () => {
|
||||
controller.getTotalQuantity = jest.fn();
|
||||
|
||||
controller.prices = [
|
||||
{grouping: 10, quantity: 0},
|
||||
{grouping: 100, quantity: 0},
|
||||
{grouping: 1000, quantity: 0},
|
||||
];
|
||||
|
||||
expect(controller.getTotalQuantity).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getTotalQuantity()', () => {
|
||||
it('should set the totalQuantity and maxQuantity properties', () => {
|
||||
controller.getTotalQuantity();
|
||||
|
||||
expect(controller.totalQuantity).toEqual(100);
|
||||
expect(controller.maxQuantity).toEqual(900);
|
||||
});
|
||||
});
|
||||
|
||||
describe('addQuantity()', () => {
|
||||
it('should call to the getTotalQuantity() method and NOT set the quantity property', () => {
|
||||
jest.spyOn(controller, 'getTotalQuantity');
|
||||
|
||||
controller.prices = [
|
||||
{grouping: 10, quantity: 0},
|
||||
{grouping: 100, quantity: 0},
|
||||
{grouping: 1000, quantity: 1000},
|
||||
];
|
||||
|
||||
const oneThousandGrouping = controller.prices[2];
|
||||
|
||||
expect(oneThousandGrouping.quantity).toEqual(1000);
|
||||
|
||||
controller.addQuantity(oneThousandGrouping);
|
||||
|
||||
expect(controller.getTotalQuantity).toHaveBeenCalledWith();
|
||||
expect(oneThousandGrouping.quantity).toEqual(1000);
|
||||
});
|
||||
|
||||
it('should call to the getTotalQuantity() method and then set the quantity property', () => {
|
||||
jest.spyOn(controller, 'getTotalQuantity');
|
||||
|
||||
const oneHandredGrouping = controller.prices[1];
|
||||
controller.addQuantity(oneHandredGrouping);
|
||||
|
||||
expect(controller.getTotalQuantity).toHaveBeenCalledWith();
|
||||
expect(oneHandredGrouping.quantity).toEqual(200);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getGroupings()', () => {
|
||||
it('should return a row with the total filled quantity', () => {
|
||||
jest.spyOn(controller, 'getTotalQuantity');
|
||||
|
||||
controller.prices = [
|
||||
{warehouseFk: 1, grouping: 10, quantity: 10},
|
||||
{warehouseFk: 1, grouping: 100, quantity: 100},
|
||||
{warehouseFk: 1, grouping: 1000, quantity: 1000},
|
||||
];
|
||||
|
||||
const rows = controller.getGroupings();
|
||||
const firstRow = rows[0];
|
||||
|
||||
expect(rows.length).toEqual(1);
|
||||
expect(firstRow.quantity).toEqual(1110);
|
||||
});
|
||||
|
||||
it('should return two filled rows with a quantity', () => {
|
||||
jest.spyOn(controller, 'getTotalQuantity');
|
||||
|
||||
controller.prices = [
|
||||
{warehouseFk: 1, grouping: 10, quantity: 10},
|
||||
{warehouseFk: 2, grouping: 10, quantity: 10},
|
||||
{warehouseFk: 1, grouping: 100, quantity: 0},
|
||||
{warehouseFk: 1, grouping: 1000, quantity: 1000},
|
||||
];
|
||||
|
||||
const rows = controller.getGroupings();
|
||||
const firstRow = rows[0];
|
||||
const secondRow = rows[1];
|
||||
|
||||
expect(rows.length).toEqual(2);
|
||||
expect(firstRow.quantity).toEqual(1010);
|
||||
expect(secondRow.quantity).toEqual(10);
|
||||
});
|
||||
});
|
||||
|
||||
describe('submit()', () => {
|
||||
it('should throw an error if none of the rows contains a quantity', () => {
|
||||
jest.spyOn(controller, 'getTotalQuantity');
|
||||
jest.spyOn(controller.vnApp, 'showError');
|
||||
|
||||
controller.prices = [
|
||||
{warehouseFk: 1, grouping: 10, quantity: 0},
|
||||
{warehouseFk: 1, grouping: 100, quantity: 0}
|
||||
];
|
||||
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`First you must add some quantity`);
|
||||
});
|
||||
|
||||
it(`should throw an error if the quantity doesn't match the grouping value`, () => {
|
||||
jest.spyOn(controller, 'getTotalQuantity');
|
||||
jest.spyOn(controller.vnApp, 'showError');
|
||||
|
||||
controller.prices = [
|
||||
{warehouseFk: 1, grouping: 10, quantity: 0},
|
||||
{warehouseFk: 1, grouping: 100, quantity: 101}
|
||||
];
|
||||
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The amounts doesn't match with the grouping`);
|
||||
});
|
||||
|
||||
it('should should make an http query and then show a success message', () => {
|
||||
jest.spyOn(controller, 'getTotalQuantity');
|
||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||
|
||||
controller.prices = [
|
||||
{warehouseFk: 1, grouping: 10, quantity: 0},
|
||||
{warehouseFk: 1, grouping: 100, quantity: 100}
|
||||
];
|
||||
|
||||
const params = {
|
||||
orderFk: orderId,
|
||||
items: [{warehouseFk: 1, grouping: 100, quantity: 100}]
|
||||
};
|
||||
|
||||
$httpBackend.expectPOST('OrderRows/addToOrder', params).respond(200);
|
||||
controller.submit();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith(`Data saved!`);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,4 +1,3 @@
|
|||
Last entries: Últimas entradas
|
||||
Qty.: Cant.
|
||||
Wrong quantity: Cantidad errónea
|
||||
First you must add some quantity: Primero debes agregar alguna cantidad
|
||||
First you must add some quantity: Primero debes agregar alguna cantidad
|
||||
The amounts doesn't match with the grouping: Las cantidades no coinciden con el grouping
|
|
@ -1,47 +1,18 @@
|
|||
@import "variables";
|
||||
|
||||
.vn-order-prices-popover .content {
|
||||
max-width: 350px;
|
||||
|
||||
.header > a:first-child {
|
||||
visibility: hidden;
|
||||
}
|
||||
img[ng-src] {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
vn-vertical.data {
|
||||
padding-right: 16px;
|
||||
border-right: 1px solid $color-main;
|
||||
}
|
||||
.prices {
|
||||
vn-table {
|
||||
.warehouse {
|
||||
width: 48px;
|
||||
max-width: 48px;
|
||||
}
|
||||
.price-kg {
|
||||
color: $color-font-secondary;
|
||||
font-size: .75rem
|
||||
}
|
||||
.vn-input-number {
|
||||
width: 56px;
|
||||
width: 80px;
|
||||
}
|
||||
}
|
||||
.footer {
|
||||
text-align: center;
|
||||
|
||||
.error {
|
||||
display: none;
|
||||
}
|
||||
&.invalid {
|
||||
.error {
|
||||
display: block;
|
||||
padding-top: 10px;
|
||||
color: $color-alert;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@
|
|||
<vn-item
|
||||
ng-click="addTurn.show()"
|
||||
vn-acl="buyer"
|
||||
ng-show="$ctrl.isEditable"
|
||||
vn-acl-action="remove"
|
||||
name="addTurn"
|
||||
translate>
|
||||
|
|
Loading…
Reference in New Issue