2742--invoiceIn-create #670

Merged
joan merged 7 commits from 2742--invoiceIn-create into dev 2021-06-21 11:20:28 +00:00
11 changed files with 184 additions and 18 deletions

View File

@ -31,16 +31,9 @@ BEGIN
*/ */
DECLARE vPrice DECIMAL(10,2); DECLARE vPrice DECIMAL(10,2);
DECLARE vBonus DECIMAL(10,2); DECLARE vBonus DECIMAL(10,2);
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk); CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk);
START TRANSACTION;
IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
UPDATE ticket t UPDATE ticket t
@ -95,7 +88,6 @@ BEGIN
DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.sale;
DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
END IF; END IF;
COMMIT;
DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview; DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview;
END$$ END$$

View File

@ -0,0 +1,62 @@
<vn-watcher
vn-id="watcher"
url="InvoiceIns"
data="$ctrl.invoiceIn"
insert-mode="true"
form="form">
</vn-watcher>
<form name="form" vn-http-submit="$ctrl.onSubmit()" class="vn-w-md">
<div class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-autocomplete
vn-focus
vn-id="supplier"
url="Suppliers"
label="Supplier"
search-function="{or: [{id: $search}, {name: {like: '%'+ $search +'%'}}]}"
show-field="name"
value-field="id"
ng-model="$ctrl.invoiceIn.supplierFk"
order="id"
vn-focus>
<tpl-item>{{id}}: {{name}}</tpl-item>
</vn-autocomplete>
<vn-textfield
vn-one
label="supplierRef"
ng-model="$ctrl.invoiceIn.supplierRef">
</vn-textfield>
<vn-date-picker
label="Issued"
ng-model="$ctrl.invoiceIn.issued">
</vn-date-picker>
<vn-autocomplete
vn-one
label="Currency"
ng-model="$ctrl.invoiceIn.currencyFk"
url="Currencies"
show-field="code"
value-field="id">
</vn-autocomplete>
<vn-autocomplete
vn-one
label="Company"
ng-model="$ctrl.companyFk"
url="companies"
show-field="code"
value-field="id">
</vn-autocomplete>
</vn-card>
<vn-button-bar>
<vn-submit
disabled="!watcher.dataChanged()"
label="Create">
</vn-submit>
<vn-button
class="cancel"
label="Cancel"
ui-sref="InvoiceIn.index">
</vn-button>
</vn-button-bar>
</div>
</form>

View File

@ -0,0 +1,29 @@
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
$onInit() {
this.invoiceIn = {};
if (this.$params && this.$params.supplierFk)
this.invoiceIn.supplierFk = this.$params.supplierFk;
}
get companyFk() {
return this.invoiceIn.companyFk || this.vnConfig.companyFk;
}
set companyFk(value) {
this.invoiceIn.companyFk = value;
}
onSubmit() {
this.$.watcher.submit().then(
res => this.$state.go('invoiceIn.card.basicData', {id: res.data.id})
);
}
}
ngModule.vnComponent('vnInvoiceInCreate', {
template: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,52 @@
import './index.js';
import watcher from 'core/mocks/watcher';
describe('InvoiceIn', () => {
describe('Component vnInvoiceInCreate', () => {
let controller;
let $element;
beforeEach(ngModule('invoiceIn'));
beforeEach(inject(($componentController, $rootScope) => {
const $scope = $rootScope.$new();
$scope.watcher = watcher;
$element = angular.element('<vn-invoice-in-create></vn-invoice-in-create>');
controller = $componentController('vnInvoiceInCreate', {$element, $scope});
controller.$params = {};
}));
afterEach(() => {
$element.remove();
});
describe('onInit()', () => {
it(`should defined the controller's invoiceIn property`, () => {
expect(controller.invoiceIn).toBeUndefined();
controller.$onInit();
expect(controller.invoiceIn).toEqual({});
});
it(`should define invoiceIn and it's supplierFk when received via params`, () => {
controller.$params.supplierFk = 'supplierId';
controller.$onInit();
expect(controller.invoiceIn.supplierFk).toEqual('supplierId');
});
});
describe('onSubmit()', () => {
it(`should redirect to basic data by calling the $state.go function`, () => {
jest.spyOn(controller.$state, 'go');
controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('invoiceIn.card.basicData', {id: 1234});
});
});
});
});

View File

@ -0,0 +1 @@
a:a

View File

@ -8,4 +8,5 @@ import './descriptor';
import './descriptor-popover'; import './descriptor-popover';
import './summary'; import './summary';
import './basic-data'; import './basic-data';
import './create';
import './log'; import './log';

View File

@ -1,5 +1,5 @@
InvoiceIn: Facturas recibidas InvoiceIn: Facturas recibidas
Search invoices in by reference: Buscar facturas recibidas por referencia Search invoices in by reference: Buscar facturas recibidas por referencia
Entries list: Listado de entradas Entries list: Listado de entradas
Invoice list: Listado de entradas Invoice list: Listado de facturas recibidas
InvoiceIn deleted: Factura eliminada InvoiceIn deleted: Factura eliminada

View File

@ -2,11 +2,17 @@
"module": "invoiceIn", "module": "invoiceIn",
"name": "Invoices in", "name": "Invoices in",
"icon": "icon-invoiceIn", "icon": "icon-invoiceIn",
"validations" : true, "validations": true,
"dependencies": ["worker", "supplier"], "dependencies": [
"worker",
"supplier"
],
"menus": { "menus": {
"main": [ "main": [
{"state": "invoiceIn.index", "icon": "icon-invoiceIn"} {
"state": "invoiceIn.index",
"icon": "icon-invoiceIn"
}
], ],
"card": [ "card": [
{ {
@ -32,7 +38,9 @@
"state": "invoiceIn.index", "state": "invoiceIn.index",
"component": "vn-invoice-in-index", "component": "vn-invoice-in-index",
"description": "InvoiceIn", "description": "InvoiceIn",
"acl": ["administrative"] "acl": [
"administrative"
]
}, },
{ {
"url": "/:id", "url": "/:id",
@ -48,7 +56,9 @@
"params": { "params": {
"invoice-in": "$ctrl.invoiceIn" "invoice-in": "$ctrl.invoiceIn"
}, },
"acl": ["administrative"] "acl": [
"administrative"
]
}, },
{ {
"url": "/basic-data", "url": "/basic-data",
@ -58,14 +68,27 @@
"params": { "params": {
"invoice-in": "$ctrl.invoiceIn" "invoice-in": "$ctrl.invoiceIn"
}, },
"acl": ["administrative"] "acl": [
"administrative"
]
},
{
"url": "/create?supplierFk",
"state": "invoiceIn.create",
"component": "vn-invoice-in-create",
"description": "New InvoiceIn",
"acl": [
"administrative"
]
}, },
{ {
"url": "/log", "url": "/log",
"state": "invoiceIn.card.log", "state": "invoiceIn.card.log",
"component": "vn-invoice-in-log", "component": "vn-invoice-in-log",
"description": "Log", "description": "Log",
"acl": ["administrative"] "acl": [
"administrative"
]
} }
] ]
} }

View File

@ -56,6 +56,11 @@
</vn-quick-link> </vn-quick-link>
</div> </div>
<div ng-transclude="btnThree"> <div ng-transclude="btnThree">
<vn-quick-link
tooltip="Create invoiceIn"
state="['invoiceIn.create', {supplierFk: $ctrl.id}]"
icon="icon-invoice-in-create">
</vn-quick-link>
</div> </div>
</div> </div>
</slot-body> </slot-body>

View File

@ -4,3 +4,4 @@ Go to client: Ir al cliente
Verified supplier: Proveedor verificado Verified supplier: Proveedor verificado
Unverified supplier: Proveedor no verificado Unverified supplier: Proveedor no verificado
Inactive supplier: Proveedor inactivo Inactive supplier: Proveedor inactivo
Create invoiceIn: Crear factura recibida