3408-worker_calendar #914
|
@ -1,2 +0,0 @@
|
||||||
INSERT INTO salix.ACL (id, model, property, accessType, permission, principalType, principalId)
|
|
||||||
VALUES(301, 'Agency', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES(304, 'Agency', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('SupplierAgencyTerm', '*', '*', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -0,0 +1,48 @@
|
||||||
|
ALTER TABLE `vn`.`agencyTerm` ADD `supplierFk` INT NULL;
|
||||||
|
ALTER TABLE `vn`.`agencyTerm` CHANGE `supplierFk` `supplierFk` INT NULL AFTER `agencyFk`;
|
||||||
|
|
||||||
|
UPDATE `vn`.`agencyTerm` `at`
|
||||||
|
JOIN `vn`.`agency` `a` ON `a`.`id` = `at`.`agencyFk`
|
||||||
|
SET `at`.`supplierFk` = `a`.`supplierFk`;
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`agencyTerm` ADD CONSTRAINT `agencyTerm_FK` FOREIGN KEY (`agencyFk`) REFERENCES `vn`.`agency`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
ALTER TABLE `vn`.`agencyTerm` ADD CONSTRAINT `agencyTerm_FK_1` FOREIGN KEY (`supplierFk`) REFERENCES `vn`.`supplier`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
RENAME TABLE `vn`.`agencyTerm` TO `vn`.`supplierAgencyTerm`;
|
||||||
|
|
||||||
|
CREATE OR REPLACE
|
||||||
|
ALGORITHM = UNDEFINED
|
||||||
|
DEFINER=`root`@`localhost`
|
||||||
|
VIEW `vn`.`agencyTerm` AS
|
||||||
|
SELECT
|
||||||
|
`sat`.`agencyFk` AS `agencyFk`,
|
||||||
|
`sat`.`minimumPackages` AS `minimumPackages`,
|
||||||
|
`sat`.`kmPrice` AS `kmPrice`,
|
||||||
|
`sat`.`packagePrice` AS `packagePrice`,
|
||||||
|
`sat`.`routePrice` AS `routePrice`,
|
||||||
|
`sat`.`minimumKm` AS `minimumKm`,
|
||||||
|
`sat`.`minimumM3` AS `minimumM3`,
|
||||||
|
`sat`.`m3Price` AS `m3Price`
|
||||||
|
FROM
|
||||||
|
`vn`.`supplierAgencyTerm` `sat`;
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`agency` DROP FOREIGN KEY `agency_ibfk_4`;
|
||||||
|
ALTER TABLE `vn`.`agency` CHANGE `supplierFk` `supplierFk__` int(11) DEFAULT NULL NULL;
|
||||||
|
|
||||||
|
CREATE OR REPLACE
|
||||||
|
ALGORITHM = UNDEFINED
|
||||||
|
DEFINER=`root`@`localhost`
|
||||||
|
VIEW `vn2008`.`agency` AS
|
||||||
|
SELECT
|
||||||
|
`a`.`id` AS `agency_id`,
|
||||||
|
`a`.`name` AS `name`,
|
||||||
|
`a`.`warehouseFk` AS `warehouse_id`,
|
||||||
|
`a`.`isVolumetric` AS `por_volumen`,
|
||||||
|
`a`.`bankFk` AS `Id_Banco`,
|
||||||
|
`a`.`warehouseAliasFk` AS `warehouse_alias_id`,
|
||||||
|
`a`.`isOwn` AS `propios`,
|
||||||
|
`a`.`labelZone` AS `zone_label`,
|
||||||
|
`a`.`workCenterFk` AS `workCenterFk`,
|
||||||
|
`a`.`supplierFk__` AS `supplierFk__`
|
||||||
|
FROM
|
||||||
|
`vn`.`agency` `a`;
|
|
@ -2477,12 +2477,6 @@ INSERT INTO `bs`.`defaulter` (`clientFk`, `amount`, `created`, `defaulterSinced`
|
||||||
(1107, 500, CURDATE(), CURDATE()),
|
(1107, 500, CURDATE(), CURDATE()),
|
||||||
(1109, 500, CURDATE(), CURDATE());
|
(1109, 500, CURDATE(), CURDATE());
|
||||||
|
|
||||||
INSERT INTO `vn`.`agencyTerm` (`agencyFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`)
|
|
||||||
VALUES
|
|
||||||
(1, 0, 0.00, 0.00, NULL, 0, 0.00, 0),
|
|
||||||
(3, 0, 0.00, 3.05, NULL, 0, 0.00, 0),
|
|
||||||
(2, 60, 0.00, 0.00, NULL, 0, 5.00, 33);
|
|
||||||
|
|
||||||
UPDATE `vn`.`agency`
|
UPDATE `vn`.`agency`
|
||||||
SET `supplierFk`=1
|
SET `supplierFk`=1
|
||||||
WHERE `id`=1;
|
WHERE `id`=1;
|
||||||
|
@ -2518,3 +2512,11 @@ INSERT INTO `vn`.`docuware` (`code`, `fileCabinetName`, `dialogName` , `find`)
|
||||||
INSERT INTO `vn`.`docuwareConfig` (`url`)
|
INSERT INTO `vn`.`docuwareConfig` (`url`)
|
||||||
VALUES
|
VALUES
|
||||||
('https://verdnatura.docuware.cloud/docuware/platform');
|
('https://verdnatura.docuware.cloud/docuware/platform');
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`)
|
||||||
|
VALUES
|
||||||
|
(1, 1, 0, 0.00, 0.00, NULL, 0, 0.00, 23),
|
||||||
|
(2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33),
|
||||||
|
(3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0),
|
||||||
|
(4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0),
|
||||||
|
(5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0);
|
||||||
|
|
|
@ -221,6 +221,7 @@
|
||||||
"Can't transfer claimed sales": "No puedes transferir lineas reclamadas",
|
"Can't transfer claimed sales": "No puedes transferir lineas reclamadas",
|
||||||
"You don't have privileges to create pay back": "No tienes permisos para crear un abono",
|
"You don't have privileges to create pay back": "No tienes permisos para crear un abono",
|
||||||
"The item is required": "El artículo es requerido",
|
"The item is required": "El artículo es requerido",
|
||||||
|
"The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo",
|
||||||
"date in the future": "Fecha en el futuro",
|
"date in the future": "Fecha en el futuro",
|
||||||
"reference duplicated": "Referencia duplicada"
|
"reference duplicated": "Referencia duplicada"
|
||||||
}
|
}
|
|
@ -87,21 +87,21 @@ module.exports = Self => {
|
||||||
SUM(t.packages) packages,
|
SUM(t.packages) packages,
|
||||||
r.m3,
|
r.m3,
|
||||||
r.kmEnd - r.kmStart kmTotal,
|
r.kmEnd - r.kmStart kmTotal,
|
||||||
CAST(IFNULL(ate.routePrice,
|
CAST(IFNULL(sat.routePrice,
|
||||||
(ate.kmPrice * (GREATEST(r.kmEnd - r.kmStart , ate.minimumKm))
|
(sat.kmPrice * (GREATEST(r.kmEnd - r.kmStart , sat.minimumKm))
|
||||||
+ GREATEST(r.m3 , ate.minimumM3) * ate.m3Price)
|
+ GREATEST(r.m3 , sat.minimumM3) * sat.m3Price)
|
||||||
+ ate.packagePrice * SUM(t.packages) )
|
+ sat.packagePrice * SUM(t.packages) )
|
||||||
AS DECIMAL(10,2)) price,
|
AS DECIMAL(10,2)) price,
|
||||||
r.invoiceInFk,
|
r.invoiceInFk,
|
||||||
a.supplierFk,
|
sat.supplierFk,
|
||||||
s.name supplierName
|
s.name supplierName
|
||||||
FROM vn.route r
|
FROM vn.route r
|
||||||
LEFT JOIN vn.agencyMode am ON r.agencyModeFk = am.id
|
LEFT JOIN vn.agencyMode am ON r.agencyModeFk = am.id
|
||||||
LEFT JOIN vn.agency a ON am.agencyFk = a.id
|
LEFT JOIN vn.agency a ON am.agencyFk = a.id
|
||||||
LEFT JOIN vn.ticket t ON t.routeFk = r.id
|
LEFT JOIN vn.ticket t ON t.routeFk = r.id
|
||||||
LEFT JOIN vn.agencyTerm ate ON ate.agencyFk = a.id
|
LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id
|
||||||
LEFT JOIN vn.supplier s ON s.id = a.supplierFk
|
LEFT JOIN vn.supplier s ON s.id = sat.supplierFk
|
||||||
WHERE r.created > DATE_ADD(CURDATE(), INTERVAL -2 MONTH) AND a.supplierFk IS NOT NULL
|
WHERE r.created > DATE_ADD(CURDATE(), INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL
|
||||||
GROUP BY r.id
|
GROUP BY r.id
|
||||||
) a`
|
) a`
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe('AgencyTerm filter()', () => {
|
||||||
const firstAgencyTerm = agencyTerms[0];
|
const firstAgencyTerm = agencyTerms[0];
|
||||||
|
|
||||||
expect(firstAgencyTerm.routeFk).toEqual(1);
|
expect(firstAgencyTerm.routeFk).toEqual(1);
|
||||||
expect(agencyTerms.length).toEqual(3);
|
expect(agencyTerms.length).toEqual(5);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -72,7 +72,7 @@ describe('AgencyTerm filter()', () => {
|
||||||
|
|
||||||
const results = await models.AgencyTerm.filter(ctx, options);
|
const results = await models.AgencyTerm.filter(ctx, options);
|
||||||
|
|
||||||
expect(results.length).toBe(3);
|
expect(results.length).toBe(5);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||||
|
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('freeAgencies', {
|
||||||
|
description: 'Returns a list of agencies without a supplier assigned',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'object',
|
||||||
|
description: `Filter defining where, order, offset, and limit - must be a JSON-encoded string`
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/freeAgencies`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.freeAgencies = async(filter, options) => {
|
||||||
|
const conn = Self.dataSource.connector;
|
||||||
|
const where = {'sat.supplierFk': null};
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
filter = mergeFilters(filter, {where});
|
||||||
|
|
||||||
|
let stmt = new ParameterizedSQL(
|
||||||
|
`SELECT a.name, a.id
|
||||||
|
FROM agency a
|
||||||
|
LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = a.id`,
|
||||||
|
null, myOptions);
|
||||||
|
|
||||||
|
stmt.merge(conn.makeSuffix(filter));
|
||||||
|
|
||||||
|
return conn.executeStmt(stmt);
|
||||||
|
};
|
||||||
|
};
|
|
@ -11,6 +11,9 @@
|
||||||
"SupplierAccount": {
|
"SupplierAccount": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"SupplierAgencyTerm": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"SupplierLog": {
|
"SupplierLog": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.rewriteDbError(function(err) {
|
||||||
|
if (err.code === 'ER_DUP_ENTRY')
|
||||||
|
return new UserError(`The agency is already assigned to another autonomous`);
|
||||||
|
return err;
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
"name": "SupplierAgencyTerm",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "supplierAgencyTerm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"agencyFk": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true
|
||||||
|
},
|
||||||
|
"supplierFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"minimumPackages": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"kmPrice": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"packagePrice": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"routePrice": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"minimumKm": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"minimumM3": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"m3Price": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"agency": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Agency",
|
||||||
|
"foreignKey": "agencyFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ module.exports = Self => {
|
||||||
require('../methods/supplier/getSummary')(Self);
|
require('../methods/supplier/getSummary')(Self);
|
||||||
require('../methods/supplier/updateFiscalData')(Self);
|
require('../methods/supplier/updateFiscalData')(Self);
|
||||||
require('../methods/supplier/consumption')(Self);
|
require('../methods/supplier/consumption')(Self);
|
||||||
|
require('../methods/supplier/freeAgencies')(Self);
|
||||||
|
|
||||||
Self.validatesPresenceOf('name', {
|
Self.validatesPresenceOf('name', {
|
||||||
message: 'The social name cannot be empty'
|
message: 'The social name cannot be empty'
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
<vn-watcher
|
||||||
|
vn-id="watcher"
|
||||||
|
url="SupplierAgencyTerms"
|
||||||
|
primary-key="agencyFk"
|
||||||
|
data="$ctrl.supplierAgencyTerm"
|
||||||
|
insert-mode="true"
|
||||||
|
form="form">
|
||||||
|
</vn-watcher>
|
||||||
|
<vn-crud-model
|
||||||
|
auto-load="true"
|
||||||
|
url="Suppliers/freeAgencies"
|
||||||
|
data="$ctrl.agencies">
|
||||||
|
</vn-crud-model>
|
||||||
|
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||||
|
<vn-card class="vn-pa-lg">
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-autocomplete vn-one
|
||||||
|
label="Agency"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.agencyFk"
|
||||||
|
data="$ctrl.agencies"
|
||||||
|
show-field="name"
|
||||||
|
value-field="id"
|
||||||
|
rule>
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Minimum M3"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.minimumM3"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Package Price"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.packagePrice"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Km Price"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.kmPrice"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="M3 Price"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.m3Price"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Route Price"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.routePrice"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Minimum Km"
|
||||||
|
ng-model="$ctrl.supplierAgencyTerm.minimumKm"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
</vn-horizontal>
|
||||||
|
</vn-card>
|
||||||
|
<vn-button-bar>
|
||||||
|
<vn-submit label="Save"></vn-submit>
|
||||||
|
<vn-button
|
||||||
|
label="Cancel"
|
||||||
|
ui-sref="supplier.card.agencyTerm.index">
|
||||||
|
</vn-button>
|
||||||
|
</vn-button-bar>
|
||||||
|
</form>
|
|
@ -0,0 +1,26 @@
|
||||||
|
import ngModule from '../../module';
|
||||||
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
|
export default class Controller extends Section {
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
|
||||||
|
this.supplierAgencyTerm = {
|
||||||
|
supplierFk: this.$params.id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
this.$.watcher.submit().then(res => {
|
||||||
|
this.$state.go('supplier.card.agencyTerm.index');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngModule.vnComponent('vnSupplierAgencyTermCreate', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
supplier: '<'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,28 @@
|
||||||
|
import './index';
|
||||||
|
import watcher from 'core/mocks/watcher';
|
||||||
|
|
||||||
|
describe('Supplier', () => {
|
||||||
|
describe('Component vnSupplierAddressCreate', () => {
|
||||||
|
let $scope;
|
||||||
|
let controller;
|
||||||
|
let $element;
|
||||||
|
|
||||||
|
beforeEach(ngModule('supplier'));
|
||||||
|
|
||||||
|
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$scope.watcher = watcher;
|
||||||
|
$element = angular.element('<vn-supplier-agency-term-create></vn-supplier-agency-term-create>');
|
||||||
|
controller = $componentController('vnSupplierAgencyTermCreate', {$element, $scope});
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onSubmit()', () => {
|
||||||
|
it(`should redirect to 'supplier.card.agencyTerm.index' state`, () => {
|
||||||
|
jest.spyOn(controller.$state, 'go');
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.agencyTerm.index');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,85 @@
|
||||||
|
<vn-crud-model
|
||||||
|
vn-id="model"
|
||||||
|
url="SupplierAgencyTerms"
|
||||||
|
link="{supplierFk: $ctrl.$params.id}"
|
||||||
|
primary-key="agencyFk"
|
||||||
|
filter="$ctrl.filter"
|
||||||
|
data="$ctrl.supplierAgencyTerms"
|
||||||
|
auto-load="true">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-watcher
|
||||||
|
vn-id="watcher"
|
||||||
|
data="$ctrl.supplierAgencyTerms"
|
||||||
|
form="form">
|
||||||
|
</vn-watcher>
|
||||||
|
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-lg">
|
||||||
|
<vn-card class="vn-pa-lg">
|
||||||
|
<vn-horizontal ng-repeat="supplierAgencyTerm in $ctrl.supplierAgencyTerms">
|
||||||
|
<vn-textfield
|
||||||
|
disabled="true"
|
||||||
|
vn-id="agency"
|
||||||
|
label="Agency"
|
||||||
|
ng-model="supplierAgencyTerm.agency.name"
|
||||||
|
rule>
|
||||||
|
</vn-textfield>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Minimum M3"
|
||||||
|
ng-model="supplierAgencyTerm.minimumM3"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Package Price"
|
||||||
|
ng-model="supplierAgencyTerm.packagePrice"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Km Price"
|
||||||
|
ng-model="supplierAgencyTerm.kmPrice"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="M3 Price"
|
||||||
|
ng-model="supplierAgencyTerm.m3Price"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Route Price"
|
||||||
|
ng-model="supplierAgencyTerm.routePrice"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
type="number"
|
||||||
|
label="Minimum Km"
|
||||||
|
ng-model="supplierAgencyTerm.minimumKm"
|
||||||
|
rule>
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-none>
|
||||||
|
<vn-icon-button
|
||||||
|
vn-tooltip="Remove row"
|
||||||
|
icon="delete"
|
||||||
|
ng-click="model.remove($index)"
|
||||||
|
tabindex="-1">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-none>
|
||||||
|
</vn-horizontal>
|
||||||
|
</vn-card>
|
||||||
|
<vn-button-bar>
|
||||||
|
<vn-submit
|
||||||
|
disabled="!watcher.dataChanged()"
|
||||||
|
label="Save">
|
||||||
|
</vn-submit>
|
||||||
|
</vn-button-bar>
|
||||||
|
</form>
|
||||||
|
<vn-float-button
|
||||||
|
vn-bind="+"
|
||||||
|
fixed-bottom-right
|
||||||
|
vn-tooltip="New row"
|
||||||
|
ui-sref="supplier.card.agencyTerm.create"
|
||||||
|
icon="add"
|
||||||
|
label="Add">
|
||||||
|
</vn-float-button>
|
|
@ -0,0 +1,36 @@
|
||||||
|
import ngModule from '../../module';
|
||||||
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
|
class Controller extends Section {
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
this.filter = {
|
||||||
|
include:
|
||||||
|
{relation: 'agency',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
add() {
|
||||||
|
this.$.model.insert({});
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
this.$.watcher.check();
|
||||||
|
this.$.model.save().then(() => {
|
||||||
|
this.$.watcher.notifySaved();
|
||||||
|
this.$.watcher.updateOriginalData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngModule.vnComponent('vnSupplierAgencyTermIndex', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
supplier: '<'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,37 @@
|
||||||
|
import './index';
|
||||||
|
import watcher from 'core/mocks/watcher';
|
||||||
|
import crudModel from 'core/mocks/crud-model';
|
||||||
|
|
||||||
|
describe('Supplier', () => {
|
||||||
|
describe('Component vnSupplierAddressCreate', () => {
|
||||||
|
let $scope;
|
||||||
|
let controller;
|
||||||
|
let $element;
|
||||||
|
|
||||||
|
beforeEach(ngModule('supplier'));
|
||||||
|
|
||||||
|
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$scope.model = crudModel;
|
||||||
|
$scope.watcher = watcher;
|
||||||
|
$element = angular.element('<vn-supplier-agency-term-index></vn-supplier-agency-term-index>');
|
||||||
|
controller = $componentController('vnSupplierAgencyTermIndex', {$element, $scope});
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onSubmit()', () => {
|
||||||
|
it('should make HTTP POST request to save values', () => {
|
||||||
|
jest.spyOn($scope.watcher, 'check');
|
||||||
|
jest.spyOn($scope.watcher, 'notifySaved');
|
||||||
|
jest.spyOn($scope.watcher, 'updateOriginalData');
|
||||||
|
jest.spyOn($scope.model, 'save');
|
||||||
|
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect($scope.model.save).toHaveBeenCalledWith();
|
||||||
|
expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
||||||
|
expect($scope.watcher.check).toHaveBeenCalledWith();
|
||||||
|
expect($scope.watcher.notifySaved).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,8 @@
|
||||||
|
Minimum M3: M3 minimos
|
||||||
|
Package Price: Precio bulto
|
||||||
|
Km Price: Precio Km
|
||||||
|
M3 Price: Precio M3
|
||||||
|
Route Price: Precio ruta
|
||||||
|
Minimum Km: Km minimos
|
||||||
|
Remove row: Eliminar fila
|
||||||
|
Add row: Añadir fila
|
|
@ -18,3 +18,5 @@ import './billing-data';
|
||||||
import './address/index';
|
import './address/index';
|
||||||
import './address/create';
|
import './address/create';
|
||||||
import './address/edit';
|
import './address/edit';
|
||||||
|
import './agency-term/index';
|
||||||
|
import './agency-term/create';
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
{"state": "supplier.card.address.index", "icon": "icon-delivery"},
|
{"state": "supplier.card.address.index", "icon": "icon-delivery"},
|
||||||
{"state": "supplier.card.account", "icon": "icon-account"},
|
{"state": "supplier.card.account", "icon": "icon-account"},
|
||||||
{"state": "supplier.card.contact", "icon": "contact_phone"},
|
{"state": "supplier.card.contact", "icon": "contact_phone"},
|
||||||
|
{"state": "supplier.card.agencyTerm.index", "icon": "contact_support"},
|
||||||
{"state": "supplier.card.log", "icon": "history"},
|
{"state": "supplier.card.log", "icon": "history"},
|
||||||
{"state": "supplier.card.consumption", "icon": "show_chart"}
|
{"state": "supplier.card.consumption", "icon": "show_chart"}
|
||||||
]
|
]
|
||||||
|
@ -86,6 +87,30 @@
|
||||||
"supplier": "$ctrl.supplier"
|
"supplier": "$ctrl.supplier"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"url": "/agency-term",
|
||||||
|
"state": "supplier.card.agencyTerm",
|
||||||
|
"component": "ui-view",
|
||||||
|
"abstract": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/index",
|
||||||
|
"state": "supplier.card.agencyTerm.index",
|
||||||
|
"component": "vn-supplier-agency-term-index",
|
||||||
|
"description": "Autonomous",
|
||||||
|
"params": {
|
||||||
|
"supplier": "$ctrl.supplier"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/create",
|
||||||
|
"state": "supplier.card.agencyTerm.create",
|
||||||
|
"component": "vn-supplier-agency-term-create",
|
||||||
|
"description": "New autonomous",
|
||||||
|
"params": {
|
||||||
|
"supplier": "$ctrl.supplier"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"url": "/consumption?q",
|
"url": "/consumption?q",
|
||||||
"state": "supplier.card.consumption",
|
"state": "supplier.card.consumption",
|
||||||
|
|
|
@ -16,5 +16,12 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": false
|
"required": false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"supplierAgencyTerm": {
|
||||||
|
"type": "hasOne",
|
||||||
|
"model": "SupplierAgencyTerm",
|
||||||
|
"foreignKey": "agencyFk"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue