master #3125
335
CHANGELOG.md
335
CHANGELOG.md
|
@ -1,3 +1,337 @@
|
|||
# Version 24.38 - 2024-09-17
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- chore: refs #7323 filter data by:jorgep
|
||||
- chore: refs #7323 fix test by:jorgep
|
||||
- chore: refs #7323 worker changes by:jorgep
|
||||
- chore: refs #7323 worker changes wip by:jorgep
|
||||
- chore: refs #7524 add select limit by:jorgep
|
||||
- feat(AccessToken&ACL): refs #7547 upgrade security by:alexm
|
||||
- feat: deleted code and redirect to Lilium by:Jon
|
||||
- feat: refs #4515 New throw buy_checkItem by:guillermo
|
||||
- feat: refs #6650 Added saleGroupLog by:guillermo
|
||||
- feat: refs #6650 new itemShelvingLog by:guillermo
|
||||
- feat: refs #6760 refs #actualiza campo nickname by:jgallego
|
||||
- feat: refs #7277 fdescribe by:jgallego
|
||||
- feat: refs #7277 fit by:jgallego
|
||||
- feat: refs #7277 refundInvoices by:jgallego
|
||||
- feat: refs #7277 test with warehouse by:jgallego
|
||||
- feat: refs #7277 traducciones by:jgallego
|
||||
- feat: refs #7277 transfer addressFk by:jgallego
|
||||
- feat: refs #7532 Requested changes by:guillermo
|
||||
- feat: refs #7564 Added proc by:guillermo
|
||||
- feat: refs #7564 Added ticket_setVolumeItemCost by:guillermo
|
||||
- feat: refs #7564 Added volume column by:guillermo
|
||||
- feat: refs #7564 Fix version by:guillermo
|
||||
- feat: refs #7564 Requested changes by:guillermo
|
||||
- feat: refs #7615 setDeleted by:robert
|
||||
- feat: refs #7650 Added no transfer lines to inventory entry and fixtures by:guillermo
|
||||
- feat: refs #7650 Fix tests by:guillermo
|
||||
- feat: refs #7747 Delete buyUltimate and buyUltimateFromInterval by:ivanm
|
||||
- feat: refs #7759 Changed defined only of vn objects by:guillermo
|
||||
- feat: refs #7759 Changed definer root to vn-admin by:guillermo
|
||||
- feat: refs #7759 Changed name by:guillermo
|
||||
- feat: refs #7759 Deleted version 11163-maroonEucalyptus by:guillermo
|
||||
- feat: refs #7759 Revoke routine grants vn by:guillermo
|
||||
- feat: refs #7811 Added comment by:guillermo
|
||||
- feat: refs #7811 Added new params in datasources.json by:guillermo
|
||||
- feat: refs #7898 Add column "floor" in vn.parking by:ivanm
|
||||
- feat: refs #7898 Modify default by:ivanm
|
||||
- feat: refs #7905 Added new method getBuysCsv by:guillermo
|
||||
- feat: refs #7905 Added param toCsv by:guillermo
|
||||
- feat: refs #7938 remove unnecessary insert in clientLog by:alexm
|
||||
- feat: refs #7953 pullinfo (7953-devToTest_2438) by:alexm
|
||||
- feat(salix): #7671 define isDestiny field in model by:Javier Segarra
|
||||
- feat(salix): refs #7896 update version and changelog (origin/7896_down_devToTest_2436) by:Javier Segarra
|
||||
- feat(salix): refs #7905 #7905 use getBuys toCSV flattened by:Javier Segarra
|
||||
- feat(ssalix): refs #7671 #7671 checkDates by:Javier Segarra
|
||||
- feat(ssalix): refs #7671 #7671 checkDates to present by:Javier Segarra
|
||||
- feat: ticket 215005 Changed acl show transferClient by:guillermo
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- perf: refs #7671 improve showBadDates by:Javier Segarra
|
||||
- perf(salix): refs #7671 #7671 imrpove and revert where changes by:Javier Segarra
|
||||
- refactor: deleted e2e & added back descriptor and summary by:Jon
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- chore: refs #7323 fix test by:jorgep
|
||||
- feat: refs #7650 Added no transfer lines to inventory entry and fixtures by:guillermo
|
||||
- fix by:guillermo
|
||||
- fixes: refs #7760 collection problems by:Carlos Andrés
|
||||
- fix merge dev (7407-workerMedical) by:alexm
|
||||
- fix: refs #6727 No delete log tables data in clean procedures by:guillermo
|
||||
- fix: refs #6897 back and tests by:carlossa
|
||||
- fix: refs #6897 back by:carlossa
|
||||
- fix: refs #6897 fix filter by:carlossa
|
||||
- fix: refs #6897 fix json by:carlossa
|
||||
- fix: refs #6897 travel filter by:carlossa
|
||||
- fix: refs #6897 error test by:jgallego
|
||||
- fix: refs #7323 fetch from right source by:jorgep
|
||||
- fix: refs #7564 Deleted query by:guillermo
|
||||
- fix: refs #7759 Added user 'vn'@'localhost' & grants by:guillermo
|
||||
- fix: refs #7760 collection problems by:Carlos Andrés
|
||||
- fix: refs #7760 tmp.ticketIPT by:Carlos Andrés
|
||||
- fix: refs #7905 added comments to flatten.js by:guillermo
|
||||
- fix: refs ##7905 Handle error by:guillermo
|
||||
- fix(salix): refs #7905 #7905 use right fn to flatten data by:Javier Segarra
|
||||
- perf(salix): refs #7671 #7671 imrpove and revert where changes by:Javier Segarra
|
||||
- refs #6898 fix supplier remove by:carlossa
|
||||
- refs #7407 fix acls fixtures by:carlossa
|
||||
- test: fix connections e2e (7547-accessToken-security) by:alexm
|
||||
- test: refs #7277 fix test proposal by:Javier Segarra
|
||||
- test(salix): refs #7671 #7671 improve and revert where changes by:Javier Segarra
|
||||
|
||||
# Version 24.36 - 2024-09-03
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- chore: refs #7524 WIP limit call by:jorgep
|
||||
- chore: refs #7524 modify ormConfig table col (origin/7524-warmfix-modifyColumn) by:jorgep
|
||||
- feat(update-user): refs #7848 add twoFactor by:alexm
|
||||
- feat: #3199 Requested changes by:guillermo
|
||||
- feat: refs #3199 Added more scopes ticket_recalcByScope by:guillermo
|
||||
- feat: refs #3199 Added one more scope ticket_recalcByScope by:guillermo
|
||||
- feat: refs #3199 Created ticket_recalcItemTaxCountryByScope by:guillermo
|
||||
- feat: refs #3199 Requested changes by:guillermo
|
||||
- feat: refs #7346 add multiple feature by:jgallego
|
||||
- feat: refs #7346 backTest checks new implementation by:jgallego
|
||||
- feat: refs #7346 mas intuitivo by:jgallego
|
||||
- feat: refs #7514 Changes to put srt log (origin/7514-srtLog) by:guillermo
|
||||
- feat: refs #7524 add default limit (origin/7524-limitSelect) by:jorgep
|
||||
- feat: refs #7524 add mock limit on find query by:jorgep
|
||||
- feat: refs #7524 wip remote hooks by:jorgep
|
||||
- feat: refs #7562 Requested changes by:guillermo
|
||||
- feat: refs #7567 Changed time to call event by:guillermo
|
||||
- feat: refs #7567 Requested changes by:guillermo
|
||||
- feat: refs #7710 pr revision by:jgallego
|
||||
- feat: refs #7710 test fixed (origin/7710-cloneWithTicketPackaging, 7710-cloneWithTicketPackaging) by:jgallego
|
||||
- feat: refs #7712 Fix by:guillermo
|
||||
- feat: refs #7712 Unify by:guillermo
|
||||
- feat: refs #7712 sizeLimit (origin/7712-sizeLimit) by:guillermo
|
||||
- feat: refs #7758 Add code mandateType and accountDetailType by:ivanm
|
||||
- feat: refs #7758 Modify code lowerCamelCase and UNIQUE by:ivanm
|
||||
- feat: refs #7758 accountDetailType fix deploy error by:ivanm
|
||||
- feat: refs #7784 Changes in entry-order-pdf by:guillermo
|
||||
- feat: refs #7784 Requested changes by:guillermo
|
||||
- feat: refs #7799 Added Fk in vn.item.itemPackingTypeFk by:guillermo
|
||||
- feat: refs #7800 Added company Fk by:guillermo
|
||||
- feat: refs #7842 Added editorFk in vn.host by:guillermo
|
||||
- feat: refs #7860 Update new packagings (origin/7860-newPackaging) by:guillermo
|
||||
- feat: refs #7862 roadmap new fields by:ivanm
|
||||
- feat: refs #7882 Added quadMindsConfig table by:guillermo
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- refactor: refs #7567 Fix and improvement by:guillermo
|
||||
- refactor: refs #7567 Minor change by:guillermo
|
||||
- refactor: refs #7756 Fix tests by:guillermo
|
||||
- refactor: refs #7798 Drop bi.Greuges_comercial_detail by:guillermo
|
||||
- refactor: refs #7848 adapt to lilium by:alexm
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- feat: refs #7710 test fixed (origin/7710-cloneWithTicketPackaging, 7710-cloneWithTicketPackaging) by:jgallego
|
||||
- feat: refs #7758 accountDetailType fix deploy error by:ivanm
|
||||
- fix(salix): #7283 ItemFixedPrice duplicated (origin/7283_itemFixedPrice_duplicated) by:Javier Segarra
|
||||
- fix: refs #7346 minor error (origin/7346, 7346) by:jgallego
|
||||
- fix: refs #7355 remove and tests accounts (origin/7355-accountMigration2) by:carlossa
|
||||
- fix: refs #7355 remove and tests accounts by:carlossa
|
||||
- fix: refs #7524 default limit select by:jorgep
|
||||
- fix: refs #7756 Foreign keys invoiceOut (origin/7756-fixRefFk) by:guillermo
|
||||
- fix: refs #7756 id 0 by:guillermo
|
||||
- fix: refs #7800 tpvMerchantEnable PRIMARY KEY (origin/7800-tpvMerchantEnable) by:guillermo
|
||||
- fix: refs #7800 tpvMerchantEnable PRIMARY KEY by:guillermo
|
||||
- fix: refs #7916 itemShelving_transfer (origin/test, test) by:guillermo
|
||||
- fix: refs #pako Deleted duplicated version by:guillermo
|
||||
|
||||
# Version 24.34 - 2024-08-20
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- #6900 feat: clear empty by:jorgep
|
||||
- #6900 feat: empty commit by:jorgep
|
||||
- chore: refs #6900 beautify code by:jorgep
|
||||
- chore: refs #6989 add config model by:jorgep
|
||||
- feat workerActivity refs #6078 by:sergiodt
|
||||
- feat: #6453 Refactor (origin/6453-orderConfirm) by:guillermo
|
||||
- feat: #6453 Rollback always split by itemPackingType by:guillermo
|
||||
- feat: deleted worker module code & redirect to Lilium by:Jon
|
||||
- feat: refs #6453 Added new ticket search by:guillermo
|
||||
- feat: refs #6453 Fixes by:guillermo
|
||||
- feat: refs #6453 Minor changes by:guillermo
|
||||
- feat: refs #6453 Requested changes by:guillermo
|
||||
- feat: refs #6900 drop section by:jorgep
|
||||
- feat: refs #7283 order by desc date by:jorgep
|
||||
- feat: refs #7323 add locale by:jorgep
|
||||
- feat: refs #7323 redirect to lilium by:jorgep
|
||||
- feat: refs #7646 delete scannableCodeType by:robert
|
||||
- feat: refs #7713 Created ACLLog by:guillermo
|
||||
- feat: refs #7774 (origin/7774-ticket_cloneWeekly) by:robert
|
||||
- feat: refs #7774 #7774 Changes ticket_cloneWeekly by:guillermo
|
||||
- feat: refs #7774 ticket_cloneWeekly by:robert
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- refactor: refs #6453 Major changes by:guillermo
|
||||
- refactor: refs #6453 Minor changes by:guillermo
|
||||
- refactor: refs #6453 order_confirmWithUser by:guillermo
|
||||
- refactor: refs #7646 #7646 Deleted scannable* variables productionConfig by:guillermo
|
||||
- refactor: refs #7820 Deprecated silexACL by:guillermo
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- #6900 fix: #6900 rectificative filter by:jorgep
|
||||
- #6900 fix: empty commit by:jorgep
|
||||
- fix(orders_filter): add sourceApp accepts by:alexm
|
||||
- fix: refs #6130 commit lint by:pablone
|
||||
- fix: refs #6453 order_confirmWithUser by:guillermo
|
||||
- fix: refs #7283 sql by:jorgep
|
||||
- fix: refs #7713 ACL Log by:guillermo
|
||||
- test: fix claim descriptor redirect to lilium by:alexm
|
||||
- test: fix ticket redirect to lilium by:alexm
|
||||
- test: fix ticket sale e2e by:alexm
|
||||
|
||||
# Version 24.32 - 2024-08-06
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- chore: refs #7197 add supplierActivityFk filter by:jorgep
|
||||
- feat checkExpeditionPrintOut refs #7751 by:sergiodt
|
||||
- feat(defaulter_filter): add department by:alexm
|
||||
- feat: redirect to lilium page not found by:alexm
|
||||
- feat: refactor buyUltimate refs #7736 by:Carlos Andrés
|
||||
- feat: refs #6403 add delete by:pablone
|
||||
- feat: refs #7126 Added manaClaim calc by:guillermo
|
||||
- feat: refs #7126 Refactor and added columns in bs.waste table & proc by:guillermo
|
||||
- feat: refs #7197 filter by correcting by:jorgep
|
||||
- feat: refs #7297 add new columns by:pablone
|
||||
- feat: refs #7356 new parameters in sql for Weekly tickets front by:Jon
|
||||
- feat: refs #7401 redirect lilium by:pablone
|
||||
- feat: refs #7511 Fix tests by:guillermo
|
||||
- feat: refs #7511 Rename to multiConfig tables by:guillermo
|
||||
- feat: refs #7589 Added display (item_valuateInventory) by:guillermo
|
||||
- feat: refs #7589 Added vItemTypeFk & vItemCategoryFk (item_valuateInventory) by:guillermo
|
||||
- feat: refs #7681 Changes by:guillermo
|
||||
- feat: refs #7681 Optimization and refactor by:guillermo
|
||||
- feat: refs #7683 drop temporary table by:robert
|
||||
- feat: refs #7683 productionControl by:robert
|
||||
- feat: refs #7728 Added throw due date by:guillermo
|
||||
- feat: refs #7740 Ticket before update added restriction by:guillermo
|
||||
- feat(salix): #7648 Add field for endpoint as buyLabel report by:Javier Segarra
|
||||
- feat(salix): #7648 remove white line by:Javier Segarra
|
||||
- feat: tabla config dias margen vctos. refs #7728 by:Carlos Andrés
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- eat: refactor buyUltimate refs #7736 by:Carlos Andrés
|
||||
- feat: refactor buyUltimate refs #7736 by:Carlos Andrés
|
||||
- feat: refs #7681 Optimization and refactor by:guillermo
|
||||
- refactor: refs #7126 Requested changes by:guillermo
|
||||
- refactor: refs #7511 Minor change by:guillermo
|
||||
- refactor: refs #7640 Multipleinventory available by:guillermo
|
||||
- refactor: refs #7681 Changes by:guillermo
|
||||
- refactor: refs #7681 Requested changes by:guillermo
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- add prefix (hotFix_liliumRedirection) by:alexm
|
||||
- fix(client_filter): add recovery by:alexm
|
||||
- fix: defaulter filter correct sql (6943-fix_defaulter_filter) by:alexm
|
||||
- fix(deletExpeditions): merge test → dev by:guillermo
|
||||
- fix: refs #6403 fix mrw cancel shipment return type by:pablone
|
||||
- fix: refs #7126 Added addressWaste type by:guillermo
|
||||
- fix: refs #7126 Fix by:guillermo
|
||||
- fix: refs #7126 Minor change by:guillermo
|
||||
- fix: refs #7126 Primary key no unique data by:guillermo
|
||||
- fix: refs #7126 Slow update by:guillermo
|
||||
- fix: refs #7511 Minor change by:guillermo
|
||||
- fix: refs #7546 Deleted insert util.binlogQueue by:guillermo
|
||||
- fix: refs #7811 Variables pm2 by:guillermo
|
||||
- fix: without path by:alexm
|
||||
|
||||
# Version 24.28 - 2024-07-09
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- feat boxPicking refs #7357 by:sergiodt
|
||||
- feat boxPicking refs #7357 (origin/7357_dipole_review) by:sergiodt
|
||||
- feat:concurrency issue refs #6861 by:Carlos Andrés
|
||||
- feat expeditionPalletPrint refs #5210 by:sergiodt
|
||||
- feat front-reservas refs #6861 (origin/6861-Reservas-front) by:sergiodt
|
||||
- feat itemShelving_filterBuyer refs #7023 by:sergiodt
|
||||
- feat itemShelvingLog refs #7168 by:sergiodt
|
||||
- feat itemShelvingSale refs #6861 by:sergiodt
|
||||
- feat: previas con reserva refs #6861 by:Carlos Andrés
|
||||
- feat: previas con sitema de reservas refs #6861 by:Carlos Andrés
|
||||
- feat: previas con sitema de reservas refs #6861 (origin/6861-Pasar-modo-trabajo-de-previa-a-reservas) by:Carlos Andrés
|
||||
- feat refactor setParking REGEXP refs #7575 (origin/7575_setParking_regExp) by:sergiodt
|
||||
- feat: refs #6238 add travelKgPercentage table and model (origin/6238-addPercentage) by:jorgep
|
||||
- feat: refs #6286 check if is teamBoss (origin/6286-setRightWorkerTimeControlAcls) by:jorgep
|
||||
- feat: refs #6701 Fix error by:guillermo
|
||||
- feat: refs #6861 trigger by:sergiodt
|
||||
- feat: refs #7027 mailError managed by:jgallego
|
||||
- feat: refs #7168 Added vRecords param in proc by:guillermo
|
||||
- feat: refs #7168 Minor change by:guillermo
|
||||
- feat: refs #7216 logUnpaid (origin/7216-clientUnpaid) by:jgallego
|
||||
- feat: refs #7216 triggers by:jgallego
|
||||
- feat: refs #7296 by:robert
|
||||
- feat: refs #7296 drop column expeditionTruckFk by:robert
|
||||
- feat: refs #7490 Changes (origin/7490-duaInvoiceInBooking) by:guillermo
|
||||
- feat: refs #7545 Deleted hasIncoterms client column (origin/7545-hasIncoterms) by:guillermo
|
||||
- feat: refs #7555 remove account.password__ by:alexm
|
||||
- feat: return sql check error by:alexm
|
||||
- feat roadmap refs #7195 by:sergiodt
|
||||
- #refs 5890 feat:add assignCollection by:sergiodt
|
||||
- refs#5890 feat: delete trigger and modify getTickets by:sergiodt
|
||||
- refs #5890 feat:itemShelving_add by:sergiodt
|
||||
- refs #5890 feat:reserves by:sergiodt
|
||||
- refs #5890 feat:trigger by:sergiodt
|
||||
- refs #5890 feat: triggers by:sergiodt
|
||||
- refs #6861 feat: getLock by:sergiodt
|
||||
- refs #6861 feat: obsrevation by:sergiodt
|
||||
- refs #6861 feat: previas a reservas by:sergiodt
|
||||
- refs #6861 feat:reserve previos by:sergiodt
|
||||
- refs #6861 feat: reservePrevious by:sergiodt
|
||||
- refs #6861 feat:reserveWithReservation by:sergiodt
|
||||
- refs #6861 feat:sectoCollection reserve by:sergiodt
|
||||
- refs #6861 feat: skipTest by:sergiodt
|
||||
- refs #6861 feat: trigger by:sergiodt
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- feat refactor setParking REGEXP refs #7575 (origin/7575_setParking_regExp) by:sergiodt
|
||||
- refactor: refs #5447 changed models by:Jon
|
||||
- refactor: refs #6238 drop useless round by:jorgep
|
||||
- refactor: refs #6286 replace name by:jorgep
|
||||
- refactor: refs #6701 Refactor claim_ratio_routine by:guillermo
|
||||
- refactor: refs #7490 Added final update by:guillermo
|
||||
- refactor: refs #7490 Deleted update duaInvoiceInBooking by:guillermo
|
||||
- refactor: refs #7490 Minor changes by:guillermo
|
||||
- refactor: refs #7519 Minor change by:guillermo
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- acls, fixtures, models by:carlossa
|
||||
- fix: refs #6238 delete unused SQL script by:jorgep
|
||||
- fix: refs #6238 insert ignore by:jorgep
|
||||
- fix: refs #6238 use scheme by:jorgep
|
||||
- fix: refs #6286 replace id for reason by:jorgep
|
||||
- fix: refs #6286 update WorkerTimeControl permissions by:jorgep
|
||||
- fix(WorkerIncome): refs #7409 fix models by:alexm
|
||||
- refs #5890 fix: dev by:sergiodt
|
||||
- refs #6897 fix entry Salix by:carlossa
|
||||
- refs #6897 fix es.yml by:carlossa
|
||||
- refs #6897 fix redirection by:carlossa
|
||||
- refs #6897 fix remove by:carlossa
|
||||
- refs #7406 fix back by:carlossa
|
||||
- refs #7406 fix pr by:carlossa
|
||||
- refs #7409 fix acls by:carlossa
|
||||
- refs #7409 fix back (origin/7409-workerIncome) by:carlossa
|
||||
- refs #7409 fix pr by:carlossa
|
||||
|
||||
# Version 24.24 - 2024-06-11
|
||||
|
||||
### Added 🆕
|
||||
|
@ -22,6 +356,7 @@
|
|||
- feat: refs #7438 Added volume to item_valuateInventory by:guillermo
|
||||
- feat: refs #7438 Requested changes and little changes by:guillermo
|
||||
- refs #6281 feat:buyFk in itemShelving by:sergiodt
|
||||
- feat: refs #6449 item ID is displayed in the sale line by:jorgep
|
||||
|
||||
### Changed 📦
|
||||
|
||||
|
|
|
@ -20,9 +20,14 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const [, , [{collectionFk}]] =
|
||||
await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
|
||||
[userId], myOptions);
|
||||
const randStr = Math.random().toString(36).substring(3);
|
||||
const result = await Self.rawSql(`
|
||||
CALL vn.collection_assign(?, @vCollectionFk);
|
||||
SELECT @vCollectionFk ?
|
||||
`, [userId, randStr], myOptions);
|
||||
|
||||
// Por si entra en SELECT FOR UPDATE una o varias veces
|
||||
const collectionFk = result.find(item => item[0]?.[randStr] !== undefined)?.[0]?.[randStr];
|
||||
|
||||
if (!collectionFk) throw new UserError('There are not picking tickets');
|
||||
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('assignCollection', {
|
||||
description: 'Assign a collection',
|
||||
accessType: 'WRITE',
|
||||
http: {
|
||||
path: `/assignCollection`,
|
||||
verb: 'POST'
|
||||
},
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
});
|
||||
|
||||
Self.assignCollection = async(ctx, options) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {userId};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const randStr = Math.random().toString(36).substring(3);
|
||||
const result = await Self.rawSql(`
|
||||
CALL vn.collection_getAssigned(?, @vCollectionFk);
|
||||
SELECT @vCollectionFk ?
|
||||
`, [userId, randStr], myOptions);
|
||||
|
||||
const collectionFk = result.find(item => item[0]?.[randStr] !== undefined)?.[0]?.[randStr];
|
||||
|
||||
if (!collectionFk) throw new UserError('There are not picking tickets');
|
||||
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
||||
|
||||
return collectionFk;
|
||||
};
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getSales', {
|
||||
description: 'Get sales from ticket or collection',
|
||||
description: 'Get sales from ticket, collection or sectorCollection',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
|
@ -60,15 +60,17 @@ module.exports = Self => {
|
|||
if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions);
|
||||
|
||||
for (let ticket of tickets) {
|
||||
let observations = ticket.observaciones.split(' ');
|
||||
if (ticket.observaciones) {
|
||||
let observations = ticket.observaciones.split(' ');
|
||||
|
||||
for (let observation of observations) {
|
||||
const salesPerson = ticket.salesPersonFk;
|
||||
if (observation.startsWith('#') || observation.startsWith('@')) {
|
||||
await models.Chat.send(ctx,
|
||||
observation,
|
||||
$t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson})
|
||||
);
|
||||
for (let observation of observations) {
|
||||
const salesPerson = ticket.salesPersonFk;
|
||||
if (observation.startsWith('#') || observation.startsWith('@')) {
|
||||
await models.Chat.send(ctx,
|
||||
observation,
|
||||
$t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ module.exports = Self => {
|
|||
|
||||
const promises = [];
|
||||
const [tickets] = await Self.rawSql(`CALL vn.collection_getTickets(?)`, [id], myOptions);
|
||||
|
||||
const sales = await Self.rawSql(`
|
||||
SELECT s.ticketFk,
|
||||
sgd.saleGroupFk,
|
||||
|
@ -56,19 +57,21 @@ module.exports = Self => {
|
|||
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving,
|
||||
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving,
|
||||
sh.code,
|
||||
IFNULL(p2.code, p.code) parkingCode,
|
||||
IFNULL(p2.pickingOrder, p.pickingOrder) pickingOrder,
|
||||
p2.code parkingCode,
|
||||
p2.pickingOrder pickingOrder,
|
||||
p.code parkingCodePrevia,
|
||||
p.pickingOrder pickingOrderPrevia,
|
||||
iss.id itemShelvingSaleFk,
|
||||
iss.isPicked
|
||||
iss.isPicked,
|
||||
iss.itemShelvingFk
|
||||
FROM ticketCollection tc
|
||||
LEFT JOIN collection c ON c.id = tc.collectionFk
|
||||
JOIN ticket t ON t.id = tc.ticketFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN sale s ON s.ticketFk = tc.ticketFk
|
||||
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
|
||||
LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
|
||||
LEFT JOIN parking p2 ON p2.id = sg.parkingFk
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||
JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
LEFT JOIN parking p ON p.id = sh.parkingFk
|
||||
|
@ -76,17 +79,58 @@ module.exports = Self => {
|
|||
LEFT JOIN origin o ON o.id = i.originFk
|
||||
WHERE tc.collectionFk = ?
|
||||
GROUP BY s.id, ish.id, p.code, p2.code
|
||||
ORDER BY pickingOrder;`, [id], myOptions);
|
||||
|
||||
UNION ALL
|
||||
SELECT s.ticketFk,
|
||||
sgd.saleGroupFk,
|
||||
s.id saleFk,
|
||||
s.itemFk,
|
||||
i.longName,
|
||||
i.size,
|
||||
ic.color,
|
||||
o.code origin,
|
||||
ish.packing,
|
||||
ish.grouping,
|
||||
s.isAdded,
|
||||
s.originalQuantity,
|
||||
s.quantity,
|
||||
iss.quantity,
|
||||
SUM(iss.quantity) OVER (PARTITION BY s.id ORDER BY ish.id),
|
||||
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY p.pickingOrder),
|
||||
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) ,
|
||||
sh.code,
|
||||
p2.code,
|
||||
p2.pickingOrder,
|
||||
p.code,
|
||||
p.pickingOrder,
|
||||
iss.id itemShelvingSaleFk,
|
||||
iss.isPicked,
|
||||
iss.itemShelvingFk
|
||||
FROM sectorCollection sc
|
||||
JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
|
||||
JOIN saleGroup sg ON sg.id = ss.saleGroupFk
|
||||
LEFT JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
|
||||
JOIN sale s ON s.id = sgd.saleFk
|
||||
LEFT JOIN parking p2 ON p2.id = sg.parkingFk
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
LEFT JOIN parking p ON p.id = sh.parkingFk
|
||||
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
|
||||
LEFT JOIN origin o ON o.id = i.originFk
|
||||
WHERE sc.id = ?
|
||||
AND sgd.saleGroupFk
|
||||
GROUP BY s.id, ish.id, p.code, p2.code`, [id, id], myOptions);
|
||||
if (print)
|
||||
await Self.rawSql(`CALL vn.collection_printSticker(?, ?)`, [id, null], myOptions);
|
||||
|
||||
const collection = {collectionFk: id, tickets: []};
|
||||
|
||||
if (tickets && tickets.length) {
|
||||
for (const ticket of tickets) {
|
||||
const ticketId = ticket.ticketFk;
|
||||
if (ticket.observaciones != '') {
|
||||
for (observation of ticket.observaciones.split(' ')) {
|
||||
if (ticket.observation) {
|
||||
for (observation of ticket.observation?.split(' ')) {
|
||||
if (['#', '@'].includes(observation.charAt(0))) {
|
||||
promises.push(Self.app.models.Chat.send(ctx, observation,
|
||||
$t('The ticket is in preparation', {
|
||||
|
@ -100,11 +144,11 @@ module.exports = Self => {
|
|||
if (sales && sales.length) {
|
||||
const barcodes = await Self.rawSql(`
|
||||
SELECT s.id saleFk, b.code, c.id
|
||||
FROM vn.sale s
|
||||
LEFT JOIN vn.itemBarcode b ON b.itemFk = s.itemFk
|
||||
LEFT JOIN vn.buy c ON c.itemFk = s.itemFk
|
||||
LEFT JOIN vn.entry e ON e.id = c.entryFk
|
||||
LEFT JOIN vn.travel tr ON tr.id = e.travelFk
|
||||
FROM sale s
|
||||
LEFT JOIN itemBarcode b ON b.itemFk = s.itemFk
|
||||
LEFT JOIN buy c ON c.itemFk = s.itemFk
|
||||
LEFT JOIN entry e ON e.id = c.entryFk
|
||||
LEFT JOIN travel tr ON tr.id = e.travelFk
|
||||
WHERE s.ticketFk = ?
|
||||
AND tr.landed >= util.VN_CURDATE() - INTERVAL 1 YEAR`,
|
||||
[ticketId], myOptions);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('ticket assignCollection()', () => {
|
||||
let ctx;
|
||||
let options;
|
||||
let tx;
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 1106},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => value
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req});
|
||||
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
if (tx) await tx.rollback();
|
||||
});
|
||||
|
||||
it('should throw an error when there is not picking tickets', async() => {
|
||||
try {
|
||||
await models.Collection.assignCollection(ctx, options);
|
||||
} catch (e) {
|
||||
expect(e.message).toEqual('There are not picking tickets');
|
||||
}
|
||||
});
|
||||
});
|
|
@ -4,15 +4,7 @@ describe('collection getSales()', () => {
|
|||
const collectionOrTicketFk = 999999;
|
||||
const print = true;
|
||||
const source = 'CHECKER';
|
||||
|
||||
beforeAll(() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'},
|
||||
}
|
||||
};
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should return a collection with tickets, placements and barcodes settled correctly', async() => {
|
||||
const tx = await models.Collection.beginTransaction({});
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('collection getTickets()', () => {
|
||||
let ctx;
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
};
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should get tickets, sales and barcodes from collection', async() => {
|
||||
const tx = await models.Collection.beginTransaction({});
|
||||
|
@ -26,8 +18,8 @@ describe('collection getTickets()', () => {
|
|||
expect(collectionTickets.tickets[1].ticketFk).toEqual(2);
|
||||
expect(collectionTickets.tickets[2].ticketFk).toEqual(23);
|
||||
expect(collectionTickets.tickets[0].sales[0].ticketFk).toEqual(1);
|
||||
expect(collectionTickets.tickets[0].sales[1].ticketFk).toEqual(1);
|
||||
expect(collectionTickets.tickets[0].sales[2].ticketFk).toEqual(1);
|
||||
expect(collectionTickets.tickets[1].sales.length).toEqual(0);
|
||||
expect(collectionTickets.tickets[2].sales.length).toEqual(0);
|
||||
expect(collectionTickets.tickets[0].sales[0].Barcodes.length).toBeTruthy();
|
||||
|
||||
await tx.rollback();
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('setSaleQuantity()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should change quantity sale', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
|
|
@ -4,21 +4,45 @@ module.exports = Self => {
|
|||
/**
|
||||
* Returns basic headers
|
||||
*
|
||||
* @param {string} cookie - The docuware cookie
|
||||
* @return {object} - The headers
|
||||
*/
|
||||
Self.getOptions = async() => {
|
||||
const docuwareConfig = await Self.app.models.DocuwareConfig.findOne();
|
||||
const now = Date.vnNow();
|
||||
let {url, username, password, token, expired} = docuwareConfig;
|
||||
|
||||
if (process.env.NODE_ENV && (!expired || expired < now + 60)) {
|
||||
const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`);
|
||||
const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`);
|
||||
const {data} = await axios.post(token_endpoint, {
|
||||
grant_type: 'password',
|
||||
scope: 'docuware.platform',
|
||||
client_id: 'docuware.platform.net.client',
|
||||
username,
|
||||
password
|
||||
}, {headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}});
|
||||
|
||||
const newToken = data.access_token;
|
||||
token = data.token_type + ' ' + newToken;
|
||||
await docuwareConfig.updateAttributes({
|
||||
token,
|
||||
expired: now + data.expires_in
|
||||
});
|
||||
}
|
||||
|
||||
const headers = {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Cookie': docuwareConfig.cookie
|
||||
'Authorization': token
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
url: docuwareConfig.url,
|
||||
url,
|
||||
headers
|
||||
};
|
||||
};
|
||||
|
|
|
@ -2,87 +2,54 @@ const axios = require('axios');
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Docuware core', () => {
|
||||
beforeAll(() => {
|
||||
const fileCabinetCode = 'deliveryNote';
|
||||
beforeAll(async() => {
|
||||
process.env.NODE_ENV = 'testing';
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
delete process.env.NODE_ENV;
|
||||
});
|
||||
|
||||
describe('getOptions()', () => {
|
||||
it('should return url and headers', async() => {
|
||||
const result = await models.Docuware.getOptions();
|
||||
|
||||
expect(result.url).toBeDefined();
|
||||
expect(result.headers).toBeDefined();
|
||||
const docuwareInfo = await models.Docuware.findOne({
|
||||
where: {
|
||||
code: fileCabinetCode
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('getDialog()', () => {
|
||||
it('should return dialogId', async() => {
|
||||
const dialogs = {
|
||||
data: {
|
||||
Dialog: [
|
||||
{
|
||||
DisplayName: 'find',
|
||||
Id: 'getDialogTest'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(dialogs)));
|
||||
const result = await models.Docuware.getDialog('deliveryNote', 'find', 'randomFileCabinetId');
|
||||
spyOn(axios, 'get').and.callFake(url => {
|
||||
if (url.includes('IdentityServiceInfo')) return {data: {IdentityServiceUrl: 'IdentityServiceUrl'}};
|
||||
if (url.includes('IdentityServiceUrl')) return {data: {token_endpoint: 'token_endpoint'}};
|
||||
if (url.includes('dialogs')) {
|
||||
return {
|
||||
data: {
|
||||
Dialog: [
|
||||
{
|
||||
DisplayName: 'find',
|
||||
Id: 'getDialogTest'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
expect(result).toEqual('getDialogTest');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFileCabinet()', () => {
|
||||
it('should return fileCabinetId', async() => {
|
||||
const code = 'deliveryNote';
|
||||
const docuwareInfo = await models.Docuware.findOne({
|
||||
where: {
|
||||
code
|
||||
}
|
||||
});
|
||||
const dialogs = {
|
||||
data: {
|
||||
if (url.includes('FileCabinets')) {
|
||||
return {data: {
|
||||
FileCabinet: [
|
||||
{
|
||||
Name: docuwareInfo.fileCabinetName,
|
||||
Id: 'getFileCabinetTest'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(dialogs)));
|
||||
const result = await models.Docuware.getFileCabinet(code);
|
||||
|
||||
expect(result).toEqual('getFileCabinetTest');
|
||||
});
|
||||
});
|
||||
|
||||
describe('get()', () => {
|
||||
it('should return data without parse', async() => {
|
||||
spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
||||
spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
||||
const data = {
|
||||
data: {
|
||||
id: 1
|
||||
}
|
||||
};
|
||||
spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data)));
|
||||
const result = await models.Docuware.get('deliveryNote');
|
||||
|
||||
expect(result.id).toEqual(1);
|
||||
}};
|
||||
}
|
||||
});
|
||||
|
||||
it('should return data with parse', async() => {
|
||||
spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
||||
spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
||||
const data = {
|
||||
data: {
|
||||
spyOn(axios, 'post').and.callFake(url => {
|
||||
if (url.includes('token_endpoint')) {
|
||||
return {data: {
|
||||
access_token: 'access_token',
|
||||
token_type: 'bearer',
|
||||
expires_in: 10000
|
||||
}};
|
||||
}
|
||||
if (url.includes('DialogExpression')) {
|
||||
return {data: {
|
||||
Items: [{
|
||||
Fields: [
|
||||
{
|
||||
|
@ -103,12 +70,52 @@ describe('Docuware core', () => {
|
|||
]
|
||||
}]
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
delete process.env.NODE_ENV;
|
||||
});
|
||||
|
||||
describe('getOptions()', () => {
|
||||
it('should return url and headers', async() => {
|
||||
const result = await models.Docuware.getOptions();
|
||||
|
||||
expect(result.url).toBeDefined();
|
||||
expect(result.headers).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dialog()', () => {
|
||||
it('should return dialogId', async() => {
|
||||
const result = await models.Docuware.getDialog('deliveryNote', 'find', 'randomFileCabinetId');
|
||||
|
||||
expect(result).toEqual('getDialogTest');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFileCabinet()', () => {
|
||||
it('should return fileCabinetId', async() => {
|
||||
const result = await models.Docuware.getFileCabinet(fileCabinetCode);
|
||||
|
||||
expect(result).toEqual('getFileCabinetTest');
|
||||
});
|
||||
});
|
||||
|
||||
describe('get()', () => {
|
||||
it('should return data without parse', async() => {
|
||||
const [result] = await models.Docuware.get('deliveryNote');
|
||||
|
||||
expect(result.firstRequiredField).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return data with parse', async() => {
|
||||
const parse = {
|
||||
'firstRequiredField': 'id',
|
||||
'secondRequiredField': 'name',
|
||||
};
|
||||
spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data)));
|
||||
const [result] = await models.Docuware.get('deliveryNote', null, parse);
|
||||
|
||||
expect(result.id).toEqual(1);
|
||||
|
@ -119,17 +126,14 @@ describe('Docuware core', () => {
|
|||
|
||||
describe('getById()', () => {
|
||||
it('should return data', async() => {
|
||||
spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
||||
spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random()))));
|
||||
const data = {
|
||||
data: {
|
||||
id: 1
|
||||
}
|
||||
};
|
||||
spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data)));
|
||||
const result = await models.Docuware.getById('deliveryNote', 1);
|
||||
spyOn(models.Docuware, 'get');
|
||||
await models.Docuware.getById('deliveryNote', 1);
|
||||
|
||||
expect(result.id).toEqual(1);
|
||||
expect(models.Docuware.get).toHaveBeenCalledWith(
|
||||
'deliveryNote',
|
||||
{condition: [Object({DBName: 'N__ALBAR_N', Value: [1]})]},
|
||||
undefined
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -143,7 +143,7 @@ module.exports = Self => {
|
|||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
'X-File-ModifiedDate': Date.vnNew(),
|
||||
'Cookie': docuwareOptions.headers.headers.Cookie,
|
||||
'Authorization': docuwareOptions.headers.headers.Authorization,
|
||||
...data.getHeaders()
|
||||
},
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx, userId: ctx.req.accessToken.userId};
|
||||
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options);
|
||||
const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileMultiConfig', null, options);
|
||||
|
||||
const updatableFiles = [];
|
||||
for (const file of files) {
|
||||
|
@ -54,7 +54,7 @@ module.exports = Self => {
|
|||
|
||||
const tables = await Self.rawSql(`
|
||||
SELECT fileName, toTable, file
|
||||
FROM edi.tableConfig
|
||||
FROM edi.tableMultiConfig
|
||||
WHERE file IN (?)`, [fileNames], options);
|
||||
|
||||
for (const table of tables) {
|
||||
|
@ -85,9 +85,9 @@ module.exports = Self => {
|
|||
for (const file of updatableFiles) {
|
||||
console.log(`Updating file ${file.name} checksum...`);
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.fileConfig
|
||||
SET checksum = ?
|
||||
WHERE name = ?`,
|
||||
UPDATE edi.fileMultiConfig
|
||||
SET checksum = ?
|
||||
WHERE name = ?`,
|
||||
[file.checksum, file.name], options);
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ module.exports = Self => {
|
|||
|
||||
await Self.rawSql(sqlTemplate, [filePath], options);
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.tableConfig
|
||||
UPDATE edi.tableMultiConfig
|
||||
SET updated = ?
|
||||
WHERE fileName = ?
|
||||
`, [Date.vnNew(), baseName], options);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<soap:Header>
|
||||
<mrw:AuthInfo>
|
||||
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
|
||||
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoDepartamento/>
|
||||
<mrw:UserName><%= mrw.user %></mrw:UserName>
|
||||
<mrw:Password><%= mrw.password %></mrw:Password>
|
||||
|
|
|
@ -13,7 +13,7 @@ module.exports = Self => {
|
|||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -27,9 +27,9 @@ module.exports = Self => {
|
|||
|
||||
const mrw = await models.MrwConfig.findOne();
|
||||
const {externalId} = await models.Expedition.findById(expeditionFk);
|
||||
|
||||
const clientType = await models.MrwConfig.getClientType(expeditionFk);
|
||||
const template = fs.readFileSync(__dirname + '/cancelShipment.ejs', 'utf-8');
|
||||
const renderedXml = ejs.render(template, {mrw, externalId});
|
||||
const renderedXml = ejs.render(template, {mrw, externalId, clientType});
|
||||
const response = await axios.post(mrw.url, renderedXml, {
|
||||
headers: {
|
||||
'Content-Type': 'application/soap+xml; charset=utf-8'
|
||||
|
@ -39,6 +39,7 @@ module.exports = Self => {
|
|||
const xmlString = response.data;
|
||||
const parser = new DOMParser();
|
||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||
return xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
||||
const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
||||
return result.toLowerCase().includes('se ha cancelado correctamente');
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<soap:Header>
|
||||
<mrw:AuthInfo>
|
||||
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
|
||||
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoDepartamento/>
|
||||
<mrw:UserName><%= mrw.user %></mrw:UserName>
|
||||
<mrw:Password><%= mrw.password %></mrw:Password>
|
||||
|
@ -25,7 +25,7 @@
|
|||
</mrw:Direccion>
|
||||
<mrw:Nif><%= expeditionData.fi %></mrw:Nif>
|
||||
<mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre>
|
||||
<mrw:Telefono><%= expeditionData.phone %></mrw:Telefono>
|
||||
<mrw:Telefono><%= expeditionData.mobile %></mrw:Telefono>
|
||||
<mrw:Observaciones><%= expeditionData.deliveryObservation %></mrw:Observaciones>
|
||||
</mrw:DatosEntrega>
|
||||
<mrw:DatosServicio>
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
const axios = require('axios');
|
||||
const {DOMParser} = require('xmldom');
|
||||
const fs = require('fs');
|
||||
const ejs = require('ejs');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
|
@ -23,23 +19,21 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.createShipment = async(expeditionFk, options) => {
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
Self.createShipment = async expeditionFk => {
|
||||
const models = Self.app.models;
|
||||
const mrw = await models.MrwConfig.findOne(null, myOptions);
|
||||
const mrw = await Self.getConfig();
|
||||
const clientType = await models.MrwConfig.getClientType(expeditionFk);
|
||||
|
||||
if (!mrw)
|
||||
throw new UserError(`Some mrwConfig parameters are not set`);
|
||||
const today = Date.vnNew();
|
||||
const [hours, minutes] = mrw?.expeditionDeadLine ? mrw.expeditionDeadLine.split(':').map(Number) : [0, 0];
|
||||
|
||||
const deadLine = Date.vnNew();
|
||||
deadLine.setHours(hours, minutes, 0);
|
||||
|
||||
if (today > deadLine && (!mrw.notified || mrw.notified.setHours(0, 0, 0, 0) !== today.setHours(0, 0, 0, 0))) {
|
||||
await models.NotificationQueue.create({notificationFk: 'mrw-deadline'});
|
||||
await mrw.updateAttributes({notified: Date.vnNow()});
|
||||
}
|
||||
|
||||
const query =
|
||||
`SELECT
|
||||
|
@ -53,67 +47,45 @@ module.exports = Self => {
|
|||
co.code countryCode,
|
||||
c.fi,
|
||||
c.name clientName,
|
||||
c.phone,
|
||||
IFNULL(a.mobile, c.mobile) mobile,
|
||||
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
||||
t.shipped,
|
||||
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
|
||||
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType,
|
||||
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType,
|
||||
IF(mw.weekdays, 'S', 'N') weekDays,
|
||||
oa.description deliveryObservation
|
||||
ta.description deliveryObservation
|
||||
FROM expedition e
|
||||
JOIN ticket t ON e.ticketFk = t.id
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN mrwService ms ON ms.agencyModeCodeFk = am.code
|
||||
LEFT JOIN mrwServiceWeekday mw ON mw.weekdays | 1 << WEEKDAY(t.landed)
|
||||
LEFT JOIN mrwServiceWeekday mw ON mw.agencyModeCodeFk = am.code
|
||||
AND mw.weekDays & (1 << WEEKDAY(t.landed))
|
||||
JOIN client c ON t.clientFk = c.id
|
||||
JOIN address a ON t.addressFk = a.id
|
||||
LEFT JOIN addressObservation oa ON oa.addressFk = a.id
|
||||
LEFT JOIN observationType ot ON ot.id = oa.observationTypeFk
|
||||
AND ot.code = 'delivery'
|
||||
LEFT JOIN ticketObservation ta ON ta.ticketFk = t.id
|
||||
AND ta.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'agency')
|
||||
JOIN province p ON a.provinceFk = p.id
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
JOIN mrwConfig mc
|
||||
WHERE e.id = ?
|
||||
LIMIT 1`;
|
||||
|
||||
const [expeditionData] = await Self.rawSql(query, [expeditionFk], myOptions);
|
||||
const [expeditionData] = await Self.rawSql(query, [expeditionFk]);
|
||||
|
||||
if (!expeditionData)
|
||||
throw new UserError(`This expedition is not a MRW shipment`);
|
||||
|
||||
const today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
if (expeditionData?.shipped.setHours(0, 0, 0, 0) < today)
|
||||
if (expeditionData?.shipped.setHours(0, 0, 0, 0) < today.setHours(0, 0, 0, 0))
|
||||
throw new UserError(`This ticket has a shipped date earlier than today`);
|
||||
|
||||
const shipmentResponse = await sendXmlDoc('createShipment', {mrw, expeditionData}, 'application/soap+xml');
|
||||
const shipmentId = getTextByTag(shipmentResponse, 'NumeroEnvio');
|
||||
const shipmentResponse = await Self.sendXmlDoc(
|
||||
__dirname + `/createShipment.ejs`,
|
||||
{mrw, expeditionData, clientType},
|
||||
'application/soap+xml'
|
||||
);
|
||||
const shipmentId = Self.getTextByTag(shipmentResponse, 'NumeroEnvio');
|
||||
|
||||
if (!shipmentId)
|
||||
throw new UserError(getTextByTag(shipmentResponse, 'Mensaje'));
|
||||
if (!shipmentId) throw new UserError(Self.getTextByTag(shipmentResponse, 'Mensaje'));
|
||||
|
||||
const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml');
|
||||
const file = getTextByTag(getLabelResponse, 'EtiquetaFile');
|
||||
|
||||
if (tx) await tx.commit();
|
||||
const file = await models.MrwConfig.getLabel(shipmentId, clientType);
|
||||
|
||||
return {shipmentId, file};
|
||||
};
|
||||
|
||||
function getTextByTag(xmlDoc, tag) {
|
||||
return xmlDoc?.getElementsByTagName(tag)[0]?.textContent;
|
||||
}
|
||||
|
||||
async function sendXmlDoc(xmlDock, params, contentType) {
|
||||
const parser = new DOMParser();
|
||||
|
||||
const xmlTemplate = fs.readFileSync(__dirname + `/${xmlDock}.ejs`, 'utf-8');
|
||||
const renderedTemplate = ejs.render(xmlTemplate, params);
|
||||
const data = await axios.post(params.mrw.url, renderedTemplate, {
|
||||
headers: {
|
||||
'Content-Type': `${contentType}; charset=utf-8`
|
||||
}
|
||||
});
|
||||
return parser.parseFromString(data.data, 'text/xml');
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<soapenv:Header>
|
||||
<mrw:AuthInfo>
|
||||
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
|
||||
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoDepartamento/>
|
||||
<mrw:UserName><%= mrw.user %></mrw:UserName>
|
||||
<mrw:Password><%= mrw.password %></mrw:Password>
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getLabel', {
|
||||
description: 'Return a base64Binary label from de MRW WebService',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'shipmentId',
|
||||
type: 'string',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'clientType',
|
||||
type: 'string',
|
||||
required: true
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: 'string',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getLabel`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getLabel = async(shipmentId, clientType) => {
|
||||
const mrw = await Self.getConfig();
|
||||
|
||||
const getLabelResponse = await Self.sendXmlDoc(
|
||||
__dirname + `/getLabel.ejs`,
|
||||
{mrw, shipmentId, clientType},
|
||||
'text/xml'
|
||||
);
|
||||
|
||||
return Self.getTextByTag(getLabelResponse, 'EtiquetaFile');
|
||||
};
|
||||
};
|
|
@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models;
|
|||
const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
|
||||
const filter = {notificationFk: 'mrw-deadline'};
|
||||
const mockBase64Binary = 'base64BinaryString';
|
||||
const ticket1 = {
|
||||
'id': '44',
|
||||
|
@ -11,9 +12,8 @@ const ticket1 = {
|
|||
'addressFk': 1,
|
||||
'agencyModeFk': 999
|
||||
};
|
||||
|
||||
let expedition;
|
||||
const expedition1 = {
|
||||
'id': 17,
|
||||
'agencyModeFk': 999,
|
||||
'ticketFk': 44,
|
||||
'freightItemFk': 71,
|
||||
|
@ -28,25 +28,49 @@ const expedition1 = {
|
|||
'editorFk': 100
|
||||
};
|
||||
|
||||
let tx;
|
||||
let options;
|
||||
|
||||
describe('MRWConfig createShipment()', () => {
|
||||
beforeEach(async() => {
|
||||
options = tx = undefined;
|
||||
tx = await models.MrwConfig.beginTransaction({});
|
||||
options = {transaction: tx};
|
||||
|
||||
beforeAll(async() => {
|
||||
await models.Agency.create(
|
||||
{'id': 999, 'name': 'mrw'},
|
||||
options
|
||||
{'id': 999, 'name': 'mrw'}
|
||||
);
|
||||
|
||||
await models.AgencyMode.create(
|
||||
{'id': 999, 'name': 'mrw', 'agencyFk': 999, 'code': 'mrw'},
|
||||
options
|
||||
{'id': 999, 'name': 'mrw', 'agencyFk': 999, 'code': 'mrw'}
|
||||
|
||||
);
|
||||
|
||||
await models.MrwService.create(
|
||||
{'agencyModeCodeFk': 'mrw', 'clientType': '000001', 'serviceType': 105, 'kg': 10}
|
||||
);
|
||||
|
||||
await createMrwConfig();
|
||||
|
||||
await models.Ticket.create(ticket1);
|
||||
expedition = await models.Expedition.create(expedition1);
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await cleanFixtures();
|
||||
await models.Ticket.destroyAll(ticket1);
|
||||
await models.Expedition.destroyAll(ticket1);
|
||||
});
|
||||
|
||||
beforeEach(async() => {
|
||||
const mockPostResponses = [
|
||||
{data: fs.readFileSync(__dirname + '/mockGetLabel.xml', 'utf-8')},
|
||||
{data: fs.readFileSync(__dirname + '/mockCreateShipment.xml', 'utf-8')}
|
||||
];
|
||||
|
||||
spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop()));
|
||||
await cleanFixtures();
|
||||
});
|
||||
|
||||
async function cleanFixtures() {
|
||||
await models.NotificationQueue.destroyAll(filter);
|
||||
await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: null, notified: null});
|
||||
}
|
||||
|
||||
async function createMrwConfig() {
|
||||
await models.MrwConfig.create(
|
||||
{
|
||||
'id': 1,
|
||||
|
@ -54,68 +78,82 @@ describe('MRWConfig createShipment()', () => {
|
|||
'user': 'user',
|
||||
'password': 'password',
|
||||
'franchiseCode': 'franchiseCode',
|
||||
'subscriberCode': 'subscriberCode'
|
||||
}, options
|
||||
'subscriberCode': 'subscriberCode',
|
||||
'clientTypeWidth': 6
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
await models.Application.rawSql(
|
||||
`INSERT INTO vn.mrwService
|
||||
SET agencyModeCodeFk = 'mrw',
|
||||
clientType = 1,
|
||||
serviceType = 1,
|
||||
kg = 1`, null, options
|
||||
);
|
||||
await models.Ticket.create(ticket1, options);
|
||||
await models.Expedition.create(expedition1, options);
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
async function getLastNotification() {
|
||||
return models.NotificationQueue.findOne({
|
||||
order: 'id DESC',
|
||||
where: filter
|
||||
});
|
||||
}
|
||||
|
||||
it('should create a shipment and return a base64Binary label', async() => {
|
||||
const mockPostResponses = [
|
||||
{data: fs.readFileSync(__dirname + '/mockGetLabel.xml', 'utf-8')},
|
||||
{data: fs.readFileSync(__dirname + '/mockCreateShipment.xml', 'utf-8')}
|
||||
];
|
||||
|
||||
spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop()));
|
||||
|
||||
const {file} = await models.MrwConfig.createShipment(expedition1.id, options);
|
||||
const {file} = await models.MrwConfig.createShipment(expedition.id);
|
||||
|
||||
expect(file).toEqual(mockBase64Binary);
|
||||
});
|
||||
|
||||
it('should fail if mrwConfig has no data', async() => {
|
||||
let error;
|
||||
await models.MrwConfig.createShipment(expedition1.id).catch(e => {
|
||||
await models.MrwConfig.destroyAll();
|
||||
await models.MrwConfig.createShipment(expedition.id).catch(e => {
|
||||
error = e;
|
||||
}).finally(async() => {
|
||||
expect(error.message).toEqual(`Some mrwConfig parameters are not set`);
|
||||
expect(error.message).toEqual(`MRW service is not configured`);
|
||||
});
|
||||
await createMrwConfig();
|
||||
|
||||
expect(error).toBeDefined();
|
||||
});
|
||||
|
||||
it('should fail if expeditionFk is not a MrwExpedition', async() => {
|
||||
let error;
|
||||
await models.MrwConfig.createShipment(undefined, options).catch(e => {
|
||||
await models.MrwConfig.createShipment(15).catch(e => {
|
||||
error = e;
|
||||
}).finally(async() => {
|
||||
expect(error.message).toEqual(`This expedition is not a MRW shipment`);
|
||||
expect(error.message).toEqual(`ClientType not available`);
|
||||
});
|
||||
});
|
||||
|
||||
it(' should fail if the creation date of this ticket is before the current date it', async() => {
|
||||
it('should fail if the creation date of this ticket is before the current date', async() => {
|
||||
let error;
|
||||
const yesterday = Date.vnNew();
|
||||
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
await models.Ticket.updateAll({id: ticket1.id}, {shipped: yesterday}, options);
|
||||
await models.MrwConfig.createShipment(expedition1.id, options).catch(e => {
|
||||
|
||||
await models.Ticket.updateAll({id: ticket1.id}, {shipped: yesterday});
|
||||
await models.MrwConfig.createShipment(expedition.id).catch(e => {
|
||||
error = e;
|
||||
}).finally(async() => {
|
||||
expect(error.message).toEqual(`This ticket has a shipped date earlier than today`);
|
||||
});
|
||||
await models.Ticket.updateAll({id: ticket1.id}, {shipped: Date.vnNew()});
|
||||
});
|
||||
|
||||
it('should send mail if you are past the dead line and is not notified today', async() => {
|
||||
await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: '10:00:00', notified: null});
|
||||
await models.MrwConfig.createShipment(expedition.id);
|
||||
const notification = await getLastNotification();
|
||||
|
||||
expect(notification.notificationFk).toEqual(filter.notificationFk);
|
||||
});
|
||||
|
||||
it('should send mail if you are past the dead line and it is notified from another day', async() => {
|
||||
await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: '10:00:00', notified: new Date()});
|
||||
await models.MrwConfig.createShipment(expedition.id);
|
||||
const notification = await getLastNotification();
|
||||
|
||||
expect(notification.notificationFk).toEqual(filter.notificationFk);
|
||||
});
|
||||
|
||||
it('should not send mail if you are past the dead line and it is notified', async() => {
|
||||
await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: '10:00:00', notified: Date.vnNew()});
|
||||
await models.MrwConfig.createShipment(expedition.id);
|
||||
const notification = await getLastNotification();
|
||||
|
||||
expect(notification).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,13 +11,6 @@ module.exports = Self => {
|
|||
arg: 'filter',
|
||||
type: 'object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'search',
|
||||
type: 'string',
|
||||
description: 'Value to filter',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
|
@ -29,13 +22,11 @@ module.exports = Self => {
|
|||
verb: 'GET',
|
||||
},
|
||||
});
|
||||
Self.filter = async(ctx, filter, options) => {
|
||||
Self.filter = async(filter = {}, options) => {
|
||||
const myOptions = {};
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
filter = ctx?.filter ?? {};
|
||||
|
||||
const conn = Self.dataSource.connector;
|
||||
const where = buildFilter(filter?.where, (param, value) => {
|
||||
switch (param) {
|
||||
|
@ -50,31 +41,33 @@ module.exports = Self => {
|
|||
};
|
||||
}
|
||||
}) ?? {};
|
||||
delete ctx.filter.where;
|
||||
delete filter.where;
|
||||
|
||||
const stmts = [];
|
||||
let stmt;
|
||||
stmt = new ParameterizedSQL(`
|
||||
SELECT
|
||||
pc.townFk,
|
||||
t.provinceFk,
|
||||
p.countryFk,
|
||||
pc.code,
|
||||
t.name as town,
|
||||
p.name as province,
|
||||
c.name country
|
||||
FROM
|
||||
postCode pc
|
||||
JOIN town t on t.id = pc.townFk
|
||||
JOIN province p on p.id = t.provinceFk
|
||||
JOIN country c on c.id = p.countryFk
|
||||
SELECT
|
||||
pc.townFk,
|
||||
t.provinceFk,
|
||||
p.countryFk,
|
||||
pc.code,
|
||||
t.name as town,
|
||||
p.name as province,
|
||||
c.name country
|
||||
FROM
|
||||
postCode pc
|
||||
JOIN town t on t.id = pc.townFk
|
||||
JOIN province p on p.id = t.provinceFk
|
||||
JOIN country c on c.id = p.countryFk
|
||||
`);
|
||||
|
||||
stmt.merge(conn.makeSuffix({where, ...ctx}));
|
||||
stmt.merge(conn.makeSuffix({where}));
|
||||
stmt.merge(conn.makeLimit(filter));
|
||||
const itemsIndex = stmts.push(stmt) - 1;
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const result = await conn.executeStmt(sql, myOptions);
|
||||
|
||||
return itemsIndex === 0 ? result : result[itemsIndex];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -6,12 +6,9 @@ describe('Postcode filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
filter: {
|
||||
},
|
||||
const results = await models.Postcode.filter({
|
||||
limit: 1
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
}, options);
|
||||
|
||||
expect(results.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
|
@ -26,16 +23,13 @@ describe('Postcode filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
filter: {
|
||||
where: {
|
||||
search: 46,
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
const results = await models.Postcode.filter({
|
||||
where: {
|
||||
search: 46,
|
||||
}
|
||||
}, options);
|
||||
|
||||
expect(results.length).toEqual(4);
|
||||
expect(results.length).toEqual(5);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
@ -48,14 +42,9 @@ describe('Postcode filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
filter: {
|
||||
where: {
|
||||
search: 'Alz',
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
const results = await models.Postcode.filter({where: {
|
||||
search: 'Alz',
|
||||
}}, options);
|
||||
|
||||
expect(results.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
|
@ -70,16 +59,11 @@ describe('Postcode filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
filter: {
|
||||
where: {
|
||||
search: 'one',
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
const results = await models.Postcode.filter({where: {
|
||||
search: 'one',
|
||||
}}, options);
|
||||
|
||||
expect(results.length).toEqual(4);
|
||||
expect(results.length).toEqual(5);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
@ -92,14 +76,11 @@ describe('Postcode filter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {
|
||||
filter: {
|
||||
where: {
|
||||
search: 'Ec',
|
||||
}
|
||||
},
|
||||
};
|
||||
const results = await models.Postcode.filter(ctx, options);
|
||||
const results = await models.Postcode.filter({
|
||||
where: {
|
||||
search: 'Ec',
|
||||
}
|
||||
}, options);
|
||||
|
||||
expect(results.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
const axios = require('axios');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('sendOrders', {
|
||||
description: 'Sends a set of orders',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'tickets',
|
||||
type: ['number'],
|
||||
required: true
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: 'string',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/sendOrders`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
Self.sendOrders = async tickets => {
|
||||
const config = await Self.app.models.QuadmindsApiConfig.findOne();
|
||||
if (!config) throw new UserError('Config params not set');
|
||||
|
||||
if (tickets.length > config.maxObjects)
|
||||
throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`);
|
||||
|
||||
let poisData = [];
|
||||
let isOk;
|
||||
for (let offset = 0; !isOk; offset = offset + config.limit) {
|
||||
const pois = await axios.get(`${config.url}pois/search?limit=${config.limit}&offset=${offset}`, {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'X-Saas-Apikey': config.key
|
||||
}
|
||||
});
|
||||
pois.data.data.length ? poisData.push(...pois.data.data) : isOk = true;
|
||||
}
|
||||
|
||||
const poiMap = new Map(poisData.map(poi => [poi.code, poi._id]));
|
||||
|
||||
let orders = await Self.rawSql(`
|
||||
SELECT a.id poiCode,
|
||||
t.id code,
|
||||
t.shipped date,
|
||||
'PEDIDO' operation,
|
||||
t.totalWithVat totalAmount,
|
||||
t.totalWithoutVat totalAmountWithoutTaxes,
|
||||
SUM(sv.volume) volume
|
||||
FROM ticket t
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
JOIN saleVolume sv ON sv.ticketFk = t.id
|
||||
WHERE t.id IN (?)
|
||||
GROUP BY t.id
|
||||
`, [tickets]);
|
||||
|
||||
// Transformo code en string ya que lo obtenermos como integer
|
||||
orders = orders.map(order => {
|
||||
return {
|
||||
...order,
|
||||
poiId: poiMap.get(order.poiCode.toString()) || undefined,
|
||||
code: order.code.toString(),
|
||||
date: moment(order.date).format('YYYY-MM-DD'),
|
||||
totalAmount: order.totalAmount || undefined,
|
||||
totalAmountWithoutTaxes: order.totalAmountWithoutTaxes || undefined,
|
||||
timeWindow: [{
|
||||
from: config.orderTimeFrom,
|
||||
to: config.orderTimeTo
|
||||
}],
|
||||
orderMeasures: [{
|
||||
constraintId: 3, // Volumen
|
||||
value: order.volume
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
await axios.post(`${config.url}orders`, orders, {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'X-Saas-Apikey': config.key
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
|
@ -0,0 +1,87 @@
|
|||
const axios = require('axios');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('sendPois', {
|
||||
description: 'Sends a set of pois',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'tickets',
|
||||
type: ['number'],
|
||||
required: true
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: 'string',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/sendPois`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
Self.sendPois = async tickets => {
|
||||
const config = await Self.app.models.QuadmindsApiConfig.findOne();
|
||||
if (!config) throw new UserError('Config params not set');
|
||||
|
||||
if (tickets.length > config.maxObjects)
|
||||
throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`);
|
||||
|
||||
let pois = await Self.rawSql(`
|
||||
WITH deliveryNotes AS (
|
||||
SELECT t.id, t.routeFk, tn.description
|
||||
FROM ticket t
|
||||
JOIN ticketObservation tn ON tn.ticketFk = t.id
|
||||
JOIN observationType ot ON ot.id = tn.observationTypeFk
|
||||
WHERE ot.code = 'delivery'
|
||||
)
|
||||
SELECT a.id code,
|
||||
c.socialName name,
|
||||
IF(ABS(a.latitude - ROUND(a.latitude)) < 0.000001, NULL, a.latitude) latitude,
|
||||
IF(ABS(a.longitude - ROUND(a.longitude)) < 0.000001, NULL, a.longitude) longitude,
|
||||
a.street,
|
||||
a.city locality,
|
||||
p.name state,
|
||||
co.name country,
|
||||
CONCAT_WS(', ', IFNULL(a.street, ''), IFNULL(a.city, ''), IFNULL(p.name, '')) longAddress,
|
||||
CONCAT(IFNULL(a.mobile, c.mobile)) phoneNumber,
|
||||
dn.description poiDeliveryComments,
|
||||
c.email email
|
||||
FROM ticket t
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
JOIN province p ON p.id = a.provinceFk
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
LEFT JOIN deliveryNotes dn ON dn.id = t.id
|
||||
WHERE t.id IN (?)
|
||||
GROUP BY t.id
|
||||
`, [tickets]);
|
||||
|
||||
// Transformo code en string ya que lo obtenermos como integer
|
||||
pois = pois.map(poi => {
|
||||
return {
|
||||
...poi,
|
||||
code: poi.code.toString(),
|
||||
latitude: poi.latitude || undefined,
|
||||
longitude: poi.longitude || undefined,
|
||||
address: {
|
||||
street: poi.street || undefined,
|
||||
locality: poi.locality || undefined,
|
||||
state: poi.state || undefined,
|
||||
country: poi.country || undefined
|
||||
},
|
||||
poiDeliveryComments: poi.poiDeliveryComments || undefined,
|
||||
phoneNumber: poi.phoneNumber || undefined,
|
||||
email: poi.email || undefined
|
||||
};
|
||||
});
|
||||
|
||||
await axios.post(`${config.url}pois`, pois, {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'X-Saas-Apikey': config.key
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
|
@ -1,22 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('getStarredModules()', () => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
const ctx = {req: activeCtx};
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it(`should return the starred modules for a given user`, async() => {
|
||||
const newStarred = await models.StarredModule.create({workerFk: 9, moduleFk: 'customer', position: 1});
|
||||
|
|
|
@ -1,24 +1,8 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('setPosition()', () => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
const ctx = {
|
||||
req: activeCtx
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should increase the orders module position by replacing it with clients and vice versa', async() => {
|
||||
const tx = await models.StarredModule.beginTransaction({});
|
||||
|
|
|
@ -1,24 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('toggleStarredModule()', () => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
const ctx = {
|
||||
req: activeCtx
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should create a new starred module and then remove it by calling the method again with same args', async() => {
|
||||
const starredModule = await models.StarredModule.toggleStarredModule(ctx, 'order');
|
||||
|
@ -26,7 +9,7 @@ describe('toggleStarredModule()', () => {
|
|||
|
||||
expect(starredModules.length).toEqual(1);
|
||||
expect(starredModule.moduleFk).toEqual('order');
|
||||
expect(starredModule.workerFk).toEqual(activeCtx.accessToken.userId);
|
||||
expect(starredModule.workerFk).toEqual(ctx.req.accessToken.userId);
|
||||
expect(starredModule.position).toEqual(starredModules.length);
|
||||
|
||||
await models.StarredModule.toggleStarredModule(ctx, 'order');
|
||||
|
|
|
@ -22,7 +22,7 @@ module.exports = Self => {
|
|||
const url = await Self.app.models.Url.findOne({
|
||||
where: {
|
||||
appName,
|
||||
environment: process.env.NODE_ENV || 'development'
|
||||
environment: process.env.NODE_ENV || 'dev'
|
||||
}
|
||||
});
|
||||
return url?.url;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('userConfig getUserConfig()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it(`should return the configuration data of a given user`, async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const result = await models.UserConfig.getUserConfig(ctx, options);
|
||||
|
||||
expect(result.warehouseFk).toEqual(1);
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.renderer = async (expeditionFk) => {
|
||||
Self.renderer = async expeditionFk => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const viaexpressConfig = await models.ViaexpressConfig.findOne({
|
||||
|
@ -109,7 +109,7 @@ module.exports = Self => {
|
|||
const ticket = expedition.ticket();
|
||||
const sender = ticket.company().client();
|
||||
const shipped = ticket.shipped.toISOString();
|
||||
const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk)
|
||||
const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk);
|
||||
const data = {
|
||||
viaexpressConfig,
|
||||
sender,
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('killSession', {
|
||||
description: 'Kill session',
|
||||
accepts: [{
|
||||
arg: 'userId',
|
||||
type: 'integer',
|
||||
description: 'The user id',
|
||||
required: true,
|
||||
}, {
|
||||
arg: 'created',
|
||||
type: 'date',
|
||||
description: 'The created time',
|
||||
required: true,
|
||||
}],
|
||||
accessType: 'WRITE',
|
||||
http: {
|
||||
path: `/killSession`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.killSession = async function(ctx, userId, created) {
|
||||
await Self.app.models.VnUser.userSecurity(ctx, ctx.req.accessToken.userId);
|
||||
const tokens = await Self.app.models.AccessToken.find({where: {userId, created}});
|
||||
if (!tokens?.length) return;
|
||||
for (const token of tokens)
|
||||
await Self.app.models.AccessToken.deleteById(token.id);
|
||||
};
|
||||
};
|
|
@ -16,36 +16,51 @@ module.exports = Self => {
|
|||
accessScopes: ['DEFAULT', 'read:multimedia']});
|
||||
|
||||
Self.renewToken = async function(ctx) {
|
||||
const {accessToken: token} = ctx.req;
|
||||
|
||||
const {courtesyTime} = await models.AccessTokenConfig.findOne({
|
||||
fields: ['courtesyTime']
|
||||
});
|
||||
const isNotExceeded = await Self.validateToken(ctx);
|
||||
if (isNotExceeded)
|
||||
return token;
|
||||
|
||||
// Schedule to remove current token
|
||||
setTimeout(async() => {
|
||||
try {
|
||||
const exists = await models.AccessToken.findById(token.id);
|
||||
exists && await Self.logout(token.id);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
}
|
||||
}, courtesyTime * 1000);
|
||||
|
||||
// Get scopes
|
||||
|
||||
let createTokenOptions = {};
|
||||
const {scopes} = token;
|
||||
if (scopes)
|
||||
createTokenOptions = {scopes: [scopes[0]]};
|
||||
// Create new accessToken
|
||||
const user = await Self.findById(token.userId);
|
||||
const accessToken = await user.accessTokens.create(createTokenOptions);
|
||||
let token; let isNotExceeded;
|
||||
try {
|
||||
token = ctx.req.accessToken;
|
||||
|
||||
return {id: accessToken.id, ttl: accessToken.ttl};
|
||||
const {courtesyTime} = await models.AccessTokenConfig.findOne({
|
||||
fields: ['courtesyTime']
|
||||
});
|
||||
isNotExceeded = await Self.validateToken(ctx);
|
||||
if (isNotExceeded)
|
||||
return token;
|
||||
|
||||
// Schedule to remove current token
|
||||
setTimeout(async() => {
|
||||
try {
|
||||
await Self.logout(token.id);
|
||||
} catch (error) {
|
||||
// FIXME: Crash if do throw new Error(error)
|
||||
}
|
||||
}, courtesyTime * 1000);
|
||||
|
||||
// Get scopes
|
||||
const {scopes} = token;
|
||||
if (scopes)
|
||||
createTokenOptions = {scopes: [scopes[0]]};
|
||||
// Create new accessToken
|
||||
const user = await Self.findById(token.userId);
|
||||
const accessToken = await user.accessTokens.create(createTokenOptions);
|
||||
|
||||
return {id: accessToken.id, ttl: accessToken.ttl};
|
||||
} catch (error) {
|
||||
const body = {
|
||||
error: error.message,
|
||||
userId: token?.userId ?? null,
|
||||
token: token?.id,
|
||||
scopes: token?.scopes,
|
||||
createTokenOptions,
|
||||
isNotExceeded
|
||||
};
|
||||
await handleError(JSON.stringify(body));
|
||||
throw new Error(error);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
async function handleError(body) {
|
||||
await models.Application.rawSql('CALL util.debugAdd(?,?);', ['renewToken', body]);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,9 @@ module.exports = Self => {
|
|||
if (vnUser.twoFactor === 'email') {
|
||||
const $ = Self.app.models;
|
||||
|
||||
const code = String(Math.floor(Math.random() * 999999));
|
||||
const min = 100000;
|
||||
const max = 999999;
|
||||
const code = String(Math.floor(Math.random() * (max - min + 1)) + min);
|
||||
const maxTTL = ((60 * 1000) * 5); // 5 min
|
||||
await $.AuthCode.upsertWithWhere({userFk: vnUser.id}, {
|
||||
userFk: vnUser.id,
|
||||
|
|
|
@ -61,4 +61,21 @@ describe('Renew Token', () => {
|
|||
expect(error).toBeUndefined();
|
||||
expect(response.id).toEqual(ctx.req.accessToken.id);
|
||||
});
|
||||
|
||||
it('throw error', async() => {
|
||||
let error;
|
||||
|
||||
try {
|
||||
await models.VnUser.renewToken({req: {token: null}});
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBeDefined();
|
||||
const query = 'SELECT * FROM util.debug';
|
||||
|
||||
const debugLog = await models.Application.rawSql(query, null);
|
||||
|
||||
expect(debugLog.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,6 +24,10 @@ module.exports = Self => {
|
|||
arg: 'lang',
|
||||
type: 'string',
|
||||
description: 'The user lang'
|
||||
}, {
|
||||
arg: 'twoFactor',
|
||||
type: 'any',
|
||||
description: 'The user twoFactor'
|
||||
}
|
||||
],
|
||||
http: {
|
||||
|
@ -32,8 +36,8 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.updateUser = async(ctx, id, name, nickname, email, lang) => {
|
||||
Self.updateUser = async(ctx, id, name, nickname, email, lang, twoFactor) => {
|
||||
await Self.userSecurity(ctx, id);
|
||||
await Self.upsertWithWhere({id}, {name, nickname, email, lang});
|
||||
await Self.upsertWithWhere({id}, {name, nickname, email, lang, twoFactor});
|
||||
};
|
||||
};
|
||||
|
|
|
@ -58,7 +58,7 @@ module.exports = Self => {
|
|||
fields: ['name', 'twoFactor']
|
||||
}, myOptions);
|
||||
|
||||
if (user.name !== username)
|
||||
if (user.name.toLowerCase() !== username.toLowerCase())
|
||||
throw new UserError('Authentication failed');
|
||||
|
||||
await authCode.destroy(myOptions);
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('add', {
|
||||
description: 'Add activity if the activity is different or is the same but have exceed time for break',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'code',
|
||||
type: 'string',
|
||||
description: 'Code for activity'
|
||||
},
|
||||
{
|
||||
arg: 'model',
|
||||
type: 'string',
|
||||
description: 'Origin model from insert'
|
||||
},
|
||||
|
||||
],
|
||||
http: {
|
||||
path: `/add`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.add = async(ctx, code, model, options) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
return await Self.rawSql(`
|
||||
INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model)
|
||||
SELECT ?, ?, ?
|
||||
FROM workerTimeControlParams wtcp
|
||||
LEFT JOIN (
|
||||
SELECT wa.workerFk,
|
||||
wa.created,
|
||||
wat.code
|
||||
FROM workerActivity wa
|
||||
LEFT JOIN workerActivityType wat ON wat.code = wa.workerActivityTypeFk
|
||||
WHERE wa.workerFk = ?
|
||||
ORDER BY wa.created DESC
|
||||
LIMIT 1
|
||||
) sub ON TRUE
|
||||
WHERE sub.workerFk IS NULL
|
||||
OR sub.code <> ?
|
||||
OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;`
|
||||
, [userId, code, model, userId, code], myOptions);
|
||||
};
|
||||
};
|
|
@ -0,0 +1,30 @@
|
|||
const {models} = require('vn-loopback');
|
||||
|
||||
describe('workerActivity insert()', () => {
|
||||
const ctx = beforeAll.getCtx(1106);
|
||||
|
||||
it('should insert in workerActivity', async() => {
|
||||
const tx = await models.WorkerActivity.beginTransaction({});
|
||||
let count = 0;
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
await models.WorkerActivityType.create(
|
||||
{'code': 'STOP', 'description': 'STOP'}, options
|
||||
);
|
||||
|
||||
await models.WorkerActivity.add(ctx, 'STOP', 'APP', options);
|
||||
|
||||
count = await models.WorkerActivity.count(
|
||||
{'workerFK': 1106}, options
|
||||
);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(count).toEqual(1);
|
||||
});
|
||||
});
|
|
@ -28,6 +28,9 @@
|
|||
"Company": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Config": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Continent": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -64,6 +67,9 @@
|
|||
"EmailUser": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Expedition_PrintOut": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Image": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -112,9 +118,15 @@
|
|||
"NotificationSubscription": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"OrmConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Province": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"QuadmindsApiConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Autonomy": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -166,6 +178,9 @@
|
|||
"ViaexpressConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"VnToken": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"VnUser": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -189,5 +204,8 @@
|
|||
},
|
||||
"RouteConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"MrwService": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ module.exports = Self => {
|
|||
require('../methods/collection/setSaleQuantity')(Self);
|
||||
require('../methods/collection/previousLabel')(Self);
|
||||
require('../methods/collection/getTickets')(Self);
|
||||
require('../methods/collection/assignCollection')(Self);
|
||||
require('../methods/collection/assign')(Self);
|
||||
require('../methods/collection/getSales')(Self);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "Config",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "config"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"inventoried": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -25,6 +25,9 @@
|
|||
},
|
||||
"isSocialNameUnique": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"continentFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -32,6 +35,11 @@
|
|||
"type": "belongsTo",
|
||||
"model": "Currency",
|
||||
"foreignKey": "currencyFk"
|
||||
},
|
||||
"continent": {
|
||||
"type": "belongsTo",
|
||||
"model": "Continent",
|
||||
"foreignKey": "continentFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "salix.defaultViewConfig"
|
||||
"table": "salix.defaultViewMultiConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
|
|
|
@ -16,17 +16,17 @@
|
|||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"cookie": {
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"expired":{
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"property": "*",
|
||||
"accessType": "*",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "Expedition_PrintOut",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "dipole.expedition_PrintOut"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"expeditionFk": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "id expeditionFk"
|
||||
},
|
||||
"itemFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"isChecked": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,60 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/mrw-config/createShipment')(Self);
|
||||
require('../methods/mrw-config/getLabel')(Self);
|
||||
require('../methods/mrw-config/cancelShipment')(Self);
|
||||
|
||||
const fs = require('fs');
|
||||
const ejs = require('ejs');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
const {DOMParser} = require('xmldom');
|
||||
const axios = require('axios');
|
||||
|
||||
Self.getConfig = async function() {
|
||||
const mrw = await Self.app.models.MrwConfig.findOne(null);
|
||||
if (!mrw) throw new UserError(`MRW service is not configured`);
|
||||
return mrw;
|
||||
};
|
||||
|
||||
Self.getTextByTag = function(xmlDoc, tag) {
|
||||
return xmlDoc?.getElementsByTagName(tag)[0]?.textContent;
|
||||
};
|
||||
|
||||
Self.sendXmlDoc = async function(path, params, contentType) {
|
||||
const parser = new DOMParser();
|
||||
|
||||
const xmlTemplate = fs.readFileSync(path, 'utf-8');
|
||||
const renderedTemplate = ejs.render(xmlTemplate, params);
|
||||
const data = await axios.post(params.mrw.url, renderedTemplate, {
|
||||
headers: {
|
||||
'Content-Type': `${contentType}; charset=utf-8`
|
||||
}
|
||||
});
|
||||
return parser.parseFromString(data.data, 'text/xml');
|
||||
};
|
||||
|
||||
Self.getClientType = async function(expeditionFk) {
|
||||
if (!expeditionFk) throw new UserError(`No expeditionFk defined`);
|
||||
|
||||
const {clientTypeWidth} = await Self.getConfig();
|
||||
const result = await Self.app.models.Expedition.findById(expeditionFk,
|
||||
{include: [{
|
||||
relation: 'ticket',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'agencyMode',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'mrwService',
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]}
|
||||
);
|
||||
const clientType = result?.ticket()?.agencyMode()?.mrwService()?.clientType;
|
||||
if (!clientType || !clientTypeWidth) throw new UserError(`ClientType not available`);
|
||||
|
||||
return clientType.toString().padStart(clientTypeWidth, '0');
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -39,6 +39,15 @@
|
|||
},
|
||||
"defaultWeight": {
|
||||
"type": "number"
|
||||
},
|
||||
"expeditionDeadLine": {
|
||||
"type": "string"
|
||||
},
|
||||
"notified":{
|
||||
"type": "date"
|
||||
},
|
||||
"clientTypeWidth": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "MrwService",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "mrwService"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"agencyModeCodeFk": {
|
||||
"id": true,
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"clientType": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"serviceType": {
|
||||
"type": "number"
|
||||
},
|
||||
"kg": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"agency": {
|
||||
"type": "hasOne",
|
||||
"model": "AgencyMode",
|
||||
"foreignKey": "code"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "OrmConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "ormConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"selectLimit": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "*",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -9,7 +9,8 @@
|
|||
"properties": {
|
||||
"code": {
|
||||
"id": true,
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -47,4 +48,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/quadminds-api-config/sendPois')(Self);
|
||||
require('../methods/quadminds-api-config/sendOrders')(Self);
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "QuadmindsApiConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "quadmindsApiConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"required": true
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"key": {
|
||||
"type": "string"
|
||||
},
|
||||
"maxObjects": {
|
||||
"type": "number"
|
||||
},
|
||||
"limit": {
|
||||
"type": "number"
|
||||
},
|
||||
"orderTimeFrom": {
|
||||
"type": "string"
|
||||
},
|
||||
"orderTimeTo": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('loopback model MailAliasAccount', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should add a mail Alias', async() => {
|
||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||
let error;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
||||
const options = {transaction: tx, ctx};
|
||||
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
||||
|
||||
await tx.rollback();
|
||||
|
@ -23,7 +24,7 @@ describe('loopback model MailAliasAccount', () => {
|
|||
let error;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
||||
const options = {transaction: tx, ctx};
|
||||
await models.MailAliasAccount.create({mailAlias: 3, account: 5}, options);
|
||||
|
||||
await tx.rollback();
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
"type": "number"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -54,4 +55,4 @@
|
|||
"fields": ["id", "name", "provinceFk"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "userConfig"
|
||||
"table": "userMultiConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
const vnModel = require('vn-loopback/common/models/vn-model');
|
||||
module.exports = function(Self) {
|
||||
vnModel(Self);
|
||||
require('../methods/vn-token/killSession')(Self);
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "VnToken",
|
||||
"base": "AccessToken",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "salix.AccessToken"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"created": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userId"
|
||||
}
|
||||
},
|
||||
"hidden": ["id"]
|
||||
}
|
|
@ -101,9 +101,10 @@ module.exports = function(Self) {
|
|||
const headers = httpRequest.headers;
|
||||
const origin = headers.origin;
|
||||
|
||||
const defaultHash = '/reset-password?access_token=$token$';
|
||||
const defaultHash = '!/reset-password?access_token=$token$';
|
||||
const recoverHashes = {
|
||||
hedera: 'verificationToken=$token$'
|
||||
hedera: '!verificationToken=$token$',
|
||||
lilium: '/resetPassword?access_token=$token$'
|
||||
};
|
||||
|
||||
const app = info.options?.app;
|
||||
|
@ -115,7 +116,7 @@ module.exports = function(Self) {
|
|||
const params = {
|
||||
recipient: info.email,
|
||||
lang: user.lang,
|
||||
url: origin + '/#!' + recoverHash
|
||||
url: origin + '/#' + recoverHash
|
||||
};
|
||||
|
||||
const options = Object.assign({}, info.options);
|
||||
|
|
|
@ -165,7 +165,8 @@
|
|||
"hasGrant",
|
||||
"realm",
|
||||
"email",
|
||||
"emailVerified"
|
||||
"emailVerified",
|
||||
"twoFactor"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,21 +9,39 @@
|
|||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
"type": "string"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
"type": "string"
|
||||
},
|
||||
"isInventory": {
|
||||
"type": "number"
|
||||
"type": "number"
|
||||
},
|
||||
"isManaged":{
|
||||
"type": "boolean"
|
||||
"isManaged": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isDestiny": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"countryFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"country": {
|
||||
"type": "belongsTo",
|
||||
"model": "Country",
|
||||
"foreignKey": "countryFk"
|
||||
},
|
||||
"address": {
|
||||
"type": "belongsTo",
|
||||
"model": "Address",
|
||||
"foreignKey": "addressFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
@ -34,5 +52,11 @@
|
|||
"permission": "ALLOW"
|
||||
}
|
||||
],
|
||||
"scope" : {"where": {"isForTicket": {"neq": 0}}}
|
||||
"scope": {
|
||||
"where": {
|
||||
"isForTicket": {
|
||||
"neq": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/workerActivity/add')(Self);
|
||||
};
|
|
@ -22,18 +22,18 @@
|
|||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"workerFk": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"relations": {
|
||||
"workerFk": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"workerActivityTypeFk": {
|
||||
"type": "belongsTo",
|
||||
"model": "WorkerActivityType",
|
||||
"foreignKey": "workerActivityTypeFk"
|
||||
}
|
||||
"workerActivityTypeFk": {
|
||||
"type": "belongsTo",
|
||||
"model": "WorkerActivityType",
|
||||
"foreignKey": "workerActivityTypeFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,6 @@ apps:
|
|||
- script: ./loopback/server/server.js
|
||||
name: salix-back
|
||||
instances: 1
|
||||
max_restarts: 3
|
||||
restart_delay: 15000
|
||||
max_restarts: 0
|
||||
autorestart: false
|
||||
node_args: --tls-min-v1.0 --openssl-legacy-provider
|
||||
|
|
|
@ -10,7 +10,6 @@ async function init() {
|
|||
host: process.env.DB_HOST,
|
||||
port: process.env.DB_PORT
|
||||
});
|
||||
|
||||
const bootOptions = {dataSources};
|
||||
await new Promise((resolve, reject) => {
|
||||
app.boot(bootOptions,
|
||||
|
@ -33,3 +32,4 @@ module.exports = {
|
|||
|
||||
if (require.main === module)
|
||||
init();
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ async function test() {
|
|||
'loopback/**/*[sS]pec.js',
|
||||
'modules/*/back/**/*.[sS]pec.js'
|
||||
],
|
||||
helpers: []
|
||||
helpers: [`back/vn-jasmine.js`],
|
||||
};
|
||||
|
||||
if (PARALLEL) {
|
||||
|
@ -114,7 +114,6 @@ async function test() {
|
|||
if (opts.ci)
|
||||
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = SPEC_TIMEOUT;
|
||||
|
||||
// runner.loadConfigFile('back/jasmine.json');
|
||||
runner.loadConfig(config);
|
||||
process.env.SPEC_IS_RUNNING = true;
|
||||
await runner.execute();
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const getAccessToken = (userId = 9) => {
|
||||
return {accessToken: {userId}};
|
||||
};
|
||||
const DEFAULT_HEADERS = {headers: {origin: 'http://localhost'}};
|
||||
const default_before_all = userId => {
|
||||
return {
|
||||
req: {
|
||||
...getAccessToken(userId),
|
||||
...DEFAULT_HEADERS,
|
||||
...{__: value => value}
|
||||
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
};
|
||||
const default_loopback_ctx = userId => {
|
||||
return {
|
||||
...getAccessToken(userId),
|
||||
...default_before_all(userId),
|
||||
http: {
|
||||
...default_before_all(userId)
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
};
|
||||
|
||||
function vnBeforeAll() {
|
||||
Object.assign(beforeAll, {getCtx: default_before_all, mockLoopBackContext});
|
||||
}
|
||||
|
||||
const mockLoopBackContext = userId => {
|
||||
const activeCtx = default_loopback_ctx(userId);
|
||||
beforeAll(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
return activeCtx;
|
||||
};
|
||||
module.exports = {
|
||||
mockLoopBackContext
|
||||
};
|
||||
|
||||
(function init() {
|
||||
vnBeforeAll();
|
||||
})();
|
|
@ -9,7 +9,7 @@
|
|||
},
|
||||
"vn": {
|
||||
"view": {
|
||||
"expeditionPallet_Print": "ced2b84a114fcb99fce05f0c34f4fc03f3fa387bef92621be1bc306608a84345"
|
||||
"expeditionPallet_Print": "99f75145ac2e7b612a6d71e74b6e55f194a465780fd9875a15eb01e6596b447e"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1 +1,14 @@
|
|||
-- Executed before dump
|
||||
|
||||
CREATE USER 'vn'@'localhost';
|
||||
|
||||
GRANT SELECT,
|
||||
INSERT,
|
||||
UPDATE,
|
||||
DELETE,
|
||||
DROP,
|
||||
CREATE TEMPORARY TABLES,
|
||||
EXECUTE,
|
||||
EVENT,
|
||||
TRIGGER
|
||||
ON *.* TO 'vn'@'localhost';
|
||||
|
|
|
@ -10,9 +10,6 @@ SET foreign_key_checks = 0;
|
|||
INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled)
|
||||
VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
|
||||
|
||||
INSERT INTO util.binlogQueue (code,logName, `position`)
|
||||
VALUES ('mylogger', 'bin.000001', 4);
|
||||
|
||||
/* #5483
|
||||
INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk)
|
||||
VALUES(1, NULL, 1, 300, 1);
|
||||
|
@ -314,5 +311,4 @@ INSERT INTO mysql.roles_mapping (`User`, `Host`, `Role`, `Admin_option`)
|
|||
SELECT SUBSTR(`User`, @prefixLen + 1), `Host`, `Role`, `Admin_option`
|
||||
FROM mysql.roles_mapping
|
||||
WHERE `User` LIKE @prefixedLike AND `Host` = @genRoleHost;
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
|
|
|
@ -108,6 +108,7 @@ INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
|
|||
UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20;
|
||||
UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9;
|
||||
UPDATE `vn`.`worker` SET bossFk = 19 WHERE id = 18;
|
||||
UPDATE `vn`.`worker` SET bossFk = 50 WHERE id = 49;
|
||||
|
||||
DELETE FROM `vn`.`worker` WHERE firstName ='customer';
|
||||
|
||||
|
@ -115,10 +116,13 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType`
|
|||
VALUES
|
||||
(1, 978, 1, 0, 2000, 9, 0);
|
||||
|
||||
INSERT INTO hedera.orderConfig (`id`, `employeeFk`, `defaultAgencyFk`, `guestMethod`, `guestAgencyFk`, `reserveTime`, `defaultCompanyFk`)
|
||||
VALUES (1, 1, 2, 'PICKUP', 1, '00:20:00', 442);
|
||||
|
||||
INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`)
|
||||
VALUES
|
||||
(1101, 'brucewayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es','1101'),
|
||||
(1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en','1102'),
|
||||
(1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 131, 1, 'PetterParker@mydomain.com', 'en','1102'),
|
||||
(1103, 'clarkkent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr','1103'),
|
||||
(1104, 'tonystark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es','1104'),
|
||||
(1105, 'maxeisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt','1105'),
|
||||
|
@ -301,6 +305,17 @@ UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 8;
|
|||
UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 4 WHERE `id` = 23;
|
||||
UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 10;
|
||||
|
||||
UPDATE `vn`.`agencyMode` SET `description` = 'inhouse pickup' WHERE `id` = 1;
|
||||
UPDATE `vn`.`agencyMode` SET `description` = 'Super-Man delivery' WHERE `id` = 2;
|
||||
UPDATE `vn`.`agencyMode` SET `description` = 'Teleportation device' WHERE `id` = 3;
|
||||
UPDATE `vn`.`agencyMode` SET `description` = 'Entanglement' WHERE `id` = 4;
|
||||
UPDATE `vn`.`agencyMode` SET `description` = 'Quantum break device' WHERE `id` = 5;
|
||||
UPDATE `vn`.`agencyMode` SET `description` = 'Walking' WHERE `id` = 6;
|
||||
UPDATE `vn`.`agencyMode` SET `description` = 'Gotham247' WHERE `id` = 7;
|
||||
UPDATE `vn`.`agencyMode` SET `description` = 'Gotham247Expensive' WHERE `id` = 8;
|
||||
UPDATE `vn`.`agencyMode` SET `description` = 'Other agency' WHERE `id` = 10;
|
||||
UPDATE `vn`.`agencyMode` SET `description` = 'Refund' WHERE `id` = 23;
|
||||
|
||||
UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com';
|
||||
|
||||
UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23;
|
||||
|
@ -320,21 +335,21 @@ INSERT INTO `vn`.`payDem`(`id`, `payDem`)
|
|||
(2, 20),
|
||||
(7, 0);
|
||||
|
||||
INSERT INTO `vn`.`autonomy`(`id`, `name`, `countryFk`)
|
||||
INSERT INTO `vn`.`autonomy`(`id`, `name`, `countryFk`, `hasDailyInvoice`)
|
||||
VALUES
|
||||
(1, 'Autonomy one', 1),
|
||||
(2, 'Autonomy two', 1),
|
||||
(3, 'Autonomy three', 2),
|
||||
(4, 'Autonomy four', 13);
|
||||
(1, 'Autonomy one', 1, 1),
|
||||
(2, 'Autonomy two', 1, 0),
|
||||
(3, 'Autonomy three', 2, 0),
|
||||
(4, 'Autonomy four', 13, 0);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`province`(`id`, `name`, `countryFk`, `autonomyFk`, `warehouseFk`)
|
||||
VALUES
|
||||
(1, 'Province one', 1, 1, NULL),
|
||||
(2, 'Province two', 1, 1, NULL),
|
||||
(3, 'Province three', 30, 2, NULL),
|
||||
(4, 'Province four', 2, 3, NULL),
|
||||
(5, 'Province five', 13, 4, NULL);
|
||||
(1, 'Province one', 1, 1, NULL),
|
||||
(2, 'Province two', 1, 1, NULL),
|
||||
(3, 'Province three', 30, 2, NULL),
|
||||
(4, 'Province four', 2, 3, NULL),
|
||||
(5, 'Province five', 13, 4, NULL);
|
||||
|
||||
INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`)
|
||||
VALUES
|
||||
|
@ -350,6 +365,7 @@ INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`)
|
|||
('46460', 2, 6),
|
||||
('46680', 3, 6),
|
||||
('46600', 4, 7),
|
||||
('46600',1, 6),
|
||||
('EC170150', 5, 8);
|
||||
|
||||
INSERT INTO `vn`.`clientType`(`code`, `type`)
|
||||
|
@ -382,7 +398,7 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
|
|||
(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, 0, 0, NULL, 0, 0, 19, 0, 'florist','normal'),
|
||||
(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, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 'florist','normal'),
|
||||
(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, 0, 0, NULL, 0, 0, 9, 0, 'florist','normal'),
|
||||
(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, 0, 0, NULL, 0, 0, NULL, 0, 'florist','normal'),
|
||||
(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, 0, NULL, 0, 0, NULL, 1, 'florist','normal'),
|
||||
(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', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'),
|
||||
(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', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses');
|
||||
|
||||
|
@ -398,7 +414,7 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`)
|
|||
(1103, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
||||
(1104, -30, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH));
|
||||
|
||||
INSERT INTO `vn`.`mandateType`(`id`, `name`)
|
||||
INSERT INTO `vn`.`mandateType`(`id`, `code`)
|
||||
VALUES
|
||||
(1, 'B2B'),
|
||||
(2, 'CORE'),
|
||||
|
@ -528,7 +544,8 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`)
|
|||
(5, 'Administrative', 'administrative'),
|
||||
(6, 'Weight', 'weight'),
|
||||
(7, 'InvoiceOut', 'invoiceOut'),
|
||||
(8, 'DropOff', 'dropOff');
|
||||
(8, 'DropOff', 'dropOff'),
|
||||
(9, 'Sustitución', 'substitution');
|
||||
|
||||
INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`)
|
||||
VALUES
|
||||
|
@ -567,6 +584,7 @@ INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`
|
|||
VALUES
|
||||
(1, 'PLANTS SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'GOTHAM', 1, 46000, 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, 46000, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
||||
(4, 'INVENTARIO', 'INVENTARIO', 4000000004, NULL, NULL, 0, util.VN_CURDATE(), 1, NULL, NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL, NULL),
|
||||
(69, 'PACKAGING', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
|
||||
(442, 'VERDNATURA LEVANTE SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 46000, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'),
|
||||
(567, 'HOLLAND', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
||||
|
@ -617,7 +635,7 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF
|
|||
('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'),
|
||||
('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'),
|
||||
('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'),
|
||||
('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'quick'),
|
||||
('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'multiple'),
|
||||
('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL),
|
||||
('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick');
|
||||
|
||||
|
@ -728,45 +746,45 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen
|
|||
(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`, `weight`, `cmrFk`)
|
||||
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`, `problem`, `risk`)
|
||||
VALUES
|
||||
(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, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1),
|
||||
(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), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2),
|
||||
(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, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3),
|
||||
(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, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL),
|
||||
(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, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL),
|
||||
(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, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(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), NULL, NULL),
|
||||
(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), NULL, NULL),
|
||||
(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), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(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(), NULL, NULL),
|
||||
(27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(28, 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(), NULL, NULL),
|
||||
(29, 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(), NULL, NULL),
|
||||
(30, 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(), NULL, NULL),
|
||||
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(33, 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(), NULL, NULL),
|
||||
(34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
|
||||
(35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
|
||||
(36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
|
||||
(37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL);
|
||||
(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, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'hasHighRisk', 901.4),
|
||||
(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), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'hasHighRisk', 901.4),
|
||||
(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, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3, NULL, NULL),
|
||||
(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, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL, NULL, NULL),
|
||||
(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, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL, NULL, NULL),
|
||||
(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, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, NULL, 'hasHighRisk', 901.4),
|
||||
(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(), NULL, NULL, 'hasHighRisk', 901.4),
|
||||
(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(), NULL, NULL, 'hasHighRisk', 901.4),
|
||||
(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(), NULL, NULL, NULL, NULL),
|
||||
(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(), NULL, NULL, 'isTooLittle', NULL),
|
||||
(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(), NULL, NULL, 'hasTicketRequest', NULL),
|
||||
(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(), NULL, NULL, NULL, NULL),
|
||||
(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(), NULL, NULL, NULL, NULL),
|
||||
(14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
|
||||
(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(), NULL, NULL, 'isFreezed', NULL),
|
||||
(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(), NULL, NULL, NULL, 388.7),
|
||||
(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(), NULL, NULL, NULL, 388.7),
|
||||
(18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL, 'isFreezed', NULL),
|
||||
(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(), NULL, NULL, 'isTaxDataChecked', NULL),
|
||||
(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), NULL, NULL, 'isTaxDataChecked', NULL),
|
||||
(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), NULL, NULL, 'isTaxDataChecked', NULL),
|
||||
(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), NULL, NULL, 'isTaxDataChecked', NULL),
|
||||
(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(), NULL, NULL, 'hasTicketRequest, hasHighRisk', 901.4),
|
||||
(24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
|
||||
(25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
|
||||
(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(), NULL, NULL, 'hasHighRisk', 901.4),
|
||||
(27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 901.4),
|
||||
(28, 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(), NULL, NULL, NULL, NULL),
|
||||
(29, 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(), NULL, NULL, NULL, NULL),
|
||||
(30, 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(), NULL, NULL, NULL, NULL),
|
||||
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
|
||||
(32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
|
||||
(33, 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(), NULL, NULL, NULL, NULL),
|
||||
(34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
|
||||
(35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
|
||||
(36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
|
||||
(37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
|
||||
VALUES
|
||||
|
@ -804,10 +822,10 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
|
|||
(12, 3, 19, util.VN_NOW()),
|
||||
(13, 3, 19, util.VN_NOW()),
|
||||
(14, 3, 19, util.VN_NOW()),
|
||||
(15, 2, 19, util.VN_NOW()),
|
||||
(15, 10, 19, util.VN_NOW()),
|
||||
(16, 3, 19, util.VN_NOW()),
|
||||
(17, 2, 19, util.VN_NOW()),
|
||||
(18, 2, 19, util.VN_NOW()),
|
||||
(37, 10, 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)),
|
||||
|
@ -839,9 +857,9 @@ INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`,
|
|||
INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
|
||||
VALUES
|
||||
(1, 'Diff', 'diff'),
|
||||
(2, 'Recover', 'recover'),
|
||||
(2, 'Recovery', 'recovery'),
|
||||
(3, 'Mana', 'mana'),
|
||||
(4, 'Reclaim', 'reclaim'),
|
||||
(4, 'Claim', 'claim'),
|
||||
(5, 'Heritage', 'heritage'),
|
||||
(6, 'Miscellaneous', 'miscellaneous'),
|
||||
(7, 'Freight Pickup', 'freightPickUp');
|
||||
|
@ -978,6 +996,14 @@ INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`
|
|||
(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`.`itemMinimumQuantity`(`itemFk`, `quantity`, `started`, `ended`, `warehouseFk`)
|
||||
VALUES
|
||||
(1, 5, util.VN_CURDATE() - INTERVAL 2 MONTH, util.VN_CURDATE() + INTERVAL 1 MONTH, 1),
|
||||
(2, 10, util.VN_CURDATE() - INTERVAL 2 DAY, util.VN_CURDATE() - INTERVAL 1 DAY, 2),
|
||||
(3, 15, util.VN_CURDATE() + INTERVAL 3 DAY, util.VN_CURDATE() + INTERVAL 2 WEEK, 3),
|
||||
(2, 10, util.VN_CURDATE() + INTERVAL 2 MONTH, NULL, 5),
|
||||
(4, 8, util.VN_CURDATE() - INTERVAL 3 MONTH, NULL, NULL);
|
||||
|
||||
INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`)
|
||||
VALUES
|
||||
(71,0.141,1);
|
||||
|
@ -1006,19 +1032,20 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
|
|||
|
||||
INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `freightItemFk`, `created`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`, `hostFk`)
|
||||
VALUES
|
||||
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, 'UR9000006041', 94, 1, 'pc1'),
|
||||
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 18, 'UR9000006041', 94, 1, NULL),
|
||||
(3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 18, 'UR9000006041', 94, 2, NULL),
|
||||
(4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 18, 'UR9000006041', 94, 2, NULL),
|
||||
(5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 3, NULL),
|
||||
(6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 18, NULL, 94, 3, NULL),
|
||||
(7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 18, NULL, 94, NULL,NULL),
|
||||
(8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 18, NULL, 94, 1, NULL),
|
||||
(9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 2, NULL),
|
||||
(10, 7, 7, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
|
||||
(11, 7, 8, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
|
||||
(12, 7, 9, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
|
||||
(13, 1, 10,71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL);
|
||||
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, 'UR9000006041', 94, 1, 'pc1'),
|
||||
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 18, 'UR9000006041', 94, 1, NULL),
|
||||
(3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 18, 'UR9000006041', 94, 2, NULL),
|
||||
(4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 18, 'UR9000006041', 94, 2, NULL),
|
||||
(5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 3, NULL),
|
||||
(6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 18, NULL, 94, 3, NULL),
|
||||
(7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 18, NULL, 94, NULL,NULL),
|
||||
(8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 18, NULL, 94, 1, NULL),
|
||||
(9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 2, NULL),
|
||||
(10, 7, 7, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
|
||||
(11, 7, 8, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
|
||||
(12, 7, 9, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
|
||||
(13, 1, 10, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL),
|
||||
(14, 1, 37, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`)
|
||||
|
@ -1036,50 +1063,50 @@ INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`,
|
|||
(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`)
|
||||
INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`, `problem`)
|
||||
VALUES
|
||||
(1, 1, 1, 'Ranged weapon longbow 200cm', 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 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
||||
(4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
||||
(5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
||||
(6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
|
||||
(7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE()),
|
||||
(8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE()),
|
||||
(9, 1, 16, 'Ranged weapon longbow 200cm', 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 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()),
|
||||
(12, 4, 16, 'Melee weapon heavy shield 100cm', 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 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()),
|
||||
(15, 1, 19, 'Ranged weapon longbow 200cm', 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 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
|
||||
(19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)),
|
||||
(20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)),
|
||||
(21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
|
||||
(22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
|
||||
(23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
|
||||
(24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()),
|
||||
(25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(30, 4, 18, 'Melee weapon heavy shield 100cm', 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 200cm', -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()),
|
||||
(34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
|
||||
(39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()),
|
||||
(40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE()),
|
||||
(41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE()),
|
||||
(42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE());
|
||||
(1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'),
|
||||
(2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'),
|
||||
(3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'),
|
||||
(4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'),
|
||||
(5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'),
|
||||
(6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 'hasComponentLack'),
|
||||
(7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'),
|
||||
(18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'),
|
||||
(19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 'hasComponentLack'),
|
||||
(20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 'hasComponentLack'),
|
||||
(21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'),
|
||||
(22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), NULL),
|
||||
(36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'),
|
||||
(39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'),
|
||||
(42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack');
|
||||
|
||||
INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
|
||||
VALUES
|
||||
|
@ -1453,7 +1480,8 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
|
|||
(2, 1),
|
||||
(3, 2),
|
||||
(5, 6),
|
||||
(15, 6);
|
||||
(15, 6),
|
||||
(17, 6);
|
||||
|
||||
INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk)
|
||||
VALUES
|
||||
|
@ -1477,7 +1505,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO
|
|||
(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, 5),
|
||||
(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, 6),
|
||||
(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, 7),
|
||||
(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, 10);
|
||||
(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, 10),
|
||||
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10);
|
||||
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
|
||||
VALUES
|
||||
|
@ -1488,25 +1517,30 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
|
|||
(5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five'),
|
||||
(6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six'),
|
||||
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'),
|
||||
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, '');
|
||||
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''),
|
||||
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''),
|
||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, '');
|
||||
|
||||
INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`)
|
||||
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
|
||||
VALUES (2, 4, 1);
|
||||
|
||||
INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWasteQuantity`, `saleExternalWaste`, `saleFaultWaste`, `saleContainerWaste`, `saleBreakWaste`, `saleOtherWaste`)
|
||||
VALUES
|
||||
('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');
|
||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 1, 1, '1062', '51', '56.20', '56.20', '56.20', '56.20', '56.20'),
|
||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '35074', '687', '53.12', '89.69', '56.20', '56.20', '56.20'),
|
||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '1777', '13', '12.02', '53.12', '56.20', '56.20', '56.20'),
|
||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '3182', '59', '51', '56.20', '56.20', '56.20', '56.20'),
|
||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '1747', '13', '53.12', '53.12', '56.20', '56.20', '56.20'),
|
||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '7182', '59', '51', '53.12', '56.20', '56.20', '56.20'),
|
||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '1777', '13', '89.69', '89.69', '56.20', '56.20', '56.20'),
|
||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 8, 1, '4181', '59', '53.12', '53.12', '56.20', '56.20', '56.20'),
|
||||
('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 9, 1, '7268', '59', '12.02', '56.20', '56.20', '56.20', '56.20'),
|
||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '-74', '0', '51', '89.69', '56.20', '56.20', '56.20'),
|
||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '-7', '0', '12.02', '53.12', '56.20', '56.20', '56.20'),
|
||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '1100', '0', '51', '56.20', '56.20', '56.20', '56.20'),
|
||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '848', '-187', '12.02', '89.69', '56.20', '56.20', '56.20'),
|
||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12', '56.20', '56.20', '56.20'),
|
||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20', '56.20', '56.20', '56.20');
|
||||
|
||||
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
||||
VALUES
|
||||
|
@ -1885,9 +1919,9 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina
|
|||
(1, 31, 4, 21, 2),
|
||||
(2, 32, 3, 21, 3);
|
||||
|
||||
INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`)
|
||||
INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`, `monthsToRefund`, `minShipped`)
|
||||
VALUES
|
||||
(1, 50);
|
||||
(1, 5, 4, '2016-10-01');
|
||||
|
||||
INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`)
|
||||
VALUES
|
||||
|
@ -1942,7 +1976,7 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`)
|
|||
(21, 21),
|
||||
(22, 22);
|
||||
|
||||
INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`)
|
||||
INSERT INTO `vn`.`userMultiConfig` (`userFk`, `warehouseFk`, `companyFk`)
|
||||
VALUES
|
||||
(1, 1, 69),
|
||||
(5, 1, 442),
|
||||
|
@ -2457,7 +2491,7 @@ INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`)
|
|||
(1104, 2),
|
||||
(1104, 3);
|
||||
|
||||
INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker`)
|
||||
INSERT INTO `vn`.`workerDms`(`id`, `workerFk`, `dmsFk`,`isReadableByWorker`)
|
||||
VALUES
|
||||
(1, 1106, 4, TRUE),
|
||||
(2, 1107, 3, FALSE);
|
||||
|
@ -2542,18 +2576,18 @@ INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate
|
|||
(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25),
|
||||
(util.VN_CURDATE(), 1, 12, 17, 22, 27);
|
||||
|
||||
INSERT INTO `vn`.`dua` (id, code, awbFk__, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk)
|
||||
INSERT INTO `vn`.`dua` (id, code, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk)
|
||||
VALUES
|
||||
(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);
|
||||
(1, '19ES0028013A481523', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442),
|
||||
(2, '21ES00280136115760', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442),
|
||||
(3, '19ES00280131956004', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442),
|
||||
(4, '19ES00280131955995', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 8242.50, 442),
|
||||
(5, '19ES00280132022070', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 10012.49, 442),
|
||||
(6, '19ES00280132032308', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 19914.25, 442),
|
||||
(7, '19ES00280132025489', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1934.06, 442),
|
||||
(8, '19ES00280132025490', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 3618.52, 442),
|
||||
(9, '19ES00280132025491', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 7126.23, 442),
|
||||
(10, '19ES00280132025492', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 4631.45, 442);
|
||||
|
||||
INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroValue`)
|
||||
VALUES
|
||||
|
@ -2868,7 +2902,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`)
|
|||
(5, 'modified-entry', 'An entry has been modified'),
|
||||
(6, 'book-entry-deleted', 'accounting entries deleted'),
|
||||
(7, 'zone-included','An email to notify zoneCollisions'),
|
||||
(8, 'backup-printer-selected','A backup printer has been selected');
|
||||
(8, 'backup-printer-selected','A backup printer has been selected'),
|
||||
(9, 'mrw-deadline','The MRW deadline has passed');
|
||||
|
||||
TRUNCATE `util`.`notificationAcl`;
|
||||
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
||||
|
@ -2881,7 +2916,8 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
|||
(5, 9),
|
||||
(6, 9),
|
||||
(7, 9),
|
||||
(8, 66);
|
||||
(8, 66),
|
||||
(9, 56);
|
||||
|
||||
TRUNCATE `util`.`notificationQueue`;
|
||||
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
|
||||
|
@ -3024,9 +3060,6 @@ INSERT INTO `vn`.`workerTimeControlMail` (`id`, `workerFk`, `year`, `week`, `sta
|
|||
(3, 9, 2000, 51, 'CONFIRMED', util.VN_NOW(), 1, NULL),
|
||||
(4, 9, 2001, 1, 'SENDED', util.VN_NOW(), 1, NULL);
|
||||
|
||||
INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`)
|
||||
VALUES
|
||||
(1, 1350, 1900, 200, 50, 6);
|
||||
|
||||
INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`)
|
||||
VALUES
|
||||
|
@ -3035,15 +3068,19 @@ INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`)
|
|||
(3, 'green', '#00ff00'),
|
||||
(4, 'blue', '#0000ff');
|
||||
|
||||
INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`, `defaultTrayColorFk`)
|
||||
VALUES
|
||||
(1, 1350, 1900, 200, 50, 6, 1);
|
||||
|
||||
INSERT INTO `vn`.`wagonType` (`id`, `name`, `divisible`)
|
||||
VALUES
|
||||
(1, 'Wagon Type #1', 1);
|
||||
|
||||
INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`)
|
||||
INSERT INTO `vn`.`wagonTypeTray` (`id`, `wagonTypeFk`, `height`, `wagonTypeColorFk`)
|
||||
VALUES
|
||||
(1, 1, 100, 1),
|
||||
(1, 1, 0, 1),
|
||||
(2, 1, 50, 2),
|
||||
(3, 1, 0, 3);
|
||||
(3, 1, 100, 3);
|
||||
|
||||
INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `courtesyTime`, `renewInterval`)
|
||||
VALUES
|
||||
|
@ -3147,7 +3184,7 @@ UPDATE vn.department
|
|||
SET workerFk = null;
|
||||
|
||||
INSERT INTO vn.packaging
|
||||
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0);
|
||||
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0,1);
|
||||
|
||||
|
||||
INSERT IGNORE INTO vn.intrastat
|
||||
|
@ -3230,7 +3267,6 @@ INSERT IGNORE INTO vn.itemType
|
|||
workerFk = 103,
|
||||
isInventory = TRUE,
|
||||
life = 10,
|
||||
density = 250,
|
||||
itemPackingTypeFk = NULL,
|
||||
temperatureFk = 'warm';
|
||||
|
||||
|
@ -3845,6 +3881,13 @@ INSERT INTO `vn`.`ledgerCompany` SET
|
|||
INSERT INTO `vn`.`ledgerConfig` SET
|
||||
maxTolerance = 0.01;
|
||||
|
||||
|
||||
INSERT INTO vn.trainingCourse (workerFk,trainingCourseTypeFk,centerFk,started,ended,hasDiscount,hasDiploma)
|
||||
VALUES
|
||||
(9,2,1,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',0,1),
|
||||
(9,1,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,0),
|
||||
(9,2,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,1);
|
||||
|
||||
INSERT INTO vn.sectorCollection
|
||||
SET id = 2,
|
||||
userFk = 18,
|
||||
|
@ -3882,3 +3925,54 @@ INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHoli
|
|||
(1, '2001-05-17', 1, 5),
|
||||
(1, '2001-05-18', 1, 5);
|
||||
|
||||
INSERT INTO vn.medicalReview
|
||||
(id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark)
|
||||
VALUES(1, 1106, 1, '2000-01-01', '08:10', 1, 200.0, NULL, '');
|
||||
INSERT INTO vn.medicalReview
|
||||
(id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark)
|
||||
VALUES(2, 1106, 2, '2001-01-01', '09:10', 0, 10.0, NULL, NULL);
|
||||
INSERT INTO vn.medicalReview
|
||||
(id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark)
|
||||
VALUES(3, 9, 2, '2000-01-01', '8:00', 1, 150.0, NULL, NULL);
|
||||
|
||||
INSERT INTO vn.payrollComponent
|
||||
(id, name, isSalaryAgreed, isVariable, isException)
|
||||
VALUES
|
||||
(1, 'Salario1', 1, 0, 0),
|
||||
(2, 'Salario2', 1, 1, 0),
|
||||
(3, 'Salario3', 1, 0, 1);
|
||||
|
||||
|
||||
INSERT INTO vn.workerIncome
|
||||
(debit, credit, incomeTypeFk, paymentDate, workerFk, concept)
|
||||
VALUES
|
||||
(1000.00, 900.00, 2, '2000-01-01', 1106, NULL),
|
||||
(1001.00, 800.00, 2, '2000-01-01', 1106, NULL);
|
||||
|
||||
|
||||
INSERT INTO dipole.printer (id, description)
|
||||
VALUES(1, '');
|
||||
|
||||
INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode,
|
||||
truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments)
|
||||
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL);
|
||||
|
||||
INSERT INTO vn.accountDetail
|
||||
(id, value, accountDetailTypeFk, supplierAccountFk)
|
||||
VALUES
|
||||
(21, 'ES12345B12345678', 3, 241),
|
||||
(35, 'ES12346B12345679', 3, 241);
|
||||
|
||||
INSERT INTO vn.accountDetailType
|
||||
(id, description, code)
|
||||
VALUES
|
||||
(1, 'IBAN', 'iban'),
|
||||
(2, 'SWIFT', 'swift'),
|
||||
(3, 'Referencia Remesas', 'remRef'),
|
||||
(4, 'Referencia Transferencias', 'trnRef'),
|
||||
(5, 'Referencia Nominas', 'payRef'),
|
||||
(6, 'ABA', 'aba');
|
||||
|
||||
INSERT IGNORE INTO ormConfig
|
||||
SET id =1,
|
||||
selectLimit = 1000;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_afterDelete`
|
||||
AFTER DELETE ON `mailAliasAccount`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO userLog
|
||||
SET `action` = 'delete',
|
||||
`changedModel` = 'MailAliasAccount',
|
||||
`changedModelId` = OLD.id,
|
||||
`userFk` = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeInsert`
|
||||
BEFORE INSERT ON `mailAliasAccount`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeUpdate`
|
||||
BEFORE UPDATE ON `mailAliasAccount`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,167 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`claim_ratio_routine`()
|
||||
BEGIN
|
||||
DECLARE vMonthToRefund INT DEFAULT 4;
|
||||
|
||||
/*
|
||||
* PAK 2015-11-20
|
||||
* Se trata de añadir a la tabla Greuges todos los
|
||||
* cargos que luego vamos a utilizar para calcular el recobro
|
||||
*/
|
||||
|
||||
-- Reclamaciones demasiado sensibles
|
||||
|
||||
INSERT INTO vn.greuge(shipped, clientFk, description,
|
||||
amount, greugeTypeFk, ticketFk)
|
||||
SELECT c.ticketCreated
|
||||
, c.clientFk
|
||||
, concat('Claim ', c.id,' : ', s.concept)
|
||||
,round( -1 * ((c.responsibility -1)/4) * s.quantity *
|
||||
s.price * (100 - s.discount) / 100, 2)
|
||||
, 4
|
||||
, s.ticketFk
|
||||
FROM vn.sale s
|
||||
JOIN vn.claimEnd ce ON ce.saleFk = s.id
|
||||
JOIN vn.claim c ON c.id = ce.claimFk
|
||||
WHERE ce.claimDestinationFk NOT IN (1,5)
|
||||
AND NOT ce.isGreuge
|
||||
AND c.claimStateFk = 3;
|
||||
|
||||
-- Reclamaciones que pasan a Maná
|
||||
|
||||
INSERT INTO vn.greuge(shipped, clientFk, description,
|
||||
amount, greugeTypeFk, ticketFk)
|
||||
SELECT c.ticketCreated
|
||||
, c.clientFk
|
||||
, concat('Claim_mana ',c.id,' : ', s.concept)
|
||||
,round( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2)
|
||||
,3
|
||||
,s.ticketFk
|
||||
FROM vn.sale s
|
||||
JOIN vn.claimEnd ce ON ce.saleFk = s.id
|
||||
JOIN vn.claim c ON c.id = ce.claimFk
|
||||
WHERE ce.claimDestinationFk NOT IN (1,5)
|
||||
AND NOT ce.isGreuge
|
||||
AND c.claimStateFk = 3
|
||||
AND c.isChargedToMana;
|
||||
|
||||
-- Marcamos para no repetir
|
||||
UPDATE vn.claimEnd ce
|
||||
JOIN vn.claim c ON c.id = ce.claimFk
|
||||
SET ce.isGreuge = TRUE
|
||||
WHERE ce.claimDestinationFk NOT IN (1,5)
|
||||
AND NOT ce.isGreuge
|
||||
AND c.claimStateFk = 3;
|
||||
|
||||
-- Recobros
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
|
||||
CREATE TEMPORARY TABLE tmp.ticket_list
|
||||
(PRIMARY KEY (Id_Ticket))
|
||||
SELECT DISTINCT t.id Id_Ticket
|
||||
FROM vn.saleComponent sc
|
||||
JOIN vn.sale s ON sc.saleFk = s.id
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
JOIN vn.ticketLastState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk
|
||||
JOIN vn.state st ON st.id = tt.stateFk
|
||||
JOIN vn.alertLevel al ON al.code = 'DELIVERED'
|
||||
WHERE sc.componentFk = 17
|
||||
AND sc.isGreuge = 0
|
||||
AND t.shipped >= '2016-10-01'
|
||||
AND t.shipped < util.VN_CURDATE()
|
||||
AND st.alertLevel >= al.id;
|
||||
|
||||
DELETE g.*
|
||||
FROM vn.greuge g
|
||||
JOIN tmp.ticket_list t ON g.ticketFk = t.Id_Ticket
|
||||
WHERE g.greugeTypeFk = 2;
|
||||
|
||||
INSERT INTO vn.greuge(clientFk, description, amount,shipped,
|
||||
greugeTypeFk, ticketFk)
|
||||
SELECT t.clientFk
|
||||
,concat('recobro ', s.ticketFk), - round(SUM(sc.value*s.quantity),2)
|
||||
AS dif,
|
||||
date(t.shipped)
|
||||
, 2
|
||||
,tt.Id_Ticket
|
||||
FROM vn.sale s
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id
|
||||
JOIN vn.saleComponent sc
|
||||
ON sc.saleFk = s.id AND sc.componentFk = 17
|
||||
GROUP BY t.id
|
||||
HAVING ABS(dif) > 1;
|
||||
|
||||
UPDATE vn.saleComponent sc
|
||||
JOIN vn.sale s ON s.id = sc.saleFk
|
||||
JOIN tmp.ticket_list tt ON tt.Id_Ticket = s.ticketFk
|
||||
SET sc.isGreuge = 1
|
||||
WHERE sc.componentFk = 17;
|
||||
|
||||
/*
|
||||
* Recalculamos la ratio de las reclamaciones, que luego
|
||||
* se va a utilizar en el recobro
|
||||
*/
|
||||
|
||||
REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro)
|
||||
SELECT id, 0,0,0,0
|
||||
FROM vn.client;
|
||||
|
||||
REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro)
|
||||
SELECT fm.Id_Cliente, 12 * fm.Consumo, Reclamaciones,
|
||||
round(Reclamaciones / (12*fm.Consumo),4), 0
|
||||
FROM bi.facturacion_media_anual fm
|
||||
LEFT JOIN(
|
||||
SELECT c.clientFk, round(sum(-1 * ((c.responsibility -1)/4) *
|
||||
s.quantity * s.price * (100 - s.discount) / 100))
|
||||
AS Reclamaciones
|
||||
FROM vn.sale s
|
||||
JOIN vn.claimEnd ce ON ce.saleFk = s.id
|
||||
JOIN vn.claim c ON c.id = ce.claimFk
|
||||
WHERE ce.claimDestinationFk NOT IN (1,5)
|
||||
AND c.claimStateFk = 3
|
||||
AND c.ticketCreated >= TIMESTAMPADD(YEAR, -1, util.VN_CURDATE())
|
||||
GROUP BY c.clientFk
|
||||
) claims ON claims.clientFk = fm.Id_Cliente;
|
||||
|
||||
|
||||
-- Calculamos el porcentaje del recobro para añadirlo al precio de venta
|
||||
UPDATE bi.claims_ratio cr
|
||||
JOIN (
|
||||
SELECT clientFk Id_Cliente, IFNULL(SUM(amount), 0) AS Greuge
|
||||
FROM vn.greuge
|
||||
WHERE shipped <= util.VN_CURDATE()
|
||||
GROUP BY clientFk
|
||||
) g ON g.Id_Cliente = cr.Id_Cliente
|
||||
SET recobro = GREATEST(0,round(IFNULL(Greuge, 0) /
|
||||
(IFNULL(Consumo, 0) * vMonthToRefund / 12 ) ,3));
|
||||
|
||||
-- Protección neonatos
|
||||
UPDATE bi.claims_ratio cr
|
||||
JOIN vn.firstTicketShipped fts ON fts.clientFk = cr.Id_Cliente
|
||||
SET recobro = 0, Ratio = 0
|
||||
WHERE fts.shipped > TIMESTAMPADD(MONTH,-1,util.VN_CURDATE());
|
||||
|
||||
-- CLIENTE 7983, JULIAN SUAU
|
||||
UPDATE bi.claims_ratio SET recobro = LEAST(0.05, recobro) WHERE Id_Cliente = 7983;
|
||||
|
||||
-- CLIENTE 4358
|
||||
UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 4358;
|
||||
|
||||
-- CLIENTE 5523, VERDECORA
|
||||
UPDATE bi.claims_ratio SET recobro = GREATEST(0.12, recobro) WHERE Id_Cliente = 5523;
|
||||
|
||||
-- CLIENTE 15979, SERVEIS VETERINARIS
|
||||
UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 15979;
|
||||
|
||||
-- CLIENTE 5189 i 8942, son de CSR i son el mateix client
|
||||
UPDATE bi.claims_ratio cr
|
||||
JOIN (SELECT sum(Consumo * recobro)/sum(Consumo) as recobro
|
||||
FROM bi.claims_ratio
|
||||
WHERE Id_Cliente IN ( 5189,8942)
|
||||
) sub
|
||||
SET cr.recobro = sub.recobro
|
||||
WHERE Id_Cliente IN ( 5189,8942);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,5 +1,5 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`clean`()
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`clean`()
|
||||
BEGIN
|
||||
DECLARE vDateShort DATETIME;
|
||||
DECLARE vDateLong DATETIME;
|
||||
|
@ -15,5 +15,5 @@ BEGIN
|
|||
|
||||
DELETE FROM bi.defaulters WHERE `date` < vDateLong;
|
||||
DELETE FROM bi.defaulting WHERE `date` < vDateLong;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`facturacion_media_anual_update`()
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`facturacion_media_anual_update`()
|
||||
BEGIN
|
||||
TRUNCATE TABLE bs.clientAnnualConsumption;
|
||||
|
||||
|
@ -12,5 +12,5 @@ BEGIN
|
|||
GROUP BY clientFk, year, month
|
||||
) vol
|
||||
GROUP BY clientFk;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -59,7 +59,7 @@ BEGIN
|
|||
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||
JOIN vn.component c ON c.id = sc.componentFk
|
||||
JOIN vn.componentType ct ON ct.id = c.typeFk
|
||||
WHERE ct.code = 'FREIGHT'
|
||||
WHERE ct.code = 'freight'
|
||||
AND r.created BETWEEN vDatedFrom AND vDatedTo
|
||||
GROUP BY r.id
|
||||
) sub ON sub.routeFk = r.Id_Ruta
|
||||
|
|
|
@ -2,7 +2,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|||
SQL SECURITY DEFINER
|
||||
VIEW `bi`.`tarifa_componentes_series`
|
||||
AS SELECT `ct`.`id` AS `tarifa_componentes_series_id`,
|
||||
`ct`.`type` AS `Serie`,
|
||||
`ct`.`name` AS `Serie`,
|
||||
`ct`.`isBase` AS `base`,
|
||||
`ct`.`isMargin` AS `margen`
|
||||
FROM `vn`.`componentType` `ct`
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`carteras_add`()
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`carteras_add`()
|
||||
BEGIN
|
||||
/**
|
||||
* Inserta en la tabla @bs.carteras las ventas desde el año pasado
|
||||
|
@ -23,5 +23,5 @@ BEGIN
|
|||
GROUP BY w.code, t.`year`, t.`month`;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.time;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`nightTask_launchAll`()
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`nightTask_launchAll`()
|
||||
BEGIN
|
||||
/**
|
||||
* Runs all nightly tasks.
|
||||
|
@ -76,5 +76,5 @@ BEGIN
|
|||
END IF;
|
||||
END LOOP;
|
||||
CLOSE vQueue;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`salesByItemTypeDay_addLauncher`()
|
||||
BEGIN
|
||||
CALL bs.salesByItemTypeDay_add(util.VN_CURDATE() - INTERVAL 30 DAY, util.VN_CURDATE());
|
||||
BEGIN
|
||||
CALL bs.salesByItemTypeDay_add(util.VN_CURDATE() - INTERVAL 30 DAY, util.VN_CURDATE());
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,31 +1,75 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`(
|
||||
vDateFrom DATE,
|
||||
vDateTo DATE
|
||||
)
|
||||
BEGIN
|
||||
DECLARE vWeek INT;
|
||||
DECLARE vYear INT;
|
||||
/**
|
||||
* Recalcula las mermas de un periodo.
|
||||
*
|
||||
* @param vDateFrom Fecha desde
|
||||
* @param vDateTo Fecha hasta
|
||||
*/
|
||||
IF vDateFrom IS NULL THEN
|
||||
SET vDateFrom = util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY;
|
||||
END IF;
|
||||
|
||||
IF vDateTo IS NULL THEN
|
||||
SET vDateTo = vDateFrom + INTERVAL 6 DAY;
|
||||
END IF;
|
||||
|
||||
CALL cache.last_buy_refresh(FALSE);
|
||||
|
||||
SELECT week, year
|
||||
INTO vWeek, vYear
|
||||
FROM vn.time
|
||||
WHERE dated = util.VN_CURDATE();
|
||||
|
||||
REPLACE bs.waste
|
||||
SELECT *, 100 * mermas / total as porcentaje
|
||||
FROM (
|
||||
SELECT buyer,
|
||||
year,
|
||||
week,
|
||||
family,
|
||||
itemFk,
|
||||
itemTypeFk,
|
||||
floor(sum(value)) as total,
|
||||
floor(sum(IF(typeFk = 'loses', value, 0))) as mermas
|
||||
FROM vn.saleValue
|
||||
where year = vYear and week = vWeek
|
||||
|
||||
GROUP BY family, itemFk
|
||||
|
||||
) sub
|
||||
ORDER BY mermas DESC;
|
||||
SELECT YEAR(t.shipped),
|
||||
WEEK(t.shipped, 4),
|
||||
it.workerFk,
|
||||
it.id,
|
||||
s.itemFk,
|
||||
SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity),
|
||||
SUM(IF(aw.`type`, s.quantity, 0)),
|
||||
SUM(IF(
|
||||
aw.`type` = 'external',
|
||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||
0
|
||||
)
|
||||
),
|
||||
SUM(IF(
|
||||
aw.`type` = 'fault',
|
||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||
0
|
||||
)
|
||||
),
|
||||
SUM(IF(
|
||||
aw.`type` = 'container',
|
||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||
0
|
||||
)
|
||||
),
|
||||
SUM(IF(
|
||||
aw.`type` = 'break',
|
||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||
0
|
||||
)
|
||||
),
|
||||
SUM(IF(
|
||||
aw.`type` = 'other',
|
||||
(b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity,
|
||||
0
|
||||
)
|
||||
)
|
||||
FROM vn.sale s
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
JOIN vn.address a FORCE INDEX (PRIMARY) ON a.id = t.addressFk
|
||||
LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseFk
|
||||
JOIN cache.last_buy lb ON lb.item_id = i.id
|
||||
AND lb.warehouse_id = w.id
|
||||
JOIN vn.buy b ON b.id = lb.buy_id
|
||||
WHERE t.shipped BETWEEN vDateFrom AND vDateTo
|
||||
AND w.isManaged
|
||||
GROUP BY YEAR(t.shipped), WEEK(t.shipped, 4), i.id;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSalesLauncher`()
|
||||
BEGIN
|
||||
CALL waste_addSales(NULL, NULL);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -117,7 +117,7 @@ proc: BEGIN
|
|||
)sub
|
||||
GROUP BY sub.itemFk;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.itemCalc, tItemRange;
|
||||
DROP TEMPORARY TABLE tmp.itemCalc, tItemRange, tmp.itemList;
|
||||
CALL cache_calc_end (vCalc);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDated` DATE)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(
|
||||
OUT `vCalc` INT,
|
||||
`vRefresh` INT,
|
||||
`vWarehouse` INT,
|
||||
`vDated` DATE
|
||||
)
|
||||
proc: BEGIN
|
||||
DECLARE vStartDate DATE;
|
||||
DECLARE vReserveDate DATETIME;
|
||||
|
@ -121,7 +126,7 @@ proc: BEGIN
|
|||
)sub
|
||||
GROUP BY sub.itemFk;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.itemCalc, itemRange;
|
||||
DROP TEMPORARY TABLE tmp.itemCalc, itemRange, tmp.itemList;
|
||||
CALL cache_calc_end (vCalc);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_updateItem`(
|
||||
`vItem` INT,
|
||||
`vWarehouse` INT,
|
||||
`vDated` DATE,
|
||||
`vQuantity` INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Immediately deduct/add an amount from the available cache (if exists).
|
||||
*
|
||||
* @param vItem The item id
|
||||
* @param vWarehouse The warehouse id
|
||||
* @param vDated Available cache date
|
||||
* @param vQuantity The amount to be deducted from the cache
|
||||
*/
|
||||
DECLARE vCalc INT;
|
||||
|
||||
SELECT id INTO vCalc
|
||||
FROM cache_calc
|
||||
WHERE cacheName = 'available'
|
||||
AND params = CONCAT_WS('/', vWarehouse, vDated);
|
||||
|
||||
IF vCalc IS NOT NULL THEN
|
||||
UPDATE available
|
||||
SET available = available - vQuantity
|
||||
WHERE calc_id = vCalc
|
||||
AND item_id = vItem;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,5 +1,5 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_end`(IN `v_calc` INT)
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_end`(IN `v_calc` INT)
|
||||
BEGIN
|
||||
DECLARE v_cache_name VARCHAR(255);
|
||||
DECLARE v_params VARCHAR(255);
|
||||
|
@ -21,5 +21,5 @@ BEGIN
|
|||
IF v_cache_name IS NOT NULL THEN
|
||||
DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, '')));
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100))
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100))
|
||||
proc: BEGIN
|
||||
DECLARE v_valid BOOL;
|
||||
DECLARE v_lock_id VARCHAR(100);
|
||||
|
@ -83,5 +83,5 @@ proc: BEGIN
|
|||
-- Si se debe recalcular mantiene el bloqueo y devuelve su identificador.
|
||||
|
||||
SET v_refresh = TRUE;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -4,7 +4,7 @@ proc: BEGIN
|
|||
/**
|
||||
* Crea o actualiza la cache con la última compra y fecha de cada
|
||||
* artículo hasta ayer. Para obtener la última compra hasta una fecha
|
||||
* determinada utilizar el procedimiento vn.buyUltimate().
|
||||
* determinada utilizar el procedimiento vn.buy_getUltimate().
|
||||
*
|
||||
* @param vRefresh %TRUE para forzar el recálculo de la cache
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@ proc: BEGIN
|
|||
SELECT inventoried INTO started FROM vn.config LIMIT 1;
|
||||
SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE());
|
||||
|
||||
CALL vn.buyUltimateFromInterval(NULL, started, ended);
|
||||
CALL vn.buy_getUltimateFromInterval(NULL, NULL, started, ended);
|
||||
|
||||
DELETE FROM last_buy;
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`visible_refresh`(OUT v_calc INT, v_refresh BOOL, v_warehouse INT)
|
||||
proc: BEGIN
|
||||
proc:BEGIN
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
CALL cache_calc_unlock (v_calc);
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse);
|
||||
CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse);
|
||||
|
||||
IF !v_refresh THEN
|
||||
LEAVE proc;
|
||||
|
@ -15,22 +15,26 @@ proc: BEGIN
|
|||
|
||||
-- Calculamos el stock hasta ayer
|
||||
|
||||
CALL `cache`.stock_refresh(false);
|
||||
CALL cache.stock_refresh(false);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible
|
||||
(PRIMARY KEY (item_id))
|
||||
ENGINE = MEMORY
|
||||
SELECT item_id, amount stock, amount visible FROM `cache`.stock
|
||||
WHERE warehouse_id = v_warehouse;
|
||||
SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible
|
||||
FROM stock s
|
||||
JOIN vn.warehouse w ON w.id = s.warehouse_id
|
||||
WHERE (v_warehouse IS NULL OR s.warehouse_id = v_warehouse)
|
||||
AND w.isComparative
|
||||
GROUP BY s.item_id;
|
||||
|
||||
-- Calculamos los movimientos confirmados de hoy
|
||||
CALL vn.item_GetVisible(v_warehouse, NULL);
|
||||
CALL vn.item_calcVisible(NULL, v_warehouse);
|
||||
DELETE FROM visible WHERE calc_id = v_calc;
|
||||
|
||||
INSERT INTO visible (calc_id, item_id,visible)
|
||||
SELECT v_calc, item_id, visible FROM tmp.itemVisible;
|
||||
|
||||
CALL cache_calc_end (v_calc);
|
||||
CALL cache_calc_end (v_calc);
|
||||
|
||||
DROP TEMPORARY TABLE tmp.itemVisible;
|
||||
END$$
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `edi`.`floramondo`
|
||||
ON SCHEDULE EVERY 6 MINUTE
|
||||
STARTS '2022-01-28 09:52:45.000'
|
||||
ON COMPLETION NOT PRESERVE
|
||||
DISABLE
|
||||
DO CALL edi.floramondo_offerRefresh()$$
|
||||
DELIMITER ;
|
|
@ -7,7 +7,6 @@ BEGIN
|
|||
*/
|
||||
DECLARE vRewriteKop INT DEFAULT NULL;
|
||||
DECLARE vTruncatePutOrder INT DEFAULT NULL;
|
||||
DECLARE vBarcode CHAR(15) DEFAULT NULL;
|
||||
DECLARE vKop INT;
|
||||
DECLARE vPutOrderFk BIGINT;
|
||||
|
||||
|
@ -16,17 +15,6 @@ BEGIN
|
|||
FROM ekt
|
||||
WHERE id = vSelf;
|
||||
|
||||
-- Generates the barcode
|
||||
|
||||
SELECT CONCAT(
|
||||
LPAD(IFNULL(auction,0), 3, 0),
|
||||
LPAD(IFNULL(klo, 99), 2, 0),
|
||||
LPAD(DAYOFYEAR(fec), 3, 0),
|
||||
COALESCE(agj, RIGHT(batchNumber,7), id))
|
||||
INTO vBarcode
|
||||
FROM ekt
|
||||
WHERE id = vSelf;
|
||||
|
||||
-- Rewrites the kop parameter
|
||||
|
||||
IF vKop IS NULL THEN
|
||||
|
@ -46,10 +34,9 @@ BEGIN
|
|||
|
||||
-- Refresh EKT
|
||||
|
||||
UPDATE ekt SET
|
||||
barcode = vBarcode
|
||||
,kop = vKop
|
||||
,putOrderFk = vTruncatePutOrder
|
||||
UPDATE ekt
|
||||
SET kop = vKop,
|
||||
putOrderFk = vTruncatePutOrder
|
||||
WHERE id = vSelf;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,522 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`()
|
||||
proc: BEGIN
|
||||
DECLARE vLanded DATETIME;
|
||||
DECLARE vDone INT DEFAULT FALSE;
|
||||
DECLARE vFreeId INT;
|
||||
DECLARE vSupplyResponseFk INT;
|
||||
DECLARE vLastInserted DATETIME;
|
||||
DECLARE vIsAuctionDay BOOLEAN;
|
||||
DECLARE vMaxNewItems INT DEFAULT 10000;
|
||||
DECLARE vStartingTime DATETIME;
|
||||
DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043';
|
||||
DECLARE vDayRange INT;
|
||||
|
||||
DECLARE cur1 CURSOR FOR
|
||||
SELECT id
|
||||
FROM edi.item_free;
|
||||
|
||||
DECLARE cur2 CURSOR FOR
|
||||
SELECT srId
|
||||
FROM itemToInsert;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
DECLARE EXIT HANDLER FOR SQLSTATE '45000'
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
DO RELEASE_LOCK('edi.floramondo_offerRefresh');
|
||||
SET @isTriggerDisabled = FALSE;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
IF 'test' = (SELECT environment FROM util.config) THEN
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
IF !GET_LOCK('edi.floramondo_offerRefresh', 0) THEN
|
||||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
SELECT dayRange INTO vDayRange
|
||||
FROM offerRefreshConfig;
|
||||
|
||||
IF vDayRange IS NULL THEN
|
||||
CALL util.throw("Variable vDayRange not declared");
|
||||
END IF;
|
||||
|
||||
SET vStartingTime = util.VN_NOW();
|
||||
|
||||
TRUNCATE edi.offerList;
|
||||
|
||||
INSERT INTO edi.offerList(supplier, total)
|
||||
SELECT v.name, COUNT(DISTINCT sr.ID) total
|
||||
FROM edi.supplyResponse sr
|
||||
JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
|
||||
WHERE sr.NumberOfUnits > 0
|
||||
AND sr.EmbalageCode != 999
|
||||
GROUP BY sr.vmpID;
|
||||
|
||||
UPDATE edi.offerList o
|
||||
JOIN (SELECT v.name, COUNT(*) total
|
||||
FROM edi.supplyOffer sr
|
||||
JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
|
||||
GROUP BY sr.vmpID) sub ON o.supplier = sub.name
|
||||
SET o.`filter` = sub.total;
|
||||
|
||||
-- Elimina de la lista de items libres aquellos que ya existen
|
||||
DELETE itf.*
|
||||
FROM edi.item_free itf
|
||||
JOIN vn.item i ON i.id = itf.id;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp
|
||||
(INDEX (`Item_ArticleCode`))
|
||||
ENGINE = MEMORY
|
||||
SELECT t.*
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM edi.supplyOffer
|
||||
ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC,
|
||||
NumberOfUnits DESC LIMIT 10000000000000000000) t
|
||||
GROUP BY t.srId;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`),
|
||||
INDEX (`ef1`), INDEX (`ef2`), INDEX (`ef3`), INDEX (`ef4`),INDEX (`ef5`), INDEX (`ef6`),
|
||||
INDEX (`s1Value`), INDEX (`s2Value`), INDEX (`s3Value`), INDEX (`s4Value`),INDEX (`s5Value`), INDEX (`s6Value`))
|
||||
ENGINE = MEMORY
|
||||
SELECT so.*,
|
||||
ev1.type_description s1Value,
|
||||
ev2.type_description s2Value,
|
||||
ev3.type_description s3Value,
|
||||
ev4.type_description s4Value,
|
||||
ev5.type_description s5Value,
|
||||
ev6.type_description s6Value,
|
||||
eif1.feature ef1,
|
||||
eif2.feature ef2,
|
||||
eif3.feature ef3,
|
||||
eif4.feature ef4,
|
||||
eif5.feature ef5,
|
||||
eif6.feature ef6
|
||||
FROM tmp so
|
||||
LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode
|
||||
AND eif1.presentation_order = 1
|
||||
AND eif1.expiry_date IS NULL
|
||||
LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode
|
||||
AND eif2.presentation_order = 2
|
||||
AND eif2.expiry_date IS NULL
|
||||
LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode
|
||||
AND eif3.presentation_order = 3
|
||||
AND eif3.expiry_date IS NULL
|
||||
LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode
|
||||
AND eif4.presentation_order = 4
|
||||
AND eif4.expiry_date IS NULL
|
||||
LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode
|
||||
AND eif5.presentation_order = 5
|
||||
AND eif5.expiry_date IS NULL
|
||||
LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode
|
||||
AND eif6.presentation_order = 6
|
||||
AND eif6.expiry_date IS NULL
|
||||
LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature
|
||||
AND so.s1 = ev1.type_value
|
||||
LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature
|
||||
AND so.s2 = ev2.type_value
|
||||
LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature
|
||||
AND so.s3 = ev3.type_value
|
||||
LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature
|
||||
AND so.s4 = ev4.type_value
|
||||
LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature
|
||||
AND so.s5 = ev5.type_value
|
||||
LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature
|
||||
AND so.s6 = ev6.type_value
|
||||
ORDER BY Price;
|
||||
|
||||
DROP TEMPORARY TABLE tmp;
|
||||
|
||||
DELETE o
|
||||
FROM edi.offer o
|
||||
LEFT JOIN vn.tag t1 ON t1.ediTypeFk = o.ef1 AND t1.overwrite = 'size'
|
||||
LEFT JOIN vn.tag t2 ON t2.ediTypeFk = o.ef2 AND t2.overwrite = 'size'
|
||||
LEFT JOIN vn.tag t3 ON t3.ediTypeFk = o.ef3 AND t3.overwrite = 'size'
|
||||
LEFT JOIN vn.tag t4 ON t4.ediTypeFk = o.ef4 AND t4.overwrite = 'size'
|
||||
LEFT JOIN vn.tag t5 ON t5.ediTypeFk = o.ef5 AND t5.overwrite = 'size'
|
||||
LEFT JOIN vn.tag t6 ON t6.ediTypeFk = o.ef6 AND t6.overwrite = 'size'
|
||||
JOIN vn.floramondoConfig fc ON TRUE
|
||||
WHERE (t1.id IS NOT NULL AND CONVERT(s1Value, UNSIGNED) > fc.itemMaxSize)
|
||||
OR (t2.id IS NOT NULL AND CONVERT(s2Value, UNSIGNED) > fc.itemMaxSize)
|
||||
OR (t3.id IS NOT NULL AND CONVERT(s3Value, UNSIGNED) > fc.itemMaxSize)
|
||||
OR (t4.id IS NOT NULL AND CONVERT(s4Value, UNSIGNED) > fc.itemMaxSize)
|
||||
OR (t5.id IS NOT NULL AND CONVERT(s5Value, UNSIGNED) > fc.itemMaxSize)
|
||||
OR (t6.id IS NOT NULL AND CONVERT(s6Value, UNSIGNED) > fc.itemMaxSize);
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
-- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos
|
||||
UPDATE IGNORE edi.offer o
|
||||
JOIN vn.item i
|
||||
ON i.name = o.product_name
|
||||
AND i.subname <=> o.company_name
|
||||
AND i.value5 <=> o.s1Value
|
||||
AND i.value6 <=> o.s2Value
|
||||
AND i.value7 <=> o.s3Value
|
||||
AND i.value8 <=> o.s4Value
|
||||
AND i.value9 <=> o.s5Value
|
||||
AND i.value10 <=> o.s6Value
|
||||
AND i.NumberOfItemsPerCask <=> o.NumberOfItemsPerCask
|
||||
AND i.EmbalageCode <=> o.EmbalageCode
|
||||
AND i.quality <=> o.Quality
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
LEFT JOIN vn.sale s ON s.itemFk = i.id
|
||||
LEFT JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
AND t.shipped > (util.VN_CURDATE() - INTERVAL 1 WEEK)
|
||||
LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
|
||||
LEFT JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID
|
||||
LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk
|
||||
AND po.OrderTradeLineDateTime > (util.VN_CURDATE() - INTERVAL 1 WEEK)
|
||||
SET i.supplyResponseFk = o.srID
|
||||
WHERE (sr.ID IS NULL
|
||||
OR sr.NumberOfUnits = 0
|
||||
OR di.LatestOrderDateTime < util.VN_NOW()
|
||||
OR di.ID IS NULL)
|
||||
AND it.isInventory
|
||||
AND t.id IS NULL
|
||||
AND po.id IS NULL;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE itemToInsert
|
||||
ENGINE = MEMORY
|
||||
SELECT o.*, CAST(NULL AS DECIMAL(6,0)) itemFk
|
||||
FROM edi.offer o
|
||||
LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId
|
||||
WHERE i.id IS NULL
|
||||
LIMIT vMaxNewItems;
|
||||
|
||||
-- Reciclado de nº de item
|
||||
OPEN cur1;
|
||||
OPEN cur2;
|
||||
|
||||
read_loop: LOOP
|
||||
|
||||
FETCH cur2 INTO vSupplyResponseFk;
|
||||
FETCH cur1 INTO vFreeId;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE read_loop;
|
||||
END IF;
|
||||
|
||||
UPDATE itemToInsert
|
||||
SET itemFk = vFreeId
|
||||
WHERE srId = vSupplyResponseFk;
|
||||
|
||||
END LOOP;
|
||||
|
||||
CLOSE cur1;
|
||||
CLOSE cur2;
|
||||
|
||||
-- Insertamos todos los items en Articles de la oferta
|
||||
INSERT INTO vn.item(id,
|
||||
`name`,
|
||||
longName,
|
||||
subName,
|
||||
expenseFk,
|
||||
typeFk,
|
||||
intrastatFk,
|
||||
originFk,
|
||||
supplyResponseFk,
|
||||
numberOfItemsPerCask,
|
||||
embalageCode,
|
||||
quality,
|
||||
isFloramondo)
|
||||
SELECT iti.itemFk,
|
||||
iti.product_name,
|
||||
iti.product_name,
|
||||
iti.company_name,
|
||||
iti.expenseFk,
|
||||
iti.itemTypeFk,
|
||||
iti.intrastatFk,
|
||||
iti.originFk,
|
||||
iti.`srId`,
|
||||
iti.NumberOfItemsPerCask,
|
||||
iti.EmbalageCode,
|
||||
iti.Quality,
|
||||
TRUE
|
||||
FROM itemToInsert iti;
|
||||
|
||||
-- Inserta la foto de los articulos nuevos (prioridad alta)
|
||||
INSERT IGNORE INTO vn.itemImageQueue(itemFk, url)
|
||||
SELECT i.id, PictureReference
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.srId
|
||||
WHERE PictureReference IS NOT NULL
|
||||
AND i.image IS NULL;
|
||||
|
||||
INSERT INTO edi.`log`(tableName, fieldName,fieldValue)
|
||||
SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*)
|
||||
FROM vn.itemImageQueue
|
||||
WHERE attempts = 0;
|
||||
|
||||
-- Inserta si se añadiesen tags nuevos
|
||||
INSERT IGNORE INTO vn.tag (name, ediTypeFk)
|
||||
SELECT description, type_id FROM edi.type;
|
||||
|
||||
-- Desabilita el trigger para recalcular los tags al final
|
||||
SET @isTriggerDisabled = TRUE;
|
||||
|
||||
-- Inserta los tags sólo en los articulos nuevos
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , ii.product_name, 1
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.tag t ON t.`name` = 'Producto'
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
|
||||
WHERE NOT ii.product_name IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , ii.Quality, 3
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.tag t ON t.`name` = 'Calidad'
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
|
||||
WHERE NOT ii.Quality IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , ii.company_name, 4
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.tag t ON t.`name` = 'Productor'
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
|
||||
WHERE NOT ii.company_name IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , s1Value, 5
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.tag t ON t.ediTypeFk = ii.ef1
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
|
||||
WHERE NOT s1Value IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , s2Value, 6
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.tag t ON t.ediTypeFk = ii.ef2
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
|
||||
WHERE NOT s2Value IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , s3Value, 7
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.tag t ON t.ediTypeFk = ii.ef3
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
|
||||
WHERE NOT s3Value IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , s4Value, 8
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.tag t ON t.ediTypeFk = ii.ef4
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
|
||||
WHERE NOT s4Value IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , s5Value, 9
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.tag t ON t.ediTypeFk = ii.ef5
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
|
||||
WHERE NOT s5Value IS NULL;
|
||||
|
||||
INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id , s6Value, 10
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.tag t ON t.ediTypeFk = ii.ef6
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
|
||||
WHERE NOT s6Value IS NULL;
|
||||
|
||||
INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority)
|
||||
SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11
|
||||
FROM itemToInsert ii
|
||||
JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
|
||||
JOIN vn.tag t ON t.`name` = 'Color'
|
||||
LEFT JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode
|
||||
LEFT JOIN edi.`type` tp ON tp.type_id = f.feature_type_id
|
||||
AND tp.`description` = 'Hoofdkleur 1'
|
||||
LEFT JOIN vn.ink ON ink.dutchCode = f.feature_value
|
||||
LEFT JOIN vn.itemInk ik ON ik.longName = i.longName
|
||||
WHERE ink.name IS NOT NULL
|
||||
OR ik.color IS NOT NULL;
|
||||
|
||||
CREATE OR REPLACE TABLE tmp.item
|
||||
(PRIMARY KEY (id))
|
||||
SELECT i.id FROM vn.item i
|
||||
JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`;
|
||||
|
||||
CALL vn.item_refreshTags();
|
||||
|
||||
DROP TABLE tmp.item;
|
||||
|
||||
SELECT MIN(LatestDeliveryDateTime) INTO vLanded
|
||||
FROM edi.supplyResponse sr
|
||||
JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID
|
||||
JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
|
||||
JOIN vn.floramondoConfig fc
|
||||
WHERE mp.isLatestOrderDateTimeRelevant
|
||||
AND di.LatestOrderDateTime > IF(
|
||||
fc.MaxLatestOrderHour > HOUR(util.VN_NOW()),
|
||||
util.VN_CURDATE(),
|
||||
util.VN_CURDATE() + INTERVAL 1 DAY);
|
||||
|
||||
UPDATE vn.floramondoConfig
|
||||
SET nextLanded = vLanded
|
||||
WHERE vLanded IS NOT NULL;
|
||||
|
||||
-- Elimina la oferta obsoleta
|
||||
UPDATE vn.buy b
|
||||
JOIN vn.entry e ON e.id = b.entryFk
|
||||
JOIN vn.travel tr ON tr.id = e.travelFk
|
||||
JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
LEFT JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
|
||||
LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk
|
||||
SET b.quantity = 0
|
||||
WHERE (IFNULL(di.LatestOrderDateTime,util.VN_NOW()) <= util.VN_NOW()
|
||||
OR i.supplyResponseFk IS NULL
|
||||
OR sr.NumberOfUnits = 0)
|
||||
AND am.name = 'LOGIFLORA'
|
||||
AND e.isRaid;
|
||||
|
||||
-- Localiza las entradas de cada almacen
|
||||
UPDATE edi.warehouseFloramondo
|
||||
SET entryFk = vn.entry_getForLogiflora(vLanded + INTERVAL travellingDays DAY, warehouseFk);
|
||||
|
||||
IF vLanded IS NOT NULL THEN
|
||||
-- Actualiza la oferta existente
|
||||
UPDATE vn.buy b
|
||||
JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
JOIN edi.offer o ON i.supplyResponseFk = o.`srId`
|
||||
SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask,
|
||||
b.buyingValue = o.price
|
||||
WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask
|
||||
OR b.buyingValue <> o.price);
|
||||
|
||||
-- Inserta el resto
|
||||
SET vLastInserted := util.VN_NOW();
|
||||
|
||||
-- Inserta la oferta
|
||||
INSERT INTO vn.buy (
|
||||
entryFk,
|
||||
itemFk,
|
||||
quantity,
|
||||
buyingValue,
|
||||
stickers,
|
||||
packing,
|
||||
`grouping`,
|
||||
groupingMode,
|
||||
packagingFk,
|
||||
deliveryFk)
|
||||
SELECT wf.entryFk,
|
||||
i.id,
|
||||
o.NumberOfUnits * o.NumberOfItemsPerCask quantity,
|
||||
o.Price,
|
||||
o.NumberOfUnits etiquetas,
|
||||
o.NumberOfItemsPerCask packing,
|
||||
GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`,
|
||||
'packing',
|
||||
o.embalageCode,
|
||||
o.diId
|
||||
FROM edi.offer o
|
||||
JOIN vn.item i ON i.supplyResponseFk = o.srId
|
||||
JOIN edi.warehouseFloramondo wf
|
||||
JOIN vn.packaging p ON p.id
|
||||
LIKE o.embalageCode
|
||||
LEFT JOIN vn.buy b ON b.itemFk = i.id
|
||||
AND b.entryFk = wf.entryFk
|
||||
WHERE b.id IS NULL; -- Quitar esta linea y mirar de crear los packages a tiempo REAL
|
||||
|
||||
INSERT INTO vn.itemCost(
|
||||
itemFk,
|
||||
warehouseFk,
|
||||
cm3,
|
||||
cm3delivery)
|
||||
SELECT b.itemFk,
|
||||
wf.warehouseFk,
|
||||
@cm3 := vn.buy_getUnitVolume(b.id),
|
||||
IFNULL((vc.standardFlowerBox * 1000) / i.packingOut, @cm3)
|
||||
FROM warehouseFloramondo wf
|
||||
JOIN vn.volumeConfig vc
|
||||
JOIN vn.buy b ON b.entryFk = wf.entryFk
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
LEFT JOIN vn.itemCost ic ON ic.itemFk = b.itemFk
|
||||
AND ic.warehouseFk = wf.warehouseFk
|
||||
WHERE (ic.cm3 IS NULL OR ic.cm3 = 0)
|
||||
ON DUPLICATE KEY UPDATE cm3 = @cm3, cm3delivery = IFNULL((vc.standardFlowerBox * 1000) / i.packingOut, @cm3);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.buyRecalc
|
||||
SELECT b.id
|
||||
FROM vn.buy b
|
||||
JOIN warehouseFloramondo wf ON wf.entryFk = b.entryFk
|
||||
WHERE b.created >= vLastInserted;
|
||||
|
||||
CALL vn.buy_recalcPrices();
|
||||
|
||||
UPDATE edi.offerList o
|
||||
JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total
|
||||
FROM vn.buy b
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
|
||||
JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
|
||||
JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
|
||||
JOIN vn.warehouse w ON w.id = wf.warehouseFk
|
||||
WHERE w.name = 'VNH'
|
||||
AND b.quantity > 0
|
||||
GROUP BY sr.vmpID) sub ON o.supplier = sub.name
|
||||
SET o.vnh = sub.total;
|
||||
|
||||
UPDATE edi.offerList o
|
||||
JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total
|
||||
FROM vn.buy b
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
|
||||
JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
|
||||
JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
|
||||
JOIN vn.warehouse w ON w.id = wf.warehouseFk
|
||||
WHERE w.name = 'ALGEMESI'
|
||||
AND b.quantity > 0
|
||||
GROUP BY sr.vmpID) sub ON o.supplier = sub.name
|
||||
SET o.algemesi = sub.total;
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
edi.offer,
|
||||
itemToInsert;
|
||||
|
||||
SET @isTriggerDisabled = FALSE;
|
||||
|
||||
COMMIT;
|
||||
|
||||
-- Esto habria que pasarlo a procesos programados o trabajar con tags y dejar las familias
|
||||
UPDATE vn.item i
|
||||
SET typeFk = 121
|
||||
WHERE i.longName LIKE 'Rosa Garden %'
|
||||
AND typeFk = 17;
|
||||
|
||||
UPDATE vn.item i
|
||||
SET typeFk = 156
|
||||
WHERE i.longName LIKE 'Rosa ec %'
|
||||
AND typeFk = 17;
|
||||
|
||||
-- Refresca las fotos de los items existentes que mostramos (prioridad baja)
|
||||
INSERT IGNORE INTO vn.itemImageQueue(itemFk, url, priority)
|
||||
SELECT i.id, sr.PictureReference, 100
|
||||
FROM edi.supplyResponse sr
|
||||
JOIN vn.item i ON i.supplyResponseFk = sr.ID
|
||||
JOIN edi.supplyOffer so ON so.srId = sr.ID
|
||||
JOIN hedera.image i2 ON i2.name = i.image
|
||||
AND i2.collectionFk = 'catalog'
|
||||
WHERE i2.updated <= (UNIX_TIMESTAMP(util.VN_NOW()) - vDayRange)
|
||||
AND sr.NumberOfUnits;
|
||||
|
||||
INSERT INTO edi.`log`
|
||||
SET tableName = 'floramondo_offerRefresh',
|
||||
fieldName = 'Tiempo de proceso',
|
||||
fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime);
|
||||
|
||||
DO RELEASE_LOCK('edi.floramondo_offerRefresh');
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -2,7 +2,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|||
SQL SECURITY DEFINER
|
||||
VIEW `edi`.`ektRecent`
|
||||
AS SELECT `e`.`id` AS `id`,
|
||||
`e`.`barcode` AS `barcode`,
|
||||
`e`.`entryYear` AS `entryYear`,
|
||||
`e`.`batchNumber` AS `batchNumber`,
|
||||
`e`.`deliveryNumber` AS `deliveryNumber`,
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE
|
||||
DEFINER=`root`@`localhost`
|
||||
EVENT `floranet`.`clean`
|
||||
ON SCHEDULE EVERY 1 DAY
|
||||
STARTS '2024-01-01 23:00:00.000'
|
||||
ON COMPLETION PRESERVE
|
||||
ENABLE
|
||||
DO
|
||||
BEGIN
|
||||
DELETE
|
||||
FROM `order`
|
||||
WHERE created < CURDATE()
|
||||
AND isPaid = FALSE;
|
||||
|
||||
DELETE c.*
|
||||
FROM catalogue c
|
||||
LEFT JOIN `order` o ON o.catalogueFk = c.id
|
||||
WHERE c.created < CURDATE()
|
||||
AND o.id IS NULL;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,16 +1,15 @@
|
|||
DROP PROCEDURE IF EXISTS floranet.catalogue_get;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15))
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15))
|
||||
READS SQL DATA
|
||||
proc:BEGIN
|
||||
/**
|
||||
* Returns list, price and all the stuff regarding the floranet items.
|
||||
* Returns list, price and all the stuff regarding the floranet items, for the designed shop
|
||||
*
|
||||
* @param vLanded Delivery date
|
||||
* @param vPostalCode Delivery address postal code
|
||||
*/
|
||||
DECLARE vAddressFk INT;
|
||||
DECLARE vLastCatalogueFk INT;
|
||||
DECLARE vLockName VARCHAR(20);
|
||||
DECLARE vLockTime INT;
|
||||
|
@ -21,7 +20,7 @@ proc:BEGIN
|
|||
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
|
||||
SET vLockName = 'catalogue_get';
|
||||
SET vLockTime = 15;
|
||||
|
||||
|
@ -32,6 +31,15 @@ proc:BEGIN
|
|||
SELECT MAX(id) INTO vLastCatalogueFk
|
||||
FROM catalogue;
|
||||
|
||||
SELECT addressFk
|
||||
INTO vAddressFk
|
||||
FROM addressPostCode apc
|
||||
WHERE apc.dayOfWeek = dayOfWeek(vLanded)
|
||||
AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR
|
||||
AND apc.postCode = vPostalCode
|
||||
-- Aquí hay que incluir los criterios de selección de tienda
|
||||
LIMIT 1;
|
||||
|
||||
INSERT INTO catalogue(
|
||||
name,
|
||||
price,
|
||||
|
@ -51,17 +59,14 @@ proc:BEGIN
|
|||
it.name,
|
||||
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image),
|
||||
i.description,
|
||||
apc.addressFk
|
||||
vAddressFk
|
||||
FROM vn.item i
|
||||
JOIN (SELECT itemFk, SUM(quantity * cost) price
|
||||
FROM recipe
|
||||
GROUP BY itemFk) r ON r.itemFk = i.id
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN addressPostCode apc
|
||||
ON apc.dayOfWeek = dayOfWeek(vLanded)
|
||||
AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR
|
||||
AND apc.postCode = vPostalCode
|
||||
JOIN vn.address a ON a.id = apc.addressFk;
|
||||
JOIN addressPostCode apc ON addressFk = vAddressFk
|
||||
JOIN vn.address a ON a.id = vAddressFk;
|
||||
|
||||
SELECT *
|
||||
FROM catalogue
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue