diff --git a/db/changes/230601/00-entry.sql b/db/changes/230601/00-entry.sql new file mode 100644 index 000000000..f62433aaf --- /dev/null +++ b/db/changes/230601/00-entry.sql @@ -0,0 +1,53 @@ +ALTER TABLE `vn`.`entry` ADD observationEditorFk INT(10) unsigned NULL COMMENT 'Ăšltimo usuario que ha modificado el campo evaNotes'; +ALTER TABLE `vn`.`entry` ADD CONSTRAINT entry_observationEditorFk FOREIGN KEY (observationEditorFk) REFERENCES account.user(id) ON UPDATE CASCADE; + +CREATE OR REPLACE DEFINER=`root`@`localhost` +VIEW `vn2008`.`entrySource` AS +select + `e`.`gestDocFk` AS `gestdoc_id`, + `e`.`id` AS `Id_Entrada`, + `e`.`invoiceNumber` AS `invoiceNumber`, + `e`.`reference` AS `reference`, + `e`.`isExcludedFromAvailable` AS `Inventario`, + `e`.`notes` AS `observaciones`, + `e`.`isConfirmed` AS `Confirmada`, + `e`.`isOrdered` AS `Pedida`, + `e`.`isRaid` AS `Redada`, + `e`.`evaNotes` AS `notas`, + `e`.`supplierFk` AS `Id_Proveedor`, + `tr`.`shipped` AS `shipment`, + `tr`.`landed` AS `landing`, + `w2`.`name` AS `wh_in`, + `w1`.`name` AS `wh_out`, + `am`.`name` AS `Agencia`, + `e`.`commission` AS `comision`, + `tr`.`warehouseInFk` AS `warehouse_id`, + `w1`.`id` AS `warehouse_id_out`, + `e`.`isBooked` AS `anotadoencaja`, + `e`.`invoiceInFk` AS `invoiceInFk`, + `e`.`companyFk` AS `empresa_id`, + `e`.`currencyFk` AS `Id_Moneda`, + `tr`.`id` AS `TravelFk`, + `e`.`sub` AS `sub`, + `e`.`kop` AS `kop`, + `e`.`pro` AS `pro`, + `e`.`invoiceAmount` AS `invoiceAmount`, + `w`.`code` AS `buyerCode`, + `e`.`typeFk` AS `typeFk`, + `w3`.`code` AS `observationWorkerCode` +from + (((((((`vn`.`entry` `e` +left join `vn`.`travel` `tr` on + (`e`.`travelFk` = `tr`.`id`)) +left join `vn`.`agencyMode` `am` on + (`am`.`id` = `tr`.`agencyModeFk`)) +left join `vn`.`warehouse` `w1` on + (`tr`.`warehouseOutFk` = `w1`.`id`)) +left join `vn`.`warehouse` `w2` on + (`tr`.`warehouseInFk` = `w2`.`id`)) +left join `vn`.`supplier` `s` on + (`e`.`supplierFk` = `s`.`id`)) +left join `vn`.`worker` `w` on + (`w`.`id` = `e`.`buyerFk`)) +left join `vn`.`worker` `w3` on + (`w3`.`id` = `e`.`observationEditorFk`));