From 768e4d5e77be2af5ecfb5d41fef1a2b3caa44df3 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 10 Aug 2022 12:13:31 +0200 Subject: [PATCH] Resolved conflicts --- back/helpers.spec.js | 5 + back/methods/account/set-password.js | 5 +- back/methods/dms/deleteTrashFiles.js | 20 +- back/models/warehouse.json | 3 - back/nodemonConfig.json | 1 + db/Dockerfile | 4 +- db/changes/10480-june/00-ACL.sql | 21 + db/changes/10480-june/00-aclShelvingLog.sql | 3 + .../10480-june/00-aclZoneExclusionGeos.sql | 4 + db/changes/10480-june/00-albaran_gestdoc.sql | 2 + db/changes/10480-june/00-client.sql | 3 + db/changes/10480-june/00-deprecations.sql | 13 + db/changes/10480-june/00-item.sql | 1 + db/changes/10480-june/00-route.sql | 10 + db/changes/10480-june/00-sample.sql | 2 + db/changes/10480-june/00-shelving.sql | 18 + .../00-ticketRefund_beforeUpsert.sql | 21 + db/changes/10480-june/01-claimObservation.sql | 13 + .../10480-june/02-claimTextMigration.sql | 2 + db/changes/10480-june/04-aclParking.sql | 2 + db/changes/10480-june/04-aclShelving.sql | 2 + db/dump/fixtures.sql | 1737 +++++++++-------- db/dump/mockDate.sql | 43 + db/export-data.sh | 2 +- db/export-structure.sh | 9 +- db/tests/vn/zone_getLanded.spec.js | 11 +- e2e/helpers/selectors.js | 65 +- .../02-client/03_edit_fiscal_data.spec.js | 2 +- e2e/paths/02-client/05_add_address.spec.js | 2 +- .../02-client/07_edit_web_access.spec.js | 36 +- e2e/paths/02-client/21_defaulter.spec.js | 6 +- e2e/paths/03-worker/04_time_control.spec.js | 478 +---- .../05-ticket/02_expeditions_and_log.spec.js | 2 +- .../05-ticket/06_basic_data_steps.spec.js | 6 +- e2e/paths/05-ticket/09_weekly.spec.js | 4 +- e2e/paths/05-ticket/12_descriptor.spec.js | 53 - e2e/paths/05-ticket/13_services.spec.js | 4 +- e2e/paths/05-ticket/14_create_ticket.spec.js | 23 +- e2e/paths/06-claim/01_basic_data.spec.js | 11 - e2e/paths/06-claim/05_summary.spec.js | 2 +- e2e/paths/06-claim/07_note.spec.js | 46 + e2e/paths/07-order/01_summary.spec.js | 2 +- e2e/paths/08-route/01_summary.spec.js | 2 +- e2e/paths/12-entry/02_descriptor.spec.js | 2 +- .../01_create_and_basic_data.spec.js | 49 +- .../02_alias_create_and_basic_data.spec.js | 2 +- front/core/filters/currency.js | 3 +- front/core/services/app.js | 16 + front/core/services/interceptor.js | 7 +- front/core/styles/icons/salixfont.css | 3 - front/core/styles/icons/salixfont.svg | 2 - front/module-import.js | 1 + front/salix/components/layout/index.html | 9 +- front/salix/components/layout/index.js | 4 + front/salix/components/layout/style.scss | 3 + front/salix/locale/es.yml | 1 + jest-front.js | 1 + loopback/locale/en.json | 13 +- loopback/locale/es.json | 12 +- loopback/server/middleware.json | 3 +- loopback/server/middleware/salix-version.js | 8 + .../importToNewRefundTicket.js | 2 +- .../claim/back/methods/claim/getSummary.js | 19 +- .../methods/claim/specs/getSummary.spec.js | 1 + modules/claim/back/model-config.json | 3 + .../claim/back/models/claim-observation.json | 43 + modules/claim/front/basic-data/index.html | 9 - modules/claim/front/index.js | 2 + modules/claim/front/locale/es.yml | 1 + modules/claim/front/note/create/index.html | 30 + modules/claim/front/note/create/index.js | 22 + modules/claim/front/note/index/index.html | 32 + modules/claim/front/note/index/index.js | 25 + modules/claim/front/note/index/style.scss | 5 + modules/claim/front/routes.json | 52 +- modules/claim/front/summary/index.html | 48 +- .../back/methods/client/createReceipt.js | 12 +- modules/client/back/methods/client/getCard.js | 8 +- modules/client/back/methods/client/getDebt.js | 6 +- .../back/methods/client/lastActiveTickets.js | 6 +- .../client/back/methods/client/setPassword.js | 32 + .../client/specs/extendedListFilter.spec.js | 14 +- .../methods/client/specs/setPassword.spec.js | 27 + .../back/methods/client/specs/summary.spec.js | 1 - .../methods/client/specs/updateUser.spec.js | 58 + modules/client/back/methods/client/summary.js | 1 - .../back/methods/client/updateFiscalData.js | 4 + .../client/back/methods/client/updateUser.js | 61 + .../client/back/methods/defaulter/filter.js | 10 +- .../methods/recovery/hasActiveRecovery.js | 6 +- modules/client/back/models/client-sample.json | 6 +- modules/client/back/models/client.js | 66 +- modules/client/back/models/client.json | 3 + modules/client/front/defaulter/index.html | 15 +- modules/client/front/defaulter/index.js | 26 +- modules/client/front/defaulter/index.spec.js | 24 +- modules/client/front/defaulter/locale/es.yml | 2 +- modules/client/front/extended-list/index.html | 2 +- modules/client/front/fiscal-data/index.html | 8 + .../client/front/fiscal-data/locale/es.yml | 3 +- modules/client/front/routes.json | 122 +- modules/client/front/sample/index/index.html | 6 +- modules/client/front/sample/index/index.js | 10 +- modules/client/front/web-access/index.html | 21 +- modules/client/front/web-access/index.js | 18 +- modules/client/front/web-access/index.spec.js | 6 +- modules/client/front/web-access/locale/es.yml | 4 +- modules/entry/back/methods/entry/getEntry.js | 2 +- .../entry/back/methods/entry/lastItemBuys.js | 1 - .../back/methods/entry/latestBuysFilter.js | 11 +- modules/entry/front/basic-data/index.html | 2 +- modules/entry/front/basic-data/index.js | 2 +- modules/entry/front/card/index.js | 2 +- modules/entry/front/descriptor/index.js | 6 +- modules/invoiceIn/front/tax/index.spec.js | 1 - .../back/methods/invoiceOut/createPdf.js | 2 +- .../back/methods/invoiceOut/download.js | 8 +- .../back/methods/invoiceOut/refund.js | 49 + .../methods/invoiceOut/specs/refund.spec.js | 28 + modules/invoiceOut/back/models/invoice-out.js | 1 + .../front/descriptor-menu/index.html | 2 + .../invoiceOut/front/descriptor-menu/index.js | 40 +- .../front/descriptor-menu/index.spec.js | 59 +- .../front/descriptor-menu/locale/en.yml | 1 + .../front/descriptor-menu/locale/es.yml | 1 + .../index/global-invoicing/index.spec.js | 4 +- .../item/back/methods/item/getWasteByItem.js | 8 +- .../back/methods/item/getWasteByWorker.js | 8 +- modules/item/back/model-config.json | 3 - modules/item/back/models/item-placement.json | 36 - modules/item/front/summary/index.html | 17 + .../methods/sales-monitor/clientsFilter.js | 7 +- .../back/methods/sales-monitor/salesFilter.js | 21 +- .../route/back/methods/agency-term/filter.js | 6 +- .../back/methods/route/specs/filter.spec.js | 29 +- .../route/specs/getDeliveryPoint.spec.js | 2 +- .../route/specs/getSuggestedTickets.spec.js | 10 +- .../route/specs/updateWorkCenter.spec.js | 51 + .../back/methods/route/updateWorkCenter.js | 54 + modules/route/back/models/route.js | 1 + modules/route/back/models/route.json | 3 + modules/route/front/create/index.js | 7 +- .../back/methods/shelving/getSummary.js | 52 + modules/shelving/back/model-config.json | 11 + modules/shelving/back/models/parking.json | 33 + .../shelving/back/models/shelving-log.json | 58 + modules/shelving/back/models/shelving.js | 3 + modules/shelving/back/models/shelving.json | 51 + modules/shelving/front/basic-data/index.html | 52 + modules/shelving/front/basic-data/index.js | 10 + modules/shelving/front/card/index.html | 8 + modules/shelving/front/card/index.js | 29 + modules/shelving/front/card/index.spec.js | 26 + modules/shelving/front/create/index.html | 51 + modules/shelving/front/create/index.js | 15 + modules/shelving/front/create/index.spec.js | 38 + modules/shelving/front/descriptor/index.html | 45 + modules/shelving/front/descriptor/index.js | 26 + .../shelving/front/descriptor/index.spec.js | 29 + modules/shelving/front/index.js | 11 + modules/shelving/front/index/index.html | 47 + modules/shelving/front/index/index.js | 14 + modules/shelving/front/index/index.spec.js | 39 + modules/shelving/front/index/locale/es.yml | 2 + modules/shelving/front/log/index.html | 1 + modules/shelving/front/log/index.js | 7 + modules/shelving/front/log/locale/es.yml | 1 + modules/shelving/front/main/index.html | 19 + modules/shelving/front/main/index.js | 29 + modules/shelving/front/main/index.spec.js | 19 + modules/shelving/front/main/locale/es.yml | 1 + modules/shelving/front/module.js | 3 + modules/shelving/front/routes.json | 70 + .../shelving/front/search-panel/index.html | 43 + modules/shelving/front/search-panel/index.js | 7 + .../shelving/front/search-panel/locale/es.yml | 1 + modules/shelving/front/summary/index.html | 51 + modules/shelving/front/summary/index.js | 41 + modules/shelving/front/summary/locale/es.yml | 5 + modules/shelving/front/summary/style.scss | 7 + .../methods/sale/getClaimableFromTicket.js | 6 +- modules/ticket/back/methods/sale/refund.js | 153 +- .../back/methods/sale/specs/refund.spec.js | 74 +- .../back/methods/ticket/canHaveStowaway.js | 48 - .../back/methods/ticket/deleteStowaway.js | 105 - modules/ticket/back/methods/ticket/filter.js | 26 +- .../methods/ticket/getPossibleStowaways.js | 74 - .../ticket/back/methods/ticket/makeInvoice.js | 4 +- modules/ticket/back/methods/ticket/refund.js | 54 + .../ticket/back/methods/ticket/setDeleted.js | 38 +- .../ticket/specs/canBeInvoiced.spec.js | 1 - .../ticket/specs/canHaveStowaway.spec.js | 39 - .../ticket/specs/deleteStowaway.spec.js | 75 - .../back/methods/ticket/specs/filter.spec.js | 4 +- .../ticket/specs/getPossibleStowaways.spec.js | 60 - .../methods/ticket/specs/setDeleted.spec.js | 106 +- modules/ticket/back/model-config.json | 7 +- modules/ticket/back/models/stowaway.js | 24 - modules/ticket/back/models/stowaway.json | 36 - .../ticket/back/models/ticket-collection.json | 22 + modules/ticket/back/models/ticket-refund.json | 40 + modules/ticket/back/models/ticket-service.js | 17 +- modules/ticket/back/models/ticket.js | 4 +- modules/ticket/back/models/ticket.json | 20 +- modules/ticket/front/card/index.js | 14 +- modules/ticket/front/create/card.html | 1 + .../ticket/front/descriptor-menu/index.html | 31 +- modules/ticket/front/descriptor-menu/index.js | 53 +- .../front/descriptor-menu/index.spec.js | 34 +- .../front/descriptor-menu/locale/en.yml | 1 + .../front/descriptor-menu/locale/es.yml | 3 +- .../ticket/front/descriptor/addStowaway.html | 36 - .../ticket/front/descriptor/addStowaway.js | 32 - modules/ticket/front/descriptor/index.html | 30 - modules/ticket/front/descriptor/locale/es.yml | 8 - modules/ticket/front/descriptor/style.scss | 6 - modules/ticket/front/index.js | 1 - modules/ticket/front/sale/index.html | 2 +- modules/ticket/front/sale/index.js | 15 +- modules/ticket/front/sale/index.spec.js | 15 +- .../methods/thermograph/createThermograph.js | 5 +- .../back/methods/travel/cloneWithEntries.js | 6 +- .../methods/travel/extraCommunityFilter.js | 6 +- modules/travel/back/methods/travel/filter.js | 8 +- .../back/methods/travel/getAverageDays.js | 8 +- .../travel/specs/cloneWithEntries.spec.js | 2 +- .../travel/specs/extraCommunityFilter.spec.js | 4 +- modules/travel/back/models/travel.json | 7 +- modules/travel/front/descriptor-menu/index.js | 4 +- .../front/descriptor-menu/index.spec.js | 4 +- modules/travel/front/descriptor/index.js | 4 +- .../extra-community-search-panel/index.html | 2 +- modules/travel/front/index/index.html | 2 +- modules/travel/front/index/index.js | 4 +- modules/travel/front/index/index.spec.js | 4 +- modules/travel/front/search-panel/index.html | 2 +- .../worker-time-control/addTimeEntry.js | 29 +- .../worker-time-control/specs/filter.spec.js | 10 +- .../specs/timeEntry.spec.js | 781 ++++++-- .../back/methods/worker/createAbsence.js | 7 +- .../worker/back/methods/worker/holidays.js | 22 +- .../methods/worker/specs/holidays.spec.js | 11 + modules/worker/back/models/worker.json | 3 + modules/worker/front/basic-data/index.html | 18 +- modules/worker/front/basic-data/locale/es.yml | 4 +- modules/worker/front/summary/index.html | 8 +- modules/worker/front/summary/index.js | 2 +- modules/worker/front/summary/locale/es.yml | 3 + .../methods/agency/specs/getLanded.spec.js | 6 +- .../zone/back/methods/zone/exclusionGeo.js | 64 + .../back/methods/zone/getEventsFiltered.js | 29 +- .../methods/zone/specs/exclusionGeo.spec.js | 41 + .../zone/specs/getEventsFiltered.spec.js | 45 +- .../methods/zone/specs/getZoneClosing.spec.js | 1 - .../zone/specs/updateExclusionGeo.spec.js | 40 + .../back/methods/zone/updateExclusionGeo.js | 55 + modules/zone/back/model-config.json | 3 + modules/zone/back/models/agency-mode.json | 5 + .../zone/back/models/zone-exclusion-geo.json | 21 + modules/zone/back/models/zone.js | 2 + modules/zone/front/calendar/index.js | 25 +- modules/zone/front/calendar/index.spec.js | 23 +- modules/zone/front/calendar/style.scss | 3 + modules/zone/front/events/index.html | 81 +- modules/zone/front/events/index.js | 193 +- modules/zone/front/events/index.spec.js | 188 +- modules/zone/front/events/locale/es.yml | 4 + modules/zone/front/events/style.scss | 11 + modules/zone/front/location/style.scss | 30 +- modules/zone/front/routes.json | 7 +- package.json | 2 +- print/methods/closure/closeAll.js | 1 + print/methods/closure/closeByAgency.js | 1 + print/methods/closure/closeByRoute.js | 1 + print/methods/closure/closeByTicket.js | 1 + print/methods/closure/closure.js | 33 +- print/methods/csv/invoice/download.js | 10 +- print/methods/csv/invoice/send.js | 14 +- print/methods/csv/invoice/sql/invoice.sql | 3 +- print/methods/csv/invoice/sql/sales.sql | 2 +- print/methods/schedule/invoice.js | 7 +- .../assets/css/import.js | 8 + .../incoterms-authorization/attachments.json | 6 + .../incoterms-authorization.html | 57 + .../incoterms-authorization.js | 27 + .../incoterms-authorization/locale/es.yml | 6 + .../incoterms-authorization/locale/fr.yml | 6 + .../incoterms-authorization/locale/pt.yml | 6 + print/templates/email/invoice/invoice.js | 8 +- print/templates/email/invoice/sql/invoice.sql | 2 +- .../letter-debtor-st/letter-debtor-st.html | 2 +- .../email/letter-debtor-st/locale/pt.yml | 16 + .../reports/cmr-authorization/sql/ticket.sql | 12 - .../reports/driver-route/driver-route.html | 3 +- .../reports/driver-route/locale/es.yml | 1 - .../reports/driver-route/sql/tickets.sql | 2 - .../reports/exportation/exportation.js | 8 +- .../reports/exportation/sql/invoice.sql | 3 +- .../extra-community/extra-community.js | 6 +- .../reports/extra-community/sql/travels.sql | 2 +- .../assets/css/import.js | 0 .../assets/css/style.css | 9 +- .../assets/images/signature.png | Bin .../incoterms-authorization.html} | 29 +- .../incoterms-authorization.js} | 15 +- .../locale/es.yml | 24 +- .../incoterms-authorization/locale/fr.yml | 38 + .../incoterms-authorization/locale/pt.yml | 42 + .../sql/client.sql | 0 .../incoterms-authorization/sql/company.sql | 8 + .../invoice-incoterms/invoice-incoterms.js | 20 +- .../reports/invoice-incoterms/sql/client.sql | 3 +- .../invoice-incoterms/sql/incoterms.sql | 7 +- .../reports/invoice-incoterms/sql/invoice.sql | 3 +- print/templates/reports/invoice/invoice.js | 53 +- .../templates/reports/invoice/sql/client.sql | 3 +- .../reports/invoice/sql/hasIncoterms.sql | 2 +- .../reports/invoice/sql/intrastat.sql | 40 +- .../templates/reports/invoice/sql/invoice.sql | 3 +- .../reports/invoice/sql/rectified.sql | 3 +- print/templates/reports/invoice/sql/sales.sql | 4 +- print/templates/reports/invoice/sql/taxes.sql | 5 +- .../templates/reports/invoice/sql/tickets.sql | 2 +- 323 files changed, 5693 insertions(+), 3204 deletions(-) create mode 100644 back/helpers.spec.js create mode 100644 db/changes/10480-june/00-ACL.sql create mode 100644 db/changes/10480-june/00-aclShelvingLog.sql create mode 100644 db/changes/10480-june/00-aclZoneExclusionGeos.sql create mode 100644 db/changes/10480-june/00-albaran_gestdoc.sql create mode 100644 db/changes/10480-june/00-client.sql create mode 100644 db/changes/10480-june/00-deprecations.sql create mode 100644 db/changes/10480-june/00-item.sql create mode 100644 db/changes/10480-june/00-route.sql create mode 100644 db/changes/10480-june/00-sample.sql create mode 100644 db/changes/10480-june/00-shelving.sql create mode 100644 db/changes/10480-june/00-ticketRefund_beforeUpsert.sql create mode 100644 db/changes/10480-june/01-claimObservation.sql create mode 100644 db/changes/10480-june/02-claimTextMigration.sql create mode 100644 db/changes/10480-june/04-aclParking.sql create mode 100644 db/changes/10480-june/04-aclShelving.sql create mode 100644 db/dump/mockDate.sql create mode 100644 e2e/paths/06-claim/07_note.spec.js create mode 100644 loopback/server/middleware/salix-version.js create mode 100644 modules/claim/back/models/claim-observation.json create mode 100644 modules/claim/front/note/create/index.html create mode 100644 modules/claim/front/note/create/index.js create mode 100644 modules/claim/front/note/index/index.html create mode 100644 modules/claim/front/note/index/index.js create mode 100644 modules/claim/front/note/index/style.scss create mode 100644 modules/client/back/methods/client/setPassword.js create mode 100644 modules/client/back/methods/client/specs/setPassword.spec.js create mode 100644 modules/client/back/methods/client/specs/updateUser.spec.js create mode 100644 modules/client/back/methods/client/updateUser.js create mode 100644 modules/invoiceOut/back/methods/invoiceOut/refund.js create mode 100644 modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js create mode 100644 modules/invoiceOut/front/descriptor-menu/locale/en.yml delete mode 100644 modules/item/back/models/item-placement.json create mode 100644 modules/route/back/methods/route/specs/updateWorkCenter.spec.js create mode 100644 modules/route/back/methods/route/updateWorkCenter.js create mode 100644 modules/shelving/back/methods/shelving/getSummary.js create mode 100644 modules/shelving/back/model-config.json create mode 100644 modules/shelving/back/models/parking.json create mode 100644 modules/shelving/back/models/shelving-log.json create mode 100644 modules/shelving/back/models/shelving.js create mode 100644 modules/shelving/back/models/shelving.json create mode 100644 modules/shelving/front/basic-data/index.html create mode 100644 modules/shelving/front/basic-data/index.js create mode 100644 modules/shelving/front/card/index.html create mode 100644 modules/shelving/front/card/index.js create mode 100644 modules/shelving/front/card/index.spec.js create mode 100644 modules/shelving/front/create/index.html create mode 100644 modules/shelving/front/create/index.js create mode 100644 modules/shelving/front/create/index.spec.js create mode 100644 modules/shelving/front/descriptor/index.html create mode 100644 modules/shelving/front/descriptor/index.js create mode 100644 modules/shelving/front/descriptor/index.spec.js create mode 100644 modules/shelving/front/index.js create mode 100644 modules/shelving/front/index/index.html create mode 100644 modules/shelving/front/index/index.js create mode 100644 modules/shelving/front/index/index.spec.js create mode 100644 modules/shelving/front/index/locale/es.yml create mode 100644 modules/shelving/front/log/index.html create mode 100644 modules/shelving/front/log/index.js create mode 100644 modules/shelving/front/log/locale/es.yml create mode 100644 modules/shelving/front/main/index.html create mode 100644 modules/shelving/front/main/index.js create mode 100644 modules/shelving/front/main/index.spec.js create mode 100644 modules/shelving/front/main/locale/es.yml create mode 100644 modules/shelving/front/module.js create mode 100644 modules/shelving/front/routes.json create mode 100644 modules/shelving/front/search-panel/index.html create mode 100644 modules/shelving/front/search-panel/index.js create mode 100644 modules/shelving/front/search-panel/locale/es.yml create mode 100644 modules/shelving/front/summary/index.html create mode 100644 modules/shelving/front/summary/index.js create mode 100644 modules/shelving/front/summary/locale/es.yml create mode 100644 modules/shelving/front/summary/style.scss delete mode 100644 modules/ticket/back/methods/ticket/canHaveStowaway.js delete mode 100644 modules/ticket/back/methods/ticket/deleteStowaway.js delete mode 100644 modules/ticket/back/methods/ticket/getPossibleStowaways.js create mode 100644 modules/ticket/back/methods/ticket/refund.js delete mode 100644 modules/ticket/back/methods/ticket/specs/canHaveStowaway.spec.js delete mode 100644 modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js delete mode 100644 modules/ticket/back/methods/ticket/specs/getPossibleStowaways.spec.js delete mode 100644 modules/ticket/back/models/stowaway.js delete mode 100644 modules/ticket/back/models/stowaway.json create mode 100644 modules/ticket/back/models/ticket-collection.json create mode 100644 modules/ticket/back/models/ticket-refund.json create mode 100644 modules/ticket/front/descriptor-menu/locale/en.yml delete mode 100644 modules/ticket/front/descriptor/addStowaway.html delete mode 100644 modules/ticket/front/descriptor/addStowaway.js create mode 100644 modules/worker/front/summary/locale/es.yml create mode 100644 modules/zone/back/methods/zone/exclusionGeo.js create mode 100644 modules/zone/back/methods/zone/specs/exclusionGeo.spec.js create mode 100644 modules/zone/back/methods/zone/specs/updateExclusionGeo.spec.js create mode 100644 modules/zone/back/methods/zone/updateExclusionGeo.js create mode 100644 modules/zone/back/models/zone-exclusion-geo.json create mode 100644 modules/zone/front/events/style.scss create mode 100644 print/templates/email/incoterms-authorization/assets/css/import.js create mode 100644 print/templates/email/incoterms-authorization/attachments.json create mode 100644 print/templates/email/incoterms-authorization/incoterms-authorization.html create mode 100755 print/templates/email/incoterms-authorization/incoterms-authorization.js create mode 100644 print/templates/email/incoterms-authorization/locale/es.yml create mode 100644 print/templates/email/incoterms-authorization/locale/fr.yml create mode 100644 print/templates/email/incoterms-authorization/locale/pt.yml create mode 100644 print/templates/email/letter-debtor-st/locale/pt.yml delete mode 100644 print/templates/reports/cmr-authorization/sql/ticket.sql rename print/templates/reports/{cmr-authorization => incoterms-authorization}/assets/css/import.js (100%) rename print/templates/reports/{cmr-authorization => incoterms-authorization}/assets/css/style.css (69%) rename print/templates/reports/{cmr-authorization => incoterms-authorization}/assets/images/signature.png (100%) rename print/templates/reports/{cmr-authorization/cmr-authorization.html => incoterms-authorization/incoterms-authorization.html} (72%) rename print/templates/reports/{cmr-authorization/cmr-authorization.js => incoterms-authorization/incoterms-authorization.js} (69%) rename print/templates/reports/{cmr-authorization => incoterms-authorization}/locale/es.yml (58%) create mode 100644 print/templates/reports/incoterms-authorization/locale/fr.yml create mode 100644 print/templates/reports/incoterms-authorization/locale/pt.yml rename print/templates/reports/{cmr-authorization => incoterms-authorization}/sql/client.sql (100%) create mode 100644 print/templates/reports/incoterms-authorization/sql/company.sql diff --git a/back/helpers.spec.js b/back/helpers.spec.js new file mode 100644 index 000000000..ba8936d41 --- /dev/null +++ b/back/helpers.spec.js @@ -0,0 +1,5 @@ +const baseTime = null; // new Date(2022, 0, 19, 8, 0, 0, 0); +if (baseTime) { + jasmine.clock().install(); + jasmine.clock().mockDate(baseTime); +} diff --git a/back/methods/account/set-password.js b/back/methods/account/set-password.js index fc54b5abe..ab4d3b3fe 100644 --- a/back/methods/account/set-password.js +++ b/back/methods/account/set-password.js @@ -1,16 +1,15 @@ - module.exports = Self => { Self.remoteMethod('setPassword', { description: 'Sets the user password', accepts: [ { arg: 'id', - type: 'Number', + type: 'number', description: 'The user id', http: {source: 'path'} }, { arg: 'newPassword', - type: 'String', + type: 'string', description: 'The new password', required: true } diff --git a/back/methods/dms/deleteTrashFiles.js b/back/methods/dms/deleteTrashFiles.js index 716e03311..7cfb9f8d1 100644 --- a/back/methods/dms/deleteTrashFiles.js +++ b/back/methods/dms/deleteTrashFiles.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); const fs = require('fs-extra'); const path = require('path'); @@ -26,6 +27,9 @@ module.exports = Self => { myOptions.transaction = tx; try { + if (process.env.NODE_ENV == 'test') + throw new UserError(`Action not allowed on the test environment`); + const models = Self.app.models; const DmsContainer = models.DmsContainer; @@ -33,9 +37,15 @@ module.exports = Self => { where: {code: 'trash'} }, myOptions); + const date = new Date(); + date.setMonth(date.getMonth() - 4); + const dmsToDelete = await models.Dms.find({ where: { - dmsTypeFk: trashDmsType.id + and: [ + {dmsTypeFk: trashDmsType.id}, + {created: {lt: date}} + ] } }, myOptions); @@ -43,8 +53,14 @@ module.exports = Self => { const pathHash = DmsContainer.getHash(dms.id); const dmsContainer = await DmsContainer.container(pathHash); const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file); + const dstFolder = path.join(dmsContainer.client.root, pathHash); await fs.unlink(dstFile); - await dms.destroy(myOptions); + try { + await fs.rmdir(dstFolder); + await dms.destroy(myOptions); + } catch (err) { + await dms.destroy(myOptions); + } } if (tx) await tx.commit(); } catch (e) { diff --git a/back/models/warehouse.json b/back/models/warehouse.json index eb86e2114..dcbf7f2d2 100644 --- a/back/models/warehouse.json +++ b/back/models/warehouse.json @@ -24,9 +24,6 @@ }, "isManaged":{ "type": "boolean" - }, - "hasStowaway":{ - "type": "boolean" } }, "acls": [ diff --git a/back/nodemonConfig.json b/back/nodemonConfig.json index a1c9ca84f..5138bc30e 100644 --- a/back/nodemonConfig.json +++ b/back/nodemonConfig.json @@ -18,6 +18,7 @@ "modules/supplier/front/**/*", "modules/ticket/front/**/*", "modules/travel/front/**/*", + "modules/shelving/front/**/*", "modules/worker/front/**/*", "modules/zone/front/**/*" ] diff --git a/db/Dockerfile b/db/Dockerfile index 8980c34f4..cb3aa741c 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -1,4 +1,4 @@ -FROM mariadb:10.4.13 +FROM mariadb:10.7.3 ENV MYSQL_ROOT_PASSWORD root ENV TZ Europe/Madrid @@ -31,11 +31,13 @@ COPY \ import-changes.sh \ config.ini \ dump/mysqlPlugins.sql \ + dump/mockDate.sql \ dump/structure.sql \ dump/dumpedFixtures.sql \ ./ RUN gosu mysql docker-init.sh \ && docker-dump.sh mysqlPlugins \ + && docker-dump.sh mockDate \ && docker-dump.sh structure \ && docker-dump.sh dumpedFixtures \ && gosu mysql docker-temp-stop.sh diff --git a/db/changes/10480-june/00-ACL.sql b/db/changes/10480-june/00-ACL.sql new file mode 100644 index 000000000..b13e56e21 --- /dev/null +++ b/db/changes/10480-june/00-ACL.sql @@ -0,0 +1,21 @@ +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES + ('InvoiceOut','refund','WRITE','ALLOW','ROLE','invoicing'), + ('InvoiceOut','refund','WRITE','ALLOW','ROLE','salesAssistant'), + ('InvoiceOut','refund','WRITE','ALLOW','ROLE','claimManager'), + ('Ticket','refund','WRITE','ALLOW','ROLE','invoicing'), + ('Ticket','refund','WRITE','ALLOW','ROLE','salesAssistant'), + ('Ticket','refund','WRITE','ALLOW','ROLE','claimManager'), + ('Sale','refund','WRITE','ALLOW','ROLE','salesAssistant'), + ('Sale','refund','WRITE','ALLOW','ROLE','claimManager'), + ('TicketRefund','*','WRITE','ALLOW','ROLE','invoicing'), + ('ClaimObservation','*','WRITE','ALLOW','ROLE','salesPerson'), + ('ClaimObservation','*','READ','ALLOW','ROLE','salesPerson'), + ('Client','setPassword','WRITE','ALLOW','ROLE','salesPerson'), + ('Client','updateUser','WRITE','ALLOW','ROLE','salesPerson'); + +DELETE FROM `salix`.`ACL` WHERE id=313; + +UPDATE `salix`.`ACL` + SET principalId='invoicing' + WHERE id=297; \ No newline at end of file diff --git a/db/changes/10480-june/00-aclShelvingLog.sql b/db/changes/10480-june/00-aclShelvingLog.sql new file mode 100644 index 000000000..dc75142d1 --- /dev/null +++ b/db/changes/10480-june/00-aclShelvingLog.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES + ('ShelvingLog','*','READ','ALLOW','ROLE','employee'); \ No newline at end of file diff --git a/db/changes/10480-june/00-aclZoneExclusionGeos.sql b/db/changes/10480-june/00-aclZoneExclusionGeos.sql new file mode 100644 index 000000000..4c0f6c991 --- /dev/null +++ b/db/changes/10480-june/00-aclZoneExclusionGeos.sql @@ -0,0 +1,4 @@ +INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('ZoneExclusionGeo', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('ZoneExclusionGeo', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'); \ No newline at end of file diff --git a/db/changes/10480-june/00-albaran_gestdoc.sql b/db/changes/10480-june/00-albaran_gestdoc.sql new file mode 100644 index 000000000..a0ba93bd3 --- /dev/null +++ b/db/changes/10480-june/00-albaran_gestdoc.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn2008`.`albaran_gestdoc` DROP FOREIGN KEY fk_albaran_gestdoc_gestdoc1; +ALTER TABLE `vn2008`.`albaran_gestdoc` ADD CONSTRAINT albaran_gestdoc_FK FOREIGN KEY (gestdoc_id) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/changes/10480-june/00-client.sql b/db/changes/10480-june/00-client.sql new file mode 100644 index 000000000..4a39bbdf9 --- /dev/null +++ b/db/changes/10480-june/00-client.sql @@ -0,0 +1,3 @@ +alter table `vn`.`client` + add hasIncoterms tinyint(1) default 0 not null comment 'Received incoterms authorization from client'; + diff --git a/db/changes/10480-june/00-deprecations.sql b/db/changes/10480-june/00-deprecations.sql new file mode 100644 index 000000000..68becd13e --- /dev/null +++ b/db/changes/10480-june/00-deprecations.sql @@ -0,0 +1,13 @@ +DROP FUNCTION `account`.`userGetId`; +DROP FUNCTION `account`.`myUserGetName`; +DROP FUNCTION `account`.`myUserGetId`; +DROP FUNCTION `account`.`myUserHasRole`; +DROP FUNCTION `account`.`myUserHasRoleId`; +DROP FUNCTION `account`.`userGetName`; +DROP FUNCTION `account`.`userHasRole`; +DROP FUNCTION `account`.`userHasRoleId`; +DROP PROCEDURE `account`.`myUserLogout`; +DROP PROCEDURE `account`.`userLogin`; +DROP PROCEDURE `account`.`userLoginWithKey`; +DROP PROCEDURE `account`.`userLoginWithName`; +DROP PROCEDURE `account`.`userSetPassword`; \ No newline at end of file diff --git a/db/changes/10480-june/00-item.sql b/db/changes/10480-june/00-item.sql new file mode 100644 index 000000000..a08d3f4c1 --- /dev/null +++ b/db/changes/10480-june/00-item.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`item` MODIFY COLUMN description TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; diff --git a/db/changes/10480-june/00-route.sql b/db/changes/10480-june/00-route.sql new file mode 100644 index 000000000..beb7d5e41 --- /dev/null +++ b/db/changes/10480-june/00-route.sql @@ -0,0 +1,10 @@ +UPDATE `vn`.`route` r + JOIN(SELECT r.id, wl.workcenterFk + FROM `vn`.`route` r + JOIN `vn`.`routeLog` rl ON rl.originFk = r.id + JOIN `vn`.`workerLabour` wl ON wl.workerFk = rl.userFk + AND r.created BETWEEN wl.started AND IFNULL(wl.ended, r.created) + WHERE r.created BETWEEN '2021-12-01' AND CURDATE() + AND rl.action = 'insert' + )sub ON sub.id = r.id + SET r.commissionWorkCenterFk = sub.workcenterFk; \ No newline at end of file diff --git a/db/changes/10480-june/00-sample.sql b/db/changes/10480-june/00-sample.sql new file mode 100644 index 000000000..18beb736d --- /dev/null +++ b/db/changes/10480-june/00-sample.sql @@ -0,0 +1,2 @@ +INSERT INTO `vn`.`sample` (code, description, isVisible, hasCompany, hasPreview, datepickerEnabled) +VALUES ('incoterms-authorization', 'Autorización de incoterms', 1, 1, 1, 0); \ No newline at end of file diff --git a/db/changes/10480-june/00-shelving.sql b/db/changes/10480-june/00-shelving.sql new file mode 100644 index 000000000..c66d164c4 --- /dev/null +++ b/db/changes/10480-june/00-shelving.sql @@ -0,0 +1,18 @@ +ALTER TABLE `vn`.`itemShelving` DROP FOREIGN KEY itemShelving_fk2; +ALTER TABLE `vn`.`shelvingLog` DROP FOREIGN KEY shelvingLog_FK_ibfk_1; +ALTER TABLE `vn`.`smartTag` DROP FOREIGN KEY smartTag_shelving_fk; +ALTER TABLE `vn`.`workerShelving` DROP FOREIGN KEY workerShelving_shelving_fk; + +ALTER TABLE `vn`.`shelving` DROP PRIMARY KEY; +ALTER TABLE `vn`.`shelving` ADD id INT auto_increment PRIMARY KEY NULL; +ALTER TABLE `vn`.`shelving` CHANGE id id int(11) auto_increment NOT NULL FIRST; +ALTER TABLE `vn`.`shelving` ADD CONSTRAINT shelving_UN UNIQUE KEY (code); + +ALTER TABLE `vn`.`itemShelving` ADD CONSTRAINT itemShelving_fk2 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `vn`.`shelvingLog` ADD CONSTRAINT shelvingLog_FK_ibfk_1 FOREIGN KEY (originFk) REFERENCES `vn`.`shelving`(code) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `vn`.`smartTag` ADD CONSTRAINT smartTag_FK FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `vn`.`workerShelving` ADD CONSTRAINT workerShelving_FK_1 FOREIGN KEY (shelvingFk) REFERENCES `vn`.`shelving`(code) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE vn.shelvingLog DROP FOREIGN KEY shelvingLog_FK_ibfk_1; +ALTER TABLE vn.shelvingLog MODIFY COLUMN originFk INT NOT NULL; +ALTER TABLE vn.shelvingLog ADD CONSTRAINT shelvingLog_FK FOREIGN KEY (originFk) REFERENCES vn.shelving(id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/changes/10480-june/00-ticketRefund_beforeUpsert.sql b/db/changes/10480-june/00-ticketRefund_beforeUpsert.sql new file mode 100644 index 000000000..e6506c5d7 --- /dev/null +++ b/db/changes/10480-june/00-ticketRefund_beforeUpsert.sql @@ -0,0 +1,21 @@ +DROP PROCEDURE IF EXISTS `vn`.`ticketRefund_beforeUpsert`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketRefund_beforeUpsert`(vRefundTicketFk INT, vOriginalTicketFk INT) +BEGIN + DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE; + + IF vRefundTicketFk = vOriginalTicketFk THEN + CALL util.throw('Original ticket and refund ticket has same id'); + END IF; + + SELECT COUNT(*) INTO vAlreadyExists + FROM ticketRefund + WHERE originalTicketFk = vOriginalTicketFk; + + IF vAlreadyExists > 0 THEN + CALL util.throw('This ticket is already a refund'); + END IF; +END$$ +DELIMITER ; diff --git a/db/changes/10480-june/01-claimObservation.sql b/db/changes/10480-june/01-claimObservation.sql new file mode 100644 index 000000000..8dc126a9e --- /dev/null +++ b/db/changes/10480-june/01-claimObservation.sql @@ -0,0 +1,13 @@ +CREATE TABLE `vn`.`claimObservation` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `claimFk` int(10) unsigned NOT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, + `text` text COLLATE utf8_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `worker_key` (`workerFk`), + KEY `claim_key` (`claimFk`), + KEY `claimObservation_created_IDX` (`created`) USING BTREE, + CONSTRAINT `claimObservation_ibfk_1` FOREIGN KEY (`claimFk`) REFERENCES `vn`.`claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `claimObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE +) COMMENT='Todas las observaciones referentes a una reclamación' \ No newline at end of file diff --git a/db/changes/10480-june/02-claimTextMigration.sql b/db/changes/10480-june/02-claimTextMigration.sql new file mode 100644 index 000000000..fa5f6fe83 --- /dev/null +++ b/db/changes/10480-june/02-claimTextMigration.sql @@ -0,0 +1,2 @@ +INSERT INTO `vn`.`claimObservation` (`claimFk`, `text`, `created`) +SELECT `id`, `observation`, `created` FROM `vn`.`claim` \ No newline at end of file diff --git a/db/changes/10480-june/04-aclParking.sql b/db/changes/10480-june/04-aclParking.sql new file mode 100644 index 000000000..05acd68b1 --- /dev/null +++ b/db/changes/10480-june/04-aclParking.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES ('Parking','*','*','ALLOW','ROLE','employee') \ No newline at end of file diff --git a/db/changes/10480-june/04-aclShelving.sql b/db/changes/10480-june/04-aclShelving.sql new file mode 100644 index 000000000..b237dfe0d --- /dev/null +++ b/db/changes/10480-june/04-aclShelving.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) + VALUES ('Shelving','*','*','ALLOW','ROLE','employee') \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 100a68ffb..78899b82d 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1,6 +1,9 @@ CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `tmp`; +UPDATE `util`.`config` + SET `environment`= 'test'; + ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; @@ -8,8 +11,7 @@ ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) VALUES - ('DEFAULT_TOKEN', '1209600', CURDATE(), 66); - + ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66); INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES @@ -135,16 +137,16 @@ INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) VALUES (1, 'Main Warehouse'), - (2, 'Silla'); + (2, 'Gotham'); -INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`) +INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`) VALUES - (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 2, 1, 1), - (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 0, 1, 2, 13, 1), - (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1), - (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1), - (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1), - (13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 0, 2, 1, 0); + (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 2, 1, 1), + (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 2, 13, 1), + (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1), + (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1), + (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1), + (13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0); INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`) VALUES @@ -153,14 +155,29 @@ INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPrepare INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) VALUES - ('1', '700', '01', '1', '700-01', '70001'), - ('2', '700', '02', '2', '700-02', '70002'); + ('1', 700, '01', 1, '700-01', 70001), + ('2', 700, '02', 2, '700-02', 70002), + ('3', 100, '01', 1, '100-01', 1), + (32397, 100, '02', 1, 'A-47-1', 1165), + (34831, 200, '01', 1, 'K-26-2', 20220), + (34965, 200, '02', 2, 'L-08-4', 21800), + (39096, 200, '03', 2, 'LR-02-3', 99999); -INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`) +INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`) VALUES - ('GVC', 1, 0, 1, 0, 1106), - ('HEJ', 2, 0, 1, 0, 1106), - ('UXN', 1, 0, 1, 0, 1106); + ('AA6', 34965, 1, 0, NULL, 0), + ('AA7', 34965, 1, 0, NULL, 0), + ('AA8', 34965, 1, 0, NULL, 0), + ('AA9', NULL, 1, 0, NULL, 0), + ('AAA', NULL, 0, 0, 1109, 1), + ('AAB', NULL, 0, 0, 1109, 1), + ('AAC', NULL, 1, 99, 1109, 1), + ('AAD', NULL, 0, 0, 1109, 1), + ('AAE', 39096, 1, 0, 1109, 1), + ('AAF', 34831, 1, 0, 1109, 1), + ('GVC', 1, 0, 1, 1106, 1), + ('HEJ', 2, 0, 1, 1106, 1), + ('UXN', 1, 0, 1, 1106, 1); INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`) VALUES @@ -173,21 +190,18 @@ INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`cod (7, 'Leasing', NULL, NULL, NULL, 0), (8, 'Compensations', 'Compensations', 'compensation', NULL, 0); -INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`) +INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`) VALUES - (1, 1, 'The Worst Bank', 'BBKKESMMMMMM'), - (128, 1, 'The Best Bank', 'TBKKESMMMMMM'), - (3117, 1, 'Another Bank', 'ANOKESMMMMMM'), - (2100, 1, 'Caixa Bank', 'CAIXESBB'); - -INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) - VALUES - (1, 'Pay on receipt', '5720000001', 3, 1, 1, 1), - (2, 'Cash', '5700000001', 2, 1, 1, 1), - (3, 'Compensation', '4000000000', 8, 1, 1, 1), - (4, 'Transfers', '4000000001', 1, 1, 1, 1), - (3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 3117, 1, 1); + (128, 1, 'The Best Bank', 'BBKKESMMMMMM'), + (2100, 1, 'Caixa Bank', 'CAIXESBB'); +INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) + VALUES + (1, 'Pay on receipt', '5720000001', 3, 128, 1, 1), + (2, 'Cash', '5700000001', 2, 128, 1, 1), + (3, 'Compensation', '4000000000', 8, 128, 1, 1), + (4, 'Transfers', '4000000001', 1, 128, 1, 1), + (3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 2100, 1, 1); INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`) VALUES @@ -198,16 +212,16 @@ INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`) INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`, `bankFk__`, `warehouseAliasFk`) VALUES - (1, 'inhouse pickup' , 1, 1, 1), - (2, 'Super-Man delivery' , 1, 1, 1), - (3, 'Teleportation device' , 1, 1, 1), - (4, 'Entanglement' , 1, 1, 1), - (5, 'Quantum break device' , 1, 1, 1), - (6, 'Walking' , 1, 1, 1), - (7, 'Silla247' , 1, 1, 1), - (8, 'Silla247Expensive' , 1, 1, 1), - (9, 'Refund' , 1, 1, 1), - (10, 'Other agency' , 1, 1, 1); + (1, 'inhouse pickup' , 1, 1, 1), + (2, 'Super-Man delivery' , 1, 1, 1), + (3, 'Teleportation device' , 1, 1, 1), + (4, 'Entanglement' , 1, 1, 1), + (5, 'Quantum break device' , 1, 1, 1), + (6, 'Walking' , 1, 1, 1), + (7, 'Gotham247' , 1, 1, 1), + (8, 'Gotham247Expensive' , 1, 1, 1), + (9, 'Refund' , 1, 1, 1), + (10, 'Other agency' , 1, 1, 1); UPDATE `vn`.`agencyMode` SET `id` = 1 WHERE `name` = 'inhouse pickup'; UPDATE `vn`.`agencyMode` SET `id` = 2 WHERE `name` = 'Super-Man delivery'; @@ -215,8 +229,8 @@ UPDATE `vn`.`agencyMode` SET `id` = 3 WHERE `name` = 'Teleportation device'; UPDATE `vn`.`agencyMode` SET `id` = 4 WHERE `name` = 'Entanglement'; UPDATE `vn`.`agencyMode` SET `id` = 5 WHERE `name` = 'Quantum break device'; UPDATE `vn`.`agencyMode` SET `id` = 6 WHERE `name` = 'Walking'; -UPDATE `vn`.`agencyMode` SET `id` = 7 WHERE `name` = 'Silla247'; -UPDATE `vn`.`agencyMode` SET `id` = 8 WHERE `name` = 'Silla247Expensive'; +UPDATE `vn`.`agencyMode` SET `id` = 7 WHERE `name` = 'Gotham247'; +UPDATE `vn`.`agencyMode` SET `id` = 8 WHERE `name` = 'Gotham247Expensive'; UPDATE `vn`.`agencyMode` SET `id` = 23 WHERE `name` = 'Refund'; UPDATE `vn`.`agencyMode` SET `id` = 10 WHERE `name` = 'Other agency'; @@ -268,7 +282,7 @@ INSERT INTO `vn`.`province`(`id`, `name`, `countryFk`, `autonomyFk`, `warehouseF INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`) VALUES (1, 'Valencia', 1), - (2, 'Silla', 1), + (2, 'Gotham', 1), (3, 'Algemesi', 1), (4, 'Alzira', 1), (5, 'Quito', 5); @@ -302,30 +316,30 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`) VALUES - (1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), - (1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'), - (1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Silla', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'), - (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'), - (1109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist'), - (1110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist'), - (1111, 'Missing', NULL, 'Missing man', 'Anton', 'The space, Universe far away', 'Silla', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL), - (1112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city, Underground', 'Silla', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL); + (1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), + (1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'), + (1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'), + (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'), + (1109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist'), + (1110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist'), + (1111, 'Missing', NULL, 'Missing man', 'Anton', 'The space, Universe far away', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL), + (1112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city, Underground', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL); INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) - SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'SILLA', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, CURDATE(), 1 + SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 FROM `account`.`role` `r` WHERE `r`.`hasLogin` = 1; INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) VALUES - (1101, 50, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (1102, 100, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (1103, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (1104, -30, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)); + (1101, 50, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (1102, 100, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (1103, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (1104, -30, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)); INSERT INTO `vn`.`clientConfig`(`riskTolerance`, `maxCreditRows`) VALUES @@ -333,51 +347,51 @@ INSERT INTO `vn`.`clientConfig`(`riskTolerance`, `maxCreditRows`) INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`) VALUES - (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1), - (2, 'Petter Parker', '20 Ingram Street', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1), - (3, 'Clark Kent', '344 Clinton Street', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1), - (4, 'Tony Stark', '10880 Malibu Point', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 1), - (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1), - (6, 'DavidCharlesHaller', 'Evil hideout', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1), - (7, 'Hank Pym', 'Anthill', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1), - (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1), - (9, 'Bruce Banner', 'Somewhere in New York', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1), - (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1), - (11, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1), - (12, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1), - (101, 'Somewhere in Thailand', 'address 01', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (102, 'Somewhere in Poland', 'address 02', 'Silla', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), - (103, 'Somewhere in Japan', 'address 03', 'Silla', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), - (104, 'Somewhere in Spain', 'address 04', 'Silla', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), - (105, 'Somewhere in Potugal', 'address 05', 'Silla', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), - (106, 'Somewhere in UK', 'address 06', 'Silla', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), - (107, 'Somewhere in Valencia', 'address 07', 'Silla', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), - (108, 'Somewhere in Silla', 'address 08', 'Silla', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), - (109, 'Somewhere in London', 'address 09', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (110, 'Somewhere in Algemesi', 'address 10', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (111, 'Somewhere in Carlet', 'address 11', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (112, 'Somewhere in Campanar', 'address 12', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (113, 'Somewhere in Malilla', 'address 13', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (114, 'Somewhere in France', 'address 14', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (115, 'Somewhere in Birmingham', 'address 15', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (116, 'Somewhere in Scotland', 'address 16', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (117, 'Somewhere in nowhere', 'address 17', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (118, 'Somewhere over the rainbow', 'address 18', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (119, 'Somewhere in Alberic', 'address 19', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (120, 'Somewhere in Montortal', 'address 20', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (121, 'the bat cave', 'address 21', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0), - (122, 'NY roofs', 'address 22', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0), - (123, 'The phone box', 'address 23', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0), - (124, 'Stark tower Silla', 'address 24', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0), - (125, 'The plastic cell', 'address 25', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0), - (126, 'Many places', 'address 26', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0), - (127, 'Your pocket', 'address 27', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0), - (128, 'Cerebro', 'address 28', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0), - (129, 'Luke Cages Bar', 'address 29', 'Silla', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0), - (130, 'Non valid address', 'address 30', 'Silla', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0); + (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1), + (2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1), + (3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1), + (4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 1), + (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1), + (6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1), + (7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1), + (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1), + (9, 'Bruce Banner', 'Somewhere in New York', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1), + (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1), + (11, 'Missing', 'The space', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1), + (12, 'Trash', 'New York city', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1), + (101, 'Somewhere in Thailand', 'address 01', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (102, 'Somewhere in Poland', 'address 02', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), + (103, 'Somewhere in Japan', 'address 03', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), + (104, 'Somewhere in Spain', 'address 04', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), + (105, 'Somewhere in Potugal', 'address 05', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), + (106, 'Somewhere in UK', 'address 06', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), + (107, 'Somewhere in Valencia', 'address 07', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), + (108, 'Somewhere in Gotham', 'address 08', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), + (109, 'Somewhere in London', 'address 09', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (110, 'Somewhere in Algemesi', 'address 10', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (111, 'Somewhere in Carlet', 'address 11', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (112, 'Somewhere in Campanar', 'address 12', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (113, 'Somewhere in Malilla', 'address 13', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (114, 'Somewhere in France', 'address 14', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (115, 'Somewhere in Birmingham', 'address 15', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (116, 'Somewhere in Scotland', 'address 16', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (117, 'Somewhere in nowhere', 'address 17', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (118, 'Somewhere over the rainbow', 'address 18', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (119, 'Somewhere in Alberic', 'address 19', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), + (121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0), + (122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0), + (123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0), + (124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0), + (125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0), + (126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0), + (127, 'Your pocket', 'address 27', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0), + (128, 'Cerebro', 'address 28', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0), + (129, 'Luke Cages Bar', 'address 29', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0), + (130, 'Non valid address', 'address 30', 'Gotham', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0); INSERT INTO `vn`.`address`( `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress`) - SELECT name, CONCAT(name, 'Street'), 'SILLA', 46460, 1, 1, id, 2, 1 + SELECT name, CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, 1, id, 2, 1 FROM `account`.`role` `r` WHERE `r`.`hasLogin` = 1; @@ -407,20 +421,20 @@ DROP TEMPORARY TABLE tmp.address; INSERT INTO `vn`.`clientCredit`(`id`, `clientFk`, `workerFk`, `amount`, `created`) VALUES - (1 , 1101, 5, 300, DATE_ADD(CURDATE(), INTERVAL -11 MONTH)), - (2 , 1101, 5, 900, DATE_ADD(CURDATE(), INTERVAL -10 MONTH)), - (3 , 1101, 5, 800, DATE_ADD(CURDATE(), INTERVAL -9 MONTH)), - (4 , 1101, 5, 700, DATE_ADD(CURDATE(), INTERVAL -8 MONTH)), - (5 , 1101, 5, 600, DATE_ADD(CURDATE(), INTERVAL -7 MONTH)), - (6 , 1101, 5, 500, DATE_ADD(CURDATE(), INTERVAL -6 MONTH)), - (7 , 1101, 5, 400, DATE_ADD(CURDATE(), INTERVAL -5 MONTH)), - (8 , 1101, 9, 300, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), - (9 , 1101, 9, 200, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), - (10, 1101, 9, 100, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (11, 1101, 9, 50 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (12, 1102, 9, 800, CURDATE()), - (14, 1104, 9, 90 , CURDATE()), - (15, 1105, 9, 90 , CURDATE()); + (1 , 1101, 5, 300, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 MONTH)), + (2 , 1101, 5, 900, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 MONTH)), + (3 , 1101, 5, 800, DATE_ADD(util.VN_CURDATE(), INTERVAL -9 MONTH)), + (4 , 1101, 5, 700, DATE_ADD(util.VN_CURDATE(), INTERVAL -8 MONTH)), + (5 , 1101, 5, 600, DATE_ADD(util.VN_CURDATE(), INTERVAL -7 MONTH)), + (6 , 1101, 5, 500, DATE_ADD(util.VN_CURDATE(), INTERVAL -6 MONTH)), + (7 , 1101, 5, 400, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 MONTH)), + (8 , 1101, 9, 300, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), + (9 , 1101, 9, 200, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), + (10, 1101, 9, 100, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), + (11, 1101, 9, 50 , DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (12, 1102, 9, 800, util.VN_CURDATE()), + (14, 1104, 9, 90 , util.VN_CURDATE()), + (15, 1105, 9, 90 , util.VN_CURDATE()); INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`) VALUES @@ -430,16 +444,16 @@ INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`) INSERT INTO `vn`.`clientObservation`(`id`, `clientFk`, `workerFk`, `text`, `created`) VALUES - (1, 1101, 1, 'Madness, as you know, is like gravity, all it takes is a little push', CURDATE()), - (2, 1102, 1, 'With great power, comes great responsibility', CURDATE()), - (3, 1103, 3, 'this is a job for Super-Man!', CURDATE()), - (4, 1104, 3, 'yes... I am Iron-Man', CURDATE()), - (5, 1105, 5, 'They do understand. Our mutant powers make us superior', CURDATE()), - (6, 1106, 5, 'My name is Legion, for we are many!', CURDATE()), - (7, 1107, 9, 'I think our first move should be calling the Avengers..', CURDATE()), - (8, 1108, 9, 'Just because someone stumbles and loses their path, does not mean they are lost forever.', CURDATE()), - (9, 1109, 18, 'HULK SMASH! ...', CURDATE()), - (10, 1110, 18, 'They say everyone is born a hero. But if you let it, life will push you over the line until you are the villain.', CURDATE()); + (1, 1101, 1, 'Madness, as you know, is like gravity, all it takes is a little push', util.VN_CURDATE()), + (2, 1102, 1, 'With great power, comes great responsibility', util.VN_CURDATE()), + (3, 1103, 3, 'this is a job for Super-Man!', util.VN_CURDATE()), + (4, 1104, 3, 'yes... I am Iron-Man', util.VN_CURDATE()), + (5, 1105, 5, 'They do understand. Our mutant powers make us superior', util.VN_CURDATE()), + (6, 1106, 5, 'My name is Legion, for we are many!', util.VN_CURDATE()), + (7, 1107, 9, 'I think our first move should be calling the Avengers..', util.VN_CURDATE()), + (8, 1108, 9, 'Just because someone stumbles and loses their path, does not mean they are lost forever.', util.VN_CURDATE()), + (9, 1109, 18, 'HULK SMASH! ...', util.VN_CURDATE()), + (10, 1110, 18, 'They say everyone is born a hero. But if you let it, life will push you over the line until you are the villain.', util.VN_CURDATE()); INSERT INTO `vn`.`observationType`(`id`,`description`, `code`) VALUES @@ -459,17 +473,17 @@ INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`desc INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`) VALUES - (1, 1101, CURDATE(), CURDATE()), - (2, 1102, CURDATE(), CURDATE()), - (3, 1103, CURDATE(), CURDATE()), - (4, 1104, CURDATE(), CURDATE()), - (5, 1105, CURDATE(), CURDATE()); + (1, 1101, util.VN_CURDATE(), util.VN_CURDATE()), + (2, 1102, util.VN_CURDATE(), util.VN_CURDATE()), + (3, 1103, util.VN_CURDATE(), util.VN_CURDATE()), + (4, 1104, util.VN_CURDATE(), util.VN_CURDATE()), + (5, 1105, util.VN_CURDATE(), util.VN_CURDATE()); INSERT INTO `vn`.`creditInsurance`(`id`, `creditClassificationFk`, `credit`, `creationDate`, `grade`) VALUES - (1, 1, 3000, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL), - (2, 2, 6000, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL), - (3, 3, 10000, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL); + (1, 1, 3000, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL), + (2, 2, 6000, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL), + (3, 3, 10000, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL); INSERT INTO `vn`.`companyGroup`(`id`, `code`) VALUES @@ -494,9 +508,9 @@ INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `pr INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`) VALUES - (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), - (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), - (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'); + (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), + (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'); INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`) VALUES @@ -535,11 +549,11 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES - (1, 'T', 1014.24, CURDATE(), 1101, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0), - (2, 'T', 121.36, CURDATE(), 1102, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0), - (3, 'T', 8.88, CURDATE(), 1103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0), - (4, 'T', 8.88, CURDATE(), 1103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0), - (5, 'A', 8.88, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 0); + (1, 'T', 1014.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (4, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0); UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1; UPDATE `vn`.`invoiceOut` SET ref = 'T2222222' WHERE id = 2; @@ -570,29 +584,29 @@ INSERT INTO `vn`.`expence`(`id`, `name`, `isWithheld`) INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk`, `created`) VALUES - (1, 1, 813.06, 2000000000, CURDATE()), - (2, 1, 33.80, 4751000000, CURDATE()), - (3, 1, 70.70, 6210000567, CURDATE()), - (4, 2, 110.33, 2000000000, CURDATE()), - (5, 3, 8.07, 2000000000, CURDATE()), - (6, 4, 8.07, 2000000000, CURDATE()), - (7, 5, 8.07, 2000000000, CURDATE()); + (1, 1, 813.06, 2000000000, util.VN_CURDATE()), + (2, 1, 33.80, 4751000000, util.VN_CURDATE()), + (3, 1, 70.70, 6210000567, util.VN_CURDATE()), + (4, 2, 110.33, 2000000000, util.VN_CURDATE()), + (5, 3, 8.07, 2000000000, util.VN_CURDATE()), + (6, 4, 8.07, 2000000000, util.VN_CURDATE()), + (7, 5, 8.07, 2000000000, util.VN_CURDATE()); INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize`) VALUES - (1, 'Zone pickup A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), - (2, 'Zone pickup B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), - (3, 'Zone 247 A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), - (4, 'Zone 247 B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), - (5, 'Zone expensive A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100), - (6, 'Zone expensive B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100), - (7, 'Zone refund', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 23, 0, 0, 0, 100), - (8, 'Zone others', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 10, 0, 0, 0, 100), - (9, 'Zone superMan', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 2, 0, 0, 0, 100), - (10, 'Zone teleportation', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 3, 0, 0, 0, 100), - (11, 'Zone pickup C', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), - (12, 'Zone entanglement', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 4, 0, 0, 0, 100), - (13, 'Zone quantum break', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 5, 0, 0, 0, 100); + (1, 'Zone pickup A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), + (2, 'Zone pickup B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), + (3, 'Zone 247 A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), + (4, 'Zone 247 B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), + (5, 'Zone expensive A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100), + (6, 'Zone expensive B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100), + (7, 'Zone refund', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 23, 0, 0, 0, 100), + (8, 'Zone others', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 10, 0, 0, 0, 100), + (9, 'Zone superMan', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 2, 0, 0, 0, 100), + (10, 'Zone teleportation', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 3, 0, 0, 0, 100), + (11, 'Zone pickup C', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), + (12, 'Zone entanglement', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 4, 0, 0, 0, 100), + (13, 'Zone quantum break', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 5, 0, 0, 0, 100); INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) VALUES @@ -612,61 +626,61 @@ INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) VALUES - (1, CURDATE(), '23:59'), - (2, CURDATE(), '23:59'), - (3, CURDATE(), '23:59'), - (4, CURDATE(), '23:59'), - (5, CURDATE(), '23:59'), - (6, CURDATE(), '23:59'), - (7, CURDATE(), '23:59'), - (8, CURDATE(), '23:59'), - (9, CURDATE(), '23:59'), - (10, CURDATE(), '23:59'), - (11, CURDATE(), '23:59'), - (12, CURDATE(), '23:59'), - (13, CURDATE(), '23:59'); + (1, util.VN_CURDATE(), '23:59'), + (2, util.VN_CURDATE(), '23:59'), + (3, util.VN_CURDATE(), '23:59'), + (4, util.VN_CURDATE(), '23:59'), + (5, util.VN_CURDATE(), '23:59'), + (6, util.VN_CURDATE(), '23:59'), + (7, util.VN_CURDATE(), '23:59'), + (8, util.VN_CURDATE(), '23:59'), + (9, util.VN_CURDATE(), '23:59'), + (10, util.VN_CURDATE(), '23:59'), + (11, util.VN_CURDATE(), '23:59'), + (12, util.VN_CURDATE(), '23:59'), + (13, util.VN_CURDATE(), '23:59'); INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1'); INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`) VALUES - (1, '1899-12-30 12:15:00', 56, CURDATE(), 1, 1, 'first route', 1.8, 10, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1), - (2, '1899-12-30 13:20:00', 56, CURDATE(), 1, 2, 'second route', 0.2, 20, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 9), - (3, '1899-12-30 14:30:00', 56, CURDATE(), 2, 3, 'third route', 0.5, 30, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 10), - (4, '1899-12-30 15:45:00', 56, CURDATE(), 3, 4, 'fourth route', 0, 40, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 12), - (5, '1899-12-30 16:00:00', 56, CURDATE(), 4, 5, 'fifth route', 0.1, 50, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 13), - (6, NULL, 57, CURDATE(), 5, 7, 'sixth route', 1.7, 60, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 3), - (7, NULL, 57, CURDATE(), 6, 8, 'seventh route', 0, 70, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 5); + (1, '1899-12-30 12:15:00', 56, util.VN_CURDATE(), 1, 1, 'first route', 1.8, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1), + (2, '1899-12-30 13:20:00', 56, util.VN_CURDATE(), 1, 2, 'second route', 0.2, 20, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 9), + (3, '1899-12-30 14:30:00', 56, util.VN_CURDATE(), 2, 3, 'third route', 0.5, 30, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 10), + (4, '1899-12-30 15:45:00', 56, util.VN_CURDATE(), 3, 4, 'fourth route', 0, 40, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 12), + (5, '1899-12-30 16:00:00', 56, util.VN_CURDATE(), 4, 5, 'fifth route', 0.1, 50, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 13), + (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3), + (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5); INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`) VALUES - (1 , 3, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, 'T1111111', 0, 1, 5, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (2 , 1, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T1111111', 0, 1, 5, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (3 , 1, 7, 1, 6, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T2222222', 0, 3, 5, 1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (4 , 3, 2, 1, 2, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T3333333', 0, 9, 5, 1, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), - (5 , 3, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T4444444', 0, 10, 5, 1, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), - (6 , 1, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, 'A1111111', 0, 10, 5, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (7 , NULL, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, CURDATE()), - (8 , NULL, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, CURDATE()), - (9 , NULL, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, CURDATE()), - (10, 1, 1, 5, 1, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, CURDATE()), - (11, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, CURDATE()), - (12, 1, 8, 1, 1, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, CURDATE()), - (13, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, CURDATE()), - (14, 1, 2, 1, NULL, CURDATE(), CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, CURDATE()), - (15, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, CURDATE()), - (16, 1, 7, 1, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, CURDATE()), - (17, 1, 7, 2, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, CURDATE()), - (18, 1, 4, 4, 4, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, CURDATE()), - (19, 1, 5, 5, NULL, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, CURDATE()), - (20, 1, 5, 5, 3, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (21, NULL, 5, 5, 5, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (22, NULL, 5, 5, 5, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (23, NULL, 8, 1, 7, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, CURDATE()), - (24 ,NULL, 8, 1, 7, CURDATE(), CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, CURDATE()), - (25 ,NULL, 8, 1, NULL, CURDATE(), CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, CURDATE()), - (26 ,NULL, 8, 1, NULL, CURDATE(), CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, CURDATE()), - (27 ,NULL, 8, 1, NULL, CURDATE(), CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, CURDATE()); + (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, 'T1111111', 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T1111111', 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T2222222', 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), + (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T3333333', 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), + (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, 'T4444444', 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), + (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, 'A1111111', 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE()), + (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE()), + (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE()), + (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE()), + (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE()), + (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE()), + (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE()), + (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE()), + (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE()), + (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE()), + (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE()), + (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, util.VN_CURDATE()), + (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE()), + (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE()), + (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE()), + (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()), + (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()), + (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE()); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES @@ -684,42 +698,38 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des (12, 11, 3, 'Delivery after 10am'); -- FIX for state hours on local, inter_afterInsert -UPDATE vncontrol.inter SET odbc_date = DATE_ADD(CURDATE(), INTERVAL -10 SECOND); +UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND); INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`) VALUES - (1, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)), - (2, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)), - (3, 16, 5 , DATE_ADD(NOW(), INTERVAL -2 MONTH)), - (4, 16, 5 , DATE_ADD(NOW(), INTERVAL -3 MONTH)), - (5, 16, 18, DATE_ADD(NOW(), INTERVAL -4 MONTH)), - (6, 16, 18, DATE_ADD(NOW(), INTERVAL -1 MONTH)), - (7, 10, 18, NOW()), - (8, 5, 19, NOW()), - (9, 5, 19, NOW()), - (10, 5, 19, NOW()), - (11, 3, 19, NOW()), - (12, 3, 19, NOW()), - (13, 3, 19, NOW()), - (14, 3, 19, NOW()), - (15, 2, 19, NOW()), - (16, 3, 19, NOW()), - (17, 2, 19, NOW()), - (18, 2, 19, NOW()), - (19, 2, 19, NOW()), - (20, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), - (21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), - (22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), - (23, 16, 21, NOW()), - (24, 16, 21, NOW()); - -INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`) - VALUES - (12, 13, CURDATE()); + (1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)), + (2, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)), + (3, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -2 MONTH)), + (4, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -3 MONTH)), + (5, 16, 18, DATE_ADD(util.VN_NOW(), INTERVAL -4 MONTH)), + (6, 16, 18, DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)), + (7, 10, 18, util.VN_NOW()), + (8, 5, 19, util.VN_NOW()), + (9, 5, 19, util.VN_NOW()), + (10, 5, 19, util.VN_NOW()), + (11, 3, 19, util.VN_NOW()), + (12, 3, 19, util.VN_NOW()), + (13, 3, 19, util.VN_NOW()), + (14, 3, 19, util.VN_NOW()), + (15, 2, 19, util.VN_NOW()), + (16, 3, 19, util.VN_NOW()), + (17, 2, 19, util.VN_NOW()), + (18, 2, 19, util.VN_NOW()), + (19, 2, 19, util.VN_NOW()), + (20, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), + (21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), + (22, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), + (23, 16, 21, util.VN_NOW()), + (24, 16, 21, util.VN_NOW()); INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`) VALUES - (1, 'Silla','46460 Av Espioca 100-Silla'); + (1, 'Gotham','1007 Mountain Drive, Gotham'); INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk`) VALUES @@ -732,7 +742,7 @@ INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`) VALUES - (1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(CURDATE(),INTERVAL -1 MONTH)); + (1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH)); INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`) VALUES @@ -746,18 +756,18 @@ INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`) INSERT INTO `vn`.`greuge`(`id`, `clientFk`, `description`, `amount`, `shipped`, `created`, `greugeTypeFk`, `ticketFk`) VALUES - (1, 1101, 'some diff charges', -19.99, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 1, 1), - (2, 1101, 'more diff charges', 60, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 2, 1), - (3, 1101, 'even more! diff charges', -9.99, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 3, 1), - (4, 1101, 'insane diff charges', 60, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 4, 1), - (5, 1101, 'gargantuous diff charges', -9.99, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 5, 1), - (6, 1101, 'diff charges', 88.30, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 6, 1), - (7, 1101, 'unaffordable diff charges', -39.12, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 1, 1), - (8, 1101, 'some recovery charges', 29.35, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 2, 1), - (9, 1101, 'some manna charges', -9.99, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 3, 1), - (10, 1101, 'some claim charges', 13.13, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 4, 1), - (11, 1101, 'some heritage charges', -15.99, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 5, 1), - (12, 1101, 'some miscellaneous charges', 58.00, DATE_ADD(CURDATE(), INTERVAL 1 MONTH), CURDATE(), 6, 1); + (1, 1101, 'some diff charges', -19.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 1, 1), + (2, 1101, 'more diff charges', 60, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 2, 1), + (3, 1101, 'even more! diff charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 3, 1), + (4, 1101, 'insane diff charges', 60, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 4, 1), + (5, 1101, 'gargantuous diff charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 5, 1), + (6, 1101, 'diff charges', 88.30, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 6, 1), + (7, 1101, 'unaffordable diff charges', -39.12, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 1, 1), + (8, 1101, 'some recovery charges', 29.35, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 2, 1), + (9, 1101, 'some manna charges', -9.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 3, 1), + (10, 1101, 'some claim charges', 13.13, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 4, 1), + (11, 1101, 'some heritage charges', -15.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 5, 1), + (12, 1101, 'some miscellaneous charges', 58.00, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 6, 1); INSERT INTO `vn`.`mandateType`(`id`, `name`) VALUES @@ -767,7 +777,7 @@ INSERT INTO `vn`.`mandateType`(`id`, `name`) INSERT INTO `vn`.`mandate`(`id`, `clientFk`, `companyFk`, `code`, `created`, `mandateTypeFk`) VALUES - (1, 1102, 442, '1-1', CURDATE(), 2); + (1, 1102, 442, '1-1', util.VN_CURDATE(), 2); INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code`) VALUES @@ -822,10 +832,10 @@ INSERT INTO `vn`.`taxType`(`id`, `nickname`, `isAccrued`, `serial`, `TIPOOPE`, ` INSERT INTO `vn`.`taxCode`(`id`, `dated`, `code`, `taxTypeFk`, `rate`, `equalizationTax`, `type`, `link`, `isActive`, `updated`, `transactionCode`) VALUES - (1 , CURDATE(), '1111111111', 1, 7.0 , 0.0, 'R', 1, 1, CURDATE(), 1), - (2 , CURDATE(), '2222222222', 2, 16.0, 0.0, 'G', 2, 1, CURDATE(), 1), - (21 , CURDATE(), '3333333333', 1, 7.0, 0.0, 'R', 3, 1, CURDATE(), 1), - (108, CURDATE(), '4444444444', 2, 8.0 , 0.0, 'R', 4, 1, CURDATE(), 1); + (1 , util.VN_CURDATE(), '1111111111', 1, 7.0 , 0.0, 'R', 1, 1, util.VN_CURDATE(), 1), + (2 , util.VN_CURDATE(), '2222222222', 2, 16.0, 0.0, 'G', 2, 1, util.VN_CURDATE(), 1), + (21 , util.VN_CURDATE(), '3333333333', 1, 7.0, 0.0, 'R', 3, 1, util.VN_CURDATE(), 1), + (108, util.VN_CURDATE(), '4444444444', 2, 8.0 , 0.0, 'R', 4, 1, util.VN_CURDATE(), 1); INSERT INTO `vn`.`taxClass`(`id`, `description`, `code`) VALUES @@ -834,9 +844,9 @@ INSERT INTO `vn`.`taxClass`(`id`, `description`, `code`) INSERT INTO `vn`.`taxClassCode`(`taxClassFk`, `effectived`, `taxCodeFk`) VALUES - (1, CURDATE(), 1), - (1, CURDATE(), 21), - (2, CURDATE(), 2); + (1, util.VN_CURDATE(), 1), + (1, util.VN_CURDATE(), 21), + (2, util.VN_CURDATE(), 2); INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) VALUES @@ -876,9 +886,9 @@ UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`, `started`, `ended`, `bonus`, `warehouseFk`, `created`) VALUES - (1, 1, 0, 0, 2.5, 2, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()), - (2, 3, 10, 10, 10, 10, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()), - (3, 13, 8.5, 10, 7.5, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 1, 2, CURDATE()); + (1, 1, 0, 0, 2.5, 2, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 0, 1, util.VN_CURDATE()), + (2, 3, 10, 10, 10, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 0, 1, util.VN_CURDATE()), + (3, 13, 8.5, 10, 7.5, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 1, 2, util.VN_CURDATE()); INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`) VALUES @@ -886,15 +896,14 @@ INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`) INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price`) VALUES - (1, 0.00, 10, 10, 0, 1, CURDATE(), 6, 1.50), - (2, 100.00, 20, 20, 0, 1, CURDATE(), 7, 1.00), - (3, 14000.00, 0, 0, 0, 1, CURDATE(), NULL, 0), - (4, 218000.00, 0, 0, 0, 0, CURDATE(), NULL, 0), - (5, 292000.00, 0, 0, 0, 0, CURDATE(), NULL, 0), - (94, 140875.00, 49.00, 115.00, 25.00, 0, CURDATE(), 71, 0.00), - ('cc', 1640038.00, 56.00, 220.00, 128.00, 1, CURDATE(), 15, 90.00), - ('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, CURDATE(), 16, 0.00); - + (1, 0.00, 10, 10, 0, 1, util.VN_CURDATE(), 6, 1.50), + (2, 100.00, 20, 20, 0, 1, util.VN_CURDATE(), 7, 1.00), + (3, 14000.00, 0, 0, 0, 1, util.VN_CURDATE(), NULL, 0), + (4, 218000.00, 0, 0, 0, 0, util.VN_CURDATE(), NULL, 0), + (5, 292000.00, 0, 0, 0, 0, util.VN_CURDATE(), NULL, 0), + (94, 140875.00, 49.00, 115.00, 25.00, 0, util.VN_CURDATE(), 71, 0.00), + ('cc', 1640038.00, 56.00, 220.00, 128.00, 1, util.VN_CURDATE(), 15, 90.00), + ('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, util.VN_CURDATE(), 16, 0.00); INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`) VALUES @@ -905,68 +914,68 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`) INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`) VALUES - (1, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1), - (2, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1), - (3, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2), - (4, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2), - (5, 1, 2, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3), - (6, 7, 3, 71, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3), - (7, 2, 4, 71, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL), - (8, 3, 5, 71, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1), - (9, 3, 6, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2), - (10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3); + (1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1), + (2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1), + (3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2), + (4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2), + (5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3), + (6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3), + (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL), + (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1), + (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2), + (10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3); INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`) VALUES - (1, CURDATE(), 1, 1, 1), - (2, CURDATE(), 2, 1, 1), - (3, CURDATE(), 3, 1, 1), - (4, CURDATE(), 3, 2, 1106), - (5, CURDATE(), 5, 1, 1106), - (6, CURDATE(), 5, 3, 1106); + (1, util.VN_CURDATE(), 1, 1, 1), + (2, util.VN_CURDATE(), 2, 1, 1), + (3, util.VN_CURDATE(), 3, 1, 1), + (4, util.VN_CURDATE(), 3, 2, 1106), + (5, util.VN_CURDATE(), 5, 1, 1106), + (6, util.VN_CURDATE(), 5, 3, 1106); INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`) VALUES - (1, 1, 2, 2, CURDATE(), NULL), - (2, 2, 2, 1, CURDATE(), NULL), - (3, 3, 2, 4, CURDATE(), NULL); + (1, 1, 2, 2, util.VN_CURDATE(), NULL), + (2, 2, 2, 1, util.VN_CURDATE(), NULL), + (3, 3, 2, 4, util.VN_CURDATE(), NULL); INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`) VALUES - (1, 1, 1, 'Ranged weapon longbow 2m', 5, 100.39, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (3, 1, 1, 'Ranged weapon longbow 2m', 2, 100.39, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (4, 4, 1, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (5, 1, 2, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (6, 1, 3, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.44, 0, 0, 0, CURDATE()), - (8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 1.79, 0, 0, 0, CURDATE()), - (9, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, CURDATE()), - (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, CURDATE()), - (11, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, CURDATE()), - (12, 4, 16, 'Melee weapon heavy shield 1x0.5m', 20, 1.71, 0, 0, 0, CURDATE()), - (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, CURDATE()), - (14, 1, 8, 'Ranged weapon longbow 2m', 2, 103.49, 0, 0, 0, CURDATE()), - (15, 1, 19, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, CURDATE()), - (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, CURDATE()), - (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (18, 4, 22, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (19, 1, 4, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), - (20, 1, 5, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), - (21, 1, 6, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (22, 1, 7, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, CURDATE()), - (23, 1, 9, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, CURDATE()), - (24, 1, 10, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, CURDATE()), - (25, 4, 12, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()), - (26, 4, 13, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()), - (27, 4, 14, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()), - (28, 4, 15, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()), - (29, 4, 17, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()), - (30, 4, 18, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, CURDATE()), - (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, CURDATE()), - (32, 1, 24, 'Ranged weapon longbow 2m', -1, 8.07, 0, 0, 0, CURDATE()), - (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, CURDATE()); + (1, 1, 1, 'Ranged weapon longbow 2m', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (3, 1, 1, 'Ranged weapon longbow 2m', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (4, 4, 1, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (5, 1, 2, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (6, 1, 3, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), + (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.44, 0, 0, 0, util.VN_CURDATE()), + (8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 1.79, 0, 0, 0, util.VN_CURDATE()), + (9, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), + (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()), + (11, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), + (12, 4, 16, 'Melee weapon heavy shield 1x0.5m', 20, 1.71, 0, 0, 0, util.VN_CURDATE()), + (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE()), + (14, 1, 8, 'Ranged weapon longbow 2m', 2, 103.49, 0, 0, 0, util.VN_CURDATE()), + (15, 1, 19, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), + (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE()), + (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (18, 4, 22, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (19, 1, 4, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), + (20, 1, 5, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), + (21, 1, 6, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (22, 1, 7, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), + (23, 1, 9, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), + (24, 1, 10, 'Ranged weapon longbow 2m', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), + (25, 4, 12, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (26, 4, 13, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (27, 4, 14, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (28, 4, 15, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (29, 4, 17, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (30, 4, 18, 'Melee weapon heavy shield 1x0.5m', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), + (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE()), + (32, 1, 24, 'Ranged weapon longbow 2m', -1, 8.07, 0, 0, 0, util.VN_CURDATE()), + (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE()); INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`) VALUES @@ -1128,10 +1137,10 @@ INSERT INTO `vncontrol`.`accion`(`accion_id`, `accion`) INSERT INTO `vn`.`saleTracking`(`saleFk`, `isChecked`, `created`, `originalQuantity`, `workerFk`, `actionFk`, `id`, `stateFk`) VALUES - (1, 0, CURDATE(), 5, 55, 3, 1, 14), - (1, 1, CURDATE(), 5, 54, 3, 2, 8), - (2, 1, CURDATE(), 10, 40, 4, 3, 8), - (3, 1, CURDATE(), 2, 40, 4, 4, 8); + (1, 0, util.VN_CURDATE(), 5, 55, 3, 1, 14), + (1, 1, util.VN_CURDATE(), 5, 54, 3, 2, 8), + (2, 1, util.VN_CURDATE(), 10, 40, 4, 3, 8), + (3, 1, util.VN_CURDATE(), 2, 40, 4, 4, 8); INSERT INTO `vn`.`itemBarcode`(`id`, `itemFk`, `code`) VALUES @@ -1147,21 +1156,15 @@ INSERT INTO `vn`.`train`(`id`, `name`) INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`) VALUES - (1, 1106, 5, DATE_ADD(CURDATE(),INTERVAL +1 DAY), 1), - (2, 1106, 14, CURDATE(), 1); + (1, 1106, 5, DATE_ADD(util.VN_CURDATE(),INTERVAL +1 DAY), 1), + (2, 1106, 14, util.VN_CURDATE(), 1); -INSERT INTO `vn`.`ticketCollection`(`id`, `ticketFk`, `collectionFk`) +INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`) VALUES - (2, 2, 1), - (3, 3, 2); - -INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`) - VALUES - ('100', '01', 1, '100-01', 1); - -INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `level`) - VALUES - (1, 1, 1); + (1, 1, 1), + (2, 1, NULL), + (3, 2, NULL), + (23, 1, NULL); INSERT INTO `vn`.`genus`(`id`, `name`) VALUES @@ -1307,9 +1310,9 @@ INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) VALUES (1, 1, 1, 0), (2, 2, 2, 0), - (3, 3, 3, 1), - (4, 1, 4, 1), - (5, 1, 5, 3); + (3, 3, 3, 0), + (4, 1, 4, 4), + (5, 1, 5, 5); CALL `vn`.`itemRefreshTags`(NULL); @@ -1319,10 +1322,10 @@ INSERT INTO `vn`.`itemLog` (`id`, `originFk`, `userFk`, `action`, `description`) INSERT INTO `vn`.`recovery`(`id`, `clientFk`, `started`, `finished`, `amount`, `period`) VALUES - (1, 1101, DATE_ADD(CURDATE(),INTERVAL -7 MONTH), DATE_ADD(CURDATE(),INTERVAL -3 MONTH), 50, 7), - (2, 1102, DATE_ADD(CURDATE(),INTERVAL -5 MONTH), CURDATE(), 100, 1), - (3, 1102, CURDATE(), DATE_ADD(CURDATE(),INTERVAL 1 MONTH), 50, 7), - (4, 1103, CURDATE(), NULL, 50, 7); + (1, 1101, DATE_ADD(util.VN_CURDATE(),INTERVAL -7 MONTH), DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), 50, 7), + (2, 1102, DATE_ADD(util.VN_CURDATE(),INTERVAL -5 MONTH), util.VN_CURDATE(), 100, 1), + (3, 1102, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(),INTERVAL 1 MONTH), 50, 7), + (4, 1103, util.VN_CURDATE(), NULL, 50, 7); INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) VALUES @@ -1334,9 +1337,9 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) VALUES - (1, 2, 'available', CONCAT_WS('/',1,CURDATE()), CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL 15 MINUTE), CURDATE(), NULL), - (2, 4, 'last_buy', CONCAT_WS('/',1,CURDATE()), CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL 15 MINUTE), CURDATE(), NULL), - (3, 8, 'visible', CONCAT_WS('/',1,CURDATE()), CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL 15 MINUTE), CURDATE(), NULL); + (1, 2, 'available', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL), + (2, 4, 'last_buy', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL), + (3, 8, 'visible', CONCAT_WS('/',1,util.VN_CURDATE()), util.VN_NOW(), DATE_ADD(util.VN_NOW(),INTERVAL 15 MINUTE), util.VN_CURDATE(), NULL); INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`) VALUES @@ -1346,27 +1349,27 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`) (4, 4), (5, 6); -INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`) +INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`) VALUES - (1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1), - (2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2), - (3, CURDATE(), CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1), - (4, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2), - (5, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1), - (6, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2), - (7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1), - (8, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2); + (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1), + (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2), + (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1), + (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2), + (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1), + (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2), + (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1), + (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `ref`,`isExcludedFromAvailable`, `isRaid`, `notes`, `evaNotes`) VALUES - (1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'Movement 1', 0, 0, '', ''), - (2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'Movement 2', 0, 0, 'this is the note two', 'observation two'), - (3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'Movement 3', 0, 0, 'this is the note three', 'observation three'), - (4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'Movement 4', 0, 0, 'this is the note four', 'observation four'), - (5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'Movement 5', 0, 0, 'this is the note five', 'observation five'), - (6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'Movement 6', 0, 0, 'this is the note six', 'observation six'), - (7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'Movement 7', 0, 0, 'this is the note seven', 'observation seven'), - (8, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'Movement 8', 1, 1, '', ''); + (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'Movement 1', 0, 0, '', ''), + (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'Movement 2', 0, 0, 'this is the note two', 'observation two'), + (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'Movement 3', 0, 0, 'this is the note three', 'observation three'), + (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'Movement 4', 0, 0, 'this is the note four', 'observation four'), + (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'Movement 5', 0, 0, 'this is the note five', 'observation five'), + (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'Movement 6', 0, 0, 'this is the note six', 'observation six'), + (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'Movement 7', 0, 0, 'this is the note seven', 'observation seven'), + (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'Movement 8', 1, 1, '', ''); INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES @@ -1377,97 +1380,97 @@ INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRa INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`) VALUES - ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'), - ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'), - ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'), - ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'), - ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'), - ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'), - ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'), - ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'), - ('CharlesXavier', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'), - ('DavidCharlesHaller', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'), - ('DavidCharlesHaller', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'), - ('DavidCharlesHaller', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'), - ('HankPym', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'), - ('HankPym', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'), - ('HankPym', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0'); + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'), + ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'), + ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'), + ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'), + ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'), + ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'), + ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'), + ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0'); INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packageFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`,`producer`,`printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`) VALUES - (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, CURDATE()), - (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, NULL, 0, 1, 0, 2.5, CURDATE()), - (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, NULL, 0, 1, 0, 2.5, CURDATE()), - (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 2.5, CURDATE()), - (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, NULL, 0, 1, 0, 2.5, CURDATE()), - (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 2.5, CURDATE()), - (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, CURDATE()), - (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 4, CURDATE()), - (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, CURDATE()), - (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, CURDATE()), - (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 4, CURDATE()), - (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, NULL, 0, 1, 0, 4, CURDATE()), - (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, CURDATE()); + (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), + (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 1, util.VN_CURDATE()), + (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, NULL, 0, 1, 0, 2.5, util.VN_CURDATE()), + (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, NULL, 0, 1, 0, 2.5, util.VN_CURDATE()), + (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 2.5, util.VN_CURDATE()), + (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, NULL, 0, 1, 0, 2.5, util.VN_CURDATE()), + (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 2.5, util.VN_CURDATE()), + (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, util.VN_CURDATE()), + (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 4, util.VN_CURDATE()), + (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, util.VN_CURDATE()), + (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, util.VN_CURDATE()), + (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, NULL, 0, 1, 0, 4, util.VN_CURDATE()), + (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, NULL, 0, 1, 0, 4, util.VN_CURDATE()), + (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, NULL, 0, 1, 0, 4, util.VN_CURDATE()); INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) VALUES - (1, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 3, 1, 121, 442, NULL, 'TPV', 1,'155.89', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (2, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 3, 1, 124, 442, NULL, 'WEB', 1,'100.10', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (3, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'ANDROID', 1,'107.25', DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (4, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), - (5, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 1, 3, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(CURDATE(), INTERVAL -4 MONTH), DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), - (6, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 1, 3, 1, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (7, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 1, 442, NULL, 'SALIX', 0,'10.01', CURDATE(), CURDATE(), CURDATE()), - (8, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 121, 442, NULL, 'SALIX', 0,'123.53', CURDATE(), CURDATE(), CURDATE()), - (9, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1104, 2, 7, 124, 442, NULL, 'SALIX', 0,'10.01', CURDATE(), CURDATE(), CURDATE()), - (10, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1102, 3, 1, 2, 442, NULL, 'SALIX', 0,'10.01', CURDATE(), CURDATE(), CURDATE()), - (11, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1102, 2, 7, 122, 442, NULL, 'SALIX', 0,'60.90', CURDATE(), CURDATE(), CURDATE()), - (12, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1103, 3, 1, 3, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), - (13, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1103, 1, 2, 123, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), - (14, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1104, 1, 2, 4, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), - (15, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1105, 1, 3, 125, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), - (16, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1106, 2, 7, 126, 442, NULL, 'SALIX', 0,'155.89', CURDATE(), CURDATE(), CURDATE()), - (17, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1107, 1, 4, 127, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), - (18, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1108, 1, 4, 128, 442, NULL, 'SALIX', 0,'72.60', CURDATE(), CURDATE(), CURDATE()), - (19, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 1109, 1, 5, 129, 442, NULL, 'SALIX', 0,'16.50', CURDATE(), CURDATE(), CURDATE()), - (20, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 101, 442, NULL, 'SALIX', 0,'21.45', DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (21, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 102, 442, NULL, 'SALIX', 0,'0.00', DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (22, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 103, 442, NULL, 'SALIX', 0,'148.50', DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)); + (1, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 3, 1, 121, 442, NULL, 'TPV', 1,'155.89', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (2, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1104, 3, 1, 124, 442, NULL, 'WEB', 1,'100.10', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (3, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'ANDROID', 1,'107.25', DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), + (4, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 1, 2, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), + (5, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 1, 3, 124, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), + (6, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 1, 3, 1, 442, NULL, 'SALIX', 1,'10.01', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), + (7, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 1, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (8, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 2, 7, 121, 442, NULL, 'SALIX', 0,'123.53', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (9, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 2, 7, 124, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (10, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 3, 1, 2, 442, NULL, 'SALIX', 0,'10.01', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (11, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 2, 7, 122, 442, NULL, 'SALIX', 0,'60.90', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (12, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 3, 1, 3, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (13, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 1, 2, 123, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (14, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 1, 2, 4, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (15, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 1, 3, 125, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (16, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 2, 7, 126, 442, NULL, 'SALIX', 0,'155.89', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (17, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1107, 1, 4, 127, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (18, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 1, 4, 128, 442, NULL, 'SALIX', 0,'72.60', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (19, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 1, 5, 129, 442, NULL, 'SALIX', 0,'16.50', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE()), + (20, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 101, 442, NULL, 'SALIX', 0,'21.45', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (21, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 102, 442, NULL, 'SALIX', 0,'0.00', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), + (22, DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 1, 5, 103, 442, NULL, 'SALIX', 0,'148.50', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)); INSERT INTO `hedera`.`orderRow`(`id`, `orderFk`, `itemFk`, `warehouseFk`, `shipment`, `amount`, `price`, `rate`, `created`, `saleFk`) VALUES - (1, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1), - (2, 1, 2, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 10, 1.07, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2), - (3, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3), - (4, 1, 4, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 20, 3.06, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4), - (5, 2, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 10, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5), - (6, 3, 1, 2, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 15, 6.50, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 6), - (7, 11, 2, 1, CURDATE(), 15, 1.30, 0, CURDATE(), 7), - (8, 11, 4, 1, CURDATE(), 10, 3.26, 0, CURDATE(), 8), - (9, 16, 1, 1, CURDATE(), 5, 9.10, 0, CURDATE(), 9), - (10, 16, 2, 1, CURDATE(), 10, 1.07, 0, CURDATE(), 10), - (11, 16, 1, 1, CURDATE(), 2, 9.10, 0, CURDATE(), 11), - (12, 16, 4, 1, CURDATE(), 20, 3.06, 0, CURDATE(), 12), - (13, 8, 2, 1, CURDATE(), 15, 1.30, 0, CURDATE(), 13), - (14, 8, 1, 1, CURDATE(), 10, 9.28, 0, CURDATE(), 14), - (15, 19, 1, 1, CURDATE(), 10, 1.50, 0, CURDATE(), 15), - (16, 20, 2, 1, CURDATE(), 15, 1.30, 0, CURDATE(), 16), - (17, 22, 2, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 30, 2.30, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 17), - (18, 22, 4, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 20, 3.00, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 18), - (19, 4, 1, 1, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), 1, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), 19), - (20, 5, 1, 1, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), 1, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -4 MONTH), 20), - (21, 6, 1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 9.10, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 21), - (22, 7, 1, 1, CURDATE(), 1, 9.10, 0, CURDATE(), 22), - (23, 9, 1, 1, CURDATE(), 1, 9.10, 0, CURDATE(), 23), - (24, 10, 1, 1, CURDATE(), 1, 9.10, 0, CURDATE(), 24), - (25, 12, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 25), - (26, 13, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 26), - (27, 14, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 27), - (28, 15, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 28), - (29, 17, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 29), - (30, 18, 4, 1, CURDATE(), 20, 3.00, 0, CURDATE(), 30); + (1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1), + (2, 1, 2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 10, 1.07, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2), + (3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3), + (4, 1, 4, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 20, 3.06, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4), + (5, 2, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 10, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5), + (6, 3, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 15, 6.50, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 6), + (7, 11, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 7), + (8, 11, 4, 1, util.VN_CURDATE(), 10, 3.26, 0, util.VN_CURDATE(), 8), + (9, 16, 1, 1, util.VN_CURDATE(), 5, 9.10, 0, util.VN_CURDATE(), 9), + (10, 16, 2, 1, util.VN_CURDATE(), 10, 1.07, 0, util.VN_CURDATE(), 10), + (11, 16, 1, 1, util.VN_CURDATE(), 2, 9.10, 0, util.VN_CURDATE(), 11), + (12, 16, 4, 1, util.VN_CURDATE(), 20, 3.06, 0, util.VN_CURDATE(), 12), + (13, 8, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 13), + (14, 8, 1, 1, util.VN_CURDATE(), 10, 9.28, 0, util.VN_CURDATE(), 14), + (15, 19, 1, 1, util.VN_CURDATE(), 10, 1.50, 0, util.VN_CURDATE(), 15), + (16, 20, 2, 1, util.VN_CURDATE(), 15, 1.30, 0, util.VN_CURDATE(), 16), + (17, 22, 2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 30, 2.30, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 17), + (18, 22, 4, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 20, 3.00, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 18), + (19, 4, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 19), + (20, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 20), + (21, 6, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 9.10, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 21), + (22, 7, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 22), + (23, 9, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 23), + (24, 10, 1, 1, util.VN_CURDATE(), 1, 9.10, 0, util.VN_CURDATE(), 24), + (25, 12, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 25), + (26, 13, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 26), + (27, 14, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 27), + (28, 15, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 28), + (29, 17, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 29), + (30, 18, 4, 1, util.VN_CURDATE(), 20, 3.00, 0, util.VN_CURDATE(), 30); INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`) VALUES @@ -1655,43 +1658,43 @@ INSERT INTO `hedera`.`visitAgent`(`id`, `visitFk`) INSERT INTO `hedera`.`visitAccess`(`id`, `agentFk`, `stamp`) VALUES - (1, 1, CURDATE()), - (2, 2, CURDATE()), - (3, 3, CURDATE()), - (4, 4, CURDATE()), - (5, 5, CURDATE()), - (6, 6, CURDATE()), - (7, 7, CURDATE()), - (8, 8, CURDATE()), - (9, 9, CURDATE()), - (10, 10, CURDATE()), - (11, 11, CURDATE()); + (1, 1, util.VN_CURDATE()), + (2, 2, util.VN_CURDATE()), + (3, 3, util.VN_CURDATE()), + (4, 4, util.VN_CURDATE()), + (5, 5, util.VN_CURDATE()), + (6, 6, util.VN_CURDATE()), + (7, 7, util.VN_CURDATE()), + (8, 8, util.VN_CURDATE()), + (9, 9, util.VN_CURDATE()), + (10, 10, util.VN_CURDATE()), + (11, 11, util.VN_CURDATE()); INSERT INTO `hedera`.`visitUser`(`id`, `accessFk`, `userFk`, `stamp`) VALUES - (1, 1, 1101, CURDATE()), - (2, 2, 1101, CURDATE()), - (3, 3, 1101, CURDATE()), - (4, 4, 1102, CURDATE()), - (5, 5, 1102, CURDATE()), - (6, 6, 1102, CURDATE()), - (7, 7, 1103, CURDATE()), - (8, 8, 1103, CURDATE()), - (9, 9, 1103, CURDATE()), - (10, 10, 1102, DATE_SUB(CURDATE(), INTERVAL 1 DAY)), - (11, 11, 1103, DATE_SUB(CURDATE(), INTERVAL 1 DAY)); + (1, 1, 1101, util.VN_CURDATE()), + (2, 2, 1101, util.VN_CURDATE()), + (3, 3, 1101, util.VN_CURDATE()), + (4, 4, 1102, util.VN_CURDATE()), + (5, 5, 1102, util.VN_CURDATE()), + (6, 6, 1102, util.VN_CURDATE()), + (7, 7, 1103, util.VN_CURDATE()), + (8, 8, 1103, util.VN_CURDATE()), + (9, 9, 1103, util.VN_CURDATE()), + (10, 10, 1102, DATE_SUB(util.VN_CURDATE(), INTERVAL 1 DAY)), + (11, 11, 1103, DATE_SUB(util.VN_CURDATE(), INTERVAL 1 DAY)); INSERT INTO `hedera`.`userSession`(`created`, `lastUpdate`, `ssid`, `data`, `userVisitFk`) VALUES - (CURDATE(), CURDATE(), '121', 'data', 1), - (CURDATE(), CURDATE(), '122', 'data', 2), - (CURDATE(), CURDATE(), '123', 'data', 3), - (CURDATE(), CURDATE(), '124', 'data', 4), - (CURDATE(), CURDATE(), '125', 'data', 5), - (CURDATE(), CURDATE(), '126', 'data', 6), - (CURDATE(), CURDATE(), '127', 'data', 7), - (CURDATE(), CURDATE(), '128', 'data', 8), - (CURDATE(), CURDATE(), '129', 'data', 9); + (util.VN_CURDATE(), util.VN_CURDATE(), '121', 'data', 1), + (util.VN_CURDATE(), util.VN_CURDATE(), '122', 'data', 2), + (util.VN_CURDATE(), util.VN_CURDATE(), '123', 'data', 3), + (util.VN_CURDATE(), util.VN_CURDATE(), '124', 'data', 4), + (util.VN_CURDATE(), util.VN_CURDATE(), '125', 'data', 5), + (util.VN_CURDATE(), util.VN_CURDATE(), '126', 'data', 6), + (util.VN_CURDATE(), util.VN_CURDATE(), '127', 'data', 7), + (util.VN_CURDATE(), util.VN_CURDATE(), '128', 'data', 8), + (util.VN_CURDATE(), util.VN_CURDATE(), '129', 'data', 9); INSERT INTO `vn`.`clientContact`(`id`, `clientFk`, `name`, `phone`) VALUES @@ -1715,11 +1718,11 @@ call vn.manaSpellersRequery(18); INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `userFk`, `companyFk`) VALUES - (1, 1101, 1, CURDATE(), 18, 18, 442), - (2, 1101, 1, CURDATE(), 18, 18, 442), - (3, 1101, 2, CURDATE(), 18, 18, 442), - (4, 1102, 2, CURDATE(), 18, 18, 567), - (5, 1102, 3, CURDATE(), 19, 19, 567); + (1, 1101, 1, util.VN_CURDATE(), 18, 18, 442), + (2, 1101, 1, util.VN_CURDATE(), 18, 18, 442), + (3, 1101, 2, util.VN_CURDATE(), 18, 18, 442), + (4, 1102, 2, util.VN_CURDATE(), 18, 18, 567), + (5, 1102, 3, util.VN_CURDATE(), 19, 19, 567); INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify`) VALUES @@ -1731,12 +1734,19 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, ( 6, 'mana', 'Mana', 1, 4, 0), ( 7, 'lack', 'Faltas', 1, 2, 0); -INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `observation`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`) +INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`) VALUES - (1, CURDATE(), 1, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', 1101, 18, 3, 0, CURDATE(), 0), - (2, CURDATE(), 2, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', 1101, 18, 3, 0, CURDATE(), 1), - (3, CURDATE(), 3, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', 1101, 18, 1, 1, CURDATE(), 5), - (4, CURDATE(), 3, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', 1104, 18, 5, 0, CURDATE(), 10); + (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0), + (2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1), + (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5), + (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10); + +INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`) + VALUES + (1, 18, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', util.VN_CURDATE()), + (2, 18, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', util.VN_CURDATE()), + (3, 18, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', util.VN_CURDATE()), + (4, 18, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', util.VN_CURDATE()); INSERT INTO `vn`.`claimBeginning`(`id`, `claimFk`, `saleFk`, `quantity`) VALUES @@ -1753,6 +1763,11 @@ INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`) (4, 'Reclam.PRAG', 12), (5, 'Corregido', 11); +INSERT INTO `vn`.`claimResponsible`(`id`, `description`, `responsability`) + VALUES + (1, 'Buyers', 0), + (7, 'Quality', 0); + INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`) VALUES (1, 1, 1, 21, 1, 1, 2, 5), @@ -1773,12 +1788,12 @@ INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, ` INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`) VALUES - (1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', CURDATE()), - (2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', CURDATE()), - (3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', CURDATE()), - (4, 2, 1101, NULL, 4698, NULL, NULL, 'started', CURDATE()), - (5, 1, 1104, NULL, 2000, NULL, 'SIS0043', 'ok', CURDATE()), - (6, 2, 1104, NULL, 4000, NULL, 'SIS0044', 'started', CURDATE()); + (1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', util.VN_CURDATE()), + (2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', util.VN_CURDATE()), + (3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', util.VN_CURDATE()), + (4, 2, 1101, NULL, 4698, NULL, NULL, 'started', util.VN_CURDATE()), + (5, 1, 1104, NULL, 2000, NULL, 'SIS0043', 'ok', util.VN_CURDATE()), + (6, 2, 1104, NULL, 4000, NULL, 'SIS0044', 'started', util.VN_CURDATE()); INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) VALUES @@ -1814,10 +1829,10 @@ INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) VALUES - (1, 'Cobro web', 100.50, CURDATE(), 9, 1, 1101, CURDATE(), 442, 1), - (2, 'Cobro web', 200.50, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 9, 1, 1101, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 442, 1), - (3, 'Cobro en efectivo', 300.00, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 9, 1, 1102, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 442, 0), - (4, 'Cobro en efectivo', 400.00, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 9, 1, 1103, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 442, 0); + (1, 'Cobro web', 100.50, util.VN_CURDATE(), 9, 1, 1101, util.VN_CURDATE(), 442, 1), + (2, 'Cobro web', 200.50, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), 9, 1, 1101, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), 442, 1), + (3, 'Cobro en efectivo', 300.00, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), 9, 1, 1102, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), 442, 0), + (4, 'Cobro en efectivo', 400.00, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 9, 1, 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), 442, 0); INSERT INTO `vn`.`workerTeam`(`id`, `team`, `workerFk`) VALUES @@ -1831,11 +1846,11 @@ INSERT INTO `vn`.`workerTeam`(`id`, `team`, `workerFk`) INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `attenderFk`, `quantity`, `itemFk`, `price`, `isOk`, `saleFk`, `ticketFk`, `created`) VALUES - (1, 'Ranged weapon longbow 2m', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (3, 'Melee weapon heavy shield 1x0.5m', 18, 35, 20, NULL, 3.06, NULL, NULL, 23, CURDATE()), - (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, CURDATE()), - (5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, CURDATE()); + (1, 'Ranged weapon longbow 2m', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)), + (2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY)), + (3, 'Melee weapon heavy shield 1x0.5m', 18, 35, 20, NULL, 3.06, NULL, NULL, 23, util.VN_CURDATE()), + (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, util.VN_CURDATE()), + (5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, util.VN_CURDATE()); INSERT INTO `vn`.`ticketServiceType`(`id`, `name`, `expenceFk`) VALUES @@ -1860,7 +1875,6 @@ INSERT INTO `pbx`.`sip`(`user_id`, `extension`) (5, 1102), (9, 1201); - INSERT INTO `postgresql`.`profile`(`profile_id`, `workerFk`, `profile_type_id`) SELECT w.id, w.id, 1 FROM `vn`.`worker` `w`; @@ -1878,16 +1892,20 @@ INSERT INTO `postgresql`.`business` (`client_id`, `companyCodeFk`, `date_start`, FROM `postgresql`.`profile` `p` WHERE `p`.`profile_id` = 1109; +UPDATE `postgresql`.`business` + SET `payedHolidays`= 8 + WHERE `business_id`= 1106; + INSERT INTO `postgresql`.`business_labour` (`business_id`, `notes`, `department_id`, `professional_category_id`, `incentivo`, `calendar_labour_type_id`, `porhoras`, `labour_agreement_id`, `workcenter_id`) VALUES (1111, NULL, 23, 1, 0.0, 1, 1, 1, 1); - + UPDATE `postgresql`.`business_labour` bl JOIN `postgresql`.`business` b ON b.business_id = bl.business_id JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id SET bl.`professional_category_id` = 31 WHERE pr.`workerFk` = 1110; - + UPDATE `postgresql`.`business_labour` bl SET bl.`department_id` = 43 WHERE business_id IN(18, 19); @@ -1904,10 +1922,10 @@ INSERT INTO `postgresql`.`profile_media`(`profile_media_id`, `profile_id`, `medi INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`) VALUES - ('1', '27.5', YEAR(CURDATE())), - ('5', '22', YEAR(CURDATE())), - ('1', '24.5', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR))), - ('5', '23', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR))); + ('1', '27.5', YEAR(util.VN_CURDATE())), + ('5', '22', YEAR(util.VN_CURDATE())), + ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), + ('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))); ALTER TABLE `postgresql`.`business_labour_payroll` DROP FOREIGN KEY `business_labour_payroll_cod_categoria`; @@ -1935,21 +1953,22 @@ INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlement INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) VALUES - (1, 6, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL 10 DAY))), - (1106, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL 10 DAY))), - (1106, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -11 DAY), DATE_ADD(CURDATE(), INTERVAL 11 DAY))), - (1106, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -12 DAY), DATE_ADD(CURDATE(), INTERVAL 12 DAY))), - (1106, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -20 DAY), DATE_ADD(CURDATE(), INTERVAL 20 DAY))), - (1106, 2, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -13 DAY), DATE_ADD(CURDATE(), INTERVAL 8 DAY))), - (1106, 1, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -14 DAY), DATE_ADD(CURDATE(), INTERVAL 9 DAY))), - (1106, 2, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -15 DAY), DATE_ADD(CURDATE(), INTERVAL 7 DAY))), - (1107, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL 10 DAY))), - (1107, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -11 DAY), DATE_ADD(CURDATE(), INTERVAL 11 DAY))), - (1107, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -12 DAY), DATE_ADD(CURDATE(), INTERVAL 12 DAY))), - (1107, 1, IF(MONTH(CURDATE()) = 12 AND DAY(CURDATE()) > 10, DATE_ADD(CURDATE(), INTERVAL -20 DAY), DATE_ADD(CURDATE(), INTERVAL 20 DAY))), - (1107, 2, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -13 DAY), DATE_ADD(CURDATE(), INTERVAL 8 DAY))), - (1107, 1, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -14 DAY), DATE_ADD(CURDATE(), INTERVAL 9 DAY))), - (1107, 2, IF(MONTH(CURDATE()) >= 1 AND DAY(CURDATE()) > 20, DATE_ADD(CURDATE(), INTERVAL -15 DAY), DATE_ADD(CURDATE(), INTERVAL 7 DAY))); + (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), + (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), + (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 11 DAY))), + (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -12 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 12 DAY))), + (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -20 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 20 DAY))), + (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -13 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 8 DAY))), + (1106, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -14 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 9 DAY))), + (1106, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))), + (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), + (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 11 DAY))), + (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -12 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 12 DAY))), + (1107, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -20 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 20 DAY))), + (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -13 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 8 DAY))), + (1107, 1, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -14 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 9 DAY))), + (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))), + (1107, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL - 16 DAY)); INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) VALUES @@ -1957,12 +1976,12 @@ INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`) VALUES - (1, 19, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 1101), - (2, 18, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 1106); + (1, 19, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 1101), + (2, 18, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 1106); INSERT INTO `vn`.`sharingCart`(`id`, `workerFk`, `started`, `ended`, `workerSubstitute`, `created`) VALUES - (1, 18, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 19, DATE_ADD(CURDATE(), INTERVAL -5 DAY)); + (1, 18, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY), 19, DATE_ADD(util.VN_CURDATE(), INTERVAL -5 DAY)); CALL `vn`.zoneGeo_calcTree(); -- this is an auto calculate for table vn.zoneGeo, columns: path,lft,rgt,depth,sons @@ -2004,223 +2023,227 @@ INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`) INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) VALUES - (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9) - DAYOFWEEK(CURDATE())) DAY)), - (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), - (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), - (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), - (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)), - (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9) - DAYOFWEEK(CURDATE())) DAY)), - (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), - (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), - (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), - (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)), - (3, 'day', CURDATE()), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)), - (3, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)), - (4, 'day', CURDATE()), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)), - (4, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)), - (5, 'day', CURDATE()), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)), - (5, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)), - (6, 'day', CURDATE()), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +7 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +8 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +9 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +10 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +11 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +12 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +13 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +14 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +15 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +16 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +17 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +18 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +19 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +20 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +21 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +22 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +23 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +24 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +25 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +26 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +27 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +28 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +29 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +30 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +31 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +32 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +33 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +34 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +35 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +36 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +37 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +38 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +39 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +40 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +41 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +42 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +43 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +44 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +45 DAY)), - (6, 'day', DATE_ADD(CURDATE(), INTERVAL +46 DAY)), - (7, 'day', CURDATE()), - (7, 'day', DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (7, 'day', DATE_ADD(CURDATE(), INTERVAL +2 DAY)), - (7, 'day', DATE_ADD(CURDATE(), INTERVAL +3 DAY)), - (7, 'day', DATE_ADD(CURDATE(), INTERVAL +4 DAY)), - (7, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), - (7, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)); + (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=2, 2, 9) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=3, 3, 10) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=4, 4, 11) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=5, 5, 12) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (1, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=6, 6, 13) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=2, 2, 9) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=3, 3, 10) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=4, 4, 11) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=5, 5, 12) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (2, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=6, 6, 13) - DAYOFWEEK(util.VN_CURDATE())) DAY)), + (3, 'day', util.VN_CURDATE()), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)), + (3, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)), + (4, 'day', util.VN_CURDATE()), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)), + (4, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)), + (5, 'day', util.VN_CURDATE()), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)), + (5, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)), + (6, 'day', util.VN_CURDATE()), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +7 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +8 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +9 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +10 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +11 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +12 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +13 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +14 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +15 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +16 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +17 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +18 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +19 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +20 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +21 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +22 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +23 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +24 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +25 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +26 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +27 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +28 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +29 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +30 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +31 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +32 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +33 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +34 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +35 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +36 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +37 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +38 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +39 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +40 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +41 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +42 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +43 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +44 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +45 DAY)), + (6, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +46 DAY)), + (7, 'day', util.VN_CURDATE()), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY)), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +3 DAY)), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +4 DAY)), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY)), + (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)); INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `weekDays`) VALUES (8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'), (10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'); +INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`) + VALUES + (9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)); + INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`) VALUES - (1106, CONCAT(CURDATE(), ' 07:00'), TRUE, 'in'), - (1106, CONCAT(CURDATE(), ' 10:00'), TRUE, 'middle'), - (1106, CONCAT(CURDATE(), ' 10:10'), TRUE, 'middle'), - (1106, CONCAT(CURDATE(), ' 15:00'), TRUE, 'out'); + (1106, CONCAT(util.VN_CURDATE(), ' 07:00'), TRUE, 'in'), + (1106, CONCAT(util.VN_CURDATE(), ' 10:00'), TRUE, 'middle'), + (1106, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle'), + (1106, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out'); INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`) VALUES @@ -2247,14 +2270,14 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `c INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`) VALUES - (1, 14, '1.txt', 'text/plain', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', CURDATE()), - (2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', CURDATE()), - (3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', CURDATE()), - (4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', CURDATE()), - (5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', CURDATE()), - (6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', CURDATE()), - (7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', CURDATE()), - (8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', CURDATE()); + (1, 14, '1.txt', 'text/plain', 5, 1, 442, NULL, FALSE, 'Ticket:11', 'Ticket:11 dms for the ticket', util.VN_CURDATE()), + (2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', util.VN_CURDATE()), + (3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', util.VN_CURDATE()), + (4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', util.VN_CURDATE()), + (5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()), + (6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()), + (7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()), + (8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()); INSERT INTO `vn`.`claimDms`(`claimFk`, `dmsFk`) VALUES @@ -2301,12 +2324,12 @@ INSERT INTO `vn`.`thermograph`(`id`, `model`) INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `result`, `dmsFk`) VALUES - ('TMM190901395', CURDATE(), 1, 1, 'WARM', 'Ok', NULL), - ('TL.BBA85422', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL), - ('TL.BBA85422', CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL), - ('TZ1905012010', CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5), - ('138350-0', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), - ('138350-0', CURDATE(), 1, NULL, 'COOL', NULL, NULL); + ('TMM190901395', util.VN_CURDATE(), 1, 1, 'WARM', 'Ok', NULL), + ('TL.BBA85422', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL), + ('TL.BBA85422', util.VN_CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL), + ('TZ1905012010', util.VN_CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5), + ('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), + ('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL); REPLACE INTO `vn`.`incoterms`(`code`, `name`) VALUES @@ -2329,18 +2352,18 @@ INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) INSERT INTO `vn`.`campaign`(`code`, `dated`) VALUES - ('valentinesDay', CONCAT(YEAR(CURDATE()), '-02-14')), - ('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-02-14')), - ('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-02-14')), - ('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-02-14')), - ('mothersDay', CONCAT(YEAR(CURDATE()), '-05-05')), - ('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-05-05')), - ('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-05-05')), - ('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-05-05')), - ('allSaints', CONCAT(YEAR(CURDATE()), '-11-01')), - ('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-11-01')), - ('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-11-01')), - ('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-11-01')); + ('valentinesDay', CONCAT(YEAR(util.VN_CURDATE()), '-02-14')), + ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-02-14')), + ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-02-14')), + ('valentinesDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-02-14')), + ('mothersDay', CONCAT(YEAR(util.VN_CURDATE()), '-05-05')), + ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-05-05')), + ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-05-05')), + ('mothersDay', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-05-05')), + ('allSaints', CONCAT(YEAR(util.VN_CURDATE()), '-11-01')), + ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-11-01')), + ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-11-01')), + ('allSaints', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -3 YEAR)), '-11-01')); INSERT INTO `hedera`.`imageCollectionSize`(`id`, `collectionFk`,`width`, `height`) VALUES @@ -2352,61 +2375,61 @@ INSERT INTO `vn`.`rateConfig`(`rate0`, `rate1`, `rate2`, `rate3`) INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate3`) VALUES - (DATE_ADD(CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25), - (CURDATE(), 1, 12, 17, 22, 27); + (DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25), + (util.VN_CURDATE(), 1, 12, 17, 22, 27); INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) VALUES - (1, '07546501420', 67, 671, CURDATE(), 1761, 1, 1), - (2, '07546491421', 252, 2769, CURDATE(), 5231, 1, 1), - (3, '07546500823', 102, 1495, CURDATE(), 3221, 1, 1), - (4, '99610288821', 252, 2777, CURDATE(), 3641, 1, 1), - (5, '07546500834', 229, 3292, CURDATE(), 6601, 2, 1), - (6, '22101929561', 37, 458, CURDATE(), 441, 2, 1), - (7, '07546491432', 258, 3034, CURDATE(), 6441, 2, 1), - (8, '99610288644', 476, 4461, CURDATE(), 5751, 442, 1), - (9, '99610289193', 302, 2972, CURDATE(), 3871, 442, 1), - (10, '07546500856', 185, 2364, CURDATE(), 5321, 442, 1); + (1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1), + (2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1), + (3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1), + (4, '99610288821', 252, 2777, util.VN_CURDATE(), 3641, 1, 1), + (5, '07546500834', 229, 3292, util.VN_CURDATE(), 6601, 2, 1), + (6, '22101929561', 37, 458, util.VN_CURDATE(), 441, 2, 1), + (7, '07546491432', 258, 3034, util.VN_CURDATE(), 6441, 2, 1), + (8, '99610288644', 476, 4461, util.VN_CURDATE(), 5751, 442, 1), + (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1), + (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1); INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) VALUES - (1, '19ES0028013A481523', 1, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 1, 11276.95, 442), - (2, '21ES00280136115760', 2, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 2, 1376.20, 442), - (3, '19ES00280131956004', 3, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 3, 14268.50, 442), - (4, '19ES00280131955995', 4, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 1, 8242.50, 442), - (5, '19ES00280132022070', 5, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 2, 10012.49, 442), - (6, '19ES00280132032308', 6, CURDATE(), CURDATE(), CURDATE(), CURDATE(), 2, 19914.25, 442), - (7, '19ES00280132025489', 7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), CURDATE(), CURDATE(), CURDATE(), 2, 1934.06, 442), - (8, '19ES00280132025490', 8, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), CURDATE(), CURDATE(), CURDATE(), 2, 3618.52, 442), - (9, '19ES00280132025491', 9, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), CURDATE(), CURDATE(), CURDATE(), 2, 7126.23, 442), - (10, '19ES00280132025492', 10, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), CURDATE(), CURDATE(), CURDATE(), 2, 4631.45, 442); + (1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442), + (2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442), + (3, '19ES00280131956004', 3, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442), + (4, '19ES00280131955995', 4, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 8242.50, 442), + (5, '19ES00280132022070', 5, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 10012.49, 442), + (6, '19ES00280132032308', 6, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 19914.25, 442), + (7, '19ES00280132025489', 7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1934.06, 442), + (8, '19ES00280132025490', 8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 3618.52, 442), + (9, '19ES00280132025491', 9, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 7126.23, 442), + (10, '19ES00280132025492', 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 4631.45, 442); REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`) VALUES - (1, 1001, 'R', 1, CURDATE(), CURDATE(), 1234, 0, 442, 1), - (2, 1002, 'R', 1, CURDATE(), CURDATE(), 1235, 1, 442, 1), - (3, 1003, 'R', 1, CURDATE(), CURDATE(), 1236, 0, 442, 1), - (4, 1004, 'R', 1, CURDATE(), CURDATE(), 1237, 0, 442, 1), - (5, 1005, 'R', 1, CURDATE(), CURDATE(), 1238, 1, 442, 1), - (6, 1006, 'R', 2, CURDATE(), CURDATE(), 1239, 0, 442, 1), - (7, 1007, 'R', 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1), - (8, 1008, 'R', 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1), - (9, 1009, 'R', 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1), - (10, 1010, 'R', 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1); + (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1), + (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 1, 442, 1), + (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1), + (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1), + (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 1, 442, 1), + (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1), + (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1), + (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1), + (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1), + (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1); INSERT INTO `vn`.`invoiceInDueDay`(`invoiceInFk`, `dueDated`, `bankFk`, `amount`) VALUES - (1, CURDATE(), 1, 336.99), - (1, CURDATE(), 1, 15.25), - (2, CURDATE(), 1, 168), - (2, CURDATE(), 1, 55.17), - (3, CURDATE(), 1, 87.95), - (3, CURDATE(), 1, 7.65), - (4, CURDATE(), 1, 373.27), - (4, CURDATE(), 1, 73.36), - (5, CURDATE(), 1, 64.23), - (6, CURDATE(), 1, 32.95), - (7, CURDATE(), 1, 58.64); + (1, util.VN_CURDATE(), 1, 336.99), + (1, util.VN_CURDATE(), 1, 15.25), + (2, util.VN_CURDATE(), 1, 168), + (2, util.VN_CURDATE(), 1, 55.17), + (3, util.VN_CURDATE(), 1, 87.95), + (3, util.VN_CURDATE(), 1, 7.65), + (4, util.VN_CURDATE(), 1, 373.27), + (4, util.VN_CURDATE(), 1, 73.36), + (5, util.VN_CURDATE(), 1, 64.23), + (6, util.VN_CURDATE(), 1, 32.95), + (7, util.VN_CURDATE(), 1, 58.64); INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`) VALUES @@ -2460,24 +2483,24 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) INSERT INTO `vn`.`expeditionTruck` (`id`, `ETD`, `description`) VALUES - (1, CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet'); + (1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet'); INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPrint`) VALUES - (1, 1, CURDATE(), 1, 1); + (1, 1, util.VN_CURDATE(), 1, 1); INSERT INTO `vn`.`expeditionScan` (`id`, `expeditionFk`, `scanned`, `palletFk`) VALUES - (1, 1, CURDATE(), 1), - (2, 2, CURDATE(), 1), - (3, 3, CURDATE(), 1), - (4, 4, CURDATE(), 1), - (5, 5, CURDATE(), 1), - (6, 6, CURDATE(), 1), - (7, 7, CURDATE(), 1), - (8, 8, CURDATE(), 1), - (9, 9, CURDATE(), 1), - (10, 10, CURDATE(), 1); + (1, 1, util.VN_CURDATE(), 1), + (2, 2, util.VN_CURDATE(), 1), + (3, 3, util.VN_CURDATE(), 1), + (4, 4, util.VN_CURDATE(), 1), + (5, 5, util.VN_CURDATE(), 1), + (6, 6, util.VN_CURDATE(), 1), + (7, 7, util.VN_CURDATE(), 1), + (8, 8, util.VN_CURDATE(), 1), + (9, 9, util.VN_CURDATE(), 1), + (10, 10, util.VN_CURDATE(), 1); CALL `cache`.`last_buy_refresh`(FALSE); @@ -2486,11 +2509,11 @@ UPDATE `vn`.`item` SET `genericFk` = 9 INSERT INTO `bs`.`defaulter` (`clientFk`, `amount`, `created`, `defaulterSinced`) VALUES - (1101, 500, CURDATE(), CURDATE()), - (1102, 500, CURDATE(), CURDATE()), - (1103, 500, CURDATE(), CURDATE()), - (1107, 500, CURDATE(), CURDATE()), - (1109, 500, CURDATE(), CURDATE()); + (1101, 500, util.VN_CURDATE(), util.VN_CURDATE()), + (1102, 500, util.VN_CURDATE(), util.VN_CURDATE()), + (1103, 500, util.VN_CURDATE(), util.VN_CURDATE()), + (1107, 500, util.VN_CURDATE(), util.VN_CURDATE()), + (1109, 500, util.VN_CURDATE(), util.VN_CURDATE()); UPDATE `vn`.`route` SET `invoiceInFk`=1 @@ -2501,16 +2524,16 @@ UPDATE `vn`.`route` WHERE `id`=2; INSERT INTO `bs`.`salesPerson` (`workerFk`, `year`, `month`, `portfolioWeight`) VALUES - (18, YEAR(CURDATE()), MONTH(CURDATE()), 807.23), - (19, YEAR(CURDATE()), MONTH(CURDATE()), 34.40); + (18, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 807.23), + (19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40); INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`) VALUES - (1, 501.95, CURDATE(), 2, 1101), - (2, 70.7, CURDATE(), 2, 1101), - (3, 200.78, CURDATE(), 2, 1101), - (4, 33.8, CURDATE(), 1, 1101), - (30, 34.4, CURDATE(), 1, 1108); + (1, 501.95, util.VN_CURDATE(), 2, 1101), + (2, 70.7, util.VN_CURDATE(), 2, 1101), + (3, 200.78, util.VN_CURDATE(), 2, 1101), + (4, 33.8, util.VN_CURDATE(), 1, 1101), + (30, 34.4, util.VN_CURDATE(), 1, 1108); INSERT INTO `vn`.`docuware` (`code`, `fileCabinetName`, `dialogName` , `find`) VALUES @@ -2530,7 +2553,7 @@ INSERT INTO `vn`.`calendarHolidaysType` (`id`, `name`, `hexColour`) INSERT INTO `vn`.`calendarHolidays` (`id`, `calendarHolidaysTypeFk`, `dated`, `calendarHolidaysNameFk`, `workCenterFk`) VALUES - (1, 1, CONCAT(YEAR(CURDATE()), '-12-09'), 1, 1); + (1, 1, CONCAT(YEAR(util.VN_CURDATE()), '-12-09'), 1, 1); INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`) VALUES @@ -2542,8 +2565,8 @@ INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackage INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`) VALUES - (1101, '@PetterParker', CURDATE(), 1, 'First test message', 0, 0), - (1101, '@PetterParker', CURDATE(), 0, 'Second test message', 0, 0); + (1101, '@PetterParker', util.VN_CURDATE(), 1, 'First test message', 0, 0), + (1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 0); INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`) @@ -2558,10 +2581,19 @@ INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmen INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`) VALUES - (1106, 1, CURDATE(), CURDATE()), - (1106, 1, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (1106, 2, CURDATE(), NULL), - (1106, 2, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)); + (1106, 1, util.VN_CURDATE(), util.VN_CURDATE()), + (1106, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), + (1106, 2, util.VN_CURDATE(), NULL), + (1106, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)); + +INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`) +VALUES + (1, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100), + (2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100); + +INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`) + VALUES + (2, 1); INSERT INTO `vn`.`mdbBranch` (`name`) VALUES @@ -2576,3 +2608,28 @@ INSERT INTO `vn`.`mdbVersion` (`app`, `branchFk`, `version`) INSERT INTO `vn`.`accountingConfig` (`id`, `minDate`, `maxDate`) VALUES (1, '2022-01-01', '2023-01-01'); + + +INSERT INTO `vn`.`saleGroup` (`userFk`, `parkingFk`, `sectorFk`) + VALUES + (1, 1, 1); + +INSERT INTO `vn`.`saleGroupDetail` (`saleFk`, `saleGroupFk`) + VALUES + (31, 1); + +INSERT INTO `vn`.`sectorCollection` (`userFk`, `sectorFk`) + VALUES + (1, 1); + +INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk`) + VALUES + (1, 1); + +INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`) + VALUES + (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); + +INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) + VALUES + (1, 9); diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql new file mode 100644 index 000000000..c63c2d76c --- /dev/null +++ b/db/dump/mockDate.sql @@ -0,0 +1,43 @@ +CREATE SCHEMA IF NOT EXISTS `util`; +USE `util`; + +DELIMITER ;; +DROP FUNCTION IF EXISTS `util`.`mockedDate`; +CREATE FUNCTION `util`.`mockedDate`() +RETURNS DATETIME +DETERMINISTIC +BEGIN + RETURN NOW(); + -- '2022-01-19 08:00:00' +END ;; +DELIMITER ; + +DELIMITER ;; +DROP FUNCTION IF EXISTS `util`.`VN_CURDATE`; +CREATE FUNCTION `util`.`VN_CURDATE`() +RETURNS DATE +DETERMINISTIC +BEGIN + RETURN DATE(mockedDate()); +END ;; +DELIMITER ; + +DELIMITER ;; +DROP FUNCTION IF EXISTS `util`.`VN_CURTIME`; +CREATE FUNCTION `util`.`VN_CURTIME`() +RETURNS TIME +DETERMINISTIC +BEGIN + RETURN TIME(mockedDate()); +END ;; +DELIMITER ; + +DELIMITER ;; +DROP FUNCTION IF EXISTS `util`.`VN_NOW`; +CREATE FUNCTION `util`.`VN_NOW`() +RETURNS DATETIME +DETERMINISTIC +BEGIN + RETURN mockedDate(); +END ;; +DELIMITER ; \ No newline at end of file diff --git a/db/export-data.sh b/db/export-data.sh index 101d0d8b0..bbbeb7152 100755 --- a/db/export-data.sh +++ b/db/export-data.sh @@ -111,4 +111,4 @@ TABLES=( TiposTransacciones TiposRetencion ) -dump_tables ${TABLES[@]} \ No newline at end of file +dump_tables ${TABLES[@]} diff --git a/db/export-structure.sh b/db/export-structure.sh index 9b23f43ac..88508f098 100755 --- a/db/export-structure.sh +++ b/db/export-structure.sh @@ -96,5 +96,12 @@ mysqldump \ --databases \ ${SCHEMAS[@]} \ ${IGNORETABLES[@]} \ + | sed 's/\bCURDATE\b/util.VN_CURDATE/ig'\ + | sed 's/\bCURTIME\b/util.VN_CURTIME/ig' \ + | sed 's/\bNOW\b/util.VN_NOW/ig' \ + | sed 's/\bCURRENT_DATE\b/util.VN_CURDATE/ig' \ + | sed 's/\bCURRENT_TIME\b/util.VN_CURTIME/ig' \ + | sed 's/\bLOCALTIME\b/util.VN_NOW/ig' \ + | sed 's/\bLOCALTIMESTAMP\b/util.VN_NOW/ig' \ | sed 's/ AUTO_INCREMENT=[0-9]* //g' \ - > dump/structure.sql + > dump/structure.sql \ No newline at end of file diff --git a/db/tests/vn/zone_getLanded.spec.js b/db/tests/vn/zone_getLanded.spec.js index 6673879e4..5f82156d3 100644 --- a/db/tests/vn/zone_getLanded.spec.js +++ b/db/tests/vn/zone_getLanded.spec.js @@ -5,8 +5,9 @@ describe('zone zone_getLanded()', () => { it(`should return data for a shipped in the past`, async() => { let stmts = []; let stmt; - stmts.push('START TRANSACTION'); + const date = new Date(); + date.setHours(0, 0, 0, 0); let params = { addressFk: 121, @@ -14,7 +15,8 @@ describe('zone zone_getLanded()', () => { warehouseFk: 1, showExpiredZones: true}; - stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(CURDATE(), INTERVAL -1 DAY), ?, ?, ?, ?)', [ + stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(?, INTERVAL -1 DAY), ?, ?, ?, ?)', [ + date, params.addressFk, params.agencyModeFk, params.warehouseFk, @@ -38,6 +40,8 @@ describe('zone zone_getLanded()', () => { it(`should return data for a shipped tomorrow`, async() => { let stmts = []; let stmt; + const date = new Date(); + date.setHours(0, 0, 0, 0); stmts.push('START TRANSACTION'); @@ -47,7 +51,8 @@ describe('zone zone_getLanded()', () => { warehouseFk: 1, showExpiredZones: false}; - stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(CURDATE(), INTERVAL +2 DAY), ?, ?, ?, ?)', [ + stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(?, INTERVAL +2 DAY), ?, ?, ?, ?)', [ + date, params.addressFk, params.agencyModeFk, params.warehouseFk, diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 88494bce5..37f7308a5 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -55,6 +55,7 @@ export default { setPassword: '.vn-menu [name="setPassword"]', activateAccount: '.vn-menu [name="enableAccount"]', activateUser: '.vn-menu [name="activateUser"]', + deactivateUser: '.vn-menu [name="deactivateUser"]', newPassword: 'vn-textfield[ng-model="$ctrl.newPassword"]', repeatPassword: 'vn-textfield[ng-model="$ctrl.repeatPassword"]', newRole: 'vn-autocomplete[ng-model="$ctrl.newRole"]', @@ -275,6 +276,7 @@ export default { clientWebAccess: { enableWebAccessCheckbox: 'vn-check[label="Enable web access"]', userName: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.name"]', + email: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.email"]', saveButton: 'button[type=submit]' }, clientNotes: { @@ -542,9 +544,8 @@ export default { searchResultDate: 'vn-ticket-summary [label=Landed] span', topbarSearch: 'vn-searchbar', moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]', - fourthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(4)', - fifthhWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(5)', - sixthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(6)', + fourthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(4)', + fiveWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(5)', weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr', firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]', firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-tr:nth-child(1) [ng-model="weekly.agencyModeFk"]', @@ -564,8 +565,6 @@ export default { isDeletedIcon: 'vn-ticket-descriptor vn-icon[icon="icon-deletedTicket"]', goBackToModuleIndexButton: 'vn-ticket-descriptor a[ui-sref="ticket.index"]', moreMenu: 'vn-ticket-descriptor vn-ticket-descriptor-menu > vn-icon-button[icon=more_vert]', - moreMenuAddStowaway: '.vn-menu [name="addStowaway"]', - moreMenuDeleteStowawayButton: '.vn-menu [name="deleteStowaway"]', moreMenuAddToTurn: '.vn-menu [name="addTurn"]', moreMenuDeleteTicket: '.vn-menu [name="deleteTicket"]', moreMenuRestoreTicket: '.vn-menu [name="restoreTicket"]', @@ -578,8 +577,6 @@ export default { sendSMSbutton: 'button[response="accept"]', changeShippedHourDialog: '.vn-dialog.shown', changeShippedHour: '.vn-dialog.shown vn-input-time[ng-model="$ctrl.newShipped"]', - addStowawayDialogFirstTicket: '.vn-dialog.shown vn-table vn-tbody vn-tr', - shipButton: 'vn-ticket-descriptor vn-icon[icon="icon-stowaway"]', thursdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(4)', saturdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(6)', acceptDialog: '.vn-dialog.shown button[response="accept"]', @@ -587,7 +584,6 @@ export default { descriptorDeliveryDate: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(4) > section > span', descriptorDeliveryAgency: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(5) > section > span', acceptInvoiceOutButton: '.vn-confirm.shown button[response="accept"]', - acceptDeleteStowawayButton: '.vn-dialog.shown button[response="accept"]' }, ticketNotes: { firstNoteRemoveButton: 'vn-icon[icon="delete"]', @@ -597,7 +593,7 @@ export default { submitNotesButton: 'button[type=submit]' }, ticketExpedition: { - secondExpeditionRemoveButton: 'vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button[icon="delete"]', + thirdExpeditionRemoveButton: 'vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(3) > vn-td:nth-child(1) > vn-icon-button[icon="delete"]', expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr' }, ticketPackages: { @@ -729,7 +725,7 @@ export default { claimSummary: { header: 'vn-claim-summary > vn-card > h5', state: 'vn-claim-summary vn-label-value[label="State"] > section > span', - observation: 'vn-claim-summary vn-textarea[ng-model="$ctrl.summary.claim.observation"]', + observation: 'vn-claim-summary vn-horizontal.text', firstSaleItemId: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(5) vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(1) > span', firstSaleDescriptorImage: '.vn-popover.shown vn-item-descriptor img', itemDescriptorPopover: '.vn-popover.shown vn-item-descriptor', @@ -741,7 +737,6 @@ export default { }, claimBasicData: { claimState: 'vn-claim-basic-data vn-autocomplete[ng-model="$ctrl.claim.claimStateFk"]', - observation: 'vn-textarea[ng-model="$ctrl.claim.observation"]', packages: 'vn-input-number[ng-model="$ctrl.claim.packages"]', hasToPickUpCheckbox: 'vn-claim-basic-data vn-check[ng-model="$ctrl.claim.hasToPickUp"]', saveButton: `button[type=submit]` @@ -771,6 +766,12 @@ export default { secondClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', saveDevelopmentButton: 'button[type=submit]' }, + claimNote: { + addNoteFloatButton: 'vn-float-button', + note: 'vn-textarea[ng-model="$ctrl.note.text"]', + saveButton: 'button[type=submit]', + firstNoteText: 'vn-claim-note .text' + }, claimAction: { importClaimButton: 'vn-claim-action vn-button[label="Import claim"]', anyLine: 'vn-claim-action vn-tbody > vn-tr', @@ -905,52 +906,16 @@ export default { dialogTimeInput: '.vn-dialog.shown vn-input-time[ng-model="$ctrl.newTimeEntry.timed"]', dialogTimeDirection: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.newTimeEntry.direction"]', mondayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button', - tuesdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(2) > vn-icon-button', - wednesdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(3) > vn-icon-button', - thursdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-icon-button', - fridayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(5) > vn-icon-button', - saturdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(6) > vn-icon-button', - sundayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(7) > vn-icon-button', firstEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(1) > vn-chip > div:nth-child(2)', - firstEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(1) > vn-chip > div:nth-child(2)', - firstEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(1) > vn-chip > div:nth-child(2)', - firstEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(1) > vn-chip > div:nth-child(2)', - firstEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(1) > vn-chip > div:nth-child(2)', - firstEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(1) > vn-chip > div:nth-child(2)', - firstEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(1) > vn-chip > div:nth-child(2)', + firstEntryOfMondayDelete: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(1) > vn-chip > vn-icon[icon="cancel"]', secondEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(2) > vn-chip > div:nth-child(2)', - secondEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(2) > vn-chip > div:nth-child(2)', - secondEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(2) > vn-chip > div:nth-child(2)', - secondEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(2) > vn-chip > div:nth-child(2)', - secondEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(2) > vn-chip > div:nth-child(2)', - secondEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(2) > vn-chip > div:nth-child(2)', - secondEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(2) > vn-chip > div:nth-child(2)', - thirdEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(3) > vn-chip > div:nth-child(2)', - thirdEntryOfMondayDelete: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(3) > vn-chip > vn-icon[icon="cancel"]', - thirdEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(3) > vn-chip > div:nth-child(2)', - thirdEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(3) > vn-chip > div:nth-child(2)', - thirdEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(3) > vn-chip > div:nth-child(2)', - thirdEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(3) > vn-chip > div:nth-child(2)', - thirdEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(3) > vn-chip > div:nth-child(2)', - thirdEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(3) > vn-chip > div:nth-child(2)', - fourthEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(4) > vn-chip > div:nth-child(2)', - fourthEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(4) > vn-chip > div:nth-child(2)', - fourthEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(4) > vn-chip > div:nth-child(2)', - fourthEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(4) > vn-chip > div:nth-child(2)', - fourthEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(4) > vn-chip > div:nth-child(2)', - fourthEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(4) > vn-chip > div:nth-child(2)', - fourthEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(4) > vn-chip > div:nth-child(2)', mondayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(1)', - tuesdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(2)', - wednesdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(3)', - thursdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(4)', - fridayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(5)', - saturdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(6)', - sundayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(7)', weekWorkedHours: 'vn-worker-time-control vn-side-menu vn-label-value > section > span', nextMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_right]', previousMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_left]', + monthName: 'vn-worker-time-control vn-side-menu vn-calendar div > .title', secondWeekDay: 'vn-worker-time-control vn-side-menu vn-calendar .day:nth-child(8) > .day-number', + thrirdWeekDay: 'vn-worker-time-control vn-side-menu vn-calendar .day:nth-child(15) > .day-number', navigateBackToIndex: 'vn-worker-descriptor [name="goToModuleIndex"]' }, workerCalendar: { diff --git a/e2e/paths/02-client/03_edit_fiscal_data.spec.js b/e2e/paths/02-client/03_edit_fiscal_data.spec.js index 4ae1d4eca..2a56cb535 100644 --- a/e2e/paths/02-client/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client/03_edit_fiscal_data.spec.js @@ -276,7 +276,7 @@ describe('Client Edit fiscalData path', () => { // confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 2 it(`should click on the 1st edit icon to access the address details and uncheck EQtax checkbox`, async() => { await page.waitToClick(selectors.clientAddresses.firstEditAddress); - await page.waitForTextInField(selectors.clientAddresses.city, 'Silla'); + await page.waitForTextInField(selectors.clientAddresses.city, 'Gotham'); await page.waitToClick(selectors.clientAddresses.equalizationTaxCheckbox); await page.waitToClick(selectors.clientAddresses.saveButton); const message = await page.waitForSnackbar(); diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js index c35237ab4..0581635d0 100644 --- a/e2e/paths/02-client/05_add_address.spec.js +++ b/e2e/paths/02-client/05_add_address.spec.js @@ -45,7 +45,7 @@ describe('Client Add address path', () => { expect(province).toContain('Province five'); }); - it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => { + it(`should throw after clicking save button as consignee, incoterms and customsAgent are empty`, async() => { await page.write(selectors.clientAddresses.consignee, 'Bruce Bunner'); await page.write(selectors.clientAddresses.streetAddress, '320 Park Avenue New York'); await page.waitToClick(selectors.clientAddresses.saveButton); diff --git a/e2e/paths/02-client/07_edit_web_access.spec.js b/e2e/paths/02-client/07_edit_web_access.spec.js index f75c7afad..8d8036373 100644 --- a/e2e/paths/02-client/07_edit_web_access.spec.js +++ b/e2e/paths/02-client/07_edit_web_access.spec.js @@ -1,3 +1,4 @@ +/* eslint max-len: ["error", { "code": 150 }]*/ import selectors from '../../helpers/selectors'; import getBrowser from '../../helpers/puppeteer'; @@ -8,7 +9,7 @@ describe('Client Edit web access path', () => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('employee', 'client'); - await page.accessToSearchResult('Bruce Banner'); + await page.accessToSearchResult('max'); await page.accessToSection('client.card.webAccess'); }); @@ -17,8 +18,6 @@ describe('Client Edit web access path', () => { }); it('should uncheck the Enable web access checkbox', async() => { - await page.waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox); - await page.waitToClick(selectors.clientWebAccess.saveButton); await page.waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox); await page.waitToClick(selectors.clientWebAccess.saveButton); const message = await page.waitForSnackbar(); @@ -28,7 +27,16 @@ describe('Client Edit web access path', () => { it(`should update the name`, async() => { await page.clearInput(selectors.clientWebAccess.userName); - await page.write(selectors.clientWebAccess.userName, 'Hulk'); + await page.write(selectors.clientWebAccess.userName, 'Legion'); + await page.waitToClick(selectors.clientWebAccess.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it(`should update the email`, async() => { + await page.clearInput(selectors.clientWebAccess.email); + await page.write(selectors.clientWebAccess.email, 'legion@marvel.com'); await page.waitToClick(selectors.clientWebAccess.saveButton); const message = await page.waitForSnackbar(); @@ -45,30 +53,36 @@ describe('Client Edit web access path', () => { it('should confirm web access name have been updated', async() => { const result = await page.waitToGetProperty(selectors.clientWebAccess.userName, 'value'); - expect(result).toEqual('Hulk'); + expect(result).toEqual('Legion'); + }); + + it('should confirm web access email have been updated', async() => { + const result = await page.waitToGetProperty(selectors.clientWebAccess.email, 'value'); + + expect(result).toEqual('legion@marvel.com'); }); it(`should navigate to the log section`, async() => { await page.accessToSection('client.card.log'); }); - it(`should confirm the last log is showing the updated client name and no modifications on the active checkbox`, async() => { + it(`should confirm the last log shows the updated client name and no modifications on active checkbox`, async() => { let lastModificationPreviousValue = await page .waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText'); let lastModificationCurrentValue = await page .waitToGetProperty(selectors.clientLog.lastModificationCurrentValue, 'innerText'); - expect(lastModificationPreviousValue).toEqual('name BruceBanner active false'); - expect(lastModificationCurrentValue).toEqual('name Hulk active false'); + expect(lastModificationPreviousValue).toEqual('name MaxEisenhardt active false'); + expect(lastModificationCurrentValue).toEqual('name Legion active false'); }); - it(`should confirm the penultimate log is showing the updated avtive field and no modifications on the client name`, async() => { + it(`should confirm the penultimate log shows the updated active and no modifications on client name`, async() => { let penultimateModificationPreviousValue = await page .waitToGetProperty(selectors.clientLog.penultimateModificationPreviousValue, 'innerText'); let penultimateModificationCurrentValue = await page .waitToGetProperty(selectors.clientLog.penultimateModificationCurrentValue, 'innerText'); - expect(penultimateModificationPreviousValue).toEqual('name BruceBanner active true'); - expect(penultimateModificationCurrentValue).toEqual('name BruceBanner active false'); + expect(penultimateModificationPreviousValue).toEqual('name MaxEisenhardt active true'); + expect(penultimateModificationCurrentValue).toEqual('name MaxEisenhardt active false'); }); }); diff --git a/e2e/paths/02-client/21_defaulter.spec.js b/e2e/paths/02-client/21_defaulter.spec.js index c7640d028..0eb16441f 100644 --- a/e2e/paths/02-client/21_defaulter.spec.js +++ b/e2e/paths/02-client/21_defaulter.spec.js @@ -28,12 +28,12 @@ describe('Client defaulter path', () => { const salesPersonName = await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText'); - expect(clientName).toEqual('Ororo Munroe'); - expect(salesPersonName).toEqual('salesPersonNick'); + expect(clientName).toEqual('Bruce Banner'); + expect(salesPersonName).toEqual('developer'); }); it('should first observation not changed', async() => { - const expectedObservation = 'Madness, as you know, is like gravity, all it takes is a little push'; + const expectedObservation = 'Meeting with Black Widow 21st 9am'; const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value'); expect(result).toContain(expectedObservation); diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js index 5709e6207..be8df3cf0 100644 --- a/e2e/paths/03-worker/04_time_control.spec.js +++ b/e2e/paths/03-worker/04_time_control.spec.js @@ -1,3 +1,4 @@ +/* eslint max-len: ["error", { "code": 150 }]*/ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; @@ -10,414 +11,105 @@ describe('Worker time control path', () => { await page.loginAndModule('salesBoss', 'worker'); await page.accessToSearchResult('HankPym'); await page.accessToSection('worker.card.timeControl'); - await page.waitToClick(selectors.workerTimeControl.previousMonthButton); - await page.waitToClick(selectors.workerTimeControl.secondWeekDay); }); afterAll(async() => { await browser.close(); }); - describe('as salesBoss', () => { - describe('on Monday', () => { - it('should scan in Hank Pym', async() => { - const scanTime = '07:00'; + const eightAm = '08:00'; + const fourPm = '16:00'; + const hankPymId = 1107; - await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText'); + it('should go to the next month', async() => { + const date = new Date(); + date.setMonth(date.getMonth() + 1); + const month = date.toLocaleString('default', {month: 'long'}); - expect(result).toEqual(scanTime); - }); + await page.waitToClick(selectors.workerTimeControl.nextMonthButton); + const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText'); - it(`should scan out Hank Pym for break`, async() => { - const scanTime = '10:00'; - - await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should scan in Hank Pym for a wrong hour and forget to scan in from the break`, async() => { - const scanTime = '18:00'; - - await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should delete the wrong entry for Hank Pym`, async() => { - const wrongScanTime = '18:00'; - - await page.waitForTextInElement(selectors.workerTimeControl.thirdEntryOfMonday, wrongScanTime); - await page.waitToClick(selectors.workerTimeControl.thirdEntryOfMondayDelete); - await page.respondToDialog('accept'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Entry removed'); - }); - - it(`should scan out Hank Pym to leave early`, async() => { - const scanTime = '14:00'; - - await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should add the break's scan in for Hank Pym and be in the right order`, async() => { - const scanTime = '10:20'; - - await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfMonday, 'innerText'); - - expect(result).toEqual('14:00'); - }); - - it(`should the third entry be the scan in from break`, async() => { - const scanTime = '10:20'; - - const result = await page - .waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should check Hank Pym worked 6:40 hours`, async() => { - await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '06:40 h.'); - }); - }); - - describe('on Tuesday', () => { - it('should happily scan in Hank Pym', async() => { - const scanTime = '08:00'; - - await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfTuesday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should happily scan out Hank Pym for break`, async() => { - const scanTime = '10:00'; - - await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfTuesday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should happily scan in Hank Pym from the break`, async() => { - const scanTime = '10:20'; - - await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfTuesday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should happily scan out Hank Pym for the day`, async() => { - const scanTime = '16:00'; - - await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfTuesday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should check Hank Pym worked 7:40 hours`, async() => { - await page.waitForTextInElement(selectors.workerTimeControl.tuesdayWorkedHours, '07:40 h.'); - }); - }); - - describe('on Wednesday', () => { - it('should cheerfully scan in Hank Pym', async() => { - const scanTime = '09:00'; - - await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfWednesday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should cheerfully scan out Hank Pym for break`, async() => { - const scanTime = '10:00'; - - await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfWednesday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should cheerfully scan in Hank Pym from the break`, async() => { - const scanTime = '10:20'; - - await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfWednesday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should cheerfully scan out Hank Pym for the day`, async() => { - const scanTime = '17:00'; - - await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfWednesday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should check Hank Pym worked 7:40 cheerfull hours`, async() => { - await page.waitForTextInElement(selectors.workerTimeControl.wednesdayWorkedHours, '07:40 h.'); - }); - }); - - describe('on Thursday', () => { - it('should joyfully scan in Hank Pym', async() => { - const scanTime = '09:59'; - - await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfThursday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should joyfully scan out Hank Pym for break`, async() => { - const scanTime = '10:00'; - await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfThursday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should joyfully scan in Hank Pym from the break`, async() => { - const scanTime = '10:20'; - await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfThursday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should joyfully scan out Hank Pym for the day`, async() => { - const scanTime = '17:59'; - await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfThursday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should check Hank Pym worked 7:40 joyfull hours`, async() => { - await page.waitForTextInElement(selectors.workerTimeControl.thursdayWorkedHours, '07:40 h.'); - }); - }); - - describe('on Friday', () => { - it('should smilingly scan in Hank Pym', async() => { - const scanTime = '07:30'; - await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfFriday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should smilingly scan out Hank Pym for break`, async() => { - const scanTime = '10:00'; - await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfFriday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should smilingly scan in Hank Pym from the break`, async() => { - const scanTime = '10:20'; - await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'intermediate'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfFriday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should smilingly scan out Hank Pym for the day`, async() => { - const scanTime = '15:30'; - await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfFriday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should check Hank Pym worked 7:40 hours with a smile on his face`, async() => { - await page.waitForTextInElement(selectors.workerTimeControl.fridayWorkedHours, '07:40 h.'); - }); - }); + expect(result).toContain(month); }); - describe('as HHRR', () => { - describe('on Saturday', () => { - it('should log in as hr and pick the worker module', async() => { - await page.loginAndModule('hr', 'worker'); - }); + it('should go to current month', async() => { + const date = new Date(); + const month = date.toLocaleString('default', {month: 'long'}); - it('should search for a worker and access to its summary', async() => { - await page.accessToSearchResult('HankPym'); - await page.waitForState('worker.card.summary'); - }); + await page.waitToClick(selectors.workerTimeControl.previousMonthButton); + const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText'); - it('should access to the time control section', async() => { - await page.accessToSection('worker.card.timeControl'); - await page.waitForState('worker.card.timeControl'); - await page.waitToClick(selectors.workerTimeControl.previousMonthButton); - await page.waitToClick(selectors.workerTimeControl.secondWeekDay); - }); - - it('should lovingly scan in Hank Pym', async() => { - const scanTime = '06:00'; - await page.waitForTimeout(1000); // without this timeout the dialog doesn't pop up - await page.waitToClick(selectors.workerTimeControl.saturdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfSaturday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should lovingly scan out Hank Pym for the day with no break to leave a bit early`, async() => { - const scanTime = '13:40'; - await page.waitToClick(selectors.workerTimeControl.saturdayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfSaturday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should check Hank Pym worked 7:40 hours with all his will`, async() => { - await page.waitForTextInElement(selectors.workerTimeControl.saturdayWorkedHours, '07:40 h.'); - }); - }); - - describe('on Sunday', () => { - it('should gladly scan in Hank Pym', async() => { - const scanTime = '05:00'; - await page.waitToClick(selectors.workerTimeControl.sundayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfSunday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should gladly scan out Hank Pym for the day with no break to leave a bit early`, async() => { - const scanTime = '12:40'; - await page.waitToClick(selectors.workerTimeControl.sundayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, scanTime); - await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); - await page.respondToDialog('accept'); - const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfSunday, 'innerText'); - - expect(result).toEqual(scanTime); - }); - - it(`should check Hank Pym worked 7:40 glad hours`, async() => { - await page.waitForTextInElement(selectors.workerTimeControl.sundayWorkedHours, '07:40 h.'); - }); - - it(`should check Hank Pym doesn't have hours set on the next months second week`, async() => { - await page.waitToClick(selectors.workerTimeControl.nextMonthButton); - await page.waitToClick(selectors.workerTimeControl.secondWeekDay); - await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '00:00 h.'); - }); - - it(`should check he didn't scan in this week yet`, async() => { - await page.waitToClick(selectors.workerTimeControl.navigateBackToIndex); - await page.accessToSearchResult('salesBoss'); - await page.accessToSection('worker.card.timeControl'); - - const wholeWeekHours = await page - .waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText'); - - expect(wholeWeekHours).toEqual('00:00 h.'); - }); - }); + expect(result).toContain(month); }); - describe('after all this amazing week', () => { - it('should log in Hank', async() => { - await page.loginAndModule('HankPym', 'worker'); - await page.accessToSearchResult('HankPym'); - await page.accessToSection('worker.card.timeControl'); - await page.waitToClick(selectors.workerTimeControl.previousMonthButton); - await page.waitToClick(selectors.workerTimeControl.secondWeekDay); - }); + it('should go 1 month in the past', async() => { + const date = new Date(); + date.setMonth(date.getMonth() - 1); + const timestamp = Math.round(date.getTime() / 1000); + const month = date.toLocaleString('default', {month: 'long'}); - it('should check his weekly hours are alright', async() => { - await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '52:40 h.'); - }); + await page.loginAndModule('salesBoss', 'worker'); + await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`); + await page.waitToClick(selectors.workerTimeControl.secondWeekDay); + + const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText'); + + expect(result).toContain(month); + }); + + it(`should return error when insert 'out' of first entry`, async() => { + await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); + await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm); + await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); + await page.respondToDialog('accept'); + const message = await page.waitForSnackbar(); + + expect(message.text).toBeDefined(); + }); + + it(`should insert 'in' monday`, async() => { + await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); + await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm); + await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in'); + await page.respondToDialog('accept'); + const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText'); + + expect(result).toEqual(eightAm); + }); + + it(`should insert 'out' monday`, async() => { + await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); + await page.pickTime(selectors.workerTimeControl.dialogTimeInput, fourPm); + await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); + await page.respondToDialog('accept'); + const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText'); + + expect(result).toEqual(fourPm); + }); + + it(`should check Hank Pym worked 8:20 hours`, async() => { + await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '08:20 h.'); + await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '08:20 h.'); + }); + + it('should remove first entry of monday', async() => { + await page.waitForTextInElement(selectors.workerTimeControl.firstEntryOfMonday, eightAm); + await page.waitForTextInElement(selectors.workerTimeControl.secondEntryOfMonday, fourPm); + await page.waitToClick(selectors.workerTimeControl.firstEntryOfMondayDelete); + await page.respondToDialog('accept'); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Entry removed'); + }); + + it(`should be the 'out' the first entry of monday`, async() => { + const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText'); + + expect(result).toEqual(fourPm); + }); + + it('should change week of month', async() => { + await page.waitToClick(selectors.workerTimeControl.thrirdWeekDay); + await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '00:00 h.'); }); }); diff --git a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js index 0e6482c94..dd2525f43 100644 --- a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js +++ b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js @@ -18,7 +18,7 @@ describe('Ticket expeditions and log path', () => { }); it(`should delete a former expedition and confirm the remaining expedition are the expected ones`, async() => { - await page.waitToClick(selectors.ticketExpedition.secondExpeditionRemoveButton); + await page.waitToClick(selectors.ticketExpedition.thirdExpeditionRemoveButton); await page.waitToClick(selectors.globalItems.acceptButton); await page.reloadSection('ticket.card.expedition'); diff --git a/e2e/paths/05-ticket/06_basic_data_steps.spec.js b/e2e/paths/05-ticket/06_basic_data_steps.spec.js index fa118c25d..46cbf29b8 100644 --- a/e2e/paths/05-ticket/06_basic_data_steps.spec.js +++ b/e2e/paths/05-ticket/06_basic_data_steps.spec.js @@ -42,7 +42,7 @@ describe('Ticket Edit basic data path', () => { expect(disabled).toBeFalsy(); }); - it(`should check the zone is for Silla247`, async() => { + it(`should check the zone is for Gotham247`, async() => { let zone = await page .waitToGetProperty(selectors.ticketBasicData.zone, 'value'); @@ -63,7 +63,7 @@ describe('Ticket Edit basic data path', () => { let zone = await page .waitToGetProperty(selectors.ticketBasicData.agency, 'value'); - expect(zone).toContain('Silla247Expensive'); + expect(zone).toContain('Gotham247Expensive'); }); it(`should click next`, async() => { @@ -92,7 +92,7 @@ describe('Ticket Edit basic data path', () => { }); it(`should split ticket without negatives`, async() => { - const newAgency = 'Silla247'; + const newAgency = 'Gotham247'; const newDate = new Date(); newDate.setDate(newDate.getDate() - 1); diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js index 247dd2ab3..d04138ee5 100644 --- a/e2e/paths/05-ticket/09_weekly.spec.js +++ b/e2e/paths/05-ticket/09_weekly.spec.js @@ -80,7 +80,7 @@ describe('Ticket descriptor path', () => { it('should confirm the ticket 11 was added on saturday', async() => { await page.accessToSection('ticket.weekly.index'); - const result = await page.waitToGetProperty(selectors.ticketsIndex.fifthhWeeklyTicket, 'value'); + const result = await page.waitToGetProperty(selectors.ticketsIndex.fiveWeeklyTicket, 'value'); expect(result).toEqual('Saturday'); }); @@ -108,7 +108,7 @@ describe('Ticket descriptor path', () => { }); it('should update the agency then remove it afterwards', async() => { - await page.autocompleteSearch(selectors.ticketsIndex.firstWeeklyTicketAgency, 'Silla247'); + await page.autocompleteSearch(selectors.ticketsIndex.firstWeeklyTicketAgency, 'Gotham247'); let message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); diff --git a/e2e/paths/05-ticket/12_descriptor.spec.js b/e2e/paths/05-ticket/12_descriptor.spec.js index 3429acc89..ca6fb8290 100644 --- a/e2e/paths/05-ticket/12_descriptor.spec.js +++ b/e2e/paths/05-ticket/12_descriptor.spec.js @@ -75,59 +75,6 @@ describe('Ticket descriptor path', () => { }); }); - describe('Add stowaway', () => { - it('should search for a ticket', async() => { - await page.accessToSearchResult('16'); - await page.waitForState('ticket.card.summary'); - }); - - it('should open the add stowaway dialog', async() => { - await page.waitForFunction(() => { - let element = document.querySelector('vn-ticket-descriptor-menu'); - return element.$ctrl.canShowStowaway === true; - }); - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway); - await page.waitForSelector(selectors.ticketDescriptor.addStowawayDialogFirstTicket); - const isVisible = await page.isVisible(selectors.ticketDescriptor.addStowawayDialogFirstTicket); - - expect(isVisible).toBeTruthy(); - }); - - it('should add a ticket as stowaway', async() => { - await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should check the state of the stowaway ticket is embarked`, async() => { - await page.waitForState('ticket.card.summary'); - const state = await page.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText'); - - expect(state).toEqual('State Embarcando'); - }); - - it(`should navigate back to the added ticket using the descriptors ship button`, async() => { - await page.waitToClick(selectors.ticketDescriptor.shipButton); - await page.waitForState('ticket.card.summary'); - }); - - it('should delete the stowaway', async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitForContentLoaded(); - await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteStowawayButton); - await page.waitToClick(selectors.ticketDescriptor.acceptDeleteStowawayButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the ship buton doesn't exisist any more`, async() => { - await page.waitForSelector(selectors.ticketDescriptor.shipButton, {hidden: true}); - }); - }); - describe('Make invoice', () => { it('should login as administrative role then search for a ticket', async() => { const invoiceableTicketId = '14'; diff --git a/e2e/paths/05-ticket/13_services.spec.js b/e2e/paths/05-ticket/13_services.spec.js index 03e57b588..50df23582 100644 --- a/e2e/paths/05-ticket/13_services.spec.js +++ b/e2e/paths/05-ticket/13_services.spec.js @@ -23,9 +23,9 @@ describe('Ticket services path', () => { await page.waitForClassPresent(selectors.ticketService.firstAddServiceTypeButton, 'disabled'); await page.waitToClick(selectors.ticketService.addServiceButton); await page.waitForSelector(selectors.ticketService.firstAddServiceTypeButton); - const result = await page.isDisabled(selectors.ticketService.firstAddServiceTypeButton); + const disabled = await page.isDisabled(selectors.ticketService.firstAddServiceTypeButton); - expect(result).toBe(true); + expect(disabled).toBe(true); }); it('should receive an error if you attempt to save a service without access rights', async() => { diff --git a/e2e/paths/05-ticket/14_create_ticket.spec.js b/e2e/paths/05-ticket/14_create_ticket.spec.js index bfaa08775..48b4ebdd0 100644 --- a/e2e/paths/05-ticket/14_create_ticket.spec.js +++ b/e2e/paths/05-ticket/14_create_ticket.spec.js @@ -6,7 +6,6 @@ describe('Ticket create path', () => { let page; let nextMonth = new Date(); nextMonth.setMonth(nextMonth.getMonth() + 1); - let stowawayTicketId; beforeAll(async() => { browser = await getBrowser(); @@ -27,7 +26,7 @@ describe('Ticket create path', () => { await page.autocompleteSearch(selectors.createTicketView.client, 'Clark Kent'); await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth); await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse Two'); - await page.autocompleteSearch(selectors.createTicketView.agency, 'Silla247'); + await page.autocompleteSearch(selectors.createTicketView.agency, 'Gotham247'); await page.waitToClick(selectors.createTicketView.createButton); const message = await page.waitForSnackbar(); @@ -36,8 +35,6 @@ describe('Ticket create path', () => { it('should check the url is now the summary of the ticket', async() => { await page.waitForState('ticket.card.summary'); - stowawayTicketId = await page.waitToGetProperty(selectors.ticketSummary.descriptorTicketId, 'innerText'); - stowawayTicketId = stowawayTicketId.substring(1); }); it('should again open the new ticket form', async() => { @@ -50,7 +47,7 @@ describe('Ticket create path', () => { await page.autocompleteSearch(selectors.createTicketView.client, 'Clark Kent'); await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth); await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse One'); - await page.autocompleteSearch(selectors.createTicketView.agency, 'Silla247'); + await page.autocompleteSearch(selectors.createTicketView.agency, 'Gotham247'); await page.waitToClick(selectors.createTicketView.createButton); const message = await page.waitForSnackbar(); @@ -61,15 +58,6 @@ describe('Ticket create path', () => { await page.waitForState('ticket.card.summary'); }); - it('should make the previously created ticket the stowaway of the current ticket', async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway); - await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - it('should delete the current ticket', async() => { await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket); @@ -78,11 +66,4 @@ describe('Ticket create path', () => { expect(message.text).toContain('Ticket deleted. You can undo this action within the first hour'); }); - - it('should search for the stowaway ticket of the previously deleted ticket', async() => { - await page.accessToSearchResult(stowawayTicketId); - const result = await page.countElement(selectors.ticketDescriptor.shipButton); - - expect(result).toBe(0); - }); }); diff --git a/e2e/paths/06-claim/01_basic_data.spec.js b/e2e/paths/06-claim/01_basic_data.spec.js index 2e2286939..0a08cad9f 100644 --- a/e2e/paths/06-claim/01_basic_data.spec.js +++ b/e2e/paths/06-claim/01_basic_data.spec.js @@ -22,8 +22,6 @@ describe('Claim edit basic data path', () => { it(`should edit claim state and observation fields`, async() => { await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Gestionado'); - await page.clearTextarea(selectors.claimBasicData.observation); - await page.write(selectors.claimBasicData.observation, 'edited observation'); await page.clearInput(selectors.claimBasicData.packages); await page.write(selectors.claimBasicData.packages, '2'); await page.waitToClick(selectors.claimBasicData.saveButton); @@ -59,13 +57,6 @@ describe('Claim edit basic data path', () => { expect(hasToPickUpCheckbox).toBe('checked'); }); - it('should confirm the claim observation was edited', async() => { - const result = await page - .waitToGetProperty(selectors.claimBasicData.observation, 'value'); - - expect(result).toEqual('edited observation'); - }); - it('should confirm the claim packages was edited', async() => { const result = await page .waitToGetProperty(selectors.claimBasicData.packages, 'value'); @@ -75,8 +66,6 @@ describe('Claim edit basic data path', () => { it(`should edit the claim to leave it untainted`, async() => { await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Pendiente'); - await page.clearTextarea(selectors.claimBasicData.observation); - await page.write(selectors.claimBasicData.observation, 'Observation one'); await page.clearInput(selectors.claimBasicData.packages); await page.write(selectors.claimBasicData.packages, '0'); await page.waitToClick(selectors.claimBasicData.saveButton); diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js index 589b3b6cb..00b021f88 100644 --- a/e2e/paths/06-claim/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -37,7 +37,7 @@ describe('Claim summary path', () => { }); it('should display the observation', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'value'); + const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'innerText'); expect(result).toContain('Wisi forensibus mnesarchum in cum. Per id impetus abhorreant'); }); diff --git a/e2e/paths/06-claim/07_note.spec.js b/e2e/paths/06-claim/07_note.spec.js new file mode 100644 index 000000000..830f77cbe --- /dev/null +++ b/e2e/paths/06-claim/07_note.spec.js @@ -0,0 +1,46 @@ +import selectors from '../../helpers/selectors'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Claim Add note path', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('salesPerson', 'claim'); + await page.accessToSearchResult('2'); + await page.accessToSection('claim.card.note.index'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it(`should reach the claim note index`, async() => { + await page.waitForState('claim.card.note.index'); + }); + + it(`should click on the add new note button`, async() => { + await page.waitToClick(selectors.claimNote.addNoteFloatButton); + await page.waitForState('claim.card.note.create'); + }); + + it(`should create a new note`, async() => { + await page.waitForSelector(selectors.claimNote.note); + await page.type(`${selectors.claimNote.note} textarea`, 'The delivery was unsuccessful'); + await page.waitToClick(selectors.claimNote.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it(`should redirect back to the claim notes page`, async() => { + await page.waitForState('claim.card.note.index'); + }); + + it('should confirm the note was created', async() => { + const result = await page.waitToGetProperty(selectors.claimNote.firstNoteText, 'innerText'); + + expect(result).toEqual('The delivery was unsuccessful'); + }); +}); diff --git a/e2e/paths/07-order/01_summary.spec.js b/e2e/paths/07-order/01_summary.spec.js index 9b9e37998..922d5eeee 100644 --- a/e2e/paths/07-order/01_summary.spec.js +++ b/e2e/paths/07-order/01_summary.spec.js @@ -34,7 +34,7 @@ describe('Order summary path', () => { it('should check the summary contains the order consignee', async() => { const result = await page.waitToGetProperty(selectors.orderSummary.consignee, 'innerText'); - expect(result).toEqual('address 26 - Silla (Province one)'); + expect(result).toEqual('address 26 - Gotham (Province one)'); }); it('should check the summary contains the order subtotal', async() => { diff --git a/e2e/paths/08-route/01_summary.spec.js b/e2e/paths/08-route/01_summary.spec.js index 02cc71f2f..b6052dff6 100644 --- a/e2e/paths/08-route/01_summary.spec.js +++ b/e2e/paths/08-route/01_summary.spec.js @@ -9,7 +9,7 @@ describe('Route summary path', () => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('employee', 'route'); - await page.waitToClick('vn-route-index vn-tbody > a:nth-child(1)'); + await page.waitToClick('vn-route-index vn-tbody > a:nth-child(7)'); }); afterAll(async() => { diff --git a/e2e/paths/12-entry/02_descriptor.spec.js b/e2e/paths/12-entry/02_descriptor.spec.js index 699d00517..997a6065c 100644 --- a/e2e/paths/12-entry/02_descriptor.spec.js +++ b/e2e/paths/12-entry/02_descriptor.spec.js @@ -29,7 +29,7 @@ describe('Entry descriptor path', () => { it('should click the travels button to be redirected to the travels index filtered by the current agency', async() => { await page.waitToClick(selectors.entryDescriptor.travelsQuicklink); await page.expectURL('/travel/index'); - await page.expectURL('agencyFk'); + await page.expectURL('agencyModeFk'); }); it('should go back to the entry summary', async() => { diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js index 4048413ba..0fc657375 100644 --- a/e2e/paths/14-account/01_create_and_basic_data.spec.js +++ b/e2e/paths/14-account/01_create_and_basic_data.spec.js @@ -36,8 +36,7 @@ describe('Account create and basic data path', () => { await page.waitForState('account.card.basicData'); }); - it('should reload the section and check the name is as expected', async() => { - await page.reloadSection('account.card.basicData'); + it('should check the name is as expected', async() => { const result = await page.waitToGetProperty(selectors.accountBasicData.name, 'value'); expect(result).toEqual('Remy'); @@ -103,25 +102,39 @@ describe('Account create and basic data path', () => { }); }); - // creating the account without the active property set to true seems to be creating an active user anyways - // describe('activate user', () => { - // it(`should check the inactive user icon is present in the descriptor`, async() => { - // await page.waitForSelector(selectors.accountDescriptor.activeUserIcon, {visible: true}); - // }); + describe('deactivate user', () => { + it(`should check the inactive user icon isn't present in the descriptor just yet`, async() => { + await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0); + }); - // it('should activate the user using the descriptor menu', async() => { - // await page.waitToClick(selectors.accountDescriptor.menuButton); - // await page.waitToClick(selectors.accountDescriptor.activateUser); - // await page.waitToClick(selectors.accountDescriptor.acceptButton); - // const message = await page.waitForSnackbar(); + it('should deactivate the user using the descriptor menu', async() => { + await page.waitToClick(selectors.accountDescriptor.menuButton); + await page.waitToClick(selectors.accountDescriptor.deactivateUser); + await page.waitToClick(selectors.accountDescriptor.acceptButton); + const message = await page.waitForSnackbar(); - // expect(message.text).toContain('user enabled?'); - // }); + expect(message.text).toContain('User deactivated!'); + }); - // it('should check the inactive user icon is not present anymore', async() => { - // await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0); - // }); - // }); + it('should check the inactive user icon is now present', async() => { + await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 1); + }); + }); + + describe('activate user', () => { + it('should activate the user using the descriptor menu', async() => { + await page.waitToClick(selectors.accountDescriptor.menuButton); + await page.waitToClick(selectors.accountDescriptor.activateUser); + await page.waitToClick(selectors.accountDescriptor.acceptButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('User activated!'); + }); + + it('should check the inactive user icon is not present anymore', async() => { + await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0); + }); + }); describe('mail forwarding', () => { it('should activate the mail forwarding and set the recipent email', async() => { diff --git a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js index 0514899bc..dd35dd740 100644 --- a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js +++ b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js @@ -56,7 +56,7 @@ describe('Account Alias create and basic data path', () => { expect(result).toContain('psykers'); }); - it('should search for the IT alias group then access to the users section then check the role listed is the expected one', async() => { + it('should search IT alias then access the user section to check the role listed is the expected one', async() => { await page.accessToSearchResult('IT'); await page.accessToSection('account.alias.card.users'); const rolesCount = await page.countElement(selectors.accountAliasUsers.anyResult); diff --git a/front/core/filters/currency.js b/front/core/filters/currency.js index d44457813..a25ff6b27 100644 --- a/front/core/filters/currency.js +++ b/front/core/filters/currency.js @@ -15,8 +15,9 @@ export default function currency($translate) { maximumFractionDigits: fractionSize }; + const lang = $translate.use() == 'es' ? 'de' : $translate.use(); if (typeof input == 'number') { - return new Intl.NumberFormat($translate.use(), options) + return new Intl.NumberFormat(lang, options) .format(input); } diff --git a/front/core/services/app.js b/front/core/services/app.js index 6b2cd1d2a..889b24d01 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -10,6 +10,7 @@ export default class App { constructor() { this.loaderStatus = 0; this.loading = false; + this.versionInterval = setInterval(this.getVersion.bind(this), 300000); } showMessage(message) { @@ -38,6 +39,21 @@ export default class App { if (this.loaderStatus === 0) this.loading = false; } + + getVersion() { + this.logger.$http.get('Applications/status'); + } + + setVersion(newVersion) { + if (newVersion) { + const currentVersion = localStorage.getItem('salix-version'); + if (newVersion != currentVersion) { + this.hasNewVersion = true; + clearInterval(this.versionInterval); + } + localStorage.setItem('salix-version', newVersion); + } + } } ngModule.service('vnApp', App); diff --git a/front/core/services/interceptor.js b/front/core/services/interceptor.js index b7cf3a0ec..3f3d9912b 100644 --- a/front/core/services/interceptor.js +++ b/front/core/services/interceptor.js @@ -30,14 +30,17 @@ function interceptor($q, vnApp, vnToken, $translate) { }, response(response) { vnApp.popLoader(); + const newVersion = response.headers('salix-version'); + vnApp.setVersion(newVersion); + return response; }, responseError(rejection) { vnApp.popLoader(); - let err = new HttpError(rejection.statusText); + const err = new HttpError(rejection.statusText); Object.assign(err, rejection); return $q.reject(err); - } + }, }; } ngModule.factory('vnInterceptor', interceptor); diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css index c500f976d..2dee94c3b 100644 --- a/front/core/styles/icons/salixfont.css +++ b/front/core/styles/icons/salixfont.css @@ -343,9 +343,6 @@ .icon-splur:before { content: "\e970"; } -.icon-stowaway:before { - content: "\e94f"; -} .icon-supplier:before { content: "\e925"; } diff --git a/front/core/styles/icons/salixfont.svg b/front/core/styles/icons/salixfont.svg index 2b8b1ac8a..96a584734 100644 --- a/front/core/styles/icons/salixfont.svg +++ b/front/core/styles/icons/salixfont.svg @@ -85,8 +85,6 @@ - - diff --git a/front/module-import.js b/front/module-import.js index ab1eb73d6..bc547deeb 100755 --- a/front/module-import.js +++ b/front/module-import.js @@ -21,6 +21,7 @@ export default function moduleImport(moduleName) { case 'entry' : return import('entry/front'); case 'account' : return import('account/front'); case 'supplier' : return import('supplier/front'); + case 'shelving' : return import('shelving/front'); case 'monitor' : return import('monitor/front'); } } diff --git a/front/salix/components/layout/index.html b/front/salix/components/layout/index.html index cd13c565e..5a525ef77 100644 --- a/front/salix/components/layout/index.html +++ b/front/salix/components/layout/index.html @@ -19,6 +19,14 @@
+ + -
diff --git a/front/salix/components/layout/index.js b/front/salix/components/layout/index.js index 986f61622..372e8e828 100644 --- a/front/salix/components/layout/index.js +++ b/front/salix/components/layout/index.js @@ -26,6 +26,10 @@ export class Layout extends Component { const token = this.vnToken.token; return `/api/Images/user/160x160/${userId}/download?access_token=${token}`; } + + refresh() { + window.location.reload(); + } } Layout.$inject = ['$element', '$scope', 'vnModules']; diff --git a/front/salix/components/layout/style.scss b/front/salix/components/layout/style.scss index 36522bc3a..612366228 100644 --- a/front/salix/components/layout/style.scss +++ b/front/salix/components/layout/style.scss @@ -60,6 +60,9 @@ vn-layout { font-size: 1.05rem; padding: 0; } + .vn-icon-button.refresh { + color: $color-alert; + } } & > vn-side-menu > .menu { display: flex; diff --git a/front/salix/locale/es.yml b/front/salix/locale/es.yml index 4e93ae18e..e5dc82b16 100644 --- a/front/salix/locale/es.yml +++ b/front/salix/locale/es.yml @@ -17,6 +17,7 @@ Go to module summary: Ir a la vista previa del módulo Show summary: Mostrar vista previa What is new: Novedades de la versión Settings: Ajustes +There is a new version, click here to reload: Hay una nueva versión, pulse aquí para recargar # Actions diff --git a/jest-front.js b/jest-front.js index 7a692f57c..6d7532260 100644 --- a/jest-front.js +++ b/jest-front.js @@ -13,6 +13,7 @@ import './modules/route/front/module.js'; import './modules/ticket/front/module.js'; import './modules/travel/front/module.js'; import './modules/worker/front/module.js'; +import './modules/shelving/front/module.js'; core.run(vnInterceptor => { vnInterceptor.setApiPath(null); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index b7e9b43d3..ccf16cce0 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -54,7 +54,6 @@ "You can't delete a confirmed order": "You can't delete a confirmed order", "Value has an invalid format": "Value has an invalid format", "The postcode doesn't exist. Please enter a correct one": "The postcode doesn't exist. Please enter a correct one", - "Can't create stowaway for this ticket": "Can't create stowaway for this ticket", "Swift / BIC can't be empty": "Swift / BIC can't be empty", "Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", "Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", @@ -70,7 +69,6 @@ "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked", "Claim state has changed to incomplete": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *incomplete*", "Claim state has changed to canceled": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *canceled*", - "This ticket is not an stowaway anymore": "The ticket id [{{ticketId}}]({{{ticketUrl}}}) is not an stowaway anymore", "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}", @@ -123,5 +121,14 @@ "The worker has hours recorded that day": "The worker has hours recorded that day", "isWithoutNegatives": "isWithoutNegatives", "routeFk": "routeFk", - "Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data" + "Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data", + "Can't change the password of another worker": "Can't change the password of another worker", + "No hay un contrato en vigor": "There is no existing contract", + "No está permitido trabajar": "Not allowed to work", + "Dirección incorrecta": "Wrong direction", + "No se permite fichar a futuro": "It is not allowed to sign in the future", + "Descanso diario 12h.": "Daily rest 12h.", + "Fichadas impares": "Odd signs", + "Descanso diario 9h.": "Daily rest 9h.", + "Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h." } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 37e014678..07a00024a 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -101,7 +101,6 @@ "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", - "Can't create stowaway for this ticket": "No se puede crear un polizon para este ticket", "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto", "Invalid quantity": "Cantidad invalida", "This postal code is not valid": "This postal code is not valid", @@ -138,7 +137,6 @@ "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*", "Claim state has changed to incomplete": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *incompleta*", "Claim state has changed to canceled": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *anulado*", - "This ticket is not an stowaway anymore": "El ticket id [{{ticketId}}]({{{ticketUrl}}}) ha dejado de ser un polizón", "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", @@ -226,5 +224,13 @@ "reference duplicated": "Referencia duplicada", "This ticket is already a refund": "Este ticket ya es un abono", "isWithoutNegatives": "isWithoutNegatives", - "routeFk": "routeFk" + "routeFk": "routeFk", + "Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador", + "No hay un contrato en vigor": "No hay un contrato en vigor", + "No se permite fichar a futuro": "No se permite fichar a futuro", + "No está permitido trabajar": "No está permitido trabajar", + "Fichadas impares": "Fichadas impares", + "Descanso diario 12h.": "Descanso diario 12h.", + "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.", + "Dirección incorrecta": "Dirección incorrecta" } \ No newline at end of file diff --git a/loopback/server/middleware.json b/loopback/server/middleware.json index 60bedcdb3..d65b8b34a 100644 --- a/loopback/server/middleware.json +++ b/loopback/server/middleware.json @@ -31,7 +31,8 @@ "loopback#token": {} }, "auth:after": { - "./middleware/current-user": {} + "./middleware/current-user": {}, + "./middleware/salix-version": {} }, "parse": { "body-parser#json":{} diff --git a/loopback/server/middleware/salix-version.js b/loopback/server/middleware/salix-version.js new file mode 100644 index 000000000..988a3b39c --- /dev/null +++ b/loopback/server/middleware/salix-version.js @@ -0,0 +1,8 @@ +const packageJson = require('../../../package.json'); + +module.exports = function(options) { + return function(req, res, next) { + res.set('Salix-Version', packageJson.version); + next(); + }; +}; diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js index de812417a..22a48f83e 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('importToNewRefundTicket', { - description: 'Imports lines from claimBeginning to a new ticket with specific shipped, landed dates, agency and company', + description: 'Import lines of claimBeginning to new ticket with shipped, landed dates, agency and company', accessType: 'WRITE', accepts: [{ arg: 'id', diff --git a/modules/claim/back/methods/claim/getSummary.js b/modules/claim/back/methods/claim/getSummary.js index 0accbf920..8ab39eb45 100644 --- a/modules/claim/back/methods/claim/getSummary.js +++ b/modules/claim/back/methods/claim/getSummary.js @@ -84,6 +84,20 @@ module.exports = Self => { }; promises.push(Self.app.models.ClaimBeginning.find(filter, myOptions)); + // Claim observations + filter = { + where: {claimFk: id}, + include: [ + { + relation: 'worker', + scope: { + fields: ['id', 'firstName', 'lastName'] + } + } + ] + }; + promises.push(Self.app.models.ClaimObservation.find(filter, myOptions)); + // Claim developments filter = { where: {claimFk: id}, @@ -138,8 +152,9 @@ module.exports = Self => { summary.isEditable = await Self.isEditable(ctx, id, myOptions); [summary.claim] = res[0]; summary.salesClaimed = res[1]; - summary.developments = res[2]; - summary.actions = res[3]; + summary.observations = res[2]; + summary.developments = res[3]; + summary.actions = res[4]; return summary; }; diff --git a/modules/claim/back/methods/claim/specs/getSummary.spec.js b/modules/claim/back/methods/claim/specs/getSummary.spec.js index 6eb920b29..c4d01ecdc 100644 --- a/modules/claim/back/methods/claim/specs/getSummary.spec.js +++ b/modules/claim/back/methods/claim/specs/getSummary.spec.js @@ -19,6 +19,7 @@ describe('claim getSummary()', () => { expect(keys).toContain('claim'); expect(keys).toContain('salesClaimed'); expect(keys).toContain('developments'); + expect(keys).toContain('observations'); expect(keys).toContain('actions'); expect(keys).toContain('isEditable'); diff --git a/modules/claim/back/model-config.json b/modules/claim/back/model-config.json index d4d772b58..e99a455ac 100644 --- a/modules/claim/back/model-config.json +++ b/modules/claim/back/model-config.json @@ -38,6 +38,9 @@ "ClaimLog": { "dataSource": "vn" }, + "ClaimObservation": { + "dataSource": "vn" + }, "ClaimContainer": { "dataSource": "claimStorage" } diff --git a/modules/claim/back/models/claim-observation.json b/modules/claim/back/models/claim-observation.json new file mode 100644 index 000000000..e882ad09d --- /dev/null +++ b/modules/claim/back/models/claim-observation.json @@ -0,0 +1,43 @@ +{ + "name": "ClaimObservation", + "base": "Loggable", + "log": { + "model": "ClaimLog", + "relation": "claim" + }, + "options": { + "mysql": { + "table": "claimObservation" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "claimFk": { + "type": "number", + "required": true + }, + "text": { + "type": "string", + "required": true + }, + "created": { + "type": "date" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "claim": { + "type": "belongsTo", + "model": "Claim", + "foreignKey": "claimFk" + } + } +} \ No newline at end of file diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index 28fd92472..7a91e180a 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -51,15 +51,6 @@ label="Packages received" ng-model="$ctrl.claim.packages"> - - - - - - + +
+ + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/claim/front/note/create/index.js b/modules/claim/front/note/create/index.js new file mode 100644 index 000000000..40ae9309b --- /dev/null +++ b/modules/claim/front/note/create/index.js @@ -0,0 +1,22 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + constructor($element, $) { + super($element, $); + this.note = { + claimFk: parseInt(this.$params.id), + workerFk: window.localStorage.currentUserWorkerId, + text: null + }; + } + + cancel() { + this.$state.go('claim.card.note.index', {id: this.$params.id}); + } +} + +ngModule.vnComponent('vnClaimNoteCreate', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/claim/front/note/index/index.html b/modules/claim/front/note/index/index.html new file mode 100644 index 000000000..8ffe19c2b --- /dev/null +++ b/modules/claim/front/note/index/index.html @@ -0,0 +1,32 @@ + + + + +
+ + {{::note.worker.firstName}} {{::note.worker.lastName}} + {{::note.created | date:'dd/MM/yyyy HH:mm'}} + + + {{::note.text}} + +
+
+
+ + + \ No newline at end of file diff --git a/modules/claim/front/note/index/index.js b/modules/claim/front/note/index/index.js new file mode 100644 index 000000000..5a2fd96d3 --- /dev/null +++ b/modules/claim/front/note/index/index.js @@ -0,0 +1,25 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; +import './style.scss'; + +export default class Controller extends Section { + constructor($element, $) { + super($element, $); + this.filter = { + order: 'created DESC', + }; + this.include = { + relation: 'worker', + scope: { + fields: ['id', 'firstName', 'lastName'] + } + }; + } +} + +Controller.$inject = ['$element', '$scope']; + +ngModule.vnComponent('vnClaimNote', { + template: require('./index.html'), + controller: Controller, +}); diff --git a/modules/claim/front/note/index/style.scss b/modules/claim/front/note/index/style.scss new file mode 100644 index 000000000..44ae2cee7 --- /dev/null +++ b/modules/claim/front/note/index/style.scss @@ -0,0 +1,5 @@ +vn-client-note { + .note:last-child { + margin-bottom: 0; + } +} \ No newline at end of file diff --git a/modules/claim/front/routes.json b/modules/claim/front/routes.json index 5f08255be..d02ea6f6c 100644 --- a/modules/claim/front/routes.json +++ b/modules/claim/front/routes.json @@ -12,6 +12,7 @@ {"state": "claim.card.basicData", "icon": "settings"}, {"state": "claim.card.detail", "icon": "icon-details"}, {"state": "claim.card.photos", "icon": "image"}, + {"state": "claim.card.note.index", "icon": "insert_drive_file"}, {"state": "claim.card.development", "icon": "icon-traceability"}, {"state": "claim.card.action", "icon": "icon-actions"}, {"state": "claim.card.log", "icon": "history"} @@ -27,17 +28,20 @@ "abstract": true, "component": "vn-claim", "description": "Claims" - }, { + }, + { "url": "/index?q", "state": "claim.index", "component": "vn-claim-index", "description": "Claims" - }, { + }, + { "url": "/:id", "state": "claim.card", "abstract": true, "component": "vn-claim-card" - }, { + }, + { "url": "/summary", "state": "claim.card.summary", "component": "vn-claim-summary", @@ -45,7 +49,8 @@ "params": { "claim": "$ctrl.claim" } - }, { + }, + { "url": "/basic-data", "state": "claim.card.basicData", "component": "vn-claim-basic-data", @@ -54,7 +59,8 @@ "claim": "$ctrl.claim" }, "acl": ["salesPerson"] - }, { + }, + { "url": "/detail", "state": "claim.card.detail", "component": "vn-claim-detail", @@ -63,7 +69,32 @@ "claim": "$ctrl.claim" }, "acl": ["salesPerson"] - }, { + }, + { + "url": "/note", + "state": "claim.card.note", + "component": "ui-view", + "abstract": true, + "acl": ["salesPerson"] + }, + { + "url": "/index", + "state": "claim.card.note.index", + "component": "vn-claim-note", + "description": "Notes", + "params": { + "claim": "$ctrl.claim" + }, + "acl": ["salesPerson"] + }, + { + "url": "/create", + "state": "claim.card.note.create", + "component": "vn-claim-note-create", + "description": "New note", + "acl": ["salesPerson"] + }, + { "url": "/development", "state": "claim.card.development", "component": "vn-claim-development", @@ -72,7 +103,8 @@ "claim": "$ctrl.claim" }, "acl": ["claimManager"] - }, { + }, + { "url": "/action", "state": "claim.card.action", "component": "vn-claim-action", @@ -81,7 +113,8 @@ "claim": "$ctrl.claim" }, "acl": ["claimManager"] - }, { + }, + { "url": "/photos", "state": "claim.card.photos", "component": "vn-claim-photos", @@ -89,7 +122,8 @@ "params": { "claim": "$ctrl.claim" } - }, { + }, + { "url" : "/log", "state": "claim.card.log", "component": "vn-claim-log", diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html index 5d90da516..0c12aa2e6 100644 --- a/modules/claim/front/summary/index.html +++ b/modules/claim/front/summary/index.html @@ -1,11 +1,12 @@ -
- {{::$ctrl.summary.claim.id}} - {{::$ctrl.summary.claim.client.name}} - - - - - + +

+ + Observations + +

+

+ Observations +

+
+ + {{::note.worker.firstName}} {{::note.worker.lastName}} + {{::note.created | date:'dd/MM/yyyy HH:mm'}} + + + {{::note.text}} + +
+

{ const models = Self.app.models; const args = ctx.args; + const date = new Date(); + date.setHours(0, 0, 0, 0); + let tx; const myOptions = {}; @@ -92,8 +95,9 @@ module.exports = function(Self) { throw new UserError('Invalid account'); await Self.rawSql( - `CALL vn.ledger_doCompensation(CURDATE(), ?, ?, ?, ?, ?, ?)`, + `CALL vn.ledger_doCompensation(?, ?, ?, ?, ?, ?, ?)`, [ + date, args.compensationAccount, args.bankFk, accountingType.receiptDescription + originalClient.accountingAccount, @@ -106,9 +110,10 @@ module.exports = function(Self) { } else if (accountingType.isAutoConciliated == true) { const description = `${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`; const [xdiarioNew] = await Self.rawSql( - `SELECT xdiario_new(?, CURDATE(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`, + `SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`, [ null, + date, bank.account, originalClient.accountingAccount, description, @@ -126,9 +131,10 @@ module.exports = function(Self) { ); await Self.rawSql( - `SELECT xdiario_new(?, CURDATE(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`, + `SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`, [ xdiarioNew.ledger, + date, originalClient.accountingAccount, bank.account, description, diff --git a/modules/client/back/methods/client/getCard.js b/modules/client/back/methods/client/getCard.js index 34fba0984..21b3140bd 100644 --- a/modules/client/back/methods/client/getCard.js +++ b/modules/client/back/methods/client/getCard.js @@ -62,7 +62,7 @@ module.exports = function(Self) { { relation: 'account', scope: { - fields: ['id', 'name', 'active'] + fields: ['id', 'name', 'email', 'active'] } }, { @@ -74,8 +74,10 @@ module.exports = function(Self) { ] }, myOptions); - const query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`; - const data = await Self.rawSql(query, [id], myOptions); + const date = new Date(); + date.setHours(0, 0, 0, 0); + const query = `SELECT vn.clientGetDebt(?, ?) AS debt`; + const data = await Self.rawSql(query, [id, date], myOptions); client.debt = data[0].debt; diff --git a/modules/client/back/methods/client/getDebt.js b/modules/client/back/methods/client/getDebt.js index 8eb0f2480..aafdbfa48 100644 --- a/modules/client/back/methods/client/getDebt.js +++ b/modules/client/back/methods/client/getDebt.js @@ -25,8 +25,10 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`; - const [debt] = await Self.rawSql(query, [clientFk], myOptions); + const date = new Date(); + date.setHours(0, 0, 0, 0); + const query = `SELECT vn.clientGetDebt(?, ?) AS debt`; + const [debt] = await Self.rawSql(query, [clientFk, date], myOptions); return debt; }; diff --git a/modules/client/back/methods/client/lastActiveTickets.js b/modules/client/back/methods/client/lastActiveTickets.js index da38dbee8..03616a0e3 100644 --- a/modules/client/back/methods/client/lastActiveTickets.js +++ b/modules/client/back/methods/client/lastActiveTickets.js @@ -32,6 +32,8 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); + const date = new Date(); + date.setHours(0, 0, 0, 0); const ticket = await Self.app.models.Ticket.findById(ticketId, null, myOptions); const query = ` SELECT @@ -50,12 +52,12 @@ module.exports = Self => { JOIN vn.warehouse w ON t.warehouseFk = w.id JOIN vn.address ad ON t.addressFk = ad.id JOIN vn.province pr ON ad.provinceFk = pr.id - WHERE t.shipped >= CURDATE() AND t.clientFk = ? AND ts.alertLevel = 0 + WHERE t.shipped >= ? AND t.clientFk = ? AND ts.alertLevel = 0 AND t.id <> ? AND t.warehouseFk = ? ORDER BY t.shipped LIMIT 10`; - return Self.rawSql(query, [id, ticketId, ticket.warehouseFk], myOptions); + return Self.rawSql(query, [date, id, ticketId, ticket.warehouseFk], myOptions); }; }; diff --git a/modules/client/back/methods/client/setPassword.js b/modules/client/back/methods/client/setPassword.js new file mode 100644 index 000000000..19675d0e8 --- /dev/null +++ b/modules/client/back/methods/client/setPassword.js @@ -0,0 +1,32 @@ +module.exports = Self => { + Self.remoteMethod('setPassword', { + description: 'Sets the password of a non-worker client', + accepts: [ + { + arg: 'id', + type: 'number', + description: 'The user id', + http: {source: 'path'} + }, { + arg: 'newPassword', + type: 'string', + description: 'The new password', + required: true + } + ], + http: { + path: `/:id/setPassword`, + verb: 'PATCH' + } + }); + + Self.setPassword = async function(id, newPassword) { + const models = Self.app.models; + + const isWorker = await models.Worker.findById(id); + if (isWorker) + throw new Error(`Can't change the password of another worker`); + + await models.Account.setPassword(id, newPassword); + }; +}; diff --git a/modules/client/back/methods/client/specs/extendedListFilter.spec.js b/modules/client/back/methods/client/specs/extendedListFilter.spec.js index 907c03ef9..9a0441656 100644 --- a/modules/client/back/methods/client/specs/extendedListFilter.spec.js +++ b/modules/client/back/methods/client/specs/extendedListFilter.spec.js @@ -1,4 +1,4 @@ -const { models } = require('vn-loopback/server/server'); +const {models} = require('vn-loopback/server/server'); describe('client extendedListFilter()', () => { it('should return the clients matching the filter with a limit of 20 rows', async() => { @@ -99,7 +99,7 @@ describe('client extendedListFilter()', () => { const randomIndex = Math.floor(Math.random() * result.length); const randomResultClient = result[randomIndex]; - + expect(result.length).toBeGreaterThanOrEqual(5); expect(randomResultClient.salesPersonFk).toEqual(salesPersonId); @@ -121,7 +121,7 @@ describe('client extendedListFilter()', () => { const result = await models.Client.extendedListFilter(ctx, filter, options); const firstClient = result[0]; - + expect(result.length).toEqual(1); expect(firstClient.name).toEqual('Max Eisenhardt'); @@ -138,15 +138,15 @@ describe('client extendedListFilter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 1}}, args: {city: 'Silla'}}; + const ctx = {req: {accessToken: {userId: 1}}, args: {city: 'Gotham'}}; const filter = {}; const result = await models.Client.extendedListFilter(ctx, filter, options); const randomIndex = Math.floor(Math.random() * result.length); const randomResultClient = result[randomIndex]; - + expect(result.length).toBeGreaterThanOrEqual(20); - expect(randomResultClient.city.toLowerCase()).toEqual('silla'); + expect(randomResultClient.city.toLowerCase()).toEqual('gotham'); await tx.rollback(); } catch (e) { @@ -167,7 +167,7 @@ describe('client extendedListFilter()', () => { const randomIndex = Math.floor(Math.random() * result.length); const randomResultClient = result[randomIndex]; - + expect(result.length).toBeGreaterThanOrEqual(20); expect(randomResultClient.postcode).toEqual('46460'); diff --git a/modules/client/back/methods/client/specs/setPassword.spec.js b/modules/client/back/methods/client/specs/setPassword.spec.js new file mode 100644 index 000000000..e0de20249 --- /dev/null +++ b/modules/client/back/methods/client/specs/setPassword.spec.js @@ -0,0 +1,27 @@ +const models = require('vn-loopback/server/server').models; + +describe('Client setPassword', () => { + it('should throw an error the setPassword target is not just a client but a worker', async() => { + let error; + + try { + await models.Client.setPassword(1106, 'newPass?'); + } catch (e) { + error = e; + } + + expect(error.message).toEqual(`Can't change the password of another worker`); + }); + + it('should change the password of the client', async() => { + let error; + + try { + await models.Client.setPassword(1101, 't0pl3v3l.p455w0rd!'); + } catch (e) { + error = e; + } + + expect(error).toBeUndefined(); + }); +}); diff --git a/modules/client/back/methods/client/specs/summary.spec.js b/modules/client/back/methods/client/specs/summary.spec.js index 1eef35024..f2d576e39 100644 --- a/modules/client/back/methods/client/specs/summary.spec.js +++ b/modules/client/back/methods/client/specs/summary.spec.js @@ -120,7 +120,6 @@ describe('client summary()', () => { const result = await models.Client.summary(clientId, options); expect(result.recovery.id).toEqual(3); - await tx.rollback(); } catch (e) { await tx.rollback(); diff --git a/modules/client/back/methods/client/specs/updateUser.spec.js b/modules/client/back/methods/client/specs/updateUser.spec.js new file mode 100644 index 000000000..4dc969906 --- /dev/null +++ b/modules/client/back/methods/client/specs/updateUser.spec.js @@ -0,0 +1,58 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); +describe('Client updateUser', () => { + const employeeId = 1; + const activeCtx = { + accessToken: {userId: employeeId}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + const ctx = { + req: {accessToken: {userId: employeeId}}, + args: {name: 'test', active: true} + }; + + beforeEach(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + + it('should throw an error the target user is not just a client but a worker', async() => { + let error; + try { + const clientID = 1106; + await models.Client.updateUser(ctx, clientID); + } catch (e) { + error = e; + } + + expect(error.message).toEqual(`Can't update the user details of another worker`); + }); + + it('should update the user data', async() => { + let error; + + const tx = await models.Client.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const clientID = 1105; + await models.Client.updateUser(ctx, clientID, options); + const client = await models.Account.findById(clientID, null, options); + + expect(client.name).toEqual('test'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + + expect(error).toBeUndefined(); + }); +}); diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index dccf7f39c..48cb75f31 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -122,7 +122,6 @@ module.exports = Self => { return clientModel.findOne(filter, options); } - async function getRecoveries(recoveryModel, clientId, options) { const filter = { where: { diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 7ae842c6e..9bb572fb3 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -95,6 +95,10 @@ module.exports = Self => { { arg: 'despiteOfClient', type: 'number' + }, + { + arg: 'hasIncoterms', + type: 'boolean' } ], returns: { diff --git a/modules/client/back/methods/client/updateUser.js b/modules/client/back/methods/client/updateUser.js new file mode 100644 index 000000000..ef23b92fd --- /dev/null +++ b/modules/client/back/methods/client/updateUser.js @@ -0,0 +1,61 @@ +module.exports = Self => { + Self.remoteMethodCtx('updateUser', { + description: 'Updates the user information', + accepts: [ + { + arg: 'id', + type: 'number', + description: 'The user id', + http: {source: 'path'} + }, + { + arg: 'name', + type: 'string', + description: 'the user name' + }, + { + arg: 'email', + type: 'string', + description: 'the user email' + }, + { + arg: 'active', + type: 'boolean', + description: 'whether the user is active or not' + }, + ], + http: { + path: '/:id/updateUser', + verb: 'PATCH' + } + }); + + Self.updateUser = async function(ctx, id, options) { + const models = Self.app.models; + let tx; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await models.Account.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const isWorker = await models.Worker.findById(id, null, myOptions); + if (isWorker) + throw new Error(`Can't update the user details of another worker`); + + const user = await models.Account.findById(id, null, myOptions); + + await user.updateAttributes(ctx.args, myOptions); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index ec38c0821..ce1d89818 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -51,6 +51,8 @@ module.exports = Self => { const stmts = []; + const date = new Date(); + date.setHours(0, 0, 0, 0); const stmt = new ParameterizedSQL( `SELECT * FROM ( @@ -58,12 +60,12 @@ module.exports = Self => { DISTINCT c.id clientFk, c.name clientName, c.salesPersonFk, - u.nickname salesPersonName, + u.name salesPersonName, d.amount, co.created, co.text observation, uw.id workerFk, - uw.nickname workerName, + uw.name workerName, c.creditInsurance, d.defaulterSinced FROM vn.defaulter d @@ -72,10 +74,10 @@ module.exports = Self => { LEFT JOIN account.user u ON u.id = c.salesPersonFk LEFT JOIN account.user uw ON uw.id = co.workerFk WHERE - d.created = CURDATE() + d.created = ? AND d.amount > 0 ORDER BY co.created DESC) d` - ); + , [date]); stmt.merge(conn.makeWhere(filter.where)); stmt.merge(`GROUP BY d.clientFk`); diff --git a/modules/client/back/methods/recovery/hasActiveRecovery.js b/modules/client/back/methods/recovery/hasActiveRecovery.js index a0d0064eb..6b69d99d7 100644 --- a/modules/client/back/methods/recovery/hasActiveRecovery.js +++ b/modules/client/back/methods/recovery/hasActiveRecovery.js @@ -27,13 +27,15 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); + const date = new Date(); + date.setHours(0, 0, 0, 0); const query = ` SELECT count(*) AS hasActiveRecovery FROM vn.recovery WHERE clientFk = ? - AND IFNULL(finished,CURDATE()) >= CURDATE(); + AND IFNULL(finished, ?) >= ?; `; - const [result] = await Self.rawSql(query, [id], myOptions); + const [result] = await Self.rawSql(query, [id, date, date], myOptions); return result.hasActiveRecovery != 0; }; diff --git a/modules/client/back/models/client-sample.json b/modules/client/back/models/client-sample.json index 920758217..fc64cd949 100644 --- a/modules/client/back/models/client-sample.json +++ b/modules/client/back/models/client-sample.json @@ -32,10 +32,10 @@ "model": "Sample", "foreignKey": "typeFk" }, - "worker": { + "user": { "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" + "model": "Account", + "foreignKey": "userFk" }, "account": { "type": "belongsTo", diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 90a9b9e23..746261626 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -8,30 +8,32 @@ const LoopBackContext = require('loopback-context'); module.exports = Self => { // Methods - require('../methods/client/getCard')(Self); - require('../methods/client/createWithUser')(Self); - require('../methods/client/hasCustomerRole')(Self); - require('../methods/client/canCreateTicket')(Self); - require('../methods/client/isValidClient')(Self); require('../methods/client/addressesPropagateRe')(Self); + require('../methods/client/canBeInvoiced')(Self); + require('../methods/client/canCreateTicket')(Self); + require('../methods/client/checkDuplicated')(Self); + require('../methods/client/confirmTransaction')(Self); + require('../methods/client/consumption')(Self); + require('../methods/client/createAddress')(Self); + require('../methods/client/createReceipt')(Self); + require('../methods/client/createWithUser')(Self); + require('../methods/client/extendedListFilter')(Self); + require('../methods/client/getAverageInvoiced')(Self); + require('../methods/client/getCard')(Self); require('../methods/client/getDebt')(Self); require('../methods/client/getMana')(Self); - require('../methods/client/getAverageInvoiced')(Self); - require('../methods/client/summary')(Self); - require('../methods/client/updateFiscalData')(Self); require('../methods/client/getTransactions')(Self); - require('../methods/client/confirmTransaction')(Self); - require('../methods/client/canBeInvoiced')(Self); - require('../methods/client/uploadFile')(Self); + require('../methods/client/hasCustomerRole')(Self); + require('../methods/client/isValidClient')(Self); require('../methods/client/lastActiveTickets')(Self); require('../methods/client/sendSms')(Self); - require('../methods/client/createAddress')(Self); + require('../methods/client/setPassword')(Self); + require('../methods/client/summary')(Self); require('../methods/client/updateAddress')(Self); - require('../methods/client/consumption')(Self); - require('../methods/client/createReceipt')(Self); + require('../methods/client/updateFiscalData')(Self); require('../methods/client/updatePortfolio')(Self); - require('../methods/client/checkDuplicated')(Self); - require('../methods/client/extendedListFilter')(Self); + require('../methods/client/updateUser')(Self); + require('../methods/client/uploadFile')(Self); // Validations @@ -446,7 +448,7 @@ module.exports = Self => { const app = require('vn-loopback/server/server'); app.on('started', function() { - let account = app.models.Account; + const account = app.models.Account; account.observe('before save', async ctx => { if (ctx.isNewInstance) return; @@ -454,22 +456,26 @@ module.exports = Self => { }); account.observe('after save', async ctx => { - let changes = ctx.data || ctx.instance; + const changes = ctx.data || ctx.instance; if (!ctx.isNewInstance && changes) { - let oldData = ctx.hookState.oldInstance; - let hasChanges = oldData.name != changes.name || oldData.active != changes.active; + const oldData = ctx.hookState.oldInstance; + const hasChanges = oldData.name != changes.name || oldData.active != changes.active; if (!hasChanges) return; - let userId = ctx.options.accessToken.userId; - let logRecord = { - originFk: oldData.id, - userFk: userId, - action: 'update', - changedModel: 'Account', - oldInstance: {name: oldData.name, active: oldData.active}, - newInstance: {name: changes.name, active: changes.active} - }; - await Self.app.models.ClientLog.create(logRecord); + const isClient = await Self.app.models.Client.count({id: oldData.id}); + if (isClient) { + const loopBackContext = LoopBackContext.getCurrentContext(); + const userId = loopBackContext.active.accessToken.userId; + const logRecord = { + originFk: oldData.id, + userFk: userId, + action: 'update', + changedModel: 'Account', + oldInstance: {name: oldData.name, active: oldData.active}, + newInstance: {name: changes.name, active: changes.active} + }; + await Self.app.models.ClientLog.create(logRecord); + } } }); }); diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index 1426152a4..d383ae907 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -98,6 +98,9 @@ "hasCoreVnh": { "type": "boolean" }, + "hasIncoterms": { + "type": "boolean" + }, "isTaxDataChecked":{ "type": "boolean" }, diff --git a/modules/client/front/defaulter/index.html b/modules/client/front/defaulter/index.html index 92664079c..22b78594a 100644 --- a/modules/client/front/defaulter/index.html +++ b/modules/client/front/defaulter/index.html @@ -3,6 +3,7 @@ url="Defaulters/filter" filter="::$ctrl.filter" limit="20" + order="amount DESC" data="defaulters" auto-load="true"> @@ -70,13 +71,13 @@ - Last observation D. + field="created"> + L. O. Date + field="creditInsurance" + shrink> Credit I. @@ -124,13 +125,13 @@ ng-model="defaulter.observation"> - + {{::defaulter.created | date: 'dd/MM/yyyy'}} - {{::defaulter.creditInsurance | currency: 'EUR': 2}} - {{::defaulter.defaulterSinced | date: 'dd/MM/yyyy'}} + {{::defaulter.creditInsurance | currency: 'EUR': 2}} + {{::defaulter.defaulterSinced | date: 'dd/MM/yyyy'}} diff --git a/modules/client/front/defaulter/index.js b/modules/client/front/defaulter/index.js index 80f510bf2..4beadfda6 100644 --- a/modules/client/front/defaulter/index.js +++ b/modules/client/front/defaulter/index.js @@ -26,7 +26,7 @@ export default class Controller extends Section { url: 'Workers/activeWithInheritedRole', where: `{role: 'salesPerson'}`, searchFunction: '{firstName: $search}', - showField: 'nickname', + showField: 'name', valueField: 'id', } }, @@ -35,7 +35,7 @@ export default class Controller extends Section { autocomplete: { url: 'Workers/activeWithInheritedRole', searchFunction: '{firstName: $search}', - showField: 'nickname', + showField: 'name', valueField: 'id', } }, @@ -53,16 +53,8 @@ export default class Controller extends Section { } ] }; - } - get balanceDueTotal() { - let balanceDueTotal = 0; - const defaulters = this.$.model.data || []; - - for (let defaulter of defaulters) - balanceDueTotal += defaulter.amount; - - return balanceDueTotal; + this.getBalanceDueTotal(); } get checked() { @@ -76,6 +68,18 @@ export default class Controller extends Section { return checkedLines; } + getBalanceDueTotal() { + this.$http.get('Defaulters/filter') + .then(res => { + if (!res.data) return 0; + + this.balanceDueTotal = res.data.reduce( + (accumulator, currentValue) => { + return accumulator + (currentValue['amount'] || 0); + }, 0); + }); + } + chipColor(date) { const day = 24 * 60 * 60 * 1000; const today = new Date(); diff --git a/modules/client/front/defaulter/index.spec.js b/modules/client/front/defaulter/index.spec.js index 5801fa1f8..0732c68a1 100644 --- a/modules/client/front/defaulter/index.spec.js +++ b/modules/client/front/defaulter/index.spec.js @@ -36,17 +36,6 @@ describe('client defaulter', () => { }); }); - describe('balanceDueTotal() getter', () => { - it('should return balance due total', () => { - const data = controller.$.model.data; - const expectedAmount = data[0].amount + data[1].amount + data[2].amount; - - const result = controller.balanceDueTotal; - - expect(result).toEqual(expectedAmount); - }); - }); - describe('chipColor()', () => { it('should return undefined when the date is the present', () => { let today = new Date(); @@ -93,6 +82,7 @@ describe('client defaulter', () => { const params = [{text: controller.defaulter.observation, clientFk: data[1].clientFk}]; jest.spyOn(controller.vnApp, 'showMessage'); + $httpBackend.expect('GET', `Defaulters/filter`).respond(200); $httpBackend.expect('POST', `ClientObservations`, params).respond(200, params); controller.onResponse(); @@ -115,5 +105,17 @@ describe('client defaulter', () => { expect(expr).toEqual({'d.clientFk': '5'}); }); }); + + describe('getBalanceDueTotal()', () => { + it('should return balance due total', () => { + const defaulters = controller.$.model.data; + $httpBackend.when('GET', `Defaulters/filter`).respond(defaulters); + + controller.getBalanceDueTotal(); + $httpBackend.flush(); + + expect(controller.balanceDueTotal).toEqual(875); + }); + }); }); }); diff --git a/modules/client/front/defaulter/locale/es.yml b/modules/client/front/defaulter/locale/es.yml index 3f046e8d6..c3e1d4e19 100644 --- a/modules/client/front/defaulter/locale/es.yml +++ b/modules/client/front/defaulter/locale/es.yml @@ -3,7 +3,7 @@ Add observation to all selected clients: Añadir observación a {{total}} client Balance D.: Saldo V. Credit I.: Crédito A. Last observation: Última observación -Last observation D.: Fecha última O. +L. O. Date: Fecha Ú. O. Last observation date: Fecha última observación Search client: Buscar clientes Worker who made the last observation: Trabajador que ha realizado la última observación \ No newline at end of file diff --git a/modules/client/front/extended-list/index.html b/modules/client/front/extended-list/index.html index b45a0bc5f..784e88b8a 100644 --- a/modules/client/front/extended-list/index.html +++ b/modules/client/front/extended-list/index.html @@ -162,7 +162,7 @@ {{::client.province | dashIfEmpty}} {{::client.city | dashIfEmpty}} {{::client.postcode | dashIfEmpty}} - {{::client.email | dashIfEmpty}} + {{::client.email | dashIfEmpty}} {{::client.created | date:'dd/MM/yyyy'}} {{::client.businessType | dashIfEmpty}} {{::client.payMethod | dashIfEmpty}} diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index 1f3533327..bc5898635 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -185,6 +185,14 @@ vn-acl="salesAssistant"> + + + + - {{::sample.worker.user.name}} + ng-click="workerDescriptor.show($event, sample.user.id)" + ng-class="{'link': sample.user}"> + {{::sample.user.name || 'System' | translate}} {{::sample.company.code}} diff --git a/modules/client/front/sample/index/index.js b/modules/client/front/sample/index/index.js index 132704de0..7aa44c67f 100644 --- a/modules/client/front/sample/index/index.js +++ b/modules/client/front/sample/index/index.js @@ -12,15 +12,9 @@ class Controller extends Section { fields: ['code', 'description'] } }, { - relation: 'worker', + relation: 'user', scope: { - fields: ['userFk'], - include: { - relation: 'user', - scope: { - fields: ['name'] - } - } + fields: ['id', 'name'] } }, { relation: 'company', diff --git a/modules/client/front/web-access/index.html b/modules/client/front/web-access/index.html index 610497994..b776fa577 100644 --- a/modules/client/front/web-access/index.html +++ b/modules/client/front/web-access/index.html @@ -1,11 +1,16 @@ -
+ + + + + + + { + this.$http.patch(`Clients/${this.client.id}/setPassword`, data).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); }); } catch (e) { @@ -59,6 +59,18 @@ export default class Controller extends Section { return true; } + + onSubmit() { + const data = { + name: this.account.name, + email: this.account.email, + active: this.account.active + }; + this.$http.patch(`Clients/${this.client.id}/updateUser`, data).then(() => { + this.$.watcher.notifySaved(); + this.$.watcher.updateOriginalData(); + }); + } } Controller.$inject = ['$element', '$scope']; diff --git a/modules/client/front/web-access/index.spec.js b/modules/client/front/web-access/index.spec.js index 00fa12781..c1bb47a8e 100644 --- a/modules/client/front/web-access/index.spec.js +++ b/modules/client/front/web-access/index.spec.js @@ -52,7 +52,7 @@ describe('Component VnClientWebAccess', () => { }); describe('checkConditions()', () => { - it(`should perform a query to check if the client is valid and then store a boolean into the controller`, () => { + it('should perform a query to check if the client is valid', () => { controller.client = {id: '1234'}; expect(controller.canEnableCheckBox).toBeTruthy(); @@ -82,7 +82,9 @@ describe('Component VnClientWebAccess', () => { controller.newPassword = 'm24x8'; controller.repeatPassword = 'm24x8'; controller.canChangePassword = true; - $httpBackend.expectPATCH('Accounts/1234', {password: 'm24x8'}).respond('done'); + + const query = `Clients/${controller.client.id}/setPassword`; + $httpBackend.expectPATCH(query, {newPassword: controller.newPassword}).respond('done'); controller.onPassChange(); $httpBackend.flush(); }); diff --git a/modules/client/front/web-access/locale/es.yml b/modules/client/front/web-access/locale/es.yml index 4a3ac0ab4..5090ed020 100644 --- a/modules/client/front/web-access/locale/es.yml +++ b/modules/client/front/web-access/locale/es.yml @@ -4,4 +4,6 @@ New password: Nueva contraseña Repeat password: Repetir contraseña Change password: Cambiar contraseña Passwords don't match: Las contraseñas no coinciden -You must enter a new password: Debes introducir una nueva contraseña \ No newline at end of file +You must enter a new password: Debes introducir una nueva contraseña +Recovery email: Correo de recuperación +This email is used for user to regain access their account.: Este correo electrónico se usa para que el usuario recupere el acceso a su cuenta. \ No newline at end of file diff --git a/modules/entry/back/methods/entry/getEntry.js b/modules/entry/back/methods/entry/getEntry.js index 66238d0dc..cac3c65f8 100644 --- a/modules/entry/back/methods/entry/getEntry.js +++ b/modules/entry/back/methods/entry/getEntry.js @@ -43,7 +43,7 @@ module.exports = Self => { 'name', 'shipped', 'landed', - 'agencyFk', + 'agencyModeFk', 'warehouseOutFk', 'warehouseInFk', 'isReceived', diff --git a/modules/entry/back/methods/entry/lastItemBuys.js b/modules/entry/back/methods/entry/lastItemBuys.js index 7e83f1e5f..87b99c229 100644 --- a/modules/entry/back/methods/entry/lastItemBuys.js +++ b/modules/entry/back/methods/entry/lastItemBuys.js @@ -63,7 +63,6 @@ module.exports = Self => { stmt = new ParameterizedSQL( `CREATE TEMPORARY TABLE tmp.item (PRIMARY KEY (id)) - ENGINE = MEMORY SELECT i.*, p.name AS producerName, diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js index 6399faa52..9a21d4472 100644 --- a/modules/entry/back/methods/entry/latestBuysFilter.js +++ b/modules/entry/back/methods/entry/latestBuysFilter.js @@ -96,6 +96,7 @@ module.exports = Self => { }); Self.latestBuysFilter = async(ctx, filter, options) => { + const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') @@ -143,8 +144,12 @@ module.exports = Self => { const stmts = []; let stmt; - stmts.push('CALL cache.visible_refresh(@calc_id, FALSE, 1)'); + const warehouse = await models.Warehouse.findOne({where: {code: 'ALG'}}, myOptions); + stmt = new ParameterizedSQL(`CALL cache.visible_refresh(@calc_id, FALSE, ?)`, [warehouse.id]); + stmts.push(stmt); + const date = new Date(); + date.setHours(0, 0, 0, 0); stmt = new ParameterizedSQL(` SELECT i.image, @@ -202,9 +207,9 @@ module.exports = Self => { LEFT JOIN itemType t ON t.id = i.typeFk LEFT JOIN intrastat intr ON intr.id = i.intrastatFk LEFT JOIN origin ori ON ori.id = i.originFk - LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(CURDATE(),INTERVAL 1 YEAR) + LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR) LEFT JOIN supplier s ON s.id = e.supplierFk` - ); + , [date]); if (ctx.args.tags) { let i = 1; diff --git a/modules/entry/front/basic-data/index.html b/modules/entry/front/basic-data/index.html index 8787853a5..423e9d70d 100644 --- a/modules/entry/front/basic-data/index.html +++ b/modules/entry/front/basic-data/index.html @@ -137,7 +137,7 @@ diff --git a/modules/entry/front/basic-data/index.js b/modules/entry/front/basic-data/index.js index 80870c3f3..564a3df5c 100644 --- a/modules/entry/front/basic-data/index.js +++ b/modules/entry/front/basic-data/index.js @@ -46,7 +46,7 @@ class Controller extends Section { if (!value) continue; switch (key) { - case 'agencyFk': + case 'agencyModeFk': case 'warehouseInFk': case 'warehouseOutFk': case 'shipped': diff --git a/modules/entry/front/card/index.js b/modules/entry/front/card/index.js index eafed171b..96f4702e2 100644 --- a/modules/entry/front/card/index.js +++ b/modules/entry/front/card/index.js @@ -14,7 +14,7 @@ class Controller extends ModuleCard { { relation: 'travel', scope: { - fields: ['id', 'landed', 'agencyFk', 'warehouseOutFk'], + fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'], include: [ { relation: 'agency', diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js index fed3787d4..34aa162f9 100644 --- a/modules/entry/front/descriptor/index.js +++ b/modules/entry/front/descriptor/index.js @@ -14,9 +14,9 @@ class Controller extends Descriptor { let travelFilter; const entryTravel = this.entry && this.entry.travel; - if (entryTravel && entryTravel.agencyFk) { + if (entryTravel && entryTravel.agencyModeFk) { travelFilter = this.entry && JSON.stringify({ - agencyFk: entryTravel.agencyFk + agencyModeFk: entryTravel.agencyModeFk }); } return travelFilter; @@ -49,7 +49,7 @@ class Controller extends Descriptor { { relation: 'travel', scope: { - fields: ['id', 'landed', 'agencyFk', 'warehouseOutFk'], + fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'], include: [ { relation: 'agency', diff --git a/modules/invoiceIn/front/tax/index.spec.js b/modules/invoiceIn/front/tax/index.spec.js index c62ada9ca..52114afe5 100644 --- a/modules/invoiceIn/front/tax/index.spec.js +++ b/modules/invoiceIn/front/tax/index.spec.js @@ -1,7 +1,6 @@ import './index.js'; import watcher from 'core/mocks/watcher'; import crudModel from 'core/mocks/crud-model'; -const UserError = require('vn-loopback/util/user-error'); describe('InvoiceIn', () => { describe('Component tax', () => { diff --git a/modules/invoiceOut/back/methods/invoiceOut/createPdf.js b/modules/invoiceOut/back/methods/invoiceOut/createPdf.js index 116e8b3fc..c2fdbcbba 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/createPdf.js +++ b/modules/invoiceOut/back/methods/invoiceOut/createPdf.js @@ -61,7 +61,7 @@ module.exports = Self => { responseType: 'stream', params: { authorization: auth.id, - invoiceId: id + refFk: invoiceOut.ref } }).then(async response => { const issued = invoiceOut.issued; diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index f1138dd51..19dea5b1a 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -9,7 +9,7 @@ module.exports = Self => { accepts: [ { arg: 'id', - type: 'String', + type: 'string', description: 'The invoice id', http: {source: 'path'} } @@ -21,16 +21,16 @@ module.exports = Self => { root: true }, { arg: 'Content-Type', - type: 'String', + type: 'string', http: {target: 'header'} }, { arg: 'Content-Disposition', - type: 'String', + type: 'string', http: {target: 'header'} } ], http: { - path: `/:id/download`, + path: '/:id/download', verb: 'GET' } }); diff --git a/modules/invoiceOut/back/methods/invoiceOut/refund.js b/modules/invoiceOut/back/methods/invoiceOut/refund.js new file mode 100644 index 000000000..7ad6b03ec --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/refund.js @@ -0,0 +1,49 @@ +module.exports = Self => { + Self.remoteMethod('refund', { + description: 'Create refund tickets with sales and services if provided', + accessType: 'WRITE', + accepts: [{ + arg: 'ref', + type: 'string', + description: 'The invoice reference' + }], + returns: { + type: ['number'], + root: true + }, + http: { + path: '/refund', + verb: 'post' + } + }); + + Self.refund = async(ref, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const filter = {where: {refFk: ref}}; + const tickets = await models.Ticket.find(filter, myOptions); + + const ticketsIds = tickets.map(ticket => ticket.id); + + const refundedTickets = await models.Ticket.refund(ticketsIds, myOptions); + + if (tx) await tx.commit(); + + return refundedTickets; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js new file mode 100644 index 000000000..628318d42 --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js @@ -0,0 +1,28 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +describe('InvoiceOut refund()', () => { + const userId = 5; + const activeCtx = { + accessToken: {userId: userId}, + }; + + it('should return the ids for the created refund tickets', async() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + const result = await models.InvoiceOut.refund('T1111111', options); + + expect(result.length).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index 3b2822ada..c8c97702f 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -8,4 +8,5 @@ module.exports = Self => { require('../methods/invoiceOut/createPdf')(Self); require('../methods/invoiceOut/createManualInvoice')(Self); require('../methods/invoiceOut/globalInvoicing')(Self); + require('../methods/invoiceOut/refund')(Self); }; diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index ef4c9a62e..1c0919288 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -80,6 +80,8 @@ ng-click="refundConfirmation.show()" name="refundInvoice" vn-tooltip="Create a single ticket with all the content of the current invoice" + vn-acl="invoicing, claimManager, salesAssistant" + vn-acl-action="remove" translate> Refund diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index b884e50cb..2b6d90ebf 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -84,7 +84,7 @@ class Controller extends Section { showCsvInvoice() { this.vnReport.showCsv('invoice', { recipientId: this.invoiceOut.client.id, - invoiceId: this.id + refFk: this.invoiceOut.ref }); } @@ -95,7 +95,7 @@ class Controller extends Section { return this.vnEmail.send('invoice', { recipientId: this.invoiceOut.client.id, recipient: $data.email, - invoiceId: this.id + refFk: this.invoiceOut.ref }); } @@ -106,43 +106,23 @@ class Controller extends Section { return this.vnEmail.sendCsv('invoice', { recipientId: this.invoiceOut.client.id, recipient: $data.email, - invoiceId: this.id + refFk: this.invoiceOut.ref }); } showExportationLetter() { this.vnReport.show('exportation', { recipientId: this.invoiceOut.client.id, - invoiceId: this.id + refFk: this.invoiceOut.ref }); } - async refundInvoiceOut() { - let filter = { - where: {refFk: this.invoiceOut.ref} - }; - const tickets = await this.$http.get('Tickets', {filter}); - this.tickets = tickets.data; - this.ticketsIds = []; - for (let ticket of this.tickets) - this.ticketsIds.push(ticket.id); - - filter = { - where: {ticketFk: {inq: this.ticketsIds}} - }; - const sales = await this.$http.get('Sales', {filter}); - this.sales = sales.data; - - const ticketServices = await this.$http.get('TicketServices', {filter}); - this.services = ticketServices.data; - - const params = { - sales: this.sales, - services: this.services - }; - const query = `Sales/refund`; - return this.$http.post(query, params).then(res => { - this.$state.go('ticket.card.sale', {id: res.data}); + refundInvoiceOut() { + const query = 'InvoiceOuts/refund'; + const params = {ref: this.invoiceOut.ref}; + this.$http.post(query, params).then(res => { + const ticketIds = res.data.map(ticket => ticket.id).join(', '); + this.vnApp.showSuccess(this.$t('The following refund tickets have been created', {ticketIds})); }); } } diff --git a/modules/invoiceOut/front/descriptor-menu/index.spec.js b/modules/invoiceOut/front/descriptor-menu/index.spec.js index c84c97a57..da7c87894 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.spec.js +++ b/modules/invoiceOut/front/descriptor-menu/index.spec.js @@ -6,7 +6,8 @@ describe('vnInvoiceOutDescriptorMenu', () => { let $httpParamSerializer; const invoiceOut = { id: 1, - client: {id: 1101} + client: {id: 1101}, + ref: 'T1111111' }; beforeEach(ngModule('invoiceOut')); @@ -15,14 +16,17 @@ describe('vnInvoiceOutDescriptorMenu', () => { $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; controller = $componentController('vnInvoiceOutDescriptorMenu', {$element: null}); + controller.invoiceOut = { + id: 1, + ref: 'T1111111', + client: {id: 1101} + }; })); describe('createPdfInvoice()', () => { it('should make a query to the createPdf() endpoint and show a success snackbar', () => { jest.spyOn(controller.vnApp, 'showSuccess'); - controller.invoiceOut = invoiceOut; - $httpBackend.whenGET(`InvoiceOuts/${invoiceOut.id}`).respond(); $httpBackend.expectPOST(`InvoiceOuts/${invoiceOut.id}/createPdf`).respond(); controller.createPdfInvoice(); @@ -36,11 +40,9 @@ describe('vnInvoiceOutDescriptorMenu', () => { it('should make a query to the csv invoice download endpoint and show a message snackbar', () => { jest.spyOn(window, 'open').mockReturnThis(); - controller.invoiceOut = invoiceOut; - const expectedParams = { - invoiceId: invoiceOut.id, - recipientId: invoiceOut.client.id + recipientId: invoiceOut.client.id, + refFk: invoiceOut.ref }; const serializedParams = $httpParamSerializer(expectedParams); const expectedPath = `api/csv/invoice/download?${serializedParams}`; @@ -52,7 +54,6 @@ describe('vnInvoiceOutDescriptorMenu', () => { describe('deleteInvoiceOut()', () => { it(`should make a query and call showSuccess()`, () => { - controller.invoiceOut = invoiceOut; controller.$state.reload = jest.fn(); jest.spyOn(controller.vnApp, 'showSuccess'); @@ -65,7 +66,6 @@ describe('vnInvoiceOutDescriptorMenu', () => { }); it(`should make a query and call showSuccess() after state.go if the state wasn't in invoiceOut module`, () => { - controller.invoiceOut = invoiceOut; jest.spyOn(controller.$state, 'go').mockReturnValue('ok'); jest.spyOn(controller.vnApp, 'showSuccess'); controller.$state.current.name = 'invoiceOut.card.something'; @@ -83,13 +83,11 @@ describe('vnInvoiceOutDescriptorMenu', () => { it('should make a query to the email invoice endpoint and show a message snackbar', () => { jest.spyOn(controller.vnApp, 'showMessage'); - controller.invoiceOut = invoiceOut; - const $data = {email: 'brucebanner@gothamcity.com'}; const expectedParams = { - invoiceId: invoiceOut.id, recipient: $data.email, - recipientId: invoiceOut.client.id + recipientId: invoiceOut.client.id, + refFk: invoiceOut.ref }; const serializedParams = $httpParamSerializer(expectedParams); @@ -105,13 +103,11 @@ describe('vnInvoiceOutDescriptorMenu', () => { it('should make a query to the csv invoice send endpoint and show a message snackbar', () => { jest.spyOn(controller.vnApp, 'showMessage'); - controller.invoiceOut = invoiceOut; - const $data = {email: 'brucebanner@gothamcity.com'}; const expectedParams = { - invoiceId: invoiceOut.id, recipient: $data.email, - recipientId: invoiceOut.client.id + recipientId: invoiceOut.client.id, + refFk: invoiceOut.ref }; const serializedParams = $httpParamSerializer(expectedParams); @@ -123,33 +119,16 @@ describe('vnInvoiceOutDescriptorMenu', () => { }); }); - // #4084 review with Juan - xdescribe('refundInvoiceOut()', () => { - it('should make a query and go to ticket.card.sale', () => { - controller.$state.go = jest.fn(); + describe('refundInvoiceOut()', () => { + it('should make a query and show a success message', () => { + jest.spyOn(controller.vnApp, 'showSuccess'); + const params = {ref: controller.invoiceOut.ref}; - const invoiceOut = { - id: 1, - ref: 'T1111111' - }; - controller.invoiceOut = invoiceOut; - const tickets = [{id: 1}]; - const sales = [{id: 1}]; - const services = [{id: 2}]; - - $httpBackend.expectGET(`Tickets`).respond(tickets); - $httpBackend.expectGET(`Sales`).respond(sales); - $httpBackend.expectGET(`TicketServices`).respond(services); - - const expectedParams = { - sales: sales, - services: services - }; - $httpBackend.expectPOST(`Sales/refund`, expectedParams).respond(); + $httpBackend.expectPOST(`InvoiceOuts/refund`, params).respond([{id: 1}, {id: 2}]); controller.refundInvoiceOut(); $httpBackend.flush(); - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: undefined}); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); }); diff --git a/modules/invoiceOut/front/descriptor-menu/locale/en.yml b/modules/invoiceOut/front/descriptor-menu/locale/en.yml new file mode 100644 index 000000000..d299155d7 --- /dev/null +++ b/modules/invoiceOut/front/descriptor-menu/locale/en.yml @@ -0,0 +1 @@ +The following refund tickets have been created: "The following refund tickets have been created: {{ticketIds}}" diff --git a/modules/invoiceOut/front/descriptor-menu/locale/es.yml b/modules/invoiceOut/front/descriptor-menu/locale/es.yml index 8949f1f91..488c1a3f8 100644 --- a/modules/invoiceOut/front/descriptor-menu/locale/es.yml +++ b/modules/invoiceOut/front/descriptor-menu/locale/es.yml @@ -17,3 +17,4 @@ Create a single ticket with all the content of the current invoice: Crear un tic Regenerate PDF invoice: Regenerar PDF factura The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado The email can't be empty: El correo no puede estar vacío +The following refund tickets have been created: "Se han creado los siguientes tickets de abono: {{ticketIds}}" diff --git a/modules/invoiceOut/front/index/global-invoicing/index.spec.js b/modules/invoiceOut/front/index/global-invoicing/index.spec.js index 35252c406..916364007 100644 --- a/modules/invoiceOut/front/index/global-invoicing/index.spec.js +++ b/modules/invoiceOut/front/index/global-invoicing/index.spec.js @@ -66,7 +66,9 @@ describe('InvoiceOut', () => { controller.responseHandler('accept'); - expect(controller.vnApp.showError).toHaveBeenCalledWith(`Invoice date and the max date should be filled`); + const expectedError = 'Invoice date and the max date should be filled'; + + expect(controller.vnApp.showError).toHaveBeenCalledWith(expectedError); }); it('should throw an error when fromClientId or toClientId properties are not filled in', () => { diff --git a/modules/item/back/methods/item/getWasteByItem.js b/modules/item/back/methods/item/getWasteByItem.js index a797667f5..b93d534da 100644 --- a/modules/item/back/methods/item/getWasteByItem.js +++ b/modules/item/back/methods/item/getWasteByItem.js @@ -32,6 +32,8 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); + const date = new Date(); + date.setHours(0, 0, 0, 0); const wastes = await Self.rawSql(` SELECT *, 100 * dwindle / total AS percentage FROM ( @@ -42,11 +44,11 @@ module.exports = Self => { sum(ws.saleWaste) AS dwindle FROM bs.waste ws WHERE buyer = ? AND family = ? - AND year = YEAR(TIMESTAMPADD(WEEK,-1,CURDATE())) - AND week = WEEK(TIMESTAMPADD(WEEK,-1,CURDATE()), 1) + AND year = YEAR(TIMESTAMPADD(WEEK,-1, ?)) + AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1) GROUP BY buyer, itemFk ) sub - ORDER BY family, percentage DESC`, [buyer, family], myOptions); + ORDER BY family, percentage DESC`, [buyer, family, date, date], myOptions); const details = []; diff --git a/modules/item/back/methods/item/getWasteByWorker.js b/modules/item/back/methods/item/getWasteByWorker.js index 5e40831b9..2b0b78974 100644 --- a/modules/item/back/methods/item/getWasteByWorker.js +++ b/modules/item/back/methods/item/getWasteByWorker.js @@ -19,6 +19,8 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); + const date = new Date(); + date.setHours(0, 0, 0, 0); const wastes = await Self.rawSql(` SELECT *, 100 * dwindle / total AS percentage FROM ( @@ -27,11 +29,11 @@ module.exports = Self => { sum(ws.saleTotal) AS total, sum(ws.saleWaste) AS dwindle FROM bs.waste ws - WHERE year = YEAR(TIMESTAMPADD(WEEK,-1,CURDATE())) - AND week = WEEK(TIMESTAMPADD(WEEK,-1,CURDATE()), 1) + WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?)) + AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1) GROUP BY buyer, family ) sub - ORDER BY percentage DESC`, null, myOptions); + ORDER BY percentage DESC`, [date, date], myOptions); const details = []; diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index 004aeb4b9..c31f472be 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -32,9 +32,6 @@ "ItemPackingType": { "dataSource": "vn" }, - "ItemPlacement": { - "dataSource": "vn" - }, "ItemTag": { "dataSource": "vn" }, diff --git a/modules/item/back/models/item-placement.json b/modules/item/back/models/item-placement.json deleted file mode 100644 index 0c036ef14..000000000 --- a/modules/item/back/models/item-placement.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "ItemPlacement", - "base": "VnModel", - "options": { - "mysql": { - "table": "itemPlacement" - } - }, - "properties": { - "id": { - "type": "number", - "id": true - }, - "code": { - "type": "string" - }, - "itemFk": { - "type": "number" - }, - "warehouseFk": { - "type": "number" - } - }, - "relations": { - "item": { - "type": "belongsTo", - "model": "Item", - "foreignKey": "itemFk" - }, - "warehouse": { - "type": "belongsTo", - "model": "Warehouse", - "foreignKey": "warehouseFk" - } - } -} \ No newline at end of file diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html index dfc0b6e01..5264977f3 100644 --- a/modules/item/front/summary/index.html +++ b/modules/item/front/summary/index.html @@ -117,6 +117,23 @@ value="{{tag.value}}"> + +

+ + Description + +

+

+ Description +

+

+ {{$ctrl.summary.item.description}} +

+

{ if (typeof options == 'object') Object.assign(myOptions, options); + const date = new Date(); + date.setHours(0, 0, 0, 0); const stmt = new ParameterizedSQL(` SELECT u.name AS salesPerson, @@ -47,9 +49,10 @@ module.exports = Self => { JOIN client c ON c.id = v.userFk JOIN account.user u ON c.salesPersonFk = u.id LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk - AND CURDATE() BETWEEN sc.started AND sc.ended + AND ? BETWEEN sc.started AND sc.ended LEFT JOIN workerTeamCollegues wtc - ON wtc.collegueFk = IFNULL(sc.workerSubstitute, c.salesPersonFk)`); + ON wtc.collegueFk = IFNULL(sc.workerSubstitute, c.salesPersonFk)`, + [date]); if (!filter.where) filter.where = {}; diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 9b6030e9f..9a7415055 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -104,6 +104,8 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const conn = Self.dataSource.connector; const models = Self.app.models; + const date = new Date(); + date.setHours(0, 0, 0, 0); const args = ctx.args; const myOptions = {}; @@ -264,15 +266,18 @@ module.exports = Self => { `); stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); - stmts.push(` + + stmt = new ParameterizedSQL(` CREATE TEMPORARY TABLE tmp.sale_getProblems - (INDEX (ticketFk)) - ENGINE = MEMORY - SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped - FROM tmp.filter f - LEFT JOIN alertLevel al ON al.id = f.alertLevel - WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) - AND f.shipped >= CURDATE()`); + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped + FROM tmp.filter f + LEFT JOIN alertLevel al ON al.id = f.alertLevel + WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) + AND f.shipped >= ?`, [date]); + stmts.push(stmt); + stmts.push('CALL ticket_getProblems(FALSE)'); stmts.push(` diff --git a/modules/route/back/methods/agency-term/filter.js b/modules/route/back/methods/agency-term/filter.js index 5a9cbb564..0ecec7e88 100644 --- a/modules/route/back/methods/agency-term/filter.js +++ b/modules/route/back/methods/agency-term/filter.js @@ -74,6 +74,8 @@ module.exports = Self => { filter = mergeFilters(filter, {where}); + const date = new Date(); + date.setHours(0, 0, 0, 0); const stmts = []; const stmt = new ParameterizedSQL( `SELECT * @@ -101,10 +103,10 @@ module.exports = Self => { LEFT JOIN vn.ticket t ON t.routeFk = r.id LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id LEFT JOIN vn.supplier s ON s.id = sat.supplierFk - WHERE r.created > DATE_ADD(CURDATE(), INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL + WHERE r.created > DATE_ADD(?, INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL GROUP BY r.id ) a` - ); + , [date]); stmt.merge(conn.makeWhere(filter.where)); stmt.merge(conn.makePagination(filter)); diff --git a/modules/route/back/methods/route/specs/filter.spec.js b/modules/route/back/methods/route/specs/filter.spec.js index 9b3c6edf4..9d481f21e 100644 --- a/modules/route/back/methods/route/specs/filter.spec.js +++ b/modules/route/back/methods/route/specs/filter.spec.js @@ -2,17 +2,17 @@ const app = require('vn-loopback/server/server'); const models = require('vn-loopback/server/server').models; describe('Route filter()', () => { - let today = new Date(); + const today = new Date(); today.setHours(2, 0, 0, 0); it('should return the routes matching "search"', async() => { - let ctx = { + const ctx = { args: { search: 1, } }; - let result = await app.models.Route.filter(ctx); + const result = await app.models.Route.filter(ctx); expect(result.length).toEqual(1); expect(result[0].id).toEqual(1); @@ -28,7 +28,6 @@ describe('Route filter()', () => { const to = new Date(); to.setHours(23, 59, 59, 999); - const ctx = { args: { from: from, @@ -48,43 +47,43 @@ describe('Route filter()', () => { }); it('should return the routes matching "m3"', async() => { - let ctx = { + const ctx = { args: { m3: 0.1, } }; - let result = await app.models.Route.filter(ctx); + const result = await app.models.Route.filter(ctx); expect(result.length).toEqual(1); }); it('should return the routes matching "description"', async() => { - let ctx = { + const ctx = { args: { description: 'third route', } }; - let result = await app.models.Route.filter(ctx); + const result = await app.models.Route.filter(ctx); expect(result.length).toEqual(1); }); it('should return the routes matching "workerFk"', async() => { - let ctx = { + const ctx = { args: { workerFk: 56, } }; - let result = await app.models.Route.filter(ctx); + const result = await app.models.Route.filter(ctx); expect(result.length).toEqual(5); }); it('should return the routes matching "warehouseFk"', async() => { - let ctx = { + const ctx = { args: { warehouseFk: 1, } @@ -102,25 +101,25 @@ describe('Route filter()', () => { }); it('should return the routes matching "vehicleFk"', async() => { - let ctx = { + const ctx = { args: { vehicleFk: 2, } }; - let result = await app.models.Route.filter(ctx); + const result = await app.models.Route.filter(ctx); expect(result.length).toEqual(1); }); it('should return the routes matching "agencyModeFk"', async() => { - let ctx = { + const ctx = { args: { agencyModeFk: 7, } }; - let result = await app.models.Route.filter(ctx); + const result = await app.models.Route.filter(ctx); expect(result.length).toEqual(1); }); diff --git a/modules/route/back/methods/route/specs/getDeliveryPoint.spec.js b/modules/route/back/methods/route/specs/getDeliveryPoint.spec.js index 4025b04d6..b08051c0a 100644 --- a/modules/route/back/methods/route/specs/getDeliveryPoint.spec.js +++ b/modules/route/back/methods/route/specs/getDeliveryPoint.spec.js @@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server'); describe('route getDeliveryPoint()', () => { const routeId = 1; - const deliveryPointAddress = '46460 Av Espioca 100-Silla'; + const deliveryPointAddress = '1007 Mountain Drive, Gotham'; it('should get the delivery point addres of a route with assigned vehicle', async() => { let route = await app.models.Route.findById(routeId); diff --git a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js index beb494d43..bb38cb50e 100644 --- a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js +++ b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js @@ -1,30 +1,32 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('route getSuggestedTickets()', () => { const routeID = 1; const ticketId = 12; + it('should return an array of suggested tickets', async() => { const activeCtx = { accessToken: {userId: 19}, headers: {origin: 'http://localhost'} }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: activeCtx }); - const tx = await app.models.Ticket.beginTransaction({}); + const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - const ticketInRoute = await app.models.Ticket.findById(ticketId, null, options); + const ticketInRoute = await models.Ticket.findById(ticketId, null, options); await ticketInRoute.updateAttributes({ routeFk: null, landed: new Date() }, options); - const result = await app.models.Route.getSuggestedTickets(routeID, options); + const result = await models.Route.getSuggestedTickets(routeID, options); const length = result.length; const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; diff --git a/modules/route/back/methods/route/specs/updateWorkCenter.spec.js b/modules/route/back/methods/route/specs/updateWorkCenter.spec.js new file mode 100644 index 000000000..5328dc240 --- /dev/null +++ b/modules/route/back/methods/route/specs/updateWorkCenter.spec.js @@ -0,0 +1,51 @@ +const models = require('vn-loopback/server/server').models; + +describe('route updateWorkCenter()', () => { + const routeId = 1; + + it('should set the commission work center if the worker has workCenter', async() => { + const tx = await models.Route.beginTransaction({}); + try { + const developerId = 9; + const ctx = { + req: { + accessToken: {userId: developerId} + } + }; + const options = {transaction: tx}; + + const expectedResult = 1; + const updatedRoute = await models.Route.updateWorkCenter(ctx, routeId, options); + + expect(updatedRoute.commissionWorkCenterFk).toEqual(expectedResult); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it(`shoul set the default commision work center if that worker didn't have one yet`, async() => { + const tx = await models.Route.beginTransaction({}); + try { + const userWithoutWorkCenter = 2; + const ctx = { + req: { + accessToken: {userId: userWithoutWorkCenter} + } + }; + const options = {transaction: tx}; + + const expectedResult = 9; + const updatedRoute = await models.Route.updateWorkCenter(ctx, routeId, options); + + expect(updatedRoute.commissionWorkCenterFk).toEqual(expectedResult); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/route/back/methods/route/updateWorkCenter.js b/modules/route/back/methods/route/updateWorkCenter.js new file mode 100644 index 000000000..7796fba41 --- /dev/null +++ b/modules/route/back/methods/route/updateWorkCenter.js @@ -0,0 +1,54 @@ +module.exports = Self => { + Self.remoteMethodCtx('updateWorkCenter', { + description: 'Update the commission work center through user salix connected', + accessType: 'WRITE', + accepts: { + arg: 'id', + type: 'number', + description: 'Route Id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/updateWorkCenter`, + verb: 'POST' + } + }); + + Self.updateWorkCenter = async(ctx, id, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + const userId = ctx.req.accessToken.userId; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const [result] = await Self.rawSql(` + SELECT IFNULL(wl.workCenterFk, r.defaultWorkCenterFk) AS commissionWorkCenter + FROM vn.routeConfig r + LEFT JOIN vn.workerLabour wl ON wl.workerFk = ? + AND CURDATE() BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()); + `, [userId], myOptions); + + const route = await models.Route.findById(id, null, myOptions); + await route.updateAttribute('commissionWorkCenterFk', result.commissionWorkCenter, myOptions); + + if (tx) await tx.commit(); + + return route; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index c82d1722e..4050e62fe 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -9,6 +9,7 @@ module.exports = Self => { require('../methods/route/clone')(Self); require('../methods/route/getSuggestedTickets')(Self); require('../methods/route/unlink')(Self); + require('../methods/route/updateWorkCenter')(Self); Self.validate('kmStart', validateDistance, { message: 'Distance must be lesser than 1000' diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json index 46fb6b76f..3b33cc028 100644 --- a/modules/route/back/models/route.json +++ b/modules/route/back/models/route.json @@ -47,6 +47,9 @@ }, "description": { "type": "string" + }, + "commissionWorkCenterFk": { + "type": "number" } }, "relations": { diff --git a/modules/route/front/create/index.js b/modules/route/front/create/index.js index 56c8cc25a..c81394c10 100644 --- a/modules/route/front/create/index.js +++ b/modules/route/front/create/index.js @@ -4,7 +4,12 @@ import Section from 'salix/components/section'; export default class Controller extends Section { onSubmit() { this.$.watcher.submit().then( - res => this.$state.go('route.card.summary', {id: res.data.id}) + res => { + this.$http.post(`Routes/${res.data.id}/updateWorkCenter`, null) + .then(() => { + this.$state.go('route.card.summary', {id: res.data.id}); + }); + } ); } } diff --git a/modules/shelving/back/methods/shelving/getSummary.js b/modules/shelving/back/methods/shelving/getSummary.js new file mode 100644 index 000000000..da357c7bf --- /dev/null +++ b/modules/shelving/back/methods/shelving/getSummary.js @@ -0,0 +1,52 @@ +module.exports = Self => { + Self.remoteMethod('getSummary', { + description: 'Returns the shelving summary', + accessType: 'READ', + accepts: { + arg: 'code', + type: 'string', + required: true, + description: 'The shelving code', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:code/getSummary`, + verb: 'GET' + } + }); + Self.getSummary = async code => { + let filter = { + where: {code: code}, + fields: [ + 'code', + 'parkingFk', + 'priority', + 'userFk', + 'isRecyclable' + ], + include: [ + { + relation: 'parking' + }, + { + relation: 'worker', + scope: { + fields: ['id', 'userFk'], + include: { + relation: 'user', + scope: { + fields: ['id', 'nickname'] + } + } + } + } + ] + }; + + return Self.app.models.Shelving.findOne(filter); + }; +}; diff --git a/modules/shelving/back/model-config.json b/modules/shelving/back/model-config.json new file mode 100644 index 000000000..b5619d8c5 --- /dev/null +++ b/modules/shelving/back/model-config.json @@ -0,0 +1,11 @@ +{ + "Parking": { + "dataSource": "vn" + }, + "Shelving": { + "dataSource": "vn" + }, + "ShelvingLog": { + "dataSource": "vn" + } +} diff --git a/modules/shelving/back/models/parking.json b/modules/shelving/back/models/parking.json new file mode 100644 index 000000000..7efcf72d3 --- /dev/null +++ b/modules/shelving/back/models/parking.json @@ -0,0 +1,33 @@ +{ + "name": "Parking", + "base": "VnModel", + "options": { + "mysql": { + "table": "parking" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "column": { + "type": "string", + "required": true + }, + "row": { + "type": "string", + "required": true + }, + "sectorFk": { + "type": "number" + }, + "code": { + "type": "string" + }, + "pickingOrder": { + "type": "number" + } + } +} diff --git a/modules/shelving/back/models/shelving-log.json b/modules/shelving/back/models/shelving-log.json new file mode 100644 index 000000000..a2267394e --- /dev/null +++ b/modules/shelving/back/models/shelving-log.json @@ -0,0 +1,58 @@ +{ + "name": "ShelvingLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "shelvingLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] + } +} diff --git a/modules/shelving/back/models/shelving.js b/modules/shelving/back/models/shelving.js new file mode 100644 index 000000000..3e27f5863 --- /dev/null +++ b/modules/shelving/back/models/shelving.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/shelving/getSummary')(Self); +}; diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json new file mode 100644 index 000000000..508ac428f --- /dev/null +++ b/modules/shelving/back/models/shelving.json @@ -0,0 +1,51 @@ +{ + "name": "Shelving", + "base": "Loggable", + "log": { + "model": "ShelvingLog", + "showField": "id" + }, + "options": { + "mysql": { + "table": "shelving" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "code": { + "type": "string", + "required": true + }, + "parkingFk": { + "type": "number" + }, + "isPrinted": { + "type": "boolean" + }, + "priority": { + "type": "number" + }, + "userFk": { + "type": "number" + }, + "isRecyclable": { + "type": "boolean" + } + }, + "relations": { + "parking": { + "type": "belongsTo", + "model": "Parking", + "foreignKey": "parkingFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "userFk" + } + } +} diff --git a/modules/shelving/front/basic-data/index.html b/modules/shelving/front/basic-data/index.html new file mode 100644 index 000000000..68d61e169 --- /dev/null +++ b/modules/shelving/front/basic-data/index.html @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/shelving/front/basic-data/index.js b/modules/shelving/front/basic-data/index.js new file mode 100644 index 000000000..e17c9feee --- /dev/null +++ b/modules/shelving/front/basic-data/index.js @@ -0,0 +1,10 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.vnComponent('vnShelvingBasicData', { + template: require('./index.html'), + controller: Section, + bindings: { + shelving: '<' + } +}); diff --git a/modules/shelving/front/card/index.html b/modules/shelving/front/card/index.html new file mode 100644 index 000000000..c83afc288 --- /dev/null +++ b/modules/shelving/front/card/index.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/modules/shelving/front/card/index.js b/modules/shelving/front/card/index.js new file mode 100644 index 000000000..5e2ea9b12 --- /dev/null +++ b/modules/shelving/front/card/index.js @@ -0,0 +1,29 @@ +import ngModule from '../module'; +import ModuleCard from 'salix/components/module-card'; + +class Controller extends ModuleCard { + reload() { + const filter = { + include: [ + {relation: 'worker', + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + }}, + {relation: 'parking'} + ] + }; + this.$http.get(`Shelvings/${this.$params.id}`, {filter}) + .then(res => this.shelving = res.data); + } +} + +ngModule.vnComponent('vnShelvingCard', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/shelving/front/card/index.spec.js b/modules/shelving/front/card/index.spec.js new file mode 100644 index 000000000..85b1bd269 --- /dev/null +++ b/modules/shelving/front/card/index.spec.js @@ -0,0 +1,26 @@ +import './index'; + +describe('component vnShelvingCard', () => { + let controller; + let $httpBackend; + const data = {id: 1, code: 'AAA'}; + + beforeEach(ngModule('shelving')); + + beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { + $httpBackend = _$httpBackend_; + + let $element = angular.element('
'); + controller = $componentController('vnShelvingCard', {$element}); + + $stateParams.id = data.id; + $httpBackend.whenRoute('GET', 'Shelvings/:id').respond(data); + })); + + it('should reload the controller data', () => { + controller.reload(); + $httpBackend.flush(); + + expect(controller.shelving).toEqual(data); + }); +}); diff --git a/modules/shelving/front/create/index.html b/modules/shelving/front/create/index.html new file mode 100644 index 000000000..edb3a7d3b --- /dev/null +++ b/modules/shelving/front/create/index.html @@ -0,0 +1,51 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/shelving/front/create/index.js b/modules/shelving/front/create/index.js new file mode 100644 index 000000000..bb0e441eb --- /dev/null +++ b/modules/shelving/front/create/index.js @@ -0,0 +1,15 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + onSubmit() { + return this.$.watcher.submit().then(res => + this.$state.go('shelving.card.basicData', {id: res.data.id}) + ); + } +} + +ngModule.vnComponent('vnShelvingCreate', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/shelving/front/create/index.spec.js b/modules/shelving/front/create/index.spec.js new file mode 100644 index 000000000..0bdde9145 --- /dev/null +++ b/modules/shelving/front/create/index.spec.js @@ -0,0 +1,38 @@ +import './index'; + +describe('Shelving', () => { + describe('Component vnShelvingCreate', () => { + let $scope; + let $state; + let controller; + + beforeEach(ngModule('shelving')); + + beforeEach(inject(($componentController, $rootScope, _$state_) => { + $scope = $rootScope.$new(); + $state = _$state_; + $scope.watcher = { + submit: () => { + return { + then: callback => { + callback({data: {id: 1}}); + } + }; + } + }; + const $element = angular.element(''); + controller = $componentController('vnShelvingCreate', {$element, $scope}); + controller.$params = {}; + })); + + 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('shelving.card.basicData', {id: 1}); + }); + }); + }); +}); diff --git a/modules/shelving/front/descriptor/index.html b/modules/shelving/front/descriptor/index.html new file mode 100644 index 000000000..1344bb52a --- /dev/null +++ b/modules/shelving/front/descriptor/index.html @@ -0,0 +1,45 @@ + + + + Delete + + + +
+ + + + + + + {{::$ctrl.shelving.worker.user.nickname}} + + +
+
+
+ + + + + + + \ No newline at end of file diff --git a/modules/shelving/front/descriptor/index.js b/modules/shelving/front/descriptor/index.js new file mode 100644 index 000000000..931dbb6dc --- /dev/null +++ b/modules/shelving/front/descriptor/index.js @@ -0,0 +1,26 @@ +import ngModule from '../module'; +import Descriptor from 'salix/components/descriptor'; + +class Controller extends Descriptor { + get shelving() { + return this.entity; + } + + set shelving(value) { + this.entity = value; + } + + onDelete() { + return this.$http.delete(`Shelvings/${this.shelving.id}`) + .then(() => this.$state.go('shelving.index')) + .then(() => this.vnApp.showSuccess(this.$t('Shelving removed'))); + } +} + +ngModule.vnComponent('vnShelvingDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + shelving: '<' + } +}); diff --git a/modules/shelving/front/descriptor/index.spec.js b/modules/shelving/front/descriptor/index.spec.js new file mode 100644 index 000000000..3ee33580b --- /dev/null +++ b/modules/shelving/front/descriptor/index.spec.js @@ -0,0 +1,29 @@ +import './index.js'; + +describe('component vnShelvingDescriptor', () => { + let $httpBackend; + let controller; + + const shelving = {id: 1, code: 'AA6'}; + + beforeEach(ngModule('shelving')); + + beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnShelvingDescriptor', {$element: null}, {shelving}); + jest.spyOn(controller.vnApp, 'showSuccess'); + })); + + describe('onDelete()', () => { + it('should delete entity and go to index', () => { + controller.$state.go = jest.fn(); + + $httpBackend.expectDELETE('Shelvings/1').respond(); + controller.onDelete(); + $httpBackend.flush(); + + expect(controller.$state.go).toHaveBeenCalledWith('shelving.index'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); + }); + }); +}); diff --git a/modules/shelving/front/index.js b/modules/shelving/front/index.js new file mode 100644 index 000000000..2ad9bc1b9 --- /dev/null +++ b/modules/shelving/front/index.js @@ -0,0 +1,11 @@ +export * from './module'; + +import './basic-data'; +import './card'; +import './create'; +import './descriptor'; +import './index/'; +import './main'; +import './search-panel'; +import './summary'; +import './log'; diff --git a/modules/shelving/front/index/index.html b/modules/shelving/front/index/index.html new file mode 100644 index 000000000..1532abd42 --- /dev/null +++ b/modules/shelving/front/index/index.html @@ -0,0 +1,47 @@ + + + + + +
+ + + + + + + + + \ No newline at end of file diff --git a/modules/shelving/front/index/index.js b/modules/shelving/front/index/index.js new file mode 100644 index 000000000..04d8ea9cd --- /dev/null +++ b/modules/shelving/front/index/index.js @@ -0,0 +1,14 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + preview(shelving) { + this.selectedShelving = shelving; + this.$.summary.show(); + } +} + +ngModule.vnComponent('vnShelvingIndex', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/shelving/front/index/index.spec.js b/modules/shelving/front/index/index.spec.js new file mode 100644 index 000000000..aad79fb0e --- /dev/null +++ b/modules/shelving/front/index/index.spec.js @@ -0,0 +1,39 @@ +import './index.js'; +describe('Component vnShelvingIndex', () => { + let controller; + let $window; + let shelvings = [{ + id: 1, + code: 'AAA' + }, { + id: 2, + code: 'AA1' + }, { + id: 3, + code: 'AA2' + }]; + + beforeEach(ngModule('shelving')); + + beforeEach(inject(($componentController, _$window_) => { + $window = _$window_; + const $element = angular.element(''); + controller = $componentController('vnShelvingIndex', {$element}); + })); + + describe('preview()', () => { + it('should show the dialog summary', () => { + controller.$.summary = {show: () => {}}; + jest.spyOn(controller.$.summary, 'show'); + + let event = new MouseEvent('click', { + view: $window, + bubbles: true, + cancelable: true + }); + controller.preview(event, shelvings[0]); + + expect(controller.$.summary.show).toHaveBeenCalledWith(); + }); + }); +}); diff --git a/modules/shelving/front/index/locale/es.yml b/modules/shelving/front/index/locale/es.yml new file mode 100644 index 000000000..4d30f4cee --- /dev/null +++ b/modules/shelving/front/index/locale/es.yml @@ -0,0 +1,2 @@ +Parking: Parking +Priority: Prioridad \ No newline at end of file diff --git a/modules/shelving/front/log/index.html b/modules/shelving/front/log/index.html new file mode 100644 index 000000000..8f0e6851c --- /dev/null +++ b/modules/shelving/front/log/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/modules/shelving/front/log/index.js b/modules/shelving/front/log/index.js new file mode 100644 index 000000000..588e0995a --- /dev/null +++ b/modules/shelving/front/log/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.vnComponent('vnShelvingLog', { + template: require('./index.html'), + controller: Section, +}); diff --git a/modules/shelving/front/log/locale/es.yml b/modules/shelving/front/log/locale/es.yml new file mode 100644 index 000000000..c572b78d1 --- /dev/null +++ b/modules/shelving/front/log/locale/es.yml @@ -0,0 +1 @@ +Changed by: Cambiado por \ No newline at end of file diff --git a/modules/shelving/front/main/index.html b/modules/shelving/front/main/index.html new file mode 100644 index 000000000..3f3cc718b --- /dev/null +++ b/modules/shelving/front/main/index.html @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/modules/shelving/front/main/index.js b/modules/shelving/front/main/index.js new file mode 100644 index 000000000..96689fbd9 --- /dev/null +++ b/modules/shelving/front/main/index.js @@ -0,0 +1,29 @@ +import ngModule from '../module'; +import ModuleMain from 'salix/components/module-main'; + +export default class Shelving extends ModuleMain { + constructor($element, $) { + super($element, $); + this.filter = { + include: [ + {relation: 'parking'} + ], + }; + } + + exprBuilder(param, value) { + switch (param) { + case 'search': + return {code: {like: `%${value}%`}}; + case 'parkingFk': + case 'userFk': + case 'isRecyclable': + return {[param]: value}; + } + } +} + +ngModule.vnComponent('vnShelving', { + controller: Shelving, + template: require('./index.html') +}); diff --git a/modules/shelving/front/main/index.spec.js b/modules/shelving/front/main/index.spec.js new file mode 100644 index 000000000..dcfa912bc --- /dev/null +++ b/modules/shelving/front/main/index.spec.js @@ -0,0 +1,19 @@ +import './index'; + +describe('component vnShelving', () => { + let controller; + + beforeEach(ngModule('shelving')); + + beforeEach(inject($componentController => { + controller = $componentController('vnShelving', {$element: null}); + })); + + describe('exprBuilder()', () => { + it('should search by code', () => { + let expr = controller.exprBuilder('search', 'UXN'); + + expect(expr).toEqual({code: {like: '%UXN%'}},); + }); + }); +}); diff --git a/modules/shelving/front/main/locale/es.yml b/modules/shelving/front/main/locale/es.yml new file mode 100644 index 000000000..4c39469ce --- /dev/null +++ b/modules/shelving/front/main/locale/es.yml @@ -0,0 +1 @@ +Search shelving by code, parking or worker: Busca carros por código, parking o trabajador \ No newline at end of file diff --git a/modules/shelving/front/module.js b/modules/shelving/front/module.js new file mode 100644 index 000000000..8ba261ead --- /dev/null +++ b/modules/shelving/front/module.js @@ -0,0 +1,3 @@ +import {ng} from 'core/vendor'; + +export default ng.module('shelving', ['salix']); diff --git a/modules/shelving/front/routes.json b/modules/shelving/front/routes.json new file mode 100644 index 000000000..b99ca4cac --- /dev/null +++ b/modules/shelving/front/routes.json @@ -0,0 +1,70 @@ +{ + "module": "shelving", + "name": "Shelvings", + "icon" : "contact_support", + "dependencies": ["worker"], + "validations" : true, + "menus": { + "main": [ + {"state": "shelving.index", "icon": "contact_support"} + ], + "card": [ + {"state": "shelving.card.basicData", "icon": "settings"}, + {"state": "shelving.card.log", "icon": "history"} + ] + }, + "keybindings": [ + {"key": "s", "state": "shelving.index"} + ], + "routes": [ + { + "url": "/shelving", + "state": "shelving", + "abstract": true, + "component": "vn-shelving", + "description": "Shelvings" + }, + { + "url": "/index?q", + "state": "shelving.index", + "component": "vn-shelving-index", + "description": "Shelvings" + }, + { + "url": "/create", + "state": "shelving.create", + "component": "vn-shelving-create", + "description": "New shelving" + }, + { + "url": "/:id", + "state": "shelving.card", + "abstract": true, + "component": "vn-shelving-card" + }, + { + "url": "/summary", + "state": "shelving.card.summary", + "component": "vn-shelving-summary", + "description": "Summary", + "params": { + "shelving": "$ctrl.shelving" + } + }, + { + "url": "/basic-data", + "state": "shelving.card.basicData", + "component": "vn-shelving-basic-data", + "description": "Basic data", + "params": { + "shelving": "$ctrl.shelving" + } + }, + { + "url" : "/log", + "state": "shelving.card.log", + "component": "vn-shelving-log", + "description": "Log" + } + ] +} \ No newline at end of file diff --git a/modules/shelving/front/search-panel/index.html b/modules/shelving/front/search-panel/index.html new file mode 100644 index 000000000..b7ca068a5 --- /dev/null +++ b/modules/shelving/front/search-panel/index.html @@ -0,0 +1,43 @@ +
+
+ + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/modules/shelving/front/search-panel/index.js b/modules/shelving/front/search-panel/index.js new file mode 100644 index 000000000..51b81538b --- /dev/null +++ b/modules/shelving/front/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import SearchPanel from 'core/components/searchbar/search-panel'; + +ngModule.vnComponent('vnShelvingSearchPanel', { + template: require('./index.html'), + controller: SearchPanel +}); diff --git a/modules/shelving/front/search-panel/locale/es.yml b/modules/shelving/front/search-panel/locale/es.yml new file mode 100644 index 000000000..bd19b1b33 --- /dev/null +++ b/modules/shelving/front/search-panel/locale/es.yml @@ -0,0 +1 @@ +Search shelvings by code: Busca carros por código \ No newline at end of file diff --git a/modules/shelving/front/summary/index.html b/modules/shelving/front/summary/index.html new file mode 100644 index 000000000..61e44d278 --- /dev/null +++ b/modules/shelving/front/summary/index.html @@ -0,0 +1,51 @@ + +
+ + + + {{::$ctrl.summary.code}} +
+ + +

+ + Basic data + +

+ + + + + + + + + + {{$ctrl.summary.worker.user.nickname}} + + + + + +
+
+
+ + \ No newline at end of file diff --git a/modules/shelving/front/summary/index.js b/modules/shelving/front/summary/index.js new file mode 100644 index 000000000..10a905f1d --- /dev/null +++ b/modules/shelving/front/summary/index.js @@ -0,0 +1,41 @@ +import ngModule from '../module'; +import Summary from 'salix/components/summary'; +import './style.scss'; + +class Controller extends Summary { + set shelving(value) { + this._shelving = value; + this.summary = null; + if (!value) return; + + const filter = { + include: [ + {relation: 'worker', + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + }}, + {relation: 'parking'} + ] + }; + this.$http.get(`Shelvings/${value.id}`, {filter}) + .then(res => this.summary = res.data); + } + + get shelving() { + return this._shelving; + } +} + +ngModule.vnComponent('vnShelvingSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + shelving: '<' + } +}); diff --git a/modules/shelving/front/summary/locale/es.yml b/modules/shelving/front/summary/locale/es.yml new file mode 100644 index 000000000..d5d14d52a --- /dev/null +++ b/modules/shelving/front/summary/locale/es.yml @@ -0,0 +1,5 @@ +Code: Código +Parking: Parking +Priority: Prioridad +Worker: Trabajador +Recyclable: Reciclable \ No newline at end of file diff --git a/modules/shelving/front/summary/style.scss b/modules/shelving/front/summary/style.scss new file mode 100644 index 000000000..1eb6b2323 --- /dev/null +++ b/modules/shelving/front/summary/style.scss @@ -0,0 +1,7 @@ +@import "variables"; + +vn-client-summary { + .alert span { + color: $color-alert + } +} \ No newline at end of file diff --git a/modules/ticket/back/methods/sale/getClaimableFromTicket.js b/modules/ticket/back/methods/sale/getClaimableFromTicket.js index 4e0549a4d..ecbc52b94 100644 --- a/modules/ticket/back/methods/sale/getClaimableFromTicket.js +++ b/modules/ticket/back/methods/sale/getClaimableFromTicket.js @@ -24,6 +24,8 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); + const date = new Date(); + date.setHours(0, 0, 0, 0); const query = ` SELECT s.id AS saleFk, @@ -39,11 +41,11 @@ module.exports = Self => { INNER JOIN vn.sale s ON s.ticketFk = t.id LEFT JOIN vn.claimBeginning cb ON cb.saleFk = s.id - WHERE (t.landed) >= TIMESTAMPADD(DAY, -7, CURDATE()) + WHERE (t.landed) >= TIMESTAMPADD(DAY, -7, ?) AND t.id = ? AND cb.id IS NULL ORDER BY t.landed DESC, t.id DESC`; - const claimableSales = await Self.rawSql(query, [ticketFk], myOptions); + const claimableSales = await Self.rawSql(query, [date, ticketFk], myOptions); return claimableSales; }; diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 703fb4ba7..c0c431636 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -1,23 +1,20 @@ -const UserError = require('vn-loopback/util/user-error'); - module.exports = Self => { - Self.remoteMethodCtx('refund', { - description: 'Create ticket refund with lines and services changing the sign to the quantites', + Self.remoteMethod('refund', { + description: 'Create refund tickets with sales and services if provided', accessType: 'WRITE', - accepts: [{ - arg: 'sales', - description: 'The sales', - type: ['object'], - required: false - }, - { - arg: 'services', - type: ['object'], - required: false, - description: 'The services' - }], + accepts: [ + { + arg: 'salesIds', + type: ['number'], + required: true + }, + { + arg: 'servicesIds', + type: ['number'] + }, + ], returns: { - type: 'number', + type: ['number'], root: true }, http: { @@ -26,7 +23,8 @@ module.exports = Self => { } }); - Self.refund = async(ctx, sales, services, options) => { + Self.refund = async(salesIds, servicesIds, options) => { + const models = Self.app.models; const myOptions = {}; let tx; @@ -39,56 +37,103 @@ module.exports = Self => { } try { - const userId = ctx.req.accessToken.userId; + const refundAgencyMode = await models.AgencyMode.findOne({ + include: { + relation: 'zones', + scope: { + limit: 1, + field: ['id', 'name'] + } + }, + where: {code: 'refund'} + }, myOptions); - const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager'); - const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); - const hasValidRole = isClaimManager || isSalesAssistant; + const refoundZoneId = refundAgencyMode.zones()[0].id; - if (!hasValidRole) - throw new UserError(`You don't have privileges to create refund`); + const salesFilter = { + where: {id: {inq: salesIds}}, + include: { + relation: 'components', + scope: { + fields: ['saleFk', 'componentFk', 'value'] + } + } + }; + const sales = await models.Sale.find(salesFilter, myOptions); + const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; - const salesIds = []; - if (sales) { - for (let sale of sales) - salesIds.push(sale.id); - } else - salesIds.push(null); + const refundTickets = []; - const servicesIds = []; - if (services && services.length) { - for (let service of services) - servicesIds.push(service.id); - } else - servicesIds.push(null); + const now = new Date(); + const mappedTickets = new Map(); - const query = ` - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketService; + for (let ticketId of ticketsIds) { + const filter = {include: {relation: 'address'}}; + const ticket = await models.Ticket.findById(ticketId, filter, myOptions); - CREATE TEMPORARY TABLE tmp.sale - SELECT s.id, s.itemFk, s.quantity, s.concept, s.price, s.discount, s.ticketFk - FROM sale s - WHERE s.id IN (?); + const refundTicket = await models.Ticket.create({ + clientFk: ticket.clientFk, + shipped: now, + addressFk: ticket.address().id, + agencyModeFk: refundAgencyMode.id, + nickname: ticket.address().nickname, + warehouseFk: ticket.warehouseFk, + companyFk: ticket.companyFk, + landed: now, + zoneFk: refoundZoneId + }, myOptions); - CREATE TEMPORARY TABLE tmp.ticketService - SELECT ts.description, ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk, ts.ticketFk - FROM ticketService ts - WHERE ts.id IN (?); + refundTickets.push(refundTicket); - CALL vn.ticket_doRefund(@newTicket); + mappedTickets.set(ticketId, refundTicket.id); - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE tmp.ticketService;`; + await models.TicketRefund.create({ + refundTicketFk: refundTicket.id, + originalTicketFk: ticket.id, + }, myOptions); + } - await Self.rawSql(query, [salesIds, servicesIds], myOptions); + for (const sale of sales) { + const refundTicketId = mappedTickets.get(sale.ticketFk); + const createdSale = await models.Sale.create({ + ticketFk: refundTicketId, + itemFk: sale.itemFk, + quantity: - sale.quantity, + concept: sale.concept, + price: sale.price, + discount: sale.discount, + }, myOptions); - const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions); - const newTicketId = newTicket.id; + const components = sale.components(); + for (const component of components) + component.saleFk = createdSale.id; + + await models.SaleComponent.create(components, myOptions); + } + + if (servicesIds && servicesIds.length > 0) { + const servicesFilter = { + where: {id: {inq: servicesIds}} + }; + const services = await models.TicketService.find(servicesFilter, myOptions); + + for (const service of services) { + const refundTicketId = mappedTickets.get(service.ticketFk); + + await models.TicketService.create({ + description: service.description, + quantity: - service.quantity, + price: service.price, + taxClassFk: service.taxClassFk, + ticketFk: refundTicketId, + ticketServiceTypeFk: service.ticketServiceTypeFk, + }, myOptions); + } + } if (tx) await tx.commit(); - return newTicketId; + return refundTickets; } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index 5cb353055..74077cf29 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -1,23 +1,30 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('sale refund()', () => { - const sales = [ - {id: 7, ticketFk: 11}, - {id: 8, ticketFk: 11} - ]; - const services = [{id: 1}]; + const userId = 5; + const activeCtx = { + accessToken: {userId: userId}, + }; - it('should create ticket with the selected lines changing the sign to the quantites', async() => { + const servicesIds = [3]; + + beforeEach(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + + it('should create ticket with the selected lines', async() => { const tx = await models.Sale.beginTransaction({}); - const ctx = {req: {accessToken: {userId: 9}}}; + const salesIds = [7, 8]; try { const options = {transaction: tx}; - const response = await models.Sale.refund(ctx, sales, services, options); - const [newTicketId] = await models.Sale.rawSql('SELECT MAX(t.id) id FROM vn.ticket t;', null, options); + const response = await models.Sale.refund(salesIds, servicesIds, options); - expect(response).toEqual(newTicketId.id); + expect(response.length).toBeGreaterThanOrEqual(1); await tx.rollback(); } catch (e) { @@ -26,24 +33,53 @@ describe('sale refund()', () => { } }); - it(`should throw an error if the user doesn't have privileges to create a refund`, async() => { + it('should create a ticket for each unique ticketFk in the sales', async() => { const tx = await models.Sale.beginTransaction({}); - const ctx = {req: {accessToken: {userId: 1}}}; - - let error; + const salesIds = [6, 7]; try { const options = {transaction: tx}; - await models.Sale.refund(ctx, sales, services, options); + const tickets = await models.Sale.refund(salesIds, servicesIds, options); + + const ticketsIds = tickets.map(ticket => ticket.id); + + const refundedTickets = await models.Ticket.find({ + where: { + id: { + inq: ticketsIds + } + }, + include: [ + { + relation: 'ticketSales', + scope: { + include: { + relation: 'components' + } + } + }, + { + relation: 'ticketServices', + } + ] + }, options); + + const firstRefoundedTicket = refundedTickets[0]; + const secondRefoundedTicket = refundedTickets[1]; + const salesLength = firstRefoundedTicket.ticketSales().length; + const componentsLength = firstRefoundedTicket.ticketSales()[0].components().length; + const servicesLength = secondRefoundedTicket.ticketServices().length; + + expect(refundedTickets.length).toEqual(2); + expect(salesLength).toEqual(1); + expect(componentsLength).toEqual(4); + expect(servicesLength).toBeGreaterThanOrEqual(1); await tx.rollback(); } catch (e) { await tx.rollback(); - error = e; + throw e; } - - expect(error).toBeDefined(); - expect(error.message).toEqual(`You don't have privileges to create refund`); }); }); diff --git a/modules/ticket/back/methods/ticket/canHaveStowaway.js b/modules/ticket/back/methods/ticket/canHaveStowaway.js deleted file mode 100644 index 9246d0308..000000000 --- a/modules/ticket/back/methods/ticket/canHaveStowaway.js +++ /dev/null @@ -1,48 +0,0 @@ - -module.exports = Self => { - Self.remoteMethod('canHaveStowaway', { - description: 'Returns if a ticket can have stowaway', - accessType: 'READ', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'ticket id', - http: {source: 'path'} - }], - returns: { - root: true - }, - http: { - path: `/:id/canHaveStowaway`, - verb: 'GET' - } - }); - - Self.canHaveStowaway = async(id, options) => { - const models = Self.app.models; - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - const ticket = await models.Ticket.findById(id, { - include: { - relation: 'ship', - scope: { - fields: ['id'] - } - } - }, myOptions); - - const warehouse = await models.Warehouse.findById(ticket.warehouseFk, null, myOptions); - - const hasStowaway = ticket.ship() ? true : false; - const validStowaway = warehouse && warehouse.hasStowaway && !hasStowaway; - - if (!ticket.isDeleted && validStowaway) - return true; - - return false; - }; -}; diff --git a/modules/ticket/back/methods/ticket/deleteStowaway.js b/modules/ticket/back/methods/ticket/deleteStowaway.js deleted file mode 100644 index c3e5e0db1..000000000 --- a/modules/ticket/back/methods/ticket/deleteStowaway.js +++ /dev/null @@ -1,105 +0,0 @@ - -module.exports = Self => { - Self.remoteMethodCtx('deleteStowaway', { - description: 'Deletes an stowaway', - accessType: 'WRITE', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'The ticket id', - http: {source: 'path'} - }], - returns: { - root: true - }, - http: { - path: `/:id/deleteStowaway`, - verb: 'POST' - } - }); - - Self.deleteStowaway = async(ctx, id, options) => { - const models = Self.app.models; - const $t = ctx.req.__; // $translate - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const ticket = await Self.findById(id, { - include: [{ - relation: 'ship' - }, { - relation: 'stowaway' - }, { - relation: 'client', - scope: { - include: { - relation: 'salesPersonUser', - scope: { - fields: ['id', 'name'] - } - } - } - }] - }, myOptions); - - let stowawayFk; - let shipFk; - if (ticket.stowaway()) { - shipFk = ticket.stowaway().shipFk; - stowawayFk = ticket.stowaway().id; - } else if (ticket.ship()) { - shipFk = ticket.ship().shipFk; - stowawayFk = ticket.ship().id; - } - - const stowaway = await models.Stowaway.findOne({ - where: { - id: stowawayFk, - shipFk: shipFk - } - }, myOptions); - const result = await stowaway.destroy(myOptions); - - const state = await models.State.findOne({ - where: { - code: 'BOARDING' - } - }, myOptions); - const ticketTracking = await models.TicketTracking.findOne({ - where: { - ticketFk: shipFk, - stateFk: state.id - } - }, myOptions); - - await ticketTracking.destroy(myOptions); - - const salesPerson = ticket.client().salesPersonUser(); - if (salesPerson) { - const origin = ctx.req.headers.origin; - const message = $t('This ticket is not an stowaway anymore', { - ticketId: stowawayFk, - ticketUrl: `${origin}/#!/ticket/${stowawayFk}/sale` - }); - await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message); - } - - if (tx) await tx.commit(); - - return result; - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 902831d99..da8f65be2 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -132,6 +132,8 @@ module.exports = Self => { Self.filter = async(ctx, filter, options) => { const userId = ctx.req.accessToken.userId; const conn = Self.dataSource.connector; + const date = new Date(); + date.setHours(0, 0, 0, 0); const models = Self.app.models; const args = ctx.args; @@ -198,22 +200,7 @@ module.exports = Self => { return {'t.routeFk': {neq: null}}; return {'t.routeFk': null}; case 'pending': - if (value) { - return {and: [ - {'st.alertLevel': 0}, - {'st.code': {nin: [ - 'OK', - 'BOARDING', - 'PRINTED', - 'PRINTED_AUTO', - 'PICKER_DESIGNED' - ]}} - ]}; - } else { - return {and: [ - {'st.alertLevel': {gt: 0}} - ]}; - } + return {'st.isNotValidated': value}; case 'id': case 'clientFk': case 'agencyModeFk': @@ -297,7 +284,8 @@ module.exports = Self => { stmts.push(stmt); stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); - stmts.push(` + + stmt = new ParameterizedSQL(` CREATE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY @@ -305,7 +293,9 @@ module.exports = Self => { FROM tmp.filter f LEFT JOIN alertLevel al ON al.id = f.alertLevel WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) - AND f.shipped >= CURDATE()`); + AND f.shipped >= ?`, [date]); + stmts.push(stmt); + stmts.push('CALL ticket_getProblems(FALSE)'); stmt = new ParameterizedSQL(` diff --git a/modules/ticket/back/methods/ticket/getPossibleStowaways.js b/modules/ticket/back/methods/ticket/getPossibleStowaways.js deleted file mode 100644 index c97e3de89..000000000 --- a/modules/ticket/back/methods/ticket/getPossibleStowaways.js +++ /dev/null @@ -1,74 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethod('getPossibleStowaways', { - description: 'Returns a list of allowed tickets for a stowaway ticket', - accessType: 'READ', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'ticket id', - http: {source: 'path'} - }], - returns: { - root: true - }, - http: { - path: `/:id/getPossibleStowaways`, - verb: 'GET' - } - }); - - Self.getPossibleStowaways = async(ticketFk, options) => { - const models = Self.app.models; - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - const canHaveStowaway = await models.Ticket.canHaveStowaway(ticketFk, myOptions); - - if (!canHaveStowaway) - throw new UserError(`Can't create stowaway for this ticket`); - - const ship = await models.Ticket.findById(ticketFk, null, myOptions); - - if (!ship || !ship.shipped) - return []; - - const lowestDate = new Date(ship.shipped.getTime()); - lowestDate.setHours(0, 0, -1, 0); - - const highestDate = new Date(ship.shipped.getTime()); - highestDate.setHours(23, 59, 59); - - const possibleStowaways = await models.Ticket.find({ - where: { - id: {neq: ticketFk}, - clientFk: ship.clientFk, - addressFk: ship.addressFk, - agencyModeFk: ship.agencyModeFk, - warehouseFk: {neq: ship.warehouseFk}, - shipped: { - between: [lowestDate.toJSON(), highestDate.toJSON()] - } - }, - include: [ - {relation: 'agencyMode'}, - {relation: 'warehouse'}, - {relation: 'ticketState', - scope: { - fields: ['stateFk'], - include: { - relation: 'state', - fields: ['id', 'name'], - } - }, - }, - ] - }, myOptions); - - return possibleStowaways; - }; -}; diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index befc75ffc..4e9c22a24 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -26,6 +26,8 @@ module.exports = function(Self) { Self.makeInvoice = async(ctx, ticketsIds, options) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; + const date = new Date(); + date.setHours(0, 0, 0, 0); const myOptions = {}; let tx; @@ -81,7 +83,7 @@ module.exports = function(Self) { WHERE id IN(?) AND refFk IS NULL `, [ticketsIds], myOptions); - await Self.rawSql('CALL invoiceOut_new(?, CURDATE(), null, @invoiceId)', [serial], myOptions); + await Self.rawSql('CALL invoiceOut_new(?, ?, null, @invoiceId)', [serial, date], myOptions); const [resultInvoice] = await Self.rawSql('SELECT @invoiceId id', [], myOptions); diff --git a/modules/ticket/back/methods/ticket/refund.js b/modules/ticket/back/methods/ticket/refund.js new file mode 100644 index 000000000..620c8b0c7 --- /dev/null +++ b/modules/ticket/back/methods/ticket/refund.js @@ -0,0 +1,54 @@ +module.exports = Self => { + Self.remoteMethod('refund', { + description: 'Create refund tickets with all their sales and services', + accessType: 'WRITE', + accepts: [ + { + arg: 'ticketsIds', + type: ['number'], + required: true + }, + ], + returns: { + type: ['number'], + root: true + }, + http: { + path: `/refund`, + verb: 'post' + } + }); + + Self.refund = async(ticketsIds, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const filter = {where: {ticketFk: {inq: ticketsIds}}}; + + const sales = await models.Sale.find(filter, myOptions); + const salesIds = sales.map(sale => sale.id); + + const services = await models.TicketService.find(filter, myOptions); + const servicesIds = services.map(service => service.id); + + const refundedTickets = await models.Sale.refund(salesIds, servicesIds, myOptions); + + if (tx) await tx.commit(); + + return refundedTickets; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 38bd6e7b5..cec8096a6 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -107,28 +107,9 @@ module.exports = Self => { } } } - }, { - relation: 'ship' - }, { - relation: 'stowaway' }] }, myOptions); - // Change state to "fixing" if contains an stowaway and remove the link between them - let otherTicketId; - if (ticket.stowaway()) - otherTicketId = ticket.stowaway().shipFk; - else if (ticket.ship()) - otherTicketId = ticket.ship().id; - - if (otherTicketId) { - await models.Ticket.deleteStowaway(ctx, otherTicketId, myOptions); - await models.TicketTracking.changeState(ctx, { - ticketFk: otherTicketId, - code: 'FIXING' - }, myOptions); - } - // Send notification to salesPerson const salesPersonUser = ticket.client().salesPersonUser(); if (salesPersonUser) { @@ -142,6 +123,25 @@ module.exports = Self => { const updatedTicket = await ticket.updateAttribute('isDeleted', true, myOptions); + const [ticketCollection] = await models.TicketCollection.find({ + fields: ['id'], + where: { + ticketFk: ticket.id + } + }); + + if (ticketCollection) + await models.TicketCollection.destroyById(ticketCollection.id, myOptions); + + await Self.rawSql(` + DELETE sc + FROM vn.saleGroup sg + JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id + JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk + JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id + JOIN vn.sale s ON s.id = sgd.saleFk + WHERE s.ticketFk = ?;`, [ticket.id], myOptions); + if (tx) await tx.commit(); return updatedTicket; diff --git a/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js b/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js index 43f5b93df..8b7e1685d 100644 --- a/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js +++ b/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js @@ -56,7 +56,6 @@ describe('ticket canBeInvoiced()', () => { it('should return falsy for a ticket shipping in future', async() => { const tx = await models.Ticket.beginTransaction({}); - try { const options = {transaction: tx}; diff --git a/modules/ticket/back/methods/ticket/specs/canHaveStowaway.spec.js b/modules/ticket/back/methods/ticket/specs/canHaveStowaway.spec.js deleted file mode 100644 index 2bd25c2d2..000000000 --- a/modules/ticket/back/methods/ticket/specs/canHaveStowaway.spec.js +++ /dev/null @@ -1,39 +0,0 @@ -const models = require('vn-loopback/server/server').models; - -describe('ticket canHaveStowaway()', () => { - it('should return true if the ticket warehouse have hasStowaway equal 1', async() => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = {transaction: tx}; - - const ticketId = 16; - const canStowaway = await models.Ticket.canHaveStowaway(ticketId, options); - - expect(canStowaway).toBeTruthy(); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return false if the ticket warehouse dont have hasStowaway equal 0', async() => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = {transaction: tx}; - - const ticketId = 10; - const canStowaway = await models.Ticket.canHaveStowaway(ticketId, options); - - expect(canStowaway).toBeFalsy(); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js b/modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js deleted file mode 100644 index 62bfc71be..000000000 --- a/modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js +++ /dev/null @@ -1,75 +0,0 @@ -const models = require('vn-loopback/server/server').models; - -describe('ticket deleteStowaway()', () => { - const shipId = 16; - const stowawayId = 17; - const ctx = { - req: { - accessToken: {userId: 18}, - headers: {origin: 'http://localhost'} - } - }; - ctx.req.__ = (value, params) => { - return params.nickname; - }; - - it(`should create an stowaway, delete it and see the states of both stowaway and ship go back to the last states`, async() => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = {transaction: tx}; - - await models.Stowaway.rawSql(` - INSERT INTO stowaway (id, shipFk) VALUES (?, ?) - `, [stowawayId, shipId], options); - await models.Stowaway.rawSql( - `CALL ticketStateUpdate(?, ?)`, [shipId, 'BOARDING'], options); - await models.Stowaway.rawSql( - `CALL ticketStateUpdate(?, ?)`, [stowawayId, 'BOARDING'], options); - - let createdStowaways = await models.Stowaway.count({id: stowawayId, shipFk: shipId}, options); - - expect(createdStowaways).toEqual(1); - - let shipState = await models.TicketLastState.findOne({ - where: { - ticketFk: shipId - } - }, options); - let stowawayState = await models.TicketLastState.findOne({ - where: { - ticketFk: stowawayId - } - }, options); - - expect(shipState.name).toEqual('Embarcando'); - expect(stowawayState.name).toEqual('Embarcando'); - - await models.Ticket.deleteStowaway(ctx, shipId, options); - await models.Ticket.deleteStowaway(ctx, stowawayId, options); - - createdStowaways = await models.Stowaway.count({id: stowawayId, shipFk: shipId}, options); - - expect(createdStowaways).toEqual(0); - - shipState = await models.TicketLastState.findOne({ - where: { - ticketFk: shipId - } - }, options); - stowawayState = await models.TicketLastState.findOne({ - where: { - ticketFk: stowawayId - } - }, options); - - expect(shipState.name).toEqual('OK'); - expect(stowawayState.name).toEqual('Libre'); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 4b583fc87..c3dc40092 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -153,7 +153,7 @@ describe('ticket filter()', () => { const secondRow = result[1]; const thirdRow = result[2]; - expect(result.length).toEqual(12); + expect(result.length).toEqual(17); expect(firstRow.state).toEqual('Entregado'); expect(secondRow.state).toEqual('Entregado'); expect(thirdRow.state).toEqual('Entregado'); @@ -213,7 +213,7 @@ describe('ticket filter()', () => { const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(2); + expect(result.length).toEqual(3); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/ticket/specs/getPossibleStowaways.spec.js b/modules/ticket/back/methods/ticket/specs/getPossibleStowaways.spec.js deleted file mode 100644 index ed1a327d4..000000000 --- a/modules/ticket/back/methods/ticket/specs/getPossibleStowaways.spec.js +++ /dev/null @@ -1,60 +0,0 @@ -const models = require('vn-loopback/server/server').models; -let UserError = require('vn-loopback/util/user-error'); - -describe('ticket getPossibleStowaways()', () => { - it(`should throw an error if Can't create stowaway for this ticket`, async() => { - const tx = await models.Ticket.beginTransaction({}); - - let error; - - try { - const options = {transaction: tx}; - - const ticketId = 10; - await models.Ticket.getPossibleStowaways(ticketId, options); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - error = e; - } - - expect(error).toEqual(new UserError(`Can't create stowaway for this ticket`)); - }); - - it('should return an empty list of tickets for a valid ticket', async() => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = {transaction: tx}; - - const ticketId = 12; - const possibleStowaways = await models.Ticket.getPossibleStowaways(ticketId, options); - - expect(possibleStowaways.length).toEqual(0); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return allowed list of tickets for a valid ticket', async() => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = {transaction: tx}; - - const ticketId = 16; - const possibleStowaways = await models.Ticket.getPossibleStowaways(ticketId, options); - - expect(possibleStowaways.length).toEqual(1); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js index 9b629e634..132b1938d 100644 --- a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js @@ -8,6 +8,12 @@ describe('ticket setDeleted()', () => { accessToken: {userId: userId}, }; + beforeEach(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + it('should throw an error if the given ticket has a claim', async() => { const tx = await models.Ticket.beginTransaction({}); @@ -29,86 +35,62 @@ describe('ticket setDeleted()', () => { expect(error.message).toEqual('You must delete the claim id %d first'); }); - it('should delete ticket, remove stowaway and itemshelving then change stowaway state to "FIXING" ', async() => { - pending('test excluded by task #3693'); + it('should delete a sectorCollection row', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); const ctx = { req: { - accessToken: {userId: employeeUser}, - headers: { - origin: 'http://localhost:5000' - }, - __: () => {} + accessToken: {userId: 9}, + headers: {origin: 'http://localhost:5000'}, } }; + ctx.req.__ = value => { + return value; + }; + const ticketId = 23; - const sampleTicket = await models.Ticket.findById(12); - const sampleStowaway = await models.Ticket.findById(13); + await models.Ticket.setDeleted(ctx, ticketId, options); - sampleTicket.id = undefined; - const shipTicket = await models.Ticket.create(sampleTicket, options); + const [sectorCollection] = await models.Ticket.rawSql( + `SELECT COUNT(*) numberRows + FROM vn.sectorCollection`, [], options); - sampleStowaway.id = undefined; - const stowawayTicket = await models.Ticket.create(sampleStowaway, options); + expect(sectorCollection.numberRows).toEqual(0); - await models.Stowaway.rawSql(` - INSERT INTO vn.stowaway(id, shipFk) - VALUES (?, ?)`, [stowawayTicket.id, shipTicket.id], options); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); - const boardingState = await models.State.findOne({ - where: { - code: 'BOARDING' + it('should delete a ticketCollection row', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ctx = { + req: { + accessToken: {userId: 9}, + headers: {origin: 'http://localhost:5000'}, } - }, options); + }; + ctx.req.__ = value => { + return value; + }; + const ticketId = 23; - await models.TicketTracking.create({ - ticketFk: stowawayTicket.id, - stateFk: boardingState.id, - workerFk: ctx.req.accessToken.userId - }, options); + await models.Ticket.setDeleted(ctx, ticketId, options); - const okState = await models.State.findOne({ - where: { - code: 'OK' - } - }, options); + const [ticketCollection] = await models.Ticket.rawSql( + `SELECT COUNT(*) numberRows + FROM vn.ticketCollection`, [], options); - await models.TicketTracking.create({ - ticketFk: shipTicket.id, - stateFk: okState.id, - workerFk: ctx.req.accessToken.userId - }, options); - - let stowawayTicketState = await models.TicketState.findOne({ - where: { - ticketFk: stowawayTicket.id - } - }, options); - - let stowaway = await models.Stowaway.findById(shipTicket.id, null, options); - - expect(stowaway).toBeDefined(); - expect(stowawayTicketState.code).toEqual('BOARDING'); - - await models.Ticket.setDeleted(ctx, shipTicket.id, options); - - stowawayTicketState = await models.TicketState.findOne({ - where: { - ticketFk: stowawayTicket.id - } - }, options); - - stowaway = await models.Stowaway.findById(shipTicket.id, null, options); - - expect(stowaway).toBeNull(); - expect(stowawayTicketState.code).toEqual('FIXING'); + expect(ticketCollection.numberRows).toEqual(3); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index 41885ee33..8a6ac0c00 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -38,10 +38,10 @@ "State":{ "dataSource": "vn" }, - "Stowaway": { + "Ticket": { "dataSource": "vn" }, - "Ticket": { + "TicketCollection": { "dataSource": "vn" }, "TicketDms": { @@ -56,6 +56,9 @@ "TicketPackaging": { "dataSource": "vn" }, + "TicketRefund": { + "dataSource": "vn" + }, "TicketRequest": { "dataSource": "vn" }, diff --git a/modules/ticket/back/models/stowaway.js b/modules/ticket/back/models/stowaway.js deleted file mode 100644 index 780b6b31c..000000000 --- a/modules/ticket/back/models/stowaway.js +++ /dev/null @@ -1,24 +0,0 @@ -const LoopBackContext = require('loopback-context'); -const UserError = require('vn-loopback/util/user-error'); - -module.exports = function(Self) { - Self.observe('before save', async function(ctx) { - const models = Self.app.models; - const canHaveStowaway = await models.Ticket.canHaveStowaway(ctx.instance.shipFk); - - if (!canHaveStowaway) - throw new UserError(`Can't create stowaway for this ticket`); - - if (ctx.isNewInstance) { - let where = { - code: 'BOARDING' - }; - let state = await models.State.findOne({where}); - let params = {ticketFk: ctx.instance.shipFk, stateFk: state.id}; - const loopBackContext = LoopBackContext.getCurrentContext(); - - let httpCtx = {req: loopBackContext.active}; - await models.TicketTracking.changeState(httpCtx, params); - } - }); -}; diff --git a/modules/ticket/back/models/stowaway.json b/modules/ticket/back/models/stowaway.json deleted file mode 100644 index ef3aeb40d..000000000 --- a/modules/ticket/back/models/stowaway.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "Stowaway", - "base": "VnModel", - "options": { - "mysql": { - "table": "stowaway" - } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "shipFk": { - "type": "number", - "required": false - }, - "created":{ - "type": "date", - "required": false - } - }, - "relations": { - "ship": { - "type": "belongsTo", - "model": "Ticket", - "foreignKey": "shipFk" - }, - "ticket": { - "type": "belongsTo", - "model": "Ticket", - "foreignKey": "id" - } - } -} diff --git a/modules/ticket/back/models/ticket-collection.json b/modules/ticket/back/models/ticket-collection.json new file mode 100644 index 000000000..e941ac2ce --- /dev/null +++ b/modules/ticket/back/models/ticket-collection.json @@ -0,0 +1,22 @@ +{ + "name": "TicketCollection", + "base": "VnModel", + "options": { + "mysql": { + "table": "ticketCollection" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + } + }, + "relations": { + "ticket": { + "type": "belongsTo", + "model": "Ticket", + "foreignKey": "ticketFk" + } + } +} \ No newline at end of file diff --git a/modules/ticket/back/models/ticket-refund.json b/modules/ticket/back/models/ticket-refund.json new file mode 100644 index 000000000..8fd0e2306 --- /dev/null +++ b/modules/ticket/back/models/ticket-refund.json @@ -0,0 +1,40 @@ +{ + "name": "TicketRefund", + "base": "Loggable", + "options": { + "mysql": { + "table": "ticketRefund" + } + }, + "log": { + "model": "TicketLog", + "relation": "originalTicket" + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "refundTicketFk": { + "type": "number", + "required": true + }, + "originalTicketFk": { + "type": "number", + "required": true + } + }, + "relations": { + "refundTicket": { + "type": "belongsTo", + "model": "Ticket", + "foreignKey": "refundTicketFk" + }, + "originalTicket": { + "type": "belongsTo", + "model": "Ticket", + "foreignKey": "originalTicketFk" + } + } +} diff --git a/modules/ticket/back/models/ticket-service.js b/modules/ticket/back/models/ticket-service.js index aa94c42e3..209727ee4 100644 --- a/modules/ticket/back/models/ticket-service.js +++ b/modules/ticket/back/models/ticket-service.js @@ -3,17 +3,18 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.observe('before save', async ctx => { const models = Self.app.models; - let changes = ctx.currentInstance || ctx.instance; - if (changes) { - let ticketId = changes.ticketFk; - let isLocked = await models.Ticket.isLocked(ticketId); + const changes = ctx.currentInstance || ctx.instance; + + if (changes && !ctx.isNewInstance) { + const ticketId = changes.ticketFk; + const isLocked = await models.Ticket.isLocked(ticketId); if (isLocked) throw new UserError(`The current ticket can't be modified`); + } - if (changes.ticketServiceTypeFk) { - const ticketServiceType = await models.TicketServiceType.findById(changes.ticketServiceTypeFk); - changes.description = ticketServiceType.name; - } + if (changes && changes.ticketServiceTypeFk) { + const ticketServiceType = await models.TicketServiceType.findById(changes.ticketServiceTypeFk); + changes.description = ticketServiceType.name; } }); diff --git a/modules/ticket/back/models/ticket.js b/modules/ticket/back/models/ticket.js index b217eae4d..47d105824 100644 --- a/modules/ticket/back/models/ticket.js +++ b/modules/ticket/back/models/ticket.js @@ -14,7 +14,6 @@ module.exports = Self => { require('../methods/ticket/getSales')(Self); require('../methods/ticket/getSalesPersonMana')(Self); require('../methods/ticket/filter')(Self); - require('../methods/ticket/getPossibleStowaways')(Self); require('../methods/ticket/canBeInvoiced')(Self); require('../methods/ticket/makeInvoice')(Self); require('../methods/ticket/updateEditableTicket')(Self); @@ -23,13 +22,12 @@ module.exports = Self => { require('../methods/ticket/uploadFile')(Self); require('../methods/ticket/addSale')(Self); require('../methods/ticket/transferSales')(Self); - require('../methods/ticket/canHaveStowaway')(Self); require('../methods/ticket/recalculateComponents')(Self); - require('../methods/ticket/deleteStowaway')(Self); require('../methods/ticket/sendSms')(Self); require('../methods/ticket/isLocked')(Self); require('../methods/ticket/freightCost')(Self); require('../methods/ticket/getComponentsSum')(Self); + require('../methods/ticket/refund')(Self); Self.observe('before save', async function(ctx) { const loopBackContext = LoopBackContext.getCurrentContext(); diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index 65127a78c..09b01d213 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -69,16 +69,6 @@ "model": "Client", "foreignKey": "clientFk" }, - "ship": { - "type": "hasOne", - "model": "Stowaway", - "foreignKey": "shipFk" - }, - "stowaway": { - "type": "hasOne", - "model": "Stowaway", - "foreignKey": "id" - }, "warehouse": { "type": "belongsTo", "model": "Warehouse", @@ -115,6 +105,16 @@ "model": "TicketPackaging", "foreignKey": "ticketFk" }, + "ticketSales": { + "type": "hasMany", + "model": "Sale", + "foreignKey": "ticketFk" + }, + "ticketServices": { + "type": "hasMany", + "model": "TicketService", + "foreignKey": "ticketFk" + }, "tracking": { "type": "hasMany", "model": "TicketTracking", diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index 6e38039e2..e63fb9b15 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -6,18 +6,15 @@ class Controller extends ModuleCard { let filter = { include: [ { - relation: 'address'}, + relation: 'address' + }, { - relation: 'ship'}, - { - relation: 'stowaway'}, + relation: 'zone' + }, { relation: 'warehouse', scope: {fields: ['name']} }, - { - relation: 'zone', - }, { relation: 'invoiceOut', scope: {fields: ['id']} @@ -47,7 +44,8 @@ class Controller extends ModuleCard { } }, }, - }, { + }, + { relation: 'ticketState', scope: { fields: ['stateFk'], diff --git a/modules/ticket/front/create/card.html b/modules/ticket/front/create/card.html index 65c45d3dc..e48aea681 100644 --- a/modules/ticket/front/create/card.html +++ b/modules/ticket/front/create/card.html @@ -19,6 +19,7 @@ disabled="!$ctrl.clientId" url="{{ $ctrl.clientId ? 'Clients/'+ $ctrl.clientId +'/addresses' : null }}" fields="['nickname', 'street', 'city']" + where="{isActive: true}" ng-model="$ctrl.addressId" show-field="nickname" value-field="id" diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index 1dcfd669f..ea84743bc 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -103,20 +103,6 @@ translate> SMS Minimum import - - Add stowaway - - - Delete stowaway - Refund all @@ -260,21 +248,6 @@ sms="$ctrl.newSMS"> - - - - - - - - this.ticket = res.data) .then(() => { - this.canStowaway(); this.isTicketEditable(); this.hasDocuware(); }); @@ -228,27 +228,6 @@ class Controller extends Section { this.$.sms.open(); } - canStowaway() { - this.canShowStowaway = false; - if (!this.isTicketModule || !this.ticket) return; - - this.$http.get(`Tickets/${this.id}/canHaveStowaway`) - .then(res => this.canShowStowaway = !!res.data); - } - - get canDeleteStowaway() { - if (!this.ticket || !this.isTicketModule) - return false; - - return this.ticket.stowaway || this.ticket.ship; - } - - deleteStowaway() { - return this.$http.post(`Tickets/${this.id}/deleteStowaway`) - .then(() => this.reload()) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); - } - makeInvoice() { const params = {ticketsIds: [this.id]}; return this.$http.post(`Tickets/makeInvoice`, params) @@ -274,22 +253,14 @@ class Controller extends Section { } async refund() { - const filter = { - where: {ticketFk: this.id} - }; - const sales = await this.$http.get('Sales', {filter}); - this.sales = sales.data; - - const ticketServices = await this.$http.get('TicketServices', {filter}); - this.services = ticketServices.data; - - const params = { - sales: this.sales, - services: this.services - }; - const query = `Sales/refund`; + const params = {ticketsIds: [this.id]}; + const query = 'Tickets/refund'; return this.$http.post(query, params).then(res => { - this.$state.go('ticket.card.sale', {id: res.data}); + const [refundTicket] = res.data; + this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { + ticketId: refundTicket.id + })); + this.$state.go('ticket.card.sale', {id: refundTicket.id}); }); } } diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index af377d8ea..2d08a7846 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -231,23 +231,6 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { }); }); - describe('canStowaway()', () => { - it('should make a query and return if the ticket can be stowawayed', () => { - $httpBackend.expect('GET', `Tickets/${ticket.id}/canHaveStowaway`).respond(true); - controller.canStowaway(); - $httpBackend.flush(); - - expect(controller.canShowStowaway).toBeTruthy(); - }); - - it('should not make a query if is not on the ticket module', () => { - $state.getCurrentPath = () => [null, {state: {name: 'client'}}]; - controller.canStowaway(); - - expect(controller.canShowStowaway).toBeFalsy(); - }); - }); - describe('recalculateComponents()', () => { it('should make a query and show a success message', () => { jest.spyOn(controller, 'reload').mockReturnThis(); @@ -262,27 +245,20 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { }); }); - // #4084 review with Juan - xdescribe('refund()', () => { + describe('refund()', () => { it('should make a query and go to ticket.card.sale', () => { controller.$state.go = jest.fn(); controller._id = ticket.id; - const sales = [{id: 1}]; - const services = [{id: 2}]; - $httpBackend.expectGET(`Sales`).respond(sales); - $httpBackend.expectGET(`TicketServices`).respond(services); - - const expectedParams = { - sales: sales, - services: services + const params = { + ticketsIds: [16] }; - $httpBackend.expectPOST(`Sales/refund`, expectedParams).respond(); + $httpBackend.expectPOST('Tickets/refund', params).respond([{id: 99}]); controller.refund(); $httpBackend.flush(); - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: undefined}); + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: 99}); }); }); diff --git a/modules/ticket/front/descriptor-menu/locale/en.yml b/modules/ticket/front/descriptor-menu/locale/en.yml new file mode 100644 index 000000000..03f93db8d --- /dev/null +++ b/modules/ticket/front/descriptor-menu/locale/en.yml @@ -0,0 +1 @@ +The following refund ticket have been created: "The following refund ticket have been created: {{ticketId}}" \ No newline at end of file diff --git a/modules/ticket/front/descriptor-menu/locale/es.yml b/modules/ticket/front/descriptor-menu/locale/es.yml index 060d03154..b65159a3c 100644 --- a/modules/ticket/front/descriptor-menu/locale/es.yml +++ b/modules/ticket/front/descriptor-menu/locale/es.yml @@ -8,4 +8,5 @@ Send CSV: Enviar CSV Send CSV Delivery Note: Enviar albarán en CSV Send PDF Delivery Note: Enviar albarán en PDF Show Proforma: Ver proforma -Refund all: Abonar todo \ No newline at end of file +Refund all: Abonar todo +The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}" \ No newline at end of file diff --git a/modules/ticket/front/descriptor/addStowaway.html b/modules/ticket/front/descriptor/addStowaway.html deleted file mode 100644 index 44d262d51..000000000 --- a/modules/ticket/front/descriptor/addStowaway.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - Ticket id - Shipped - Agency - Warehouse - State - - - - - {{ticket.id}} - {{ticket.landed | date: 'dd/MM/yyyy'}} - {{ticket.agencyMode.name}} - {{ticket.warehouse.name}} - {{ticket.ticketState.state.name}} - - - - - - - \ No newline at end of file diff --git a/modules/ticket/front/descriptor/addStowaway.js b/modules/ticket/front/descriptor/addStowaway.js deleted file mode 100644 index c88bda0af..000000000 --- a/modules/ticket/front/descriptor/addStowaway.js +++ /dev/null @@ -1,32 +0,0 @@ -import ngModule from '../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -class Controller extends Component { - addStowaway(stowaway) { - let params = {id: stowaway.id, shipFk: this.ticket.id}; - this.$http.post(`Stowaways/`, params) - .then(() => this.cardReload()) - .then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.dialog.hide(); - }); - } - - show() { - this.$.dialog.show(); - } - - hide() { - this.$.dialog.hide(); - } -} - -ngModule.vnComponent('vnAddStowaway', { - template: require('./addStowaway.html'), - controller: Controller, - bindings: { - ticket: '<', - cardReload: '&?' - } -}); diff --git a/modules/ticket/front/descriptor/index.html b/modules/ticket/front/descriptor/index.html index 2c27b19cd..75bcd2801 100644 --- a/modules/ticket/front/descriptor/index.html +++ b/modules/ticket/front/descriptor/index.html @@ -93,36 +93,6 @@ icon="icon-basketadd"> -
- - -
-
- - -
- -
- -
diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml index 2a7bf360f..8ab88ce09 100644 --- a/modules/ticket/front/descriptor/locale/es.yml +++ b/modules/ticket/front/descriptor/locale/es.yml @@ -1,12 +1,4 @@ -Ship: Barco -Stowaway: Polizón Cliente: Client -Ship stowaways: Polizones del barco -Stowaways to add: Polizones a añadir -Stowaways of the ticket: Polizones del ticket -Add stowaway: Añadir polizón -Delete stowaway: Eliminar polizón -Are you sure you want to delete this stowaway?: ¿Seguro que quieres eliminar este polizón? Are you sure you want to send it?: ¿Seguro que quieres enviarlo? Show pallet report: Ver hoja de pallet Change shipped hour: Cambiar hora de envío diff --git a/modules/ticket/front/descriptor/style.scss b/modules/ticket/front/descriptor/style.scss index 1a69feeff..f083f41fc 100644 --- a/modules/ticket/front/descriptor/style.scss +++ b/modules/ticket/front/descriptor/style.scss @@ -1,11 +1,5 @@ @import "variables"; -.add-stowaway { - vn-data-viewer { - width: 640px - } -} - vn-dialog.modal-form { section.header { background-color: $color-main; diff --git a/modules/ticket/front/index.js b/modules/ticket/front/index.js index 01d1d7242..85a03ffb6 100644 --- a/modules/ticket/front/index.js +++ b/modules/ticket/front/index.js @@ -5,7 +5,6 @@ import './index/'; import './search-panel'; import './card'; import './descriptor'; -import './descriptor/addStowaway'; import './descriptor-popover'; import './descriptor-menu'; import './create/card'; diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index f4e5840f3..42eb10cb0 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -514,7 +514,7 @@ Refund diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 987333e28..2724bb97d 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -483,11 +483,18 @@ class Controller extends Section { const sales = this.selectedValidSales(); if (!sales) return; - const params = {sales: sales}; - const query = `Sales/refund`; - this.resetChanges(); + const salesIds = sales.map(sale => sale.id); + + const params = {salesIds: salesIds}; + const query = 'Sales/refund'; this.$http.post(query, params).then(res => { - this.$state.go('ticket.card.sale', {id: res.data}); + const [refundTicket] = res.data; + this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { + ticketId: refundTicket.id + })); + this.$state.go('ticket.card.sale', {id: refundTicket.id}); + + this.resetChanges(); }); } diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index a8ac2f3de..28d874932 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -704,18 +704,19 @@ describe('Ticket', () => { }); describe('createRefund()', () => { - it('should make an HTTP POST query and then call to the $state go() method', () => { + it('should make a query and then navigate to the created ticket sales section', () => { jest.spyOn(controller, 'selectedValidSales').mockReturnValue(controller.sales); - jest.spyOn(controller, 'resetChanges'); jest.spyOn(controller.$state, 'go'); - - const expectedId = 9999; - $httpBackend.expect('POST', `Sales/refund`).respond(200, expectedId); + const params = { + salesIds: [1, 4], + }; + const refundTicket = {id: 99}; + const createdTickets = [refundTicket]; + $httpBackend.expect('POST', 'Sales/refund', params).respond(200, createdTickets); controller.createRefund(); $httpBackend.flush(); - expect(controller.resetChanges).toHaveBeenCalledWith(); - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: expectedId}); + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', refundTicket); }); }); diff --git a/modules/travel/back/methods/thermograph/createThermograph.js b/modules/travel/back/methods/thermograph/createThermograph.js index 137f32ac4..23d9d6037 100644 --- a/modules/travel/back/methods/thermograph/createThermograph.js +++ b/modules/travel/back/methods/thermograph/createThermograph.js @@ -40,6 +40,7 @@ module.exports = Self => { const models = Self.app.models; let tx; const myOptions = {}; + const date = new Date(); if (typeof options == 'object') Object.assign(myOptions, options); @@ -57,8 +58,8 @@ module.exports = Self => { await Self.rawSql(` INSERT INTO travelThermograph(thermographFk, warehouseFk, temperatureFk, created) - VALUES (?, ?, ?, NOW()) - `, [thermograph.id, warehouseId, temperatureFk], myOptions); + VALUES (?, ?, ?, ?) + `, [thermograph.id, warehouseId, temperatureFk, date], myOptions); if (tx) await tx.commit(); diff --git a/modules/travel/back/methods/travel/cloneWithEntries.js b/modules/travel/back/methods/travel/cloneWithEntries.js index 393194f06..611f4e429 100644 --- a/modules/travel/back/methods/travel/cloneWithEntries.js +++ b/modules/travel/back/methods/travel/cloneWithEntries.js @@ -35,7 +35,7 @@ module.exports = Self => { 'landed', 'warehouseInFk', 'warehouseOutFk', - 'agencyFk', + 'agencyModeFk', 'ref' ] }); @@ -56,7 +56,7 @@ module.exports = Self => { travel.warehouseOutFk, travel.warehouseInFk, travel.ref, - travel.agencyFk + travel.agencyModeFk ] ); stmts.push(stmt); @@ -76,7 +76,7 @@ module.exports = Self => { 'landed', 'warehouseInFk', 'warehouseOutFk', - 'agencyFk', + 'agencyModeFk', 'ref' ] }); diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index af6e1ec0a..7769b7f21 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -34,7 +34,7 @@ module.exports = Self => { description: 'The landed to date filter' }, { - arg: 'agencyFk', + arg: 'agencyModeFk', type: 'number', description: 'The agencyModeFk id' }, @@ -96,7 +96,7 @@ module.exports = Self => { case 'continent': return {'cnt.code': value}; case 'id': - case 'agencyFk': + case 'agencyModeFk': case 'warehouseOutFk': case 'warehouseInFk': case 'totalEntries': @@ -143,7 +143,7 @@ module.exports = Self => { JOIN warehouse wo ON wo.id = t.warehouseOutFk JOIN country c ON c.id = wo.countryFk LEFT JOIN continent cnt ON cnt.id = c.continentFk - JOIN agencyMode am ON am.id = t.agencyFk` + JOIN agencyMode am ON am.id = t.agencyModeFk` ); stmt.merge(conn.makeWhere(filter.where)); diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index 586b4e5aa..3fa1d65f9 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -44,7 +44,7 @@ module.exports = Self => { description: 'The landed to date filter', http: {source: 'query'} }, { - arg: 'agencyFk', + arg: 'agencyModeFk', type: 'number', description: 'The agencyModeFk id', http: {source: 'query'} @@ -102,7 +102,7 @@ module.exports = Self => { case 'landedTo': return {'t.landed': {lte: value}}; case 'id': - case 'agencyFk': + case 'agencyModeFk': case 'warehouseOutFk': case 'warehouseInFk': case 'totalEntries': @@ -124,7 +124,7 @@ module.exports = Self => { t.landed, t.warehouseInFk, t.warehouseOutFk, - t.agencyFk, + t.agencyModeFk, t.ref, t.isDelivered, t.isReceived, @@ -137,7 +137,7 @@ module.exports = Self => { wout.name warehouseOutName, cnt.code continent FROM vn.travel t - JOIN vn.agencyMode am ON am.id = t.agencyFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk JOIN vn.warehouse win ON win.id = t.warehouseInFk JOIN vn.warehouse wout ON wout.id = t.warehouseOutFk JOIN warehouse wo ON wo.id = t.warehouseOutFk diff --git a/modules/travel/back/methods/travel/getAverageDays.js b/modules/travel/back/methods/travel/getAverageDays.js index 9a9649d84..d888d80c1 100644 --- a/modules/travel/back/methods/travel/getAverageDays.js +++ b/modules/travel/back/methods/travel/getAverageDays.js @@ -32,9 +32,9 @@ module.exports = Self => { t.warehouseOutFk, t.landed, t.shipped, - t.agencyFk + t.agencyModeFk FROM travel t - WHERE t.agencyFk = ? LIMIT 50)`, [agencyModeFk]); + WHERE t.agencyModeFk = ? LIMIT 50)`, [agencyModeFk]); stmts.push(stmt); stmt = new ParameterizedSQL(` @@ -44,10 +44,10 @@ module.exports = Self => { t.warehouseOutFk, (SELECT ROUND(AVG(DATEDIFF(t.landed, t.shipped ))) FROM tmp.travel t - WHERE t.agencyFk + WHERE t.agencyModeFk ORDER BY id DESC LIMIT 50) AS dayDuration FROM tmp.travel t - WHERE t.agencyFk + WHERE t.agencyModeFk ORDER BY t.id DESC LIMIT 1`); const avgDaysIndex = stmts.push(stmt) - 1; diff --git a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js index aa92fa308..2e79ff193 100644 --- a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js +++ b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js @@ -71,7 +71,7 @@ describe('Travel cloneWithEntries()', () => { expect(newTravel.ref).toEqual('fifth travel'); expect(newTravel.warehouseInFk).toEqual(warehouseThree); expect(newTravel.warehouseOutFk).toEqual(warehouseThree); - expect(newTravel.agencyFk).toEqual(agencyModeOne); + expect(newTravel.agencyModeFk).toEqual(agencyModeOne); expect(travelEntries.length).toBeGreaterThan(0); }); }); diff --git a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js index b74160efe..3693aae82 100644 --- a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js +++ b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js @@ -70,10 +70,10 @@ describe('Travel extraCommunityFilter()', () => { expect(result.length).toEqual(3); }); - it('should return the travel matching "agencyFk"', async() => { + it('should return the travel matching "agencyModeFk"', async() => { const ctx = { args: { - agencyFk: 1 + agencyModeFk: 1 } }; diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index 95330e263..c20b7b0bf 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -44,17 +44,14 @@ "type": "number" }, "agencyModeFk": { - "type": "number", - "mysql": { - "columnName": "agencyFk" - } + "type": "number" } }, "relations": { "agency": { "type": "belongsTo", "model": "AgencyMode", - "foreignKey": "agencyFk" + "foreignKey": "agencyModeFk" }, "warehouseIn": { "type": "belongsTo", diff --git a/modules/travel/front/descriptor-menu/index.js b/modules/travel/front/descriptor-menu/index.js index 25922815e..0630bb618 100644 --- a/modules/travel/front/descriptor-menu/index.js +++ b/modules/travel/front/descriptor-menu/index.js @@ -25,7 +25,7 @@ class Controller extends Section { 'shipped', 'landed', 'totalEntries', - 'agencyFk', + 'agencyModeFk', 'warehouseInFk', 'warehouseOutFk', 'cargoSupplierFk' @@ -64,7 +64,7 @@ class Controller extends Section { onCloneAccept() { const params = JSON.stringify({ ref: this.travel.ref, - agencyModeFk: this.travel.agencyFk, + agencyModeFk: this.travel.agencyModeFk, shipped: this.travel.shipped, landed: this.travel.landed, warehouseInFk: this.travel.warehouseInFk, diff --git a/modules/travel/front/descriptor-menu/index.spec.js b/modules/travel/front/descriptor-menu/index.spec.js index 4ca93a6d6..40319e8e2 100644 --- a/modules/travel/front/descriptor-menu/index.spec.js +++ b/modules/travel/front/descriptor-menu/index.spec.js @@ -18,7 +18,7 @@ describe('Travel Component vnTravelDescriptorMenu', () => { controller.travel = { ref: 'the ref', - agencyFk: 'the agency', + agencyModeFk: 'the agency', shipped: 'the shipped date', landed: 'the landing date', warehouseInFk: 'the receiver warehouse', @@ -29,7 +29,7 @@ describe('Travel Component vnTravelDescriptorMenu', () => { const params = JSON.stringify({ ref: controller.travel.ref, - agencyModeFk: controller.travel.agencyFk, + agencyModeFk: controller.travel.agencyModeFk, shipped: controller.travel.shipped, landed: controller.travel.landed, warehouseInFk: controller.travel.warehouseInFk, diff --git a/modules/travel/front/descriptor/index.js b/modules/travel/front/descriptor/index.js index dc19f68af..b1f2f53be 100644 --- a/modules/travel/front/descriptor/index.js +++ b/modules/travel/front/descriptor/index.js @@ -14,9 +14,9 @@ class Controller extends Descriptor { let travelFilter; const travel = this.travel; - if (travel && travel.agencyFk) { + if (travel && travel.agencyModeFk) { travelFilter = this.travel && JSON.stringify({ - agencyFk: this.travel.agencyFk + agencyModeFk: this.travel.agencyModeFk }); } return travelFilter; diff --git a/modules/travel/front/extra-community-search-panel/index.html b/modules/travel/front/extra-community-search-panel/index.html index 8e51acc15..ab1e88891 100644 --- a/modules/travel/front/extra-community-search-panel/index.html +++ b/modules/travel/front/extra-community-search-panel/index.html @@ -29,7 +29,7 @@ diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index 8510cf328..27a700083 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -11,7 +11,7 @@ Id Reference - Agency + Agency Warehouse Out Shipped Delivered diff --git a/modules/travel/front/index/index.js b/modules/travel/front/index/index.js index 5cae6fa06..50036831f 100644 --- a/modules/travel/front/index/index.js +++ b/modules/travel/front/index/index.js @@ -10,7 +10,7 @@ export default class Controller extends Section { onCloneAccept(travel) { const params = JSON.stringify({ ref: travel.ref, - agencyModeFk: travel.agencyFk, + agencyModeFk: travel.agencyModeFk, shipped: travel.shipped, landed: travel.landed, warehouseInFk: travel.warehouseInFk, @@ -44,7 +44,7 @@ export default class Controller extends Section { case 'landed': return {'t.landed': {between: this.dateRange(value)}}; case 'id': - case 'agencyFk': + case 'agencyModeFk': case 'warehouseOutFk': case 'warehouseInFk': case 'totalEntries': diff --git a/modules/travel/front/index/index.spec.js b/modules/travel/front/index/index.spec.js index 1b2ab0a87..9abe46a64 100644 --- a/modules/travel/front/index/index.spec.js +++ b/modules/travel/front/index/index.spec.js @@ -35,11 +35,11 @@ describe('Travel Component vnTravelIndex', () => { const travel = { ref: 1, - agencyFk: 1 + agencyModeFk: 1 }; const travelParams = { ref: travel.ref, - agencyModeFk: travel.agencyFk + agencyModeFk: travel.agencyModeFk }; const queryParams = JSON.stringify(travelParams); controller.onCloneAccept(travel); diff --git a/modules/travel/front/search-panel/index.html b/modules/travel/front/search-panel/index.html index 8d4edec1a..2e9c796c3 100644 --- a/modules/travel/front/search-panel/index.html +++ b/modules/travel/front/search-panel/index.html @@ -29,7 +29,7 @@ diff --git a/modules/worker/back/methods/worker-time-control/addTimeEntry.js b/modules/worker/back/methods/worker-time-control/addTimeEntry.js index 06356cdaf..fef3cf223 100644 --- a/modules/worker/back/methods/worker-time-control/addTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/addTimeEntry.js @@ -46,30 +46,11 @@ module.exports = Self => { if (isSubordinate === false || (isSubordinate && isHimself && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); - const minTime = new Date(args.timed); - minTime.setHours(0, 0, 0, 0); + query = `CALL vn.workerTimeControl_clockIn(?,?,?)`; + const [response] = await Self.rawSql(query, [workerId, args.timed, args.direction], myOptions); + if (response[0] && response[0].error) + throw new UserError(response[0].error); - query = `SELECT * FROM vn.workerLabour WHERE workerFk = ? AND (ended >= ? OR ended IS NULL);`; - const [workerLabour] = await Self.rawSql(query, [workerId, minTime]); - const absence = await models.Calendar.findOne({ - where: { - businessFk: workerLabour.businessFk, - dated: minTime - } - }); - if (absence) { - const absenceType = await models.AbsenceType.findById(absence.dayOffTypeFk, null, myOptions); - const isNotHalfAbsence = absenceType.code != 'halfHoliday' - && absenceType.code != 'halfPaidLeave' - && absenceType.code != 'halfFurlough'; - if (isNotHalfAbsence) - throw new UserError(`The worker has a marked absence that day`); - } - return models.WorkerTimeControl.create({ - userFk: workerId, - direction: args.direction, - timed: args.timed, - manual: true - }, myOptions); + return response; }; }; diff --git a/modules/worker/back/methods/worker-time-control/specs/filter.spec.js b/modules/worker/back/methods/worker-time-control/specs/filter.spec.js index 7fe681ec1..927d83df3 100644 --- a/modules/worker/back/methods/worker-time-control/specs/filter.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/filter.spec.js @@ -1,8 +1,8 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('workerTimeControl filter()', () => { it('should return 1 result filtering by id', async() => { - let ctx = {req: {accessToken: {userId: 1106}}, args: {workerFk: 1106}}; + const ctx = {req: {accessToken: {userId: 1106}}, args: {workerFk: 1106}}; const firstHour = new Date(); firstHour.setHours(7, 0, 0, 0); const lastHour = new Date(); @@ -14,13 +14,13 @@ describe('workerTimeControl filter()', () => { timed: {between: [firstHour, lastHour]} } }; - let result = await app.models.WorkerTimeControl.filter(ctx, filter); + const result = await models.WorkerTimeControl.filter(ctx, filter); expect(result.length).toEqual(4); }); it('should return a privilege error for a non subordinate worker', async() => { - let ctx = {req: {accessToken: {userId: 1107}}, args: {workerFk: 1106}}; + const ctx = {req: {accessToken: {userId: 1107}}, args: {workerFk: 1106}}; const firstHour = new Date(); firstHour.setHours(7, 0, 0, 0); const lastHour = new Date(); @@ -34,7 +34,7 @@ describe('workerTimeControl filter()', () => { }; let error; - await app.models.WorkerTimeControl.filter(ctx, filter).catch(e => { + await models.WorkerTimeControl.filter(ctx, filter).catch(e => { error = e; }).finally(() => { expect(error.message).toEqual(`You don't have enough privileges`); diff --git a/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js b/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js index 0c2914934..e1e0feced 100644 --- a/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js @@ -1,6 +1,6 @@ -const app = require('vn-loopback/server/server'); +/* eslint max-len: ["error", { "code": 150 }]*/ +const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -const models = app.models; describe('workerTimeControl add/delete timeEntry()', () => { const HHRRId = 37; @@ -8,10 +8,18 @@ describe('workerTimeControl add/delete timeEntry()', () => { const employeeId = 1; const salesPersonId = 1106; const salesBossId = 19; - let activeCtx = { + const hankPymId = 1107; + const jessicaJonesId = 1110; + const monday = 1; + const tuesday = 2; + const thursday = 4; + const friday = 5; + const saturday = 6; + const sunday = 7; + const activeCtx = { accessToken: {userId: 50}, }; - let ctx = {req: activeCtx}; + const ctx = {req: activeCtx}; beforeAll(() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ @@ -19,190 +27,675 @@ describe('workerTimeControl add/delete timeEntry()', () => { }); }); - it('should fail to add a time entry if the target user is not a subordinate', async() => { - activeCtx.accessToken.userId = employeeId; - const workerId = 2; + describe('as Role errors', () => { + it('should fail to add a time entry if the target user is not a subordinate', async() => { + activeCtx.accessToken.userId = employeeId; + const workerId = 2; - let error; + let error; - try { - ctx.args = {timed: new Date(), direction: 'in'}; - await models.WorkerTimeControl.addTimeEntry(ctx, workerId); - } catch (e) { - error = e; - } + try { + ctx.args = {timed: new Date(), direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId); + } catch (e) { + error = e; + } - expect(error).toBeDefined(); - expect(error.statusCode).toBe(400); - expect(error.message).toBe(`You don't have enough privileges`); + expect(error).toBeDefined(); + expect(error.statusCode).toBe(400); + expect(error.message).toBe(`You don't have enough privileges`); + }); + + it('should fail to add if the current and the target user are the same and is not team boss', async() => { + activeCtx.accessToken.userId = employeeId; + const workerId = employeeId; + let error; + + try { + ctx.args = {timed: new Date(), direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + expect(error.statusCode).toBe(400); + expect(error.message).toBe(`You don't have enough privileges`); + }); + + it('should add if the current user is team boss and the target user is himself', async() => { + activeCtx.accessToken.userId = teamBossId; + const workerId = teamBossId; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + try { + const options = {transaction: tx}; + + const todayAtOne = new Date(); + todayAtOne.setHours(1, 0, 0, 0); + + ctx.args = {timed: todayAtOne, direction: 'in'}; + const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + expect(createdTimeEntry.id).toBeDefined(); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should try but fail to delete his own time entry', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = salesBossId; + + let error; + const tx = await models.WorkerTimeControl.beginTransaction({}); + try { + const options = {transaction: tx}; + + const todayAtOne = new Date(); + todayAtOne.setHours(1, 0, 0, 0); + + ctx.args = {timed: todayAtOne, direction: 'in'}; + const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + activeCtx.accessToken.userId = salesPersonId; + await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error).toBeDefined(); + expect(error.statusCode).toBe(400); + expect(error.message).toBe(`You don't have enough privileges`); + }); + + it('should delete the created time entry for the team boss as himself', async() => { + activeCtx.accessToken.userId = teamBossId; + const workerId = teamBossId; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + try { + const options = {transaction: tx}; + + const todayAtOne = new Date(); + todayAtOne.setHours(1, 0, 0, 0); + + ctx.args = {timed: todayAtOne, direction: 'in'}; + const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + expect(createdTimeEntry.id).toBeDefined(); + + await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options); + + const deletedTimeEntry = await models.WorkerTimeControl.findById(createdTimeEntry.id, null, options); + + expect(deletedTimeEntry).toBeNull(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should delete the created time entry for the team boss as HHRR', async() => { + activeCtx.accessToken.userId = HHRRId; + const workerId = teamBossId; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + try { + const options = {transaction: tx}; + + const todayAtOne = new Date(); + todayAtOne.setHours(1, 0, 0, 0); + + ctx.args = {timed: todayAtOne, direction: 'in'}; + const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + expect(createdTimeEntry.id).toBeDefined(); + + await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options); + + const deletedTimeEntry = await models.WorkerTimeControl.findById(createdTimeEntry.id, null, options); + + expect(deletedTimeEntry).toBeNull(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should edit the created time entry for the team boss as HHRR', async() => { + activeCtx.accessToken.userId = HHRRId; + const workerId = teamBossId; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + try { + const options = {transaction: tx}; + + const todayAtOne = new Date(); + todayAtOne.setHours(1, 0, 0, 0); + + ctx.args = {timed: todayAtOne, direction: 'in'}; + const [createdTimeEntry] = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + expect(createdTimeEntry.id).toBeDefined(); + + ctx.args = {direction: 'out'}; + const updatedTimeEntry = await models.WorkerTimeControl.updateTimeEntry(ctx, createdTimeEntry.id, options); + + expect(updatedTimeEntry.direction).toEqual('out'); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); - it('should fail to add if the current and the target user are the same and is not team boss', async() => { - activeCtx.accessToken.userId = employeeId; - const workerId = employeeId; - let error; + describe('WorkerTimeControl_clockIn calls', () => { + it('should fail to add a time entry if the target user has an absence that day', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; + const date = new Date(); + date.setDate(date.getDate() - 16); + date.setHours(8, 0, 0); + let error; - try { - ctx.args = {timed: new Date(), direction: 'in'}; - await models.WorkerTimeControl.addTimeEntry(ctx, workerId); - } catch (e) { - error = e; - } - - expect(error).toBeDefined(); - expect(error.statusCode).toBe(400); - expect(error.message).toBe(`You don't have enough privileges`); - }); - - it('should add if the current user is team boss and the target user is a himself', async() => { - activeCtx.accessToken.userId = teamBossId; - const workerId = teamBossId; - - const tx = await models.WorkerTimeControl.beginTransaction({}); - try { + const tx = await models.WorkerTimeControl.beginTransaction({}); const options = {transaction: tx}; + try { + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - const todayAtSix = new Date(); - todayAtSix.setHours(18, 30, 0, 0); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } - ctx.args = {timed: todayAtSix, direction: 'in'}; - const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + expect(error.message).toBe(`No está permitido trabajar`); + }); - expect(createdTimeEntry.id).toBeDefined(); + it('should fail to add a time entry for a worker without an existing contract', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; + const date = new Date(); + date.setFullYear(date.getFullYear() - 2); + let error; - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); + const tx = await models.WorkerTimeControl.beginTransaction({}); + try { + const options = {transaction: tx}; + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - it('should fail to add a time entry if the target user has absent that day', async() => { - activeCtx.accessToken.userId = salesBossId; - const workerId = salesPersonId; - let error; + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } - let calendar = await app.models.Calendar.findById(3); + expect(error.message).toBe(`No hay un contrato en vigor`); + }); - try { - ctx.args = {timed: new Date(calendar.dated), direction: 'in'}; - await models.WorkerTimeControl.addTimeEntry(ctx, workerId); - } catch (e) { - error = e; - } + describe('direction errors', () => { + it('should throw an error when trying "in" direction twice', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; - expect(error.message).toBe(`The worker has a marked absence that day`); - }); + let date = new Date(); + date.setDate(date.getDate() - 21); + date = weekDay(date, monday); + let error; - it('should try but fail to delete his own time entry', async() => { - activeCtx.accessToken.userId = salesBossId; - const workerId = salesBossId; + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; + date.setHours(8, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - let error; - const tx = await models.WorkerTimeControl.beginTransaction({}); - try { - const options = {transaction: tx}; + try { + date.setHours(10, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - const todayAtSeven = new Date(); - todayAtSeven.setHours(19, 30, 0, 0); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } - ctx.args = {timed: todayAtSeven, direction: 'in'}; - const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + expect(error.message).toBe(`Dirección incorrecta`); + }); - activeCtx.accessToken.userId = salesPersonId; - await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options); + it('should throw an error when trying "in" direction after insert "in" and "middle"', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } + let date = new Date(); + date.setDate(date.getDate() - 21); + date = weekDay(date, monday); + let error; - expect(error).toBeDefined(); - expect(error.statusCode).toBe(400); - expect(error.message).toBe(`You don't have enough privileges`); - }); + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; - it('should delete the created time entry for the team boss as himself', async() => { - activeCtx.accessToken.userId = teamBossId; - const workerId = teamBossId; + date.setHours(8, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + date.setHours(9, 0, 0); + ctx.args = {timed: date, direction: 'middle'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - const tx = await models.WorkerTimeControl.beginTransaction({}); - try { - const options = {transaction: tx}; + try { + date.setHours(10, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - const todayAtFive = new Date(); - todayAtFive.setHours(17, 30, 0, 0); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } - ctx.args = {timed: todayAtFive, direction: 'in'}; - const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + expect(error.message).toBe(`Dirección incorrecta`); + }); - expect(createdTimeEntry.id).toBeDefined(); + it('Should throw an error when trying "out" before closing a "middle" couple', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; - await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options); + let date = new Date(); + date.setDate(date.getDate() - 21); + date = weekDay(date, monday); + let error; - const deletedTimeEntry = await models.WorkerTimeControl.findById(createdTimeEntry.id, null, options); + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; - expect(deletedTimeEntry).toBeNull(); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); + date.setHours(8, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + date.setHours(9, 0, 0); + ctx.args = {timed: date, direction: 'middle'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - it('should delete the created time entry for the team boss as HHRR', async() => { - activeCtx.accessToken.userId = HHRRId; - const workerId = teamBossId; + try { + date.setHours(10, 0, 0); + ctx.args = {timed: date, direction: 'out'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - const tx = await models.WorkerTimeControl.beginTransaction({}); - try { - const options = {transaction: tx}; + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } - const todayAtFive = new Date(); - todayAtFive.setHours(17, 30, 0, 0); + expect(error.message).toBe(`Dirección incorrecta`); + }); - ctx.args = {timed: todayAtFive, direction: 'in'}; - const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + it('should throw an error when trying "middle" after "out"', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; - expect(createdTimeEntry.id).toBeDefined(); + let date = new Date(); + date.setDate(date.getDate() - 21); + date = weekDay(date, monday); + let error; - await models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id, options); + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; - const deletedTimeEntry = await models.WorkerTimeControl.findById(createdTimeEntry.id, null, options); + date.setHours(8, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + date.setHours(9, 0, 0); + ctx.args = {timed: date, direction: 'out'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - expect(deletedTimeEntry).toBeNull(); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); + try { + date.setHours(10, 0, 0); + ctx.args = {timed: date, direction: 'middle'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - it('should edit the created time entry for the team boss as HHRR', async() => { - activeCtx.accessToken.userId = HHRRId; - const workerId = teamBossId; + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } - const tx = await models.WorkerTimeControl.beginTransaction({}); - try { - const options = {transaction: tx}; + expect(error.message).toBe(`Dirección incorrecta`); + }); - const todayAtFive = new Date(); - todayAtFive.setHours(17, 30, 0, 0); + it('should throw an error when trying "out" direction twice', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; - ctx.args = {timed: todayAtFive, direction: 'in'}; - const createdTimeEntry = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + let date = new Date(); + date.setDate(date.getDate() - 21); + date = weekDay(date, monday); + let error; - expect(createdTimeEntry.id).toBeDefined(); + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; - ctx.args = {direction: 'out'}; - const updatedTimeEntry = await models.WorkerTimeControl.updateTimeEntry(ctx, createdTimeEntry.id, options); + date.setHours(8, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + date.setHours(9, 0, 0); + ctx.args = {timed: date, direction: 'out'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); - expect(updatedTimeEntry.direction).toEqual('out'); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + try { + date.setHours(10, 0, 0); + ctx.args = {timed: date, direction: 'out'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe(`Dirección incorrecta`); + }); + }); + + describe('12h rest', () => { + it('should throw an error when the 12h rest is not fulfilled yet', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; + + let date = new Date(); + date.setDate(date.getDate() - 21); + date = weekDay(date, monday); + let error; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; + + date.setHours(8, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + date.setHours(16, 0, 0); + ctx.args = {timed: date, direction: 'out'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + try { + date = weekDay(date, tuesday); + date.setHours(4, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe(`Descanso diario 12h.`); + }); + + it('should not fail as the 12h rest is fulfilled', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; + + let date = new Date(); + date.setDate(date.getDate() - 21); + date = weekDay(date, monday); + let error; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; + + date.setHours(8, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + date.setHours(16, 0, 0); + ctx.args = {timed: date, direction: 'out'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + try { + date = weekDay(date, tuesday); + date.setHours(4, 1, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error).not.toBeDefined; + }); + }); + + describe('for 3500kg drivers with enforced 9h rest', () => { + it('should throw an error when the 9h enforced rest is not fulfilled', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = jessicaJonesId; + + let date = new Date(); + date.setDate(date.getDate() - 21); + date = weekDay(date, monday); + let error; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; + + date.setHours(8, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + date.setHours(16, 0, 0); + ctx.args = {timed: date, direction: 'out'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + try { + date = weekDay(date, tuesday); + date.setHours(1, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe(`Descanso diario 9h.`); + }); + + it('should not fail when the 9h enforced rest is fulfilled', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = jessicaJonesId; + + let date = new Date(); + date.setDate(date.getDate() - 21); + date = weekDay(date, monday); + let error; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; + + date.setHours(8, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + date.setHours(16, 0, 0); + ctx.args = {timed: date, direction: 'out'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + try { + date = weekDay(date, tuesday); + date.setHours(1, 1, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error).not.toBeDefined; + }); + }); + + describe('for 36h weekly rest', () => { + it('should throw an error when the 36h weekly rest is not fulfilled', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; + + let date = new Date(); + date.setMonth(date.getMonth() - 2); + date.setDate(1); + let error; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; + + await populateWeek(date, monday, sunday, ctx, workerId, options); + date = nextWeek(date); + await populateWeek(date, monday, thursday, ctx, workerId, options); + date = weekDay(date, friday); + date.setHours(7, 59, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + try { + date.setHours(8, 1, 0); + ctx.args = {timed: date, direction: 'out'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe(`Descanso semanal 36h. / 72h.`); + }); + + it('should throw an error when the 36h weekly rest is not fulfilled again', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; + + let date = new Date(); + date.setMonth(date.getMonth() - 2); + date.setDate(1); + let error; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; + + await populateWeek(date, monday, sunday, ctx, workerId, options); + date = nextWeek(date); + await populateWeek(date, monday, thursday, ctx, workerId, options); + + try { + date = weekDay(date, saturday); + date.setHours(3, 59, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe(`Descanso semanal 36h. / 72h.`); + }); + }); + + describe('for 72h weekly rest', () => { + it('should throw when the 72h weekly rest is not fulfilled yet', async() => { + activeCtx.accessToken.userId = salesBossId; + const workerId = hankPymId; + + let date = new Date(); + date.setMonth(date.getMonth() - 2); + date.setDate(1); + let error; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + const options = {transaction: tx}; + + await populateWeek(date, monday, sunday, ctx, workerId, options); + date = nextWeek(date); + await populateWeek(date, monday, thursday, ctx, workerId, options); + date = nextWeek(date); + await populateWeek(date, monday, friday, ctx, workerId, options); + date = nextWeek(date); + await populateWeek(date, monday, saturday, ctx, workerId, options); + date = nextWeek(date); + await populateWeek(date, monday, saturday, ctx, workerId, options); + date = lastWeek(date); + + try { + date = weekDay(date, sunday); + date.setHours(8, 0, 0); + ctx.args = {timed: date, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe(`Descanso semanal 36h. / 72h.`); + }); + }); }); }); + +function weekDay(date, dayToSet) { + const currentDay = date.getDay(); + const distance = dayToSet - currentDay; + + date.setDate(date.getDate() + distance); + return date; +} + +function nextWeek(date) { + const sunday = 7; + const currentDay = date.getDay(); + let newDate = date; + if (currentDay != 0) + newDate = weekDay(date, sunday); + + newDate.setDate(newDate.getDate() + 1); + return newDate; +} + +function lastWeek(date) { + const monday = 1; + newDate = weekDay(date, monday); + + newDate.setDate(newDate.getDate() - 1); + return newDate; +} + +async function populateWeek(date, dayStart, dayEnd, ctx, workerId, options) { + const dateStart = new Date(weekDay(date, dayStart)); + const dateEnd = new Date(dateStart); + dateEnd.setDate(dateStart.getDate() + dayEnd); + + for (let i = dayStart; i <= dayEnd; i++) { + dateStart.setHours(8, 0, 0); + ctx.args = {timed: dateStart, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + dateStart.setHours(16, 0, 0); + ctx.args = {timed: dateStart, direction: 'out'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + dateStart.setDate(dateStart.getDate() + 1); + } +} diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 098dc55fb..430ec7dfc 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -80,6 +80,9 @@ module.exports = Self => { if (hasHoursRecorded && isNotHalfAbsence) throw new UserError(`The worker has hours recorded that day`); + const date = new Date(); + const now = new Date(); + date.setHours(0, 0, 0, 0); const [result] = await Self.rawSql( `SELECT COUNT(*) halfHolidayCounter FROM vn.calendar c @@ -87,8 +90,8 @@ module.exports = Self => { JOIN postgresql.profile p ON p.profile_id = b.client_id WHERE c.dayOffTypeFk = 6 AND p.workerFk = ? - AND c.dated BETWEEN util.firstDayOfYear(CURDATE()) - AND LAST_DAY(DATE_ADD(NOW(), INTERVAL 12-MONTH(NOW()) MONTH))`, [id]); + AND c.dated BETWEEN util.firstDayOfYear(?) + AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]); const hasHalfHoliday = result.halfHolidayCounter > 0; const isHalfHoliday = absenceType.code === 'halfHoliday'; diff --git a/modules/worker/back/methods/worker/holidays.js b/modules/worker/back/methods/worker/holidays.js index 339b84b7b..7f093a330 100644 --- a/modules/worker/back/methods/worker/holidays.js +++ b/modules/worker/back/methods/worker/holidays.js @@ -57,25 +57,9 @@ module.exports = Self => { ended.setDate(0); ended.setHours(23, 59, 59, 59); - const filter = { - where: { - and: [ - {workerFk: id}, - { - or: [ - {started: {between: [started, ended]}}, - {ended: {between: [started, ended]}}, - {and: [{started: {lt: started}}, {ended: {gt: ended}}]}, - {and: [{started: {lt: started}}, {ended: null}]} - ] - } - ], - - } - }; - const contracts = await models.WorkerLabour.find(filter, myOptions); - let [firstContract] = contracts; - const payedHolidays = firstContract.payedHolidays; + const filter = {where: {businessFk: args.businessFk}}; + const contract = await models.WorkerLabour.findOne(filter, myOptions); + const payedHolidays = contract.payedHolidays; let queryIndex; const year = started.getFullYear(); diff --git a/modules/worker/back/methods/worker/specs/holidays.spec.js b/modules/worker/back/methods/worker/specs/holidays.spec.js index 317bc8f0f..d8310b738 100644 --- a/modules/worker/back/methods/worker/specs/holidays.spec.js +++ b/modules/worker/back/methods/worker/specs/holidays.spec.js @@ -27,4 +27,15 @@ describe('Worker holidays()', () => { expect(result.totalHolidays).toEqual(27.5); expect(result.holidaysEnjoyed).toEqual(5); }); + + it('should now get the payed holidays calendar for a worker', async() => { + const now = new Date(); + const year = now.getFullYear(); + + ctx.args = {businessFk: businessId, year: year}; + + const result = await app.models.Worker.holidays(ctx, workerId); + + expect(result.payedHolidays).toEqual(8); + }); }); diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index f7a344358..3d41707ce 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -49,6 +49,9 @@ }, "labelerFk": { "type" : "number" + }, + "mobileExtension": { + "type" : "number" } }, "relations": { diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index cbe683185..5a3acdde5 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -25,10 +25,18 @@ + + + + - - + + - - + + - + + + +

User data

diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js index 3cdb2c36f..c2ad107d5 100644 --- a/modules/worker/front/summary/index.js +++ b/modules/worker/front/summary/index.js @@ -34,7 +34,7 @@ class Controller extends Summary { }, { relation: 'client', - scope: {fields: ['fi']} + scope: {fields: ['fi', 'phone']} }, { relation: 'boss', diff --git a/modules/worker/front/summary/locale/es.yml b/modules/worker/front/summary/locale/es.yml new file mode 100644 index 000000000..e9c8e5583 --- /dev/null +++ b/modules/worker/front/summary/locale/es.yml @@ -0,0 +1,3 @@ +Business phone: Teléfono de empresa +Personal phone: Teléfono personal +Mobile extension: Extensión móvil \ No newline at end of file diff --git a/modules/zone/back/methods/agency/specs/getLanded.spec.js b/modules/zone/back/methods/agency/specs/getLanded.spec.js index 3f239539f..c199b2ba6 100644 --- a/modules/zone/back/methods/agency/specs/getLanded.spec.js +++ b/modules/zone/back/methods/agency/specs/getLanded.spec.js @@ -1,4 +1,4 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('agency getLanded()', () => { it('should return a landing date', async() => { @@ -9,12 +9,12 @@ describe('agency getLanded()', () => { const agencyModeFk = 7; const warehouseFk = 1; - const tx = await app.models.Zone.beginTransaction({}); + const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - const result = await app.models.Agency.getLanded(ctx, shipped, addressFk, agencyModeFk, warehouseFk, options); + const result = await models.Agency.getLanded(ctx, shipped, addressFk, agencyModeFk, warehouseFk, options); expect(result.landed).toBeDefined(); diff --git a/modules/zone/back/methods/zone/exclusionGeo.js b/modules/zone/back/methods/zone/exclusionGeo.js new file mode 100644 index 000000000..5026c58c5 --- /dev/null +++ b/modules/zone/back/methods/zone/exclusionGeo.js @@ -0,0 +1,64 @@ + +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('exclusionGeo', { + description: 'Exclude a geo from a zone', + accepts: [ + { + arg: 'zoneFk', + type: 'number', + description: 'The zone id' + }, + { + arg: 'date', + type: 'date', + description: 'The date to exclude' + }, + { + arg: 'geoIds', + type: ['number'], + description: 'The geos id' + } + + ], + returns: { + type: 'object', + root: true + }, + http: { + path: `/exclusionGeo`, + verb: 'POST' + } + }); + + Self.exclusionGeo = async(zoneFk, date, geoIds, options) => { + const models = Self.app.models; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!geoIds[0]) throw new UserError(`You must select a location`); + + const newZoneExclusion = await models.ZoneExclusion.create({ + zoneFk: zoneFk, + dated: date + }, myOptions); + + const promises = []; + + for (const geoId of geoIds) { + const newZoneExclusionGeo = await models.ZoneExclusionGeo.create({ + zoneExclusionFk: newZoneExclusion.id, + geoFk: geoId + }, myOptions); + + promises.push(newZoneExclusionGeo); + } + + const newZoneExclusionGeos = await Promise.all(promises); + + return newZoneExclusionGeos; + }; +}; diff --git a/modules/zone/back/methods/zone/getEventsFiltered.js b/modules/zone/back/methods/zone/getEventsFiltered.js index 5e9cbae5a..b7875785d 100644 --- a/modules/zone/back/methods/zone/getEventsFiltered.js +++ b/modules/zone/back/methods/zone/getEventsFiltered.js @@ -44,20 +44,35 @@ module.exports = Self => { OR (type = 'range' AND ( (started BETWEEN ? AND ?) - OR (ended BETWEEN ? AND ?) + OR + (ended BETWEEN ? AND ?) + OR + (started <= ? AND ended >= ?) ) ) ) ORDER BY type='indefinitely' DESC, type='range' DESC, type='day' DESC;`; - const events = await Self.rawSql(query, [zoneFk, started, ended, started, ended, started, ended], myOptions); + const events = await Self.rawSql(query, + [zoneFk, started, ended, started, ended, started, ended, started, ended], myOptions); query = ` - SELECT * - FROM vn.zoneExclusion - WHERE zoneFk = ? - AND dated BETWEEN ? AND ?;`; + SELECT e.* + FROM vn.zoneExclusion e + LEFT JOIN vn.zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id + WHERE e.zoneFk = ? + AND e.dated BETWEEN ? AND ? + AND eg.zoneExclusionFk IS NULL;`; const exclusions = await Self.rawSql(query, [zoneFk, started, ended], myOptions); - return {events, exclusions}; + query = ` + SELECT eg.*, e.zoneFk, e.dated, e.created, e.userFk + FROM vn.zoneExclusion e + LEFT JOIN vn.zoneExclusionGeo eg ON eg.zoneExclusionFk = e.id + WHERE e.zoneFk = ? + AND e.dated BETWEEN ? AND ? + AND eg.zoneExclusionFk IS NOT NULL;`; + const geoExclusions = await Self.rawSql(query, [zoneFk, started, ended], myOptions); + + return {events, exclusions, geoExclusions}; }; }; diff --git a/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js b/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js new file mode 100644 index 000000000..3a345f2ce --- /dev/null +++ b/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js @@ -0,0 +1,41 @@ +const models = require('vn-loopback/server/server').models; + +describe('zone exclusionGeo()', () => { + const zoneId = 1; + const today = new Date(); + + it(`should show an error when location isn't selected`, async() => { + const tx = await models.Zone.beginTransaction({}); + + try { + const options = {transaction: tx}; + const geoIds = []; + + await models.Zone.exclusionGeo(zoneId, today, geoIds, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toContain(`You must select a location`); + }); + + it('should create two exclusion by geo', async() => { + const tx = await models.Zone.beginTransaction({}); + + try { + const options = {transaction: tx}; + const geoIds = [1, 2]; + const result = await models.Zone.exclusionGeo(zoneId, today, geoIds, options); + + expect(result.length).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js b/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js index ffa416282..8160ee05e 100644 --- a/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js +++ b/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js @@ -6,8 +6,9 @@ describe('zone getEventsFiltered()', () => { try { const options = {transaction: tx}; + const today = new Date(); - let result = await models.Zone.getEventsFiltered(10, '2021-10-01', '2021-10-02', options); + const result = await models.Zone.getEventsFiltered(10, today, today, options); expect(result.events.length).toEqual(1); expect(result.exclusions.length).toEqual(0); @@ -18,4 +19,46 @@ describe('zone getEventsFiltered()', () => { throw e; } }); + + describe('event range type', () => { + it('should return events and exclusions for the zone 9 in a range of dates', async() => { + const tx = await models.Zone.beginTransaction({}); + + try { + const options = {transaction: tx}; + const today = new Date(); + + const result = await models.Zone.getEventsFiltered(9, today, today, options); + + expect(result.events.length).toEqual(1); + expect(result.exclusions.length).toEqual(0); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should not return events and exclusions for the zone 9 in a range of dates', async() => { + const tx = await models.Zone.beginTransaction({}); + + try { + const options = {transaction: tx}; + const date = new Date(); + date.setFullYear(date.getFullYear() - 2); + const dateTomorrow = new Date(date.setDate(date.getDate() + 1)); + + const result = await models.Zone.getEventsFiltered(9, date, dateTomorrow, options); + + expect(result.events.length).toEqual(0); + expect(result.exclusions.length).toEqual(0); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + }); }); diff --git a/modules/zone/back/methods/zone/specs/getZoneClosing.spec.js b/modules/zone/back/methods/zone/specs/getZoneClosing.spec.js index 0c479dda0..4fb4b4e5c 100644 --- a/modules/zone/back/methods/zone/specs/getZoneClosing.spec.js +++ b/modules/zone/back/methods/zone/specs/getZoneClosing.spec.js @@ -8,7 +8,6 @@ describe('zone getZoneClosing()', () => { const options = {transaction: tx}; const date = new Date(); const today = date.toISOString().split('T')[0]; - const result = await models.Zone.getZoneClosing([1, 2, 3], today, options); expect(result.length).toEqual(3); diff --git a/modules/zone/back/methods/zone/specs/updateExclusionGeo.spec.js b/modules/zone/back/methods/zone/specs/updateExclusionGeo.spec.js new file mode 100644 index 000000000..9db2e24be --- /dev/null +++ b/modules/zone/back/methods/zone/specs/updateExclusionGeo.spec.js @@ -0,0 +1,40 @@ +const models = require('vn-loopback/server/server').models; + +describe('zone updateExclusionGeo()', () => { + it(`should show an error when location isn't selected`, async() => { + const tx = await models.Zone.beginTransaction({}); + + try { + const options = {transaction: tx}; + const zoneId = 1; + const geoIds = []; + + await models.Zone.updateExclusionGeo(zoneId, geoIds, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toContain(`You must select a location`); + }); + + it('should delete all exclusion and then create two exclusion by geo for a zone', async() => { + const tx = await models.Zone.beginTransaction({}); + + try { + const options = {transaction: tx}; + const zoneId = 2; + const geoIds = [1, 2]; + const result = await models.Zone.updateExclusionGeo(zoneId, geoIds, options); + + expect(result.length).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/zone/back/methods/zone/updateExclusionGeo.js b/modules/zone/back/methods/zone/updateExclusionGeo.js new file mode 100644 index 000000000..237e336e0 --- /dev/null +++ b/modules/zone/back/methods/zone/updateExclusionGeo.js @@ -0,0 +1,55 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('updateExclusionGeo', { + description: 'Update the geos excluded from a zone', + accepts: [ + { + arg: 'zoneExclusionFk', + type: 'number', + description: 'The zoneExclusion id' + }, + { + arg: 'geoIds', + type: ['number'], + description: 'The geos id' + } + + ], + returns: { + type: 'object', + root: true + }, + http: { + path: `/updateExclusionGeo`, + verb: 'POST' + } + }); + + Self.updateExclusionGeo = async(zoneExclusionFk, geoIds, options) => { + const models = Self.app.models; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!geoIds[0]) throw new UserError(`You must select a location`); + + await models.ZoneExclusionGeo.destroyAll({ + zoneExclusionFk: zoneExclusionFk + }, myOptions); + + const promises = []; + + for (const geoId of geoIds) { + const params = { + zoneExclusionFk: zoneExclusionFk, + geoFk: geoId + }; + const deletedZoneExclusionGeos = models.ZoneExclusionGeo.create(params, myOptions); + promises.push(deletedZoneExclusionGeos); + } + + return Promise.all(promises); + }; +}; diff --git a/modules/zone/back/model-config.json b/modules/zone/back/model-config.json index ee555f3f4..261a89902 100644 --- a/modules/zone/back/model-config.json +++ b/modules/zone/back/model-config.json @@ -23,6 +23,9 @@ "ZoneExclusion": { "dataSource": "vn" }, + "ZoneExclusionGeo": { + "dataSource": "vn" + }, "ZoneGeo": { "dataSource": "vn" }, diff --git a/modules/zone/back/models/agency-mode.json b/modules/zone/back/models/agency-mode.json index 027cec190..99ed43b97 100644 --- a/modules/zone/back/models/agency-mode.json +++ b/modules/zone/back/models/agency-mode.json @@ -55,6 +55,11 @@ "type": "belongsTo", "model": "DeliveryMethod", "foreignKey": "deliveryMethodFk" + }, + "zones": { + "type": "hasMany", + "model": "Zone", + "foreignKey": "agencyModeFk" } }, "acls": [ diff --git a/modules/zone/back/models/zone-exclusion-geo.json b/modules/zone/back/models/zone-exclusion-geo.json new file mode 100644 index 000000000..816e4b650 --- /dev/null +++ b/modules/zone/back/models/zone-exclusion-geo.json @@ -0,0 +1,21 @@ +{ + "name": "ZoneExclusionGeo", + "base": "VnModel", + "options": { + "mysql": { + "table": "zoneExclusionGeo" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "zoneExclusionFk": { + "type": "number" + }, + "geoFk": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/modules/zone/back/models/zone.js b/modules/zone/back/models/zone.js index ef1c8c5d9..6d5a6cdca 100644 --- a/modules/zone/back/models/zone.js +++ b/modules/zone/back/models/zone.js @@ -8,6 +8,8 @@ module.exports = Self => { require('../methods/zone/deleteZone')(Self); require('../methods/zone/includingExpired')(Self); require('../methods/zone/getZoneClosing')(Self); + require('../methods/zone/exclusionGeo')(Self); + require('../methods/zone/updateExclusionGeo')(Self); Self.validatesPresenceOf('agencyModeFk', { message: `Agency cannot be blank` diff --git a/modules/zone/front/calendar/index.js b/modules/zone/front/calendar/index.js index a24d10aef..3bc7158ef 100644 --- a/modules/zone/front/calendar/index.js +++ b/modules/zone/front/calendar/index.js @@ -75,6 +75,17 @@ class Controller extends Component { } } + this.geoExclusions = {}; + let geoExclusions = value.geoExclusions; + + if (geoExclusions) { + for (let geoExclusion of geoExclusions) { + let stamp = toStamp(geoExclusion.dated); + if (!this.geoExclusions[stamp]) this.geoExclusions[stamp] = []; + this.geoExclusions[stamp].push(geoExclusion); + } + } + let events = value.events; if (events) { @@ -135,11 +146,13 @@ class Controller extends Component { onSelection($event, $days, $type, $weekday) { let $events = []; let $exclusions = []; + let $geoExclusions = []; for (let day of $days) { let stamp = day.getTime(); $events = $events.concat(this.days[stamp] || []); $exclusions = $exclusions.concat(this.exclusions[stamp] || []); + $geoExclusions = $geoExclusions.concat(this.geoExclusions[stamp] || []); } this.emit('selection', { @@ -148,19 +161,23 @@ class Controller extends Component { $type, $weekday, $events, - $exclusions + $exclusions, + $geoExclusions }); } hasEvents(day) { let stamp = day.getTime(); - return this.days[stamp] || this.exclusions[stamp]; + return this.days[stamp] || this.exclusions[stamp] || this.geoExclusions[stamp]; } getClass(day) { let stamp = day.getTime(); - return this.exclusions[stamp] && !this.days[stamp] - ? 'excluded' : ''; + if (this.geoExclusions[stamp]) + return 'geoExcluded'; + else if (this.exclusions[stamp]) + return 'excluded'; + else return ''; } } Controller.$inject = ['$element', '$scope', 'vnWeekDays']; diff --git a/modules/zone/front/calendar/index.spec.js b/modules/zone/front/calendar/index.spec.js index be002925e..338f47917 100644 --- a/modules/zone/front/calendar/index.spec.js +++ b/modules/zone/front/calendar/index.spec.js @@ -15,6 +15,7 @@ describe('component vnZoneCalendar', () => { controller.zone = {id: 1}; controller.days = []; controller.exclusions = []; + controller.geoExclusions = []; })); describe('date() setter', () => { @@ -57,7 +58,7 @@ describe('component vnZoneCalendar', () => { }); describe('data() setter', () => { - it('should set the events and exclusions and then call the refreshEvents() method', () => { + it('should set the events, exclusions and geoExclusions and then call the refreshEvents() method', () => { jest.spyOn(controller, 'refreshEvents').mockReturnThis(); controller.data = { @@ -66,13 +67,17 @@ describe('component vnZoneCalendar', () => { }], events: [{ dated: new Date() - }] + }], + geoExclusions: [{ + dated: new Date() + }], }; expect(controller.refreshEvents).toHaveBeenCalledWith(); expect(controller.events).toBeDefined(); expect(controller.events.length).toEqual(1); expect(controller.exclusions).toBeDefined(); + expect(controller.geoExclusions).toBeDefined(); expect(Object.keys(controller.exclusions).length).toEqual(1); }); }); @@ -122,7 +127,8 @@ describe('component vnZoneCalendar', () => { $events: [], $exclusions: [], $type: 'day', - $weekday: 1 + $weekday: 1, + $geoExclusions: [], } ); }); @@ -151,5 +157,16 @@ describe('component vnZoneCalendar', () => { expect(result).toEqual('excluded'); }); + + it('should return the className "geoExcluded" for a date with geo excluded', () => { + const dated = new Date(); + + controller.geoExclusions = []; + controller.geoExclusions[dated.getTime()] = true; + + const result = controller.getClass(dated); + + expect(result).toEqual('geoExcluded'); + }); }); }); diff --git a/modules/zone/front/calendar/style.scss b/modules/zone/front/calendar/style.scss index 25b6a87d1..38491af58 100644 --- a/modules/zone/front/calendar/style.scss +++ b/modules/zone/front/calendar/style.scss @@ -33,6 +33,9 @@ vn-zone-calendar { &.excluded .day-number { background-color: $color-alert; } + &.geoExcluded .day-number { + background-color: $color-main; + } } } } diff --git a/modules/zone/front/events/index.html b/modules/zone/front/events/index.html index e71a1ae26..46ba87dea 100644 --- a/modules/zone/front/events/index.html +++ b/modules/zone/front/events/index.html @@ -2,7 +2,7 @@ id="calendar" vn-id="calendar" data="data" - on-selection="$ctrl.onSelection($days, $type, $weekday, $events, $exclusions)" + on-selection="$ctrl.onSelection($days, $type, $weekday, $events, $exclusions, $geoExclusions)" on-step="$ctrl.refresh()" class="vn-w-md"> @@ -98,7 +98,7 @@ fixed-bottom-right> @@ -198,3 +198,80 @@ message="This item will be deleted" question="Are you sure you want to continue?">
+ + + + + + + + + + + + + +
+ + + + + +
+ + + + +
+
+
+
+ + + + + + + +
diff --git a/modules/zone/front/events/index.js b/modules/zone/front/events/index.js index 0df16a42a..b86330126 100644 --- a/modules/zone/front/events/index.js +++ b/modules/zone/front/events/index.js @@ -1,5 +1,6 @@ import ngModule from '../module'; import Section from 'salix/components/section'; +import './style.scss'; class Controller extends Section { constructor($element, $, vnWeekDays) { @@ -20,6 +21,16 @@ class Controller extends Section { return `Zones/${this.$params.id}/exclusions`; } + get checked() { + const geos = this.$.model.data || []; + const checkedLines = []; + for (let geo of geos) { + if (geo.checked) + checkedLines.push(geo); + } + return checkedLines; + } + refresh() { this.$.data = null; this.$.$applyAsync(() => { @@ -48,33 +59,56 @@ class Controller extends Section { : this.$t('Everyday'); } - onSelection(days, type, weekday, events, exclusions) { + onSelection(days, type, weekday, events, exclusions, exclusionGeos) { if (this.editMode == 'include') { if (events.length) - this.edit(events[0]); - else - this.create(type, days, weekday); - } else { - if (exclusions.length) - this.exclusionDelete(exclusions); - else - this.exclusionCreate(days); + return this.editInclusion(events[0]); + return this.createInclusion(type, days, weekday); + } else if (this.editMode == 'exclude') { + if (exclusions.length || exclusionGeos.length) + return this.editExclusion(exclusions[0] || {}, exclusionGeos); + return this.createExclusion(days); } } + editExclusion(exclusion, exclusionGeos) { + this.isNew = false; + this.excludeSelected = angular.copy(exclusion); + this.excludeSelected.type = exclusionGeos.length ? + 'specificLocations' : 'all'; + + this.exclusionGeos = new Set(); + if (exclusionGeos.length) { + this.excludeSelected.id = exclusionGeos[0].zoneExclusionFk; + exclusionGeos.forEach(x => this.exclusionGeos.add(x.geoFk)); + } + + this.$.excludeDialog.show(); + } + + createExclusion(days) { + this.isNew = true; + this.excludeSelected = { + type: 'all', + dated: days[0] + }; + this.exclusionGeos = new Set(); + this.$.excludeDialog.show(); + } + onEditClick(row, event) { if (event.defaultPrevented) return; - this.edit(row); + this.editInclusion(row); } - edit(row) { + editInclusion(row) { this.isNew = false; this.selected = angular.copy(row); this.selected.wdays = this.vnWeekDays.fromSet(row.weekDays); - this.$.dialog.show(); + this.$.includeDialog.show(); } - create(type, days, weekday) { + createInclusion(type, days, weekday) { this.isNew = true; if (type == 'weekday') { @@ -92,7 +126,7 @@ class Controller extends Section { }; } - this.$.dialog.show(); + this.$.includeDialog.show(); } onIncludeResponse(response) { @@ -132,6 +166,19 @@ class Controller extends Section { } } + onExcludeResponse(response) { + const type = this.excludeSelected.type; + switch (response) { + case 'accept': { + if (type == 'all') + return this.exclusionCreate(); + return this.exclusionGeoCreate(); + } + case 'delete': + return this.exclusionDelete(this.excludeSelected); + } + } + onDeleteClick(id, event) { if (event.defaultPrevented) return; event.preventDefault(); @@ -149,31 +196,121 @@ class Controller extends Section { .then(() => this.refresh()); } - exclusionCreate(days) { - let exclusions = days.map(dated => { - return {dated}; - }); + exclusionCreate() { + const excludeSelected = this.excludeSelected; + const dated = excludeSelected.dated; + let req; - this.$http.post(this.exclusionsPath, exclusions) + if (this.isNew) + req = this.$http.post(this.exclusionsPath, [{dated}]); + if (!this.isNew) + req = this.$http.put(`${this.exclusionsPath}/${excludeSelected.id}`, {dated}); + + return req.then(() => { + this.refresh(); + }); + } + + exclusionGeoCreate() { + const excludeSelected = this.excludeSelected; + let req; + const geoIds = []; + this.exclusionGeos.forEach(id => geoIds.push(id)); + + if (this.isNew) { + const params = { + zoneFk: parseInt(this.$params.id), + date: excludeSelected.dated, + geoIds + }; + req = this.$http.post(`Zones/exclusionGeo`, params); + } else { + const params = { + zoneExclusionFk: this.excludeSelected.id, + geoIds + }; + req = this.$http.post(`Zones/updateExclusionGeo`, params); + } + return req.then(() => this.refresh()); + } + + exclusionDelete(exclusion) { + const path = `${this.exclusionsPath}/${exclusion.id}`; + return this.$http.delete(path) .then(() => this.refresh()); } - exclusionDelete(exclusions) { - let reqs = []; + set excludeSearch(value) { + this._excludeSearch = value; + if (!value) this.onSearch(); + } - for (let exclusion of exclusions) { - if (!exclusion.id) continue; - let path = `${this.exclusionsPath}/${exclusion.id}`; - reqs.push(this.$http.delete(path)); + get excludeSearch() { + return this._excludeSearch; + } + + onKeyDown(event) { + if (event.key == 'Enter') { + event.preventDefault(); + this.onSearch(); + } + } + + onSearch() { + const params = {search: this._excludeSearch}; + if (this.excludeSelected.type == 'specificLocations') { + this.$.model.applyFilter({}, params).then(() => { + const data = this.$.model.data; + this.getChecked(data); + this.$.treeview.data = data; + }); + } + } + + onFetch(item) { + const params = item ? {parentId: item.id} : null; + return this.$.model.applyFilter({}, params).then(() => { + const data = this.$.model.data; + this.getChecked(data); + return data; + }); + } + + onSort(a, b) { + if (b.selected !== a.selected) { + if (a.selected == null) + return 1; + if (b.selected == null) + return -1; + return b.selected - a.selected; } - this.$q.all(reqs) - .then(() => this.refresh()); + return a.name.localeCompare(b.name); + } + + getChecked(data) { + for (let geo of data) { + geo.checked = this.exclusionGeos.has(geo.id); + if (geo.childs) this.getChecked(geo.childs); + } + } + + onItemCheck(geoId, checked) { + if (checked) + this.exclusionGeos.add(geoId); + else + this.exclusionGeos.delete(geoId); } } Controller.$inject = ['$element', '$scope', 'vnWeekDays']; ngModule.vnComponent('vnZoneEvents', { template: require('./index.html'), - controller: Controller + controller: Controller, + bindings: { + zone: '<' + }, + require: { + card: '^vnZoneCard' + } }); diff --git a/modules/zone/front/events/index.spec.js b/modules/zone/front/events/index.spec.js index ed2c91c31..b4ff800d6 100644 --- a/modules/zone/front/events/index.spec.js +++ b/modules/zone/front/events/index.spec.js @@ -1,4 +1,5 @@ import './index'; +import crudModel from 'core/mocks/crud-model'; describe('component vnZoneEvents', () => { let $scope; @@ -34,7 +35,8 @@ describe('component vnZoneEvents', () => { const query = `Zones/getEventsFiltered?ended=${date}&started=${date}&zoneFk=${params.zoneFk}`; const response = { events: 'myEvents', - exclusions: 'myExclusions' + exclusions: 'myExclusions', + geoExclusions: 'myGeoExclusions', }; $httpBackend.whenGET(query).respond(response); controller.refresh(); @@ -48,71 +50,129 @@ describe('component vnZoneEvents', () => { }); describe('onSelection()', () => { - it('should call the edit() method', () => { - jest.spyOn(controller, 'edit').mockReturnThis(); + it('should call the editInclusion() method', () => { + jest.spyOn(controller, 'editInclusion').mockReturnThis(); const weekday = {}; const days = []; const type = 'EventType'; const events = [{name: 'Event'}]; const exclusions = []; + const exclusionsGeo = []; controller.editMode = 'include'; - controller.onSelection(days, type, weekday, events, exclusions); + controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo); - expect(controller.edit).toHaveBeenCalledWith({name: 'Event'}); + expect(controller.editInclusion).toHaveBeenCalledWith({name: 'Event'}); }); - it('should call the create() method', () => { - jest.spyOn(controller, 'create').mockReturnThis(); + it('should call the createInclusion() method', () => { + jest.spyOn(controller, 'createInclusion').mockReturnThis(); const weekday = {dated: new Date()}; const days = [weekday]; const type = 'EventType'; const events = []; const exclusions = []; + const exclusionsGeo = []; controller.editMode = 'include'; - controller.onSelection(days, type, weekday, events, exclusions); + controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo); - expect(controller.create).toHaveBeenCalledWith(type, days, weekday); + expect(controller.createInclusion).toHaveBeenCalledWith(type, days, weekday); }); - it('should call the exclusionDelete() method', () => { - jest.spyOn(controller, 'exclusionDelete').mockReturnThis(); + it('should call the editExclusion() method with exclusions', () => { + jest.spyOn(controller, 'editExclusion').mockReturnThis(); const weekday = {}; const days = []; const type = 'EventType'; const events = []; - const exclusions = [{id: 1}]; - controller.editMode = 'delete'; - controller.onSelection(days, type, weekday, events, exclusions); + const exclusions = [{name: 'Exclusion'}]; + const exclusionsGeo = []; + controller.editMode = 'exclude'; + controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo); - expect(controller.exclusionDelete).toHaveBeenCalledWith(exclusions); + expect(controller.editExclusion).toHaveBeenCalled(); }); - it('should call the exclusionCreate() method', () => { - jest.spyOn(controller, 'exclusionCreate').mockReturnThis(); + it('should call the editExclusion() method with exclusionsGeo', () => { + jest.spyOn(controller, 'editExclusion').mockReturnThis(); + + const weekday = {}; + const days = []; + const type = 'EventType'; + const events = []; + const exclusions = []; + const exclusionsGeo = [{name: 'GeoExclusion'}]; + controller.editMode = 'exclude'; + controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo); + + expect(controller.editExclusion).toHaveBeenCalled(); + }); + + it('should call the createExclusion() method', () => { + jest.spyOn(controller, 'createExclusion').mockReturnThis(); const weekday = {}; const days = [{dated: new Date()}]; const type = 'EventType'; const events = []; const exclusions = []; - controller.editMode = 'delete'; - controller.onSelection(days, type, weekday, events, exclusions); + const exclusionsGeo = []; + controller.editMode = 'exclude'; + controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo); - expect(controller.exclusionCreate).toHaveBeenCalledWith(days); + expect(controller.createExclusion).toHaveBeenCalledWith(days); }); }); - describe('create()', () => { - it('shoud set the selected property and then call the dialog show() method', () => { - controller.$.dialog = {show: jest.fn()}; + describe('editExclusion()', () => { + it('shoud set the excludeSelected.type = "specificLocations" and then call the excludeDialog show() method', () => { + controller.$.excludeDialog = {show: jest.fn()}; + + const exclusionGeos = [{id: 1}]; + const exclusions = []; + + controller.editExclusion(exclusions, exclusionGeos); + + expect(controller.excludeSelected.type).toEqual('specificLocations'); + expect(controller.$.excludeDialog.show).toHaveBeenCalledWith(); + }); + + it('shoud set the excludeSelected.type = "all" and then call the excludeDialog show() method', () => { + controller.$.excludeDialog = {show: jest.fn()}; + + const exclusionGeos = []; + const exclusions = [{id: 1}]; + + controller.editExclusion(exclusions, exclusionGeos); + + expect(controller.excludeSelected.type).toEqual('all'); + expect(controller.$.excludeDialog.show).toHaveBeenCalledWith(); + }); + }); + + describe('createExclusion()', () => { + it('shoud set the excludeSelected property and then call the excludeDialog show() method', () => { + controller.$.excludeDialog = {show: jest.fn()}; + + const days = [new Date()]; + controller.createExclusion(days); + + expect(controller.excludeSelected).toBeDefined(); + expect(controller.isNew).toBeTruthy(); + expect(controller.$.excludeDialog.show).toHaveBeenCalledWith(); + }); + }); + + describe('createInclusion()', () => { + it('shoud set the selected property and then call the includeDialog show() method', () => { + controller.$.includeDialog = {show: jest.fn()}; const type = 'weekday'; const days = [new Date()]; const weekday = 1; - controller.create(type, days, weekday); + controller.createInclusion(type, days, weekday); const selection = controller.selected; const firstWeekday = selection.wdays[weekday]; @@ -120,23 +180,23 @@ describe('component vnZoneEvents', () => { expect(selection.type).toEqual('indefinitely'); expect(firstWeekday).toBeTruthy(); expect(controller.isNew).toBeTruthy(); - expect(controller.$.dialog.show).toHaveBeenCalledWith(); + expect(controller.$.includeDialog.show).toHaveBeenCalledWith(); }); - it('shoud set the selected property with the first day and then call the dialog show() method', () => { - controller.$.dialog = {show: jest.fn()}; + it('shoud set the selected property with the first day and then call the includeDialog show() method', () => { + controller.$.includeDialog = {show: jest.fn()}; const type = 'nonListedType'; const days = [new Date()]; const weekday = 1; - controller.create(type, days, weekday); + controller.createInclusion(type, days, weekday); const selection = controller.selected; expect(selection.type).toEqual('day'); expect(selection.dated).toEqual(days[0]); expect(controller.isNew).toBeTruthy(); - expect(controller.$.dialog.show).toHaveBeenCalledWith(); + expect(controller.$.includeDialog.show).toHaveBeenCalledWith(); }); }); @@ -180,6 +240,35 @@ describe('component vnZoneEvents', () => { }); }); + describe('onExcludeResponse()', () => { + it('should call the exclusionCreate() method', () => { + jest.spyOn(controller, 'exclusionCreate').mockReturnThis(); + + controller.excludeSelected = {type: 'all'}; + controller.onExcludeResponse('accept'); + + expect(controller.exclusionCreate).toHaveBeenCalledWith(); + }); + + it('should call the exclusionGeoCreate() method', () => { + jest.spyOn(controller, 'exclusionGeoCreate').mockReturnThis(); + + controller.excludeSelected = {type: 'specificLocations'}; + controller.onExcludeResponse('accept'); + + expect(controller.exclusionGeoCreate).toHaveBeenCalledWith(); + }); + + it('should call the exclusionDelete() method', () => { + jest.spyOn(controller, 'exclusionDelete').mockReturnThis(); + + controller.excludeSelected = {id: 1, type: 'all'}; + controller.onExcludeResponse('delete'); + + expect(controller.exclusionDelete).toHaveBeenCalledWith(controller.excludeSelected); + }); + }); + describe('onDeleteResponse()', () => { it('shoud make an HTTP DELETE query and then call the refresh() method', () => { jest.spyOn(controller, 'refresh').mockReturnThis(); @@ -197,9 +286,10 @@ describe('component vnZoneEvents', () => { it('shoud make an HTTP POST query and then call the refresh() method', () => { jest.spyOn(controller, 'refresh').mockReturnThis(); - const dates = [new Date()]; + controller.excludeSelected = {}; + controller.isNew = true; $httpBackend.expect('POST', `Zones/1/exclusions`).respond({id: 1}); - controller.exclusionCreate(dates); + controller.exclusionCreate(); $httpBackend.flush(); expect(controller.refresh).toHaveBeenCalledWith(); @@ -210,25 +300,41 @@ describe('component vnZoneEvents', () => { it('shoud make an HTTP DELETE query once and then call the refresh() method', () => { jest.spyOn(controller, 'refresh').mockReturnThis(); - const exclusions = [{id: 1}]; + const exclusions = {id: 1}; const firstExclusionId = 1; - $httpBackend.when('DELETE', `Zones/1/exclusions/${firstExclusionId}`).respond(200); + $httpBackend.expectDELETE(`Zones/1/exclusions/${firstExclusionId}`).respond(200); controller.exclusionDelete(exclusions); $httpBackend.flush(); expect(controller.refresh).toHaveBeenCalledWith(); }); + }); - it('shoud make an HTTP DELETE query for every event and then call the refresh() method', () => { - jest.spyOn(controller, 'refresh').mockReturnThis(); - jest.spyOn(controller.$http, 'delete').mockReturnValue(200); + describe('onSearch()', () => { + it('should call the applyFilter() method and then set the data', () => { + jest.spyOn(controller, 'getChecked').mockReturnValue([1, 2, 3]); - const exclusions = [{id: 1}, {id: 2}, {id: 3}, {id: 4}]; - controller.exclusionDelete(exclusions); - $scope.$apply(); + controller.$.treeview = {}; + controller.$.model = crudModel; + controller.excludeSelected = {type: 'specificLocations'}; + controller._excludeSearch = 'es'; - expect(controller.$http.delete).toHaveBeenCalledTimes(4); - expect(controller.refresh).toHaveBeenCalledWith(); + controller.onSearch(); + const treeviewData = controller.$.treeview.data; + + expect(treeviewData).toBeDefined(); + expect(treeviewData.length).toEqual(3); + }); + }); + + describe('onFetch()', () => { + it('should call the applyFilter() method and then return the model data', () => { + jest.spyOn(controller, 'getChecked').mockReturnValue([1, 2, 3]); + + controller.$.model = crudModel; + const result = controller.onFetch(); + + expect(result.length).toEqual(3); }); }); }); diff --git a/modules/zone/front/events/locale/es.yml b/modules/zone/front/events/locale/es.yml index eb581a719..1fb114720 100644 --- a/modules/zone/front/events/locale/es.yml +++ b/modules/zone/front/events/locale/es.yml @@ -4,3 +4,7 @@ Exclude: Excluir Events: Eventos Add event: Añadir evento Edit event: Editar evento +All: Todo +Specific locations: Localizaciones concretas +Locations where it is not distributed: Localizaciones en las que no se reparte +You must select a location: Debes seleccionar una localización diff --git a/modules/zone/front/events/style.scss b/modules/zone/front/events/style.scss new file mode 100644 index 000000000..49a6e87a6 --- /dev/null +++ b/modules/zone/front/events/style.scss @@ -0,0 +1,11 @@ +@import "variables"; + + .width{ + width: 600px + } + + .treeview{ + max-height: 300px; + overflow: auto; + } + diff --git a/modules/zone/front/location/style.scss b/modules/zone/front/location/style.scss index 2316a2622..24d685a51 100644 --- a/modules/zone/front/location/style.scss +++ b/modules/zone/front/location/style.scss @@ -1,19 +1,21 @@ @import "variables"; -vn-treeview-child { - .content > .vn-check:not(.indeterminate):not(.checked) { - color: $color-alert; +vn-zone-location { + vn-treeview-child { + .content > .vn-check:not(.indeterminate):not(.checked) { + color: $color-alert; - & > .btn { - border-color: $color-alert; + & > .btn { + border-color: $color-alert; + } + } + .content > .vn-check.checked { + color: $color-notice; + + & > .btn { + background-color: $color-notice; + border-color: $color-notice + } } } - .content > .vn-check.checked { - color: $color-notice; - - & > .btn { - background-color: $color-notice; - border-color: $color-notice - } - } -} \ No newline at end of file +} diff --git a/modules/zone/front/routes.json b/modules/zone/front/routes.json index e08f97314..7f67260da 100644 --- a/modules/zone/front/routes.json +++ b/modules/zone/front/routes.json @@ -85,10 +85,13 @@ "description": "Warehouses" }, { - "url": "/events", + "url": "/events?q", "state": "zone.card.events", "component": "vn-zone-events", - "description": "Calendar" + "description": "Calendar", + "params": { + "zone": "$ctrl.zone" + } }, { "url": "/location?q", diff --git a/package.json b/package.json index a10e445ed..13a7096d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "1.0.0", + "version": "8.6.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", diff --git a/print/methods/closure/closeAll.js b/print/methods/closure/closeAll.js index 7af3676f2..400ca2917 100644 --- a/print/methods/closure/closeAll.js +++ b/print/methods/closure/closeAll.js @@ -15,6 +15,7 @@ module.exports = async function(request, response, next) { SELECT t.id, t.clientFk, + t.companyFk, c.name clientName, c.email recipient, c.salesPersonFk, diff --git a/print/methods/closure/closeByAgency.js b/print/methods/closure/closeByAgency.js index 7807de23a..12e6b4c53 100644 --- a/print/methods/closure/closeByAgency.js +++ b/print/methods/closure/closeByAgency.js @@ -23,6 +23,7 @@ module.exports = async function(request, response, next) { SELECT t.id, t.clientFk, + t.companyFk, c.name clientName, c.email recipient, c.salesPersonFk, diff --git a/print/methods/closure/closeByRoute.js b/print/methods/closure/closeByRoute.js index 2c0bfd1eb..32a1688d3 100644 --- a/print/methods/closure/closeByRoute.js +++ b/print/methods/closure/closeByRoute.js @@ -17,6 +17,7 @@ module.exports = async function(request, response, next) { SELECT t.id, t.clientFk, + t.companyFk, c.name clientName, c.email recipient, c.salesPersonFk, diff --git a/print/methods/closure/closeByTicket.js b/print/methods/closure/closeByTicket.js index c71b3ecd0..f6d97cba3 100644 --- a/print/methods/closure/closeByTicket.js +++ b/print/methods/closure/closeByTicket.js @@ -16,6 +16,7 @@ module.exports = async function(request, response, next) { SELECT t.id, t.clientFk, + t.companyFk, c.name clientName, c.email recipient, c.salesPersonFk, diff --git a/print/methods/closure/closure.js b/print/methods/closure/closure.js index 57f21cf4c..67a2538e8 100644 --- a/print/methods/closure/closure.js +++ b/print/methods/closure/closure.js @@ -31,7 +31,7 @@ module.exports = { if (invoiceOut) { const args = Object.assign({ - invoiceId: invoiceOut.id, + refFk: invoiceOut.ref, recipientId: ticket.clientFk, recipient: ticket.recipient, replyTo: ticket.salesPersonEmail @@ -89,6 +89,37 @@ module.exports = { const email = new Email('delivery-note-link', args); await email.send(); } + + // Incoterms authorization + const {firstOrder} = await db.findOne(` + SELECT COUNT(*) as firstOrder + FROM ticket t + JOIN client c ON c.id = t.clientFk + WHERE t.clientFk = ? + AND NOT t.isDeleted + AND c.isVies + `, [ticket.clientFk]); + + if (firstOrder == 1) { + const args = Object.assign({ + ticketId: ticket.id, + recipientId: ticket.clientFk, + recipient: ticket.recipient, + replyTo: ticket.salesPersonEmail + }, reqArgs); + + const email = new Email('incoterms-authorization', args); + await email.send(); + + const sample = await db.findOne( + `SELECT id + FROM sample + WHERE code = 'incoterms-authorization'`); + + await db.rawSql(` + INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?) + `, [ticket.clientFk, sample.id, ticket.companyFk]); + } } catch (error) { // Domain not found if (error.responseCode == 450) diff --git a/print/methods/csv/invoice/download.js b/print/methods/csv/invoice/download.js index 593d2d8d0..9cca99f2d 100644 --- a/print/methods/csv/invoice/download.js +++ b/print/methods/csv/invoice/download.js @@ -7,13 +7,13 @@ const sqlPath = path.join(__dirname, 'sql'); module.exports = async function(request, response, next) { try { const reqArgs = request.query; - if (!reqArgs.invoiceId) - throw new Error('The argument invoiceId is required'); + if (!reqArgs.refFk) + throw new Error('The argument refFk is required'); - const invoiceId = reqArgs.invoiceId; - const sales = await db.rawSqlFromDef(`${sqlPath}/sales`, [invoiceId]); + const refFk = reqArgs.refFk; + const sales = await db.rawSqlFromDef(`${sqlPath}/sales`, [refFk]); const content = toCSV(sales); - const fileName = `invoice_${invoiceId}.csv`; + const fileName = `invoice_${refFk}.csv`; response.setHeader('Content-type', 'text/csv'); response.setHeader('Content-Disposition', `inline; filename="${fileName}"`); diff --git a/print/methods/csv/invoice/send.js b/print/methods/csv/invoice/send.js index 919d7aeb1..2729e4a2b 100644 --- a/print/methods/csv/invoice/send.js +++ b/print/methods/csv/invoice/send.js @@ -8,22 +8,22 @@ const sqlPath = path.join(__dirname, 'sql'); module.exports = async function(request, response, next) { try { const reqArgs = request.query; - if (!reqArgs.invoiceId) - throw new Error('The argument invoiceId is required'); + if (!reqArgs.refFk) + throw new Error('The argument refFk is required'); - const invoiceId = reqArgs.invoiceId; - const invoice = await db.findOneFromDef(`${sqlPath}/invoice`, [invoiceId]); - const sales = await db.rawSqlFromDef(`${sqlPath}/sales`, [invoiceId]); + const refFk = reqArgs.refFk; + const invoice = await db.findOneFromDef(`${sqlPath}/invoice`, [refFk]); + const sales = await db.rawSqlFromDef(`${sqlPath}/sales`, [refFk]); const args = Object.assign({ - invoiceId: (String(invoice.id)), + refFk: invoice.refFk, recipientId: invoice.clientFk, recipient: invoice.recipient, replyTo: invoice.salesPersonEmail }, response.locals); const content = toCSV(sales); - const fileName = `invoice_${invoiceId}.csv`; + const fileName = `invoice_${refFk}.csv`; const email = new Email('invoice', args); await email.send({ overrideAttachments: true, diff --git a/print/methods/csv/invoice/sql/invoice.sql b/print/methods/csv/invoice/sql/invoice.sql index 853aaddc0..d484766a0 100644 --- a/print/methods/csv/invoice/sql/invoice.sql +++ b/print/methods/csv/invoice/sql/invoice.sql @@ -6,4 +6,5 @@ SELECT FROM invoiceOut io JOIN client c ON c.id = io.clientFk LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk -WHERE io.id = ? \ No newline at end of file + LEFT JOIN ticket t ON t.refFk = io.ref +WHERE t.refFk = ? \ No newline at end of file diff --git a/print/methods/csv/invoice/sql/sales.sql b/print/methods/csv/invoice/sql/sales.sql index 34b5af1f7..33fe62476 100644 --- a/print/methods/csv/invoice/sql/sales.sql +++ b/print/methods/csv/invoice/sql/sales.sql @@ -31,5 +31,5 @@ FROM sale s AND itc.countryFk = s2.countryFk JOIN taxClass tc ON tc.id = itc.taxClassFk JOIN invoiceOut io ON io.ref = t.refFk -WHERE io.id = ? +WHERE t.refFk = ? ORDER BY s.ticketFk, s.created \ No newline at end of file diff --git a/print/methods/schedule/invoice.js b/print/methods/schedule/invoice.js index c76ca85b5..87c696075 100644 --- a/print/methods/schedule/invoice.js +++ b/print/methods/schedule/invoice.js @@ -38,7 +38,7 @@ module.exports = async function(request, response, next) { connection.query('START TRANSACTION'); const args = Object.assign({ - invoiceId: invoiceOut.id, + refFk: invoiceOut.ref, recipientId: invoiceOut.clientFk, recipient: invoiceOut.recipient, replyTo: invoiceOut.salesPersonEmail @@ -93,11 +93,12 @@ module.exports = async function(request, response, next) { await email.send(mailOptions); } // Update queue status + const date = new Date(); sql = `UPDATE invoiceOut_queue SET status = "printed", - printed = NOW() + printed = ? WHERE invoiceFk = ?`; - connection.query(sql, [invoiceOut.id]); + connection.query(sql, [date, invoiceOut.id]); connection.query('COMMIT'); } catch (error) { connection.query('ROLLBACK'); diff --git a/print/templates/email/incoterms-authorization/assets/css/import.js b/print/templates/email/incoterms-authorization/assets/css/import.js new file mode 100644 index 000000000..b44d6bd37 --- /dev/null +++ b/print/templates/email/incoterms-authorization/assets/css/import.js @@ -0,0 +1,8 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/incoterms-authorization/attachments.json b/print/templates/email/incoterms-authorization/attachments.json new file mode 100644 index 000000000..9dfd945db --- /dev/null +++ b/print/templates/email/incoterms-authorization/attachments.json @@ -0,0 +1,6 @@ +[ + { + "filename": "incoterms-authorization.pdf", + "component": "incoterms-authorization" + } +] \ No newline at end of file diff --git a/print/templates/email/incoterms-authorization/incoterms-authorization.html b/print/templates/email/incoterms-authorization/incoterms-authorization.html new file mode 100644 index 000000000..5dd0d7da6 --- /dev/null +++ b/print/templates/email/incoterms-authorization/incoterms-authorization.html @@ -0,0 +1,57 @@ + + + + + + {{ $t('subject') }} + + + + + + + + +
+ +
+
+
+ +
+
+ +
+
+ +
+
+

{{ $t('title') }}

+

{{$t('description.dear')}},

+

{{$t('description.instructions')}}

+

{{$t('description.conclusion')}}

+
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/print/templates/email/incoterms-authorization/incoterms-authorization.js b/print/templates/email/incoterms-authorization/incoterms-authorization.js new file mode 100755 index 000000000..bac40d331 --- /dev/null +++ b/print/templates/email/incoterms-authorization/incoterms-authorization.js @@ -0,0 +1,27 @@ +const Component = require(`${appPath}/core/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); +const attachment = new Component('attachment'); +const attachments = require('./attachments.json'); + +module.exports = { + name: 'incoterms-authorization', + data() { + return {attachments}; + }, + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build(), + 'attachment': attachment.build() + }, + props: { + recipientId: { + type: [Number, String], + required: true + }, + companyId: { + type: [Number, String], + required: true + } + } +}; diff --git a/print/templates/email/incoterms-authorization/locale/es.yml b/print/templates/email/incoterms-authorization/locale/es.yml new file mode 100644 index 000000000..e8ce679fc --- /dev/null +++ b/print/templates/email/incoterms-authorization/locale/es.yml @@ -0,0 +1,6 @@ +subject: Autorización incoterms +title: Autorización incoterms +description: + dear: Estimado cliente + instructions: A continuación le adjuntamos la autorización incoterms que deberá entregar rellenada y firmada. + conclusion: ¡Gracias por su atención! \ No newline at end of file diff --git a/print/templates/email/incoterms-authorization/locale/fr.yml b/print/templates/email/incoterms-authorization/locale/fr.yml new file mode 100644 index 000000000..a2dc6fe3a --- /dev/null +++ b/print/templates/email/incoterms-authorization/locale/fr.yml @@ -0,0 +1,6 @@ +subject: Autorisation Incoterm +title: Autorisation Incoterm +description: + dear: Chers clients + instructions: Veuillez trouver ci-joint l'autorisation des INCOTERMS, une fois le document rempli doit être signé et renvoyé par e-mail. + conclusion: Dans l'attente de votre réponse, nous vous prions d'agréer, Madame, Monsieur, nos salutations distinguées. \ No newline at end of file diff --git a/print/templates/email/incoterms-authorization/locale/pt.yml b/print/templates/email/incoterms-authorization/locale/pt.yml new file mode 100644 index 000000000..bdf25ed0b --- /dev/null +++ b/print/templates/email/incoterms-authorization/locale/pt.yml @@ -0,0 +1,6 @@ +subject: Autorização do Incoterm +title: Autorização do Incoterm +description: + dear: Estimado cliente + instructions: Abaixo anexamos a autorização dos incoterms que deves preencher e reenviar-nos. + conclusion: Obrigado pela atenção. \ No newline at end of file diff --git a/print/templates/email/invoice/invoice.js b/print/templates/email/invoice/invoice.js index d92b65cb3..6f6ea8683 100755 --- a/print/templates/email/invoice/invoice.js +++ b/print/templates/email/invoice/invoice.js @@ -5,11 +5,11 @@ const emailFooter = new Component('email-footer'); module.exports = { name: 'invoice', async serverPrefetch() { - this.invoice = await this.fetchInvoice(this.invoiceId); + this.invoice = await this.fetchInvoice(this.refFk); }, methods: { - fetchInvoice(invoiceId) { - return this.findOneFromDef('invoice', [invoiceId]); + fetchInvoice(refFk) { + return this.findOneFromDef('invoice', [refFk]); }, }, components: { @@ -17,7 +17,7 @@ module.exports = { 'email-footer': emailFooter.build() }, props: { - invoiceId: { + refFk: { type: [Number, String], required: true } diff --git a/print/templates/email/invoice/sql/invoice.sql b/print/templates/email/invoice/sql/invoice.sql index 195621a36..b6f845fb0 100644 --- a/print/templates/email/invoice/sql/invoice.sql +++ b/print/templates/email/invoice/sql/invoice.sql @@ -4,4 +4,4 @@ SELECT FROM invoiceOut io JOIN ticket t ON t.refFk = io.ref JOIN client c ON c.id = io.clientFk -WHERE io.id = ? \ No newline at end of file +WHERE t.refFk = ? \ No newline at end of file diff --git a/print/templates/email/letter-debtor-st/letter-debtor-st.html b/print/templates/email/letter-debtor-st/letter-debtor-st.html index c78657ec7..364e79d56 100644 --- a/print/templates/email/letter-debtor-st/letter-debtor-st.html +++ b/print/templates/email/letter-debtor-st/letter-debtor-st.html @@ -23,7 +23,7 @@
-

{{ $t('title') }} {{$i18n.locale}}

+

{{ $t('title') }}

{{ $t('sections.introduction.title') }},

{{ $t('sections.introduction.description') }}

diff --git a/print/templates/email/letter-debtor-st/locale/pt.yml b/print/templates/email/letter-debtor-st/locale/pt.yml new file mode 100644 index 000000000..6f6082345 --- /dev/null +++ b/print/templates/email/letter-debtor-st/locale/pt.yml @@ -0,0 +1,16 @@ +subject: Aviso inicial por saldo devedor +title: Aviso inicial por saldo devedor +sections: + introduction: + title: Estimado cliente + description: Através do presente escrito comunicamos-lhe que, segundo os nossos dados contáveis, + a sua conta tem um saldo pendente de liquidar. +checkExtract: Solicitamos-lhe que comprove que o extrato anexado corresponde com os dados que dispõe. + O nosso departamento de administração aclarará qualquer dúvida que possa ter, + e igualmente lhe facilitará qualquer documento que solicite. +checkValidData: Se ao comprovar os dados aportados, resultam corretos, rogamos que proceda com a regularizar a situação +payMethod: Se não deseja acudir pessoalmente às nossas oficinas, pode realizar o pagamento mediante + transferência bancaria à conta que figura ao pé do comunicado, a indicar o seu número de cliente, + ou bem pode realizar o pagamento através do nosso sítio web. +conclusion: De antemão agradecemos-lhe a sua amável colaboração. +transferAccount: Dados para transferência bancária diff --git a/print/templates/reports/cmr-authorization/sql/ticket.sql b/print/templates/reports/cmr-authorization/sql/ticket.sql deleted file mode 100644 index c6c994f7d..000000000 --- a/print/templates/reports/cmr-authorization/sql/ticket.sql +++ /dev/null @@ -1,12 +0,0 @@ -SELECT - t.id, - t.clientFk, - cty.country, - w.name AS warehouse -FROM ticket t - JOIN warehouse w ON w.id = t.warehouseFk - JOIN address a ON a.id = t.addressFk - JOIN province p ON p.id = a.provinceFk - JOIN autonomy au ON au.id = p.autonomyFk - JOIN country cty ON cty.id = au.countryFk -WHERE t.id = ? \ No newline at end of file diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html index 5d840958d..600c49970 100644 --- a/print/templates/reports/driver-route/driver-route.html +++ b/print/templates/reports/driver-route/driver-route.html @@ -141,9 +141,8 @@ -
+

{{ticket.description}}

-

{{$t('stowaway')}}: {{ticket.shipFk}}

diff --git a/print/templates/reports/driver-route/locale/es.yml b/print/templates/reports/driver-route/locale/es.yml index 4c922ba64..3fb6b6885 100644 --- a/print/templates/reports/driver-route/locale/es.yml +++ b/print/templates/reports/driver-route/locale/es.yml @@ -20,7 +20,6 @@ phone: Teléfono warehouse: Almacén salesPerson: Comercial import: Importe -stowaway: Encajado dentro del ticket route: Ruta routeId: Ruta {0} ticket: Ticket \ No newline at end of file diff --git a/print/templates/reports/driver-route/sql/tickets.sql b/print/templates/reports/driver-route/sql/tickets.sql index 8806a0473..09e73819b 100644 --- a/print/templates/reports/driver-route/sql/tickets.sql +++ b/print/templates/reports/driver-route/sql/tickets.sql @@ -17,7 +17,6 @@ SELECT 0 AS import, am.name ticketAgency, tob.description, - s.shipFk, u.nickName salesPersonName, ipkg.itemPackingTypes FROM route r @@ -30,7 +29,6 @@ FROM route r LEFT JOIN province p ON a.provinceFk = p.id LEFT JOIN warehouse wh ON wh.id = t.warehouseFk LEFT JOIN agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN stowaway s ON s.id = t.id LEFT JOIN ( SELECT t.id AS ticketFk, GROUP_CONCAT(DISTINCT(i.itemPackingTypeFk)) AS itemPackingTypes diff --git a/print/templates/reports/exportation/exportation.js b/print/templates/reports/exportation/exportation.js index fbf663249..a7e018c48 100755 --- a/print/templates/reports/exportation/exportation.js +++ b/print/templates/reports/exportation/exportation.js @@ -5,14 +5,14 @@ const reportFooter = new Component('report-footer'); module.exports = { name: 'exportation', async serverPrefetch() { - this.invoice = await this.fetchInvoice(this.invoiceId); + this.invoice = await this.fetchInvoice(this.refFk); if (!this.invoice) throw new Error('Something went wrong'); }, methods: { - fetchInvoice(invoiceId) { - return this.findOneFromDef('invoice', [invoiceId]); + fetchInvoice(refFk) { + return this.findOneFromDef('invoice', [refFk]); } }, computed: { @@ -27,7 +27,7 @@ module.exports = { 'report-footer': reportFooter.build() }, props: { - invoiceId: { + refFk: { type: [Number, String], required: true } diff --git a/print/templates/reports/exportation/sql/invoice.sql b/print/templates/reports/exportation/sql/invoice.sql index 8e92333dd..7ea55e481 100644 --- a/print/templates/reports/exportation/sql/invoice.sql +++ b/print/templates/reports/exportation/sql/invoice.sql @@ -3,4 +3,5 @@ SELECT io.ref, io.issued FROM invoiceOut io -WHERE io.id = ? \ No newline at end of file + LEFT JOIN ticket t ON t.refFk = io.ref +WHERE t.refFk = ? \ No newline at end of file diff --git a/print/templates/reports/extra-community/extra-community.js b/print/templates/reports/extra-community/extra-community.js index 9843d6bb7..4dad5dfff 100755 --- a/print/templates/reports/extra-community/extra-community.js +++ b/print/templates/reports/extra-community/extra-community.js @@ -12,7 +12,7 @@ module.exports = { shippedFrom: this.shippedStart, continent: this.continent, id: this.id, - agencyFk: this.agencyFk, + agencyModeFk: this.agencyModeFk, warehouseInFk: this.warehouseInFk, warehouseOutFk: this.warehouseOutFk, totalEntries: this.totalEntries, @@ -68,7 +68,7 @@ module.exports = { return {'t.ref': {like: `%${value}%`}}; case 'id': return `t.id = ${value}`; - case 'agencyFk': + case 'agencyModeFk': return `am.id = ${value}`; case 'warehouseOutFk': return `wo.id = ${value}`; @@ -101,7 +101,7 @@ module.exports = { 'continent', 'ref', 'id', - 'agencyFk', + 'agencyModeFk', 'warehouseOutFk', 'warehouseInFk', 'totalEntries', diff --git a/print/templates/reports/extra-community/sql/travels.sql b/print/templates/reports/extra-community/sql/travels.sql index 167c8b1f8..f8a4e0142 100644 --- a/print/templates/reports/extra-community/sql/travels.sql +++ b/print/templates/reports/extra-community/sql/travels.sql @@ -19,4 +19,4 @@ FROM travel t JOIN warehouse wo ON wo.id = t.warehouseOutFk JOIN country c ON c.id = wo.countryFk LEFT JOIN continent cnt ON cnt.id = c.continentFk - JOIN agencyMode am ON am.id = t.agencyFk \ No newline at end of file + JOIN agencyMode am ON am.id = t.agencyModeFk \ No newline at end of file diff --git a/print/templates/reports/cmr-authorization/assets/css/import.js b/print/templates/reports/incoterms-authorization/assets/css/import.js similarity index 100% rename from print/templates/reports/cmr-authorization/assets/css/import.js rename to print/templates/reports/incoterms-authorization/assets/css/import.js diff --git a/print/templates/reports/cmr-authorization/assets/css/style.css b/print/templates/reports/incoterms-authorization/assets/css/style.css similarity index 69% rename from print/templates/reports/cmr-authorization/assets/css/style.css rename to print/templates/reports/incoterms-authorization/assets/css/style.css index adfe4b4c9..34545c951 100644 --- a/print/templates/reports/cmr-authorization/assets/css/style.css +++ b/print/templates/reports/incoterms-authorization/assets/css/style.css @@ -2,13 +2,8 @@ font-size: 1.2em } -.signature .dummy-signature { - width: 400px; - height: 190px; - display: block; - content: ''; - overflow: hidden; - clear:both +.signature { + margin-top: 100px } .signature img { diff --git a/print/templates/reports/cmr-authorization/assets/images/signature.png b/print/templates/reports/incoterms-authorization/assets/images/signature.png similarity index 100% rename from print/templates/reports/cmr-authorization/assets/images/signature.png rename to print/templates/reports/incoterms-authorization/assets/images/signature.png diff --git a/print/templates/reports/cmr-authorization/cmr-authorization.html b/print/templates/reports/incoterms-authorization/incoterms-authorization.html similarity index 72% rename from print/templates/reports/cmr-authorization/cmr-authorization.html rename to print/templates/reports/incoterms-authorization/incoterms-authorization.html index 2d8342a47..27cad97b1 100644 --- a/print/templates/reports/cmr-authorization/cmr-authorization.html +++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.html @@ -23,9 +23,10 @@

@@ -53,13 +54,13 @@

-

{{$t('signature')}}

+

{{ company.name }}

-

Juan Vicente Ferrer Roig
-
Director
+
{{company.manager}}
+
{{$t('manager')}}

{{$t('issued', [ - 'Algemesí', + company.city, issued.getDate(), $t('months')[issued.getMonth()], issued.getFullYear()]) @@ -68,22 +69,6 @@

- diff --git a/print/templates/reports/cmr-authorization/cmr-authorization.js b/print/templates/reports/incoterms-authorization/incoterms-authorization.js similarity index 69% rename from print/templates/reports/cmr-authorization/cmr-authorization.js rename to print/templates/reports/incoterms-authorization/incoterms-authorization.js index 1adc75fa6..656a9d7b0 100755 --- a/print/templates/reports/cmr-authorization/cmr-authorization.js +++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.js @@ -3,13 +3,12 @@ const reportHeader = new Component('report-header'); const reportFooter = new Component('report-footer'); module.exports = { - name: 'cmr-authorization', + name: 'incoterms-authorization', async serverPrefetch() { - this.ticket = await this.findOneFromDef('ticket', [this.ticketId]); - if (!this.ticket) + this.client = await this.findOneFromDef('client', [this.recipientId]); + this.company = await this.findOneFromDef('company', [this.companyId]); + if (!this.client) throw new Error('Something went wrong'); - - this.client = await this.findOneFromDef('client', [this.ticket.clientFk]); }, computed: { issued: function() { @@ -21,7 +20,11 @@ module.exports = { 'report-footer': reportFooter.build() }, props: { - ticketId: { + recipientId: { + type: [Number, String], + required: true + }, + companyId: { type: [Number, String], required: true } diff --git a/print/templates/reports/cmr-authorization/locale/es.yml b/print/templates/reports/incoterms-authorization/locale/es.yml similarity index 58% rename from print/templates/reports/cmr-authorization/locale/es.yml rename to print/templates/reports/incoterms-authorization/locale/es.yml index 37e40202d..6936ebda9 100644 --- a/print/templates/reports/cmr-authorization/locale/es.yml +++ b/print/templates/reports/incoterms-authorization/locale/es.yml @@ -1,32 +1,32 @@ -reportName: autorizacion-cmr +reportName: autorizacion-incoterms description: '{socialName} una sociedad debidamente constituida con responsabilidad limitada y registrada conforme al derecho de sociedades de {country} y aquí representada por ___________________. {socialName}, con domicilio en {address}, CIF {fiscalID}. En adelante denominada {name}.' issued: 'En {0}, a {1} de {2} de {3}' -client: 'Client {0}' +client: 'Cliente {0}' declaration: '{socialName} declara por la presente que:' declarations: - - 'Todas las compras realizadas por {socialName} con Verdnatura Levante, S.L. se -entregan, Ex Works (Incoterms), en el almacén de Verdnatura Levante, S.L. situado en -{destinationWarehouse}.' - - '{socialName} reconoce que es importante para Verdnatura Levante, S.L. tener + - 'Todas las compras realizadas por {socialName} con {companyName} se +entregan, Ex Works (Incoterms), en el almacén de {companyName} situado en +{companyCity}.' + - '{socialName} reconoce que es importante para {companyName} tener comprobante de la entrega intracomunitaria de la mercancía a {destinationCountry} para poder facturar con 0% de IVA.' - 'Por tanto, al firmar este acuerdo, {socialName} declara que todos los bienes que -se compren a Verdnatura Levante, S.L. serán entregados a {destinationCountry}.' - - 'Además, {socialName} deberá, a primera solicitud de Verdnatura Levante, S.L., -proporcionar una prueba de que todos los productos comprados a Verdnatura Levante, S.L. han +se compren a {companyName} serán entregados a {destinationCountry}.' + - 'Además, {socialName} deberá, a primera solicitud de {companyName}, +proporcionar una prueba de que todos los productos comprados a {companyName} han sido entregados en {destinationCountry}.' - - 'Además de lo anterior, Verdnatura Levante, S.L. proporcionará a {socialName} + - 'Además de lo anterior, {companyName} proporcionará a {socialName} un resumen mensual en el que se incluyen todas las facturas (y las entregas correspondientes). -{socialName} firmará y devolverá el resumen mensual a Verdnatura Levante, +{socialName} firmará y devolverá el resumen mensual a {companyName}, S.L. dentro de los 5 días posteriores a la recepción del resumen.' -signature: Verdnatura Levante, S.L. signer: representative: Representante representativeRole: Cargo del representante signed: Fecha de firma +manager: Gerente months: - 'Enero' - 'Febrero' diff --git a/print/templates/reports/incoterms-authorization/locale/fr.yml b/print/templates/reports/incoterms-authorization/locale/fr.yml new file mode 100644 index 000000000..f1aeb0eff --- /dev/null +++ b/print/templates/reports/incoterms-authorization/locale/fr.yml @@ -0,0 +1,38 @@ +reportName: autorizacion-incoterms +description: '{socialName} une société dûment constituée à responsabilité limitée +et enregistrée en vertu du droit des sociétés de {country} et représentée aux présentes par +___________________. {socialName}, ayant son siège social {address}, +CIF {fiscalID}. Ci-après dénommé {name}.' +issued: 'A {0}, le {1} {2} {3}' +client: 'Client {0}' +declaration: '{socialName} déclare par la présente que:' +declarations: + - "Tous les achats réalisés par {socialName} avec {companyName} +sont livrés, Ex Works (Incoterms), sur l'entrepôt de {companyName} situé à {companyCity}." + - "{socialName} reconnaît qu'il est important pou {companyName} d'avoir +la preuve de la livraison intracommunautaire des biens à {destinationCountry} afin de pouvoir facturer à 0% de TVA." + - 'Par conséquent, en signant cet accord, {socialName} déclare que tous les biens achetés à {companyName} seront livrés à {destinationCountry}.' + - 'En outre, {socialName} doit, à la première demande de {companyName}, +fournir la preuve que tous les biens achetés à {companyName} ont été livrés à {destinationCountry}.' + - 'En plus de ce qui précède, {companyName} fournira à {socialName} +un résumé mensuel comprenant toutes les factures (et les livraisons correspondantes). +{socialName} signera et retournera le résumé mensuel à {companyName}, +dans les 5 jours suivant la réception du résumé.' +signer: + representative: Représentant + representativeRole: Position du représentant + signed: Date de la signature +manager: Gérente +months: + - 'Janvier' + - 'Fevrier' + - 'Mars' + - 'Avril' + - 'Mai' + - 'Juin' + - 'Juillet' + - 'Août' + - 'Septembre' + - 'Octobre' + - 'Novembre' + - 'Decembre' \ No newline at end of file diff --git a/print/templates/reports/incoterms-authorization/locale/pt.yml b/print/templates/reports/incoterms-authorization/locale/pt.yml new file mode 100644 index 000000000..2d33e6a1a --- /dev/null +++ b/print/templates/reports/incoterms-authorization/locale/pt.yml @@ -0,0 +1,42 @@ +reportName: autorizacion-incoterms +description: '{socialName} uma sociedade devidamente constituída com responsabilidade limitada e registada +conforme ao direito de sociedades da {country} e aqui representada por +___________________. {socialName}, com domicílio em {address}, +CIF {fiscalID}. Em adiante denominada {name}.' +issued: 'Em {0}, em {1} de {2} de {3}' +client: 'Cliente {0}' +declaration: '{socialName} declara através da presente que:' +declarations: + - 'Todas as compras realizadas por {socialName} a {companyName} se entregam, + Ex Works (Incoterms), no armazém da {companyName} situado em +{companyCity}.' + - '{socialName} reconhece ser importante para {companyName} + ter o comprovante da entrega intracomunitária da mercadoria a {destinationCountry} + para poder faturar com 0% de IVA.' + - 'Portanto, ao assinar este acordo, {socialName} declara que todos os bens + que se comprem na {companyName} serão entregues na {destinationCountry}.' + - 'Além disto, {socialName} deverá, na primeira solicitude da {companyName}, + proporcionar uma prova de que todos os produtos comprados na {companyName} + foram entregues na {destinationCountry}.' + - 'Além do anterio, {companyName} proporcionará a {socialName} +um resumo mensal onde se incluem todas as faturas (e as entregas correspondentes). +{socialName} assinará e devolverá o resumo mensal à {companyName}, +dentro dos 5 dias posteriores à receção do resumo.' +signer: + representative: Representante + representativeRole: Cargo de representante + signed: Data da assinatura +manager: Gerente +months: + - 'Janeiro' + - 'Fevereiro' + - 'Marchar' + - 'abril' + - 'Poderia' + - 'Junho' + - 'Julho' + - 'Agosto' + - 'Setembro' + - 'Outubro' + - 'Novembro' + - 'Dezembro' \ No newline at end of file diff --git a/print/templates/reports/cmr-authorization/sql/client.sql b/print/templates/reports/incoterms-authorization/sql/client.sql similarity index 100% rename from print/templates/reports/cmr-authorization/sql/client.sql rename to print/templates/reports/incoterms-authorization/sql/client.sql diff --git a/print/templates/reports/incoterms-authorization/sql/company.sql b/print/templates/reports/incoterms-authorization/sql/company.sql new file mode 100644 index 000000000..39c3290d1 --- /dev/null +++ b/print/templates/reports/incoterms-authorization/sql/company.sql @@ -0,0 +1,8 @@ +SELECT + s.name, + s.city, + cl.name AS manager +FROM company c + JOIN supplier s ON s.id = c.id + JOIN client cl ON cl.id = c.workerManagerFk +WHERE c.id = ? \ No newline at end of file diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js index 99e23e15f..99a4e2e73 100755 --- a/print/templates/reports/invoice-incoterms/invoice-incoterms.js +++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js @@ -5,9 +5,9 @@ const reportFooter = new Component('report-footer'); module.exports = { name: 'invoice-incoterms', async serverPrefetch() { - this.invoice = await this.fetchInvoice(this.invoiceId); - this.client = await this.fetchClient(this.invoiceId); - this.incoterms = await this.fetchIncoterms(this.invoiceId); + this.invoice = await this.fetchInvoice(this.refFk); + this.client = await this.fetchClient(this.refFk); + this.incoterms = await this.fetchIncoterms(this.refFk); if (!this.invoice) throw new Error('Something went wrong'); @@ -16,14 +16,14 @@ module.exports = { }, methods: { - fetchInvoice(invoiceId) { - return this.findOneFromDef('invoice', [invoiceId]); + fetchInvoice(refFk) { + return this.findOneFromDef('invoice', [refFk]); }, - fetchClient(invoiceId) { - return this.findOneFromDef('client', [invoiceId]); + fetchClient(refFk) { + return this.findOneFromDef('client', [refFk]); }, - fetchIncoterms(invoiceId) { - return this.findOneFromDef('incoterms', [invoiceId, invoiceId, invoiceId]); + fetchIncoterms(refFk) { + return this.findOneFromDef('incoterms', [refFk, refFk, refFk]); } }, components: { @@ -31,7 +31,7 @@ module.exports = { 'report-footer': reportFooter.build() }, props: { - invoiceId: { + refFk: { type: [Number, String], required: true } diff --git a/print/templates/reports/invoice-incoterms/sql/client.sql b/print/templates/reports/invoice-incoterms/sql/client.sql index dd6035222..3e66c15c9 100644 --- a/print/templates/reports/invoice-incoterms/sql/client.sql +++ b/print/templates/reports/invoice-incoterms/sql/client.sql @@ -9,4 +9,5 @@ FROM vn.invoiceOut io JOIN vn.country cty ON cty.id = c.countryFk LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial AND ios.taxAreaFk = 'CEE' -WHERE io.id = ? \ No newline at end of file + LEFT JOIN ticket t ON t.refFk = io.ref +WHERE t.refFk = ? \ No newline at end of file diff --git a/print/templates/reports/invoice-incoterms/sql/incoterms.sql b/print/templates/reports/invoice-incoterms/sql/incoterms.sql index 5d894a4b2..6bb895129 100644 --- a/print/templates/reports/invoice-incoterms/sql/incoterms.sql +++ b/print/templates/reports/invoice-incoterms/sql/incoterms.sql @@ -51,7 +51,7 @@ SELECT io.issued, FROM vn.invoiceOut io JOIN vn.ticket t ON t.refFk = io.ref JOIN vn.saleVolume sv ON sv.ticketFk = t.id - WHERE io.id = ? + WHERE t.refFk = ? ) sub2 ON TRUE JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk AND itc.itemFk = s.itemFk JOIN vn.taxClass tc ON tc.id = itc.taxClassFk @@ -66,6 +66,7 @@ SELECT io.issued, JOIN vn.sale s ON t.id = s.ticketFk JOIN vn.item i ON i.id = s.itemFk JOIN vn.intrastat ir ON ir.id = i.intrastatFk - WHERE io.id = ? + WHERE t.refFk = ? )sub3 ON TRUE - WHERE io.id = ? + WHERE t.refFk = ? + diff --git a/print/templates/reports/invoice-incoterms/sql/invoice.sql b/print/templates/reports/invoice-incoterms/sql/invoice.sql index b9a929183..571ea2af3 100644 --- a/print/templates/reports/invoice-incoterms/sql/invoice.sql +++ b/print/templates/reports/invoice-incoterms/sql/invoice.sql @@ -14,4 +14,5 @@ FROM invoiceOut io JOIN company cny ON cny.id = io.companyFk JOIN supplierAccount sa ON sa.id = cny.supplierAccountFk LEFT JOIN invoiceOutSerial ios ON ios.code = io.serial -WHERE io.id = ? \ No newline at end of file + LEFT JOIN ticket t ON t.refFk = io.ref +WHERE t.refFk = ? \ No newline at end of file diff --git a/print/templates/reports/invoice/invoice.js b/print/templates/reports/invoice/invoice.js index c5abfad7e..fd4acd4b5 100755 --- a/print/templates/reports/invoice/invoice.js +++ b/print/templates/reports/invoice/invoice.js @@ -7,15 +7,15 @@ const invoiceIncoterms = new Report('invoice-incoterms'); module.exports = { name: 'invoice', async serverPrefetch() { - this.invoice = await this.fetchInvoice(this.invoiceId); - this.client = await this.fetchClient(this.invoiceId); - this.taxes = await this.fetchTaxes(this.invoiceId); - this.intrastat = await this.fetchIntrastat(this.invoiceId); - this.rectified = await this.fetchRectified(this.invoiceId); - this.hasIncoterms = await this.fetchHasIncoterms(this.invoiceId); + this.invoice = await this.fetchInvoice(this.refFk); + this.client = await this.fetchClient(this.refFk); + this.taxes = await this.fetchTaxes(this.refFk); + this.intrastat = await this.fetchIntrastat(this.refFk); + this.rectified = await this.fetchRectified(this.refFk); + this.hasIncoterms = await this.fetchHasIncoterms(this.refFk); - const tickets = await this.fetchTickets(this.invoiceId); - const sales = await this.fetchSales(this.invoiceId); + const tickets = await this.fetchTickets(this.refFk); + const sales = await this.fetchSales(this.refFk); const map = new Map(); @@ -65,29 +65,29 @@ module.exports = { } }, methods: { - fetchInvoice(invoiceId) { - return this.findOneFromDef('invoice', [invoiceId]); + fetchInvoice(refFk) { + return this.findOneFromDef('invoice', [refFk]); }, - fetchClient(invoiceId) { - return this.findOneFromDef('client', [invoiceId]); + fetchClient(refFk) { + return this.findOneFromDef('client', [refFk]); }, - fetchTickets(invoiceId) { - return this.rawSqlFromDef('tickets', [invoiceId]); + fetchTickets(refFk) { + return this.rawSqlFromDef('tickets', [refFk]); }, - fetchSales(invoiceId) { - return this.rawSqlFromDef('sales', [invoiceId, invoiceId]); + fetchSales(refFk) { + return this.rawSqlFromDef('sales', [refFk, refFk]); }, - fetchTaxes(invoiceId) { - return this.rawSqlFromDef(`taxes`, [invoiceId]); + fetchTaxes(refFk) { + return this.rawSqlFromDef(`taxes`, [refFk]); }, - fetchIntrastat(invoiceId) { - return this.rawSqlFromDef(`intrastat`, [invoiceId]); + fetchIntrastat(refFk) { + return this.rawSqlFromDef(`intrastat`, [refFk, refFk, refFk]); }, - fetchRectified(invoiceId) { - return this.rawSqlFromDef(`rectified`, [invoiceId]); + fetchRectified(refFk) { + return this.rawSqlFromDef(`rectified`, [refFk]); }, - fetchHasIncoterms(invoiceId) { - return this.findValueFromDef(`hasIncoterms`, [invoiceId]); + fetchHasIncoterms(refFk) { + return this.findValueFromDef(`hasIncoterms`, [refFk]); }, saleImport(sale) { const price = sale.quantity * sale.price; @@ -115,9 +115,8 @@ module.exports = { 'invoice-incoterms': invoiceIncoterms.build() }, props: { - invoiceId: { - type: [Number, String], - required: true + refFk: { + type: String } } }; diff --git a/print/templates/reports/invoice/sql/client.sql b/print/templates/reports/invoice/sql/client.sql index dd6035222..4c35838f2 100644 --- a/print/templates/reports/invoice/sql/client.sql +++ b/print/templates/reports/invoice/sql/client.sql @@ -9,4 +9,5 @@ FROM vn.invoiceOut io JOIN vn.country cty ON cty.id = c.countryFk LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial AND ios.taxAreaFk = 'CEE' -WHERE io.id = ? \ No newline at end of file + LEFT JOIN vn.ticket t ON t.refFk = io.ref +WHERE t.refFk = ? \ No newline at end of file diff --git a/print/templates/reports/invoice/sql/hasIncoterms.sql b/print/templates/reports/invoice/sql/hasIncoterms.sql index 27f61f57c..40a6db384 100644 --- a/print/templates/reports/invoice/sql/hasIncoterms.sql +++ b/print/templates/reports/invoice/sql/hasIncoterms.sql @@ -3,6 +3,6 @@ SELECT IF(incotermsFk IS NULL, FALSE, TRUE) AS hasIncoterms JOIN invoiceOut io ON io.ref = t.refFk JOIN client c ON c.id = t.clientFk JOIN address a ON a.id = t.addressFk - WHERE io.id = ? + WHERE t.refFk = ? AND IF(c.hasToinvoiceByAddress = FALSE, c.defaultAddressFk, TRUE) LIMIT 1 \ No newline at end of file diff --git a/print/templates/reports/invoice/sql/intrastat.sql b/print/templates/reports/invoice/sql/intrastat.sql index 6bf72c158..e2ee47667 100644 --- a/print/templates/reports/invoice/sql/intrastat.sql +++ b/print/templates/reports/invoice/sql/intrastat.sql @@ -1,18 +1,22 @@ -SELECT - ir.id AS code, - ir.description AS description, - CAST(SUM(IFNULL(i.stems,1) * s.quantity) AS DECIMAL(10,2)) as stems, - CAST(SUM(IF(sv.physicalWeight, sv.physicalWeight, i.density * sub.cm3delivery/1000000)) AS DECIMAL(10,2)) netKg, - CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) AS subtotal - FROM vn.sale s - LEFT JOIN (SELECT ic.itemFk, ic.cm3, ic.cm3delivery - FROM vn.itemCost ic - WHERE ic.cm3 - GROUP BY ic.itemFk) sub ON s.itemFk = sub.itemFk - LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id - LEFT JOIN vn.ticket t ON t.id = s.ticketFk - LEFT JOIN vn.invoiceOut io ON io.ref = t.refFk - LEFT JOIN vn.item i ON i.id = s.itemFk - JOIN vn.intrastat ir ON ir.id = i.intrastatFk - WHERE io.id = ? - GROUP BY i.intrastatFk; \ No newline at end of file +SELECT + ir.id code, + ir.description description, + CAST(SUM(IFNULL(i.stems, 1) * s.quantity) AS DECIMAL(10,2)) stems, + CAST(SUM(CAST(IFNULL(i.stems, 1) * s.quantity * IF(ic.grams, ic.grams, i.density * ic.cm3delivery / 1000) / 1000 AS DECIMAL(10,2)) * + IF(sub.weight, sub.weight / vn.invoiceOut_getWeight(?), 1)) AS DECIMAL(10,2)) netKg, + CAST(SUM((s.quantity * s.price * (100 - s.discount) / 100 )) AS DECIMAL(10,2)) subtotal + FROM vn.ticket t + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemCost ic ON ic.itemFk = i.id AND ic.warehouseFk = t.warehouseFk + JOIN vn.intrastat ir ON ir.id = i.intrastatFk + LEFT JOIN ( + SELECT t2.weight + FROM vn.ticket t2 + WHERE refFk = ? AND weight + LIMIT 1 + ) sub ON TRUE + WHERE t.refFk = ? + AND i.intrastatFk + GROUP BY i.intrastatFk + ORDER BY i.intrastatFk; \ No newline at end of file diff --git a/print/templates/reports/invoice/sql/invoice.sql b/print/templates/reports/invoice/sql/invoice.sql index aacbb0016..0f12e4f53 100644 --- a/print/templates/reports/invoice/sql/invoice.sql +++ b/print/templates/reports/invoice/sql/invoice.sql @@ -13,4 +13,5 @@ FROM invoiceOut io JOIN company cny ON cny.id = io.companyFk JOIN supplierAccount sa ON sa.id = cny.supplierAccountFk LEFT JOIN invoiceOutSerial ios ON ios.code = io.serial -WHERE io.id = ? \ No newline at end of file + LEFT JOIN ticket t ON t.refFk = io.ref +WHERE t.refFk = ? \ No newline at end of file diff --git a/print/templates/reports/invoice/sql/rectified.sql b/print/templates/reports/invoice/sql/rectified.sql index 1255b973c..ea814a05a 100644 --- a/print/templates/reports/invoice/sql/rectified.sql +++ b/print/templates/reports/invoice/sql/rectified.sql @@ -6,4 +6,5 @@ SELECT FROM vn.invoiceCorrection ic JOIN vn.invoiceOut io ON io.id = ic.correctedFk JOIN vn.invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk -where ic.correctingFk = ? \ No newline at end of file + LEFT JOIN ticket t ON t.refFk = io.ref +WHERE t.refFk = ? \ No newline at end of file diff --git a/print/templates/reports/invoice/sql/sales.sql b/print/templates/reports/invoice/sql/sales.sql index cff8794db..f5721a594 100644 --- a/print/templates/reports/invoice/sql/sales.sql +++ b/print/templates/reports/invoice/sql/sales.sql @@ -37,7 +37,7 @@ SELECT JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk AND itc.itemFk = s.itemFk JOIN vn.taxClass tc ON tc.id = itc.taxClassFk - WHERE io.id = ? + WHERE t.refFk = ? UNION ALL SELECT io.ref, @@ -69,4 +69,4 @@ SELECT JOIN vn.company co ON co.id = io.companyFk JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk JOIN vn.taxClass tc ON tc.id = ts.taxClassFk - WHERE io.id = ? \ No newline at end of file + WHERE t.refFk = ? \ No newline at end of file diff --git a/print/templates/reports/invoice/sql/taxes.sql b/print/templates/reports/invoice/sql/taxes.sql index 19b1cc00e..2203d8b8a 100644 --- a/print/templates/reports/invoice/sql/taxes.sql +++ b/print/templates/reports/invoice/sql/taxes.sql @@ -6,6 +6,7 @@ SELECT FROM invoiceOutTax iot JOIN pgc ON pgc.code = iot.pgcFk LEFT JOIN pgcEqu pe ON pe.equFk = pgc.code - JOIN invoiceOut io ON io.id = iot.invoiceOutFk - WHERE invoiceOutFk = ? + JOIN invoiceOut io ON io.id = iot.invoiceOutFk + LEFT JOIN ticket t ON t.refFk = io.ref + WHERE t.refFk = ? ORDER BY iot.id \ No newline at end of file diff --git a/print/templates/reports/invoice/sql/tickets.sql b/print/templates/reports/invoice/sql/tickets.sql index 7d135bd03..162f043e2 100644 --- a/print/templates/reports/invoice/sql/tickets.sql +++ b/print/templates/reports/invoice/sql/tickets.sql @@ -4,5 +4,5 @@ SELECT t.nickname FROM invoiceOut io JOIN ticket t ON t.refFk = io.ref -WHERE io.id = ? +WHERE t.refFk = ? ORDER BY t.shipped \ No newline at end of file