salix/db/routines/vn2008/views/entrySource.sql

56 lines
1.6 KiB
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
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`.`isConfirmed` AS `Confirmada`,
`e`.`isOrdered` AS `Pedida`,
`tr`.`daysInForward` AS `daysInForward`,
`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`)
)