refs #4823 Added warehouseConfig
This commit is contained in:
parent
7498886b43
commit
2ccde9d624
|
@ -0,0 +1,34 @@
|
|||
import { Sequelize } from 'sequelize';
|
||||
|
||||
const warehouseConfig = {
|
||||
warehouseFk: {
|
||||
type: Sequelize.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
},
|
||||
entryFk: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
travellingDays: {
|
||||
type: Sequelize.INTEGER,
|
||||
default: 0,
|
||||
allowNull: false,
|
||||
},
|
||||
dayRange: {
|
||||
type: Sequelize.INTEGER,
|
||||
default: 0,
|
||||
allowNull: false,
|
||||
},
|
||||
};
|
||||
|
||||
export default (sequelize) => {
|
||||
return sequelize.define(
|
||||
'vnWarehouseConfig',
|
||||
warehouseConfig,
|
||||
{
|
||||
timestamps: false,
|
||||
freezeTableName: true,
|
||||
}
|
||||
);
|
||||
};
|
|
@ -32,6 +32,7 @@ try {
|
|||
|
||||
// Conf Models
|
||||
import config from './config/config.js';
|
||||
import warehouseConfig from './config/warehouseConfig.js';
|
||||
import sequenceNumber from './config/sequenceNumber.js';
|
||||
|
||||
// Organization Models
|
||||
|
@ -63,6 +64,7 @@ let models = {
|
|||
sequelize: sequelize,
|
||||
sequenceNumber: sequenceNumber(sequelize),
|
||||
config: config(sequelize),
|
||||
warehouseConfig: warehouseConfig(sequelize),
|
||||
organization: organization(sequelize),
|
||||
warehouse: warehouse(sequelize),
|
||||
tradeItem: tradeItem(sequelize),
|
||||
|
@ -158,10 +160,6 @@ try {
|
|||
foreignKey: 'organizationId',
|
||||
targetKey: 'organizationId',
|
||||
});
|
||||
|
||||
// Views
|
||||
sequelize.query(fs.readFileSync('views//supplyOffer.sql', 'utf-8'));
|
||||
|
||||
} catch (err) {
|
||||
criticalError(err);
|
||||
}
|
||||
|
@ -172,6 +170,10 @@ try {
|
|||
const actionMsg = JSON.parse(env.FORCE_SYNC) ? 'Forcing' : 'Altering';
|
||||
const spinner = ora(`${actionMsg} models...`).start();
|
||||
await sequelize.sync(action);
|
||||
|
||||
// Views
|
||||
sequelize.query(fs.readFileSync('views//supplyOffer.sql', 'utf-8'));
|
||||
|
||||
spinner.succeed();
|
||||
}
|
||||
catch (err) {
|
||||
|
|
|
@ -2,23 +2,49 @@ CREATE OR REPLACE VIEW supplyOffer AS
|
|||
SELECT sl.supplyLineId,
|
||||
ti.name tradeItemName,
|
||||
o.commercialName organizationName,
|
||||
sl.type,
|
||||
sl.`type`,
|
||||
sl.salesUnit,
|
||||
slvp.pricePerPiece,
|
||||
CAST(slvp.pricePerPiece AS DECIMAL(10, 3)) pricePerPiece,
|
||||
sl.numberOfPieces,
|
||||
sl.deliveryPeriodStartDateTime ,
|
||||
ti.vbnProductCode,
|
||||
(SELECT feature FROM edi.item_feature WHERE item_id = ti.vbnProductCode AND presentation_order = 1 LIMIT 1) s1,
|
||||
(SELECT feature FROM edi.item_feature WHERE item_id = ti.vbnProductCode AND presentation_order = 2 LIMIT 1) s2,
|
||||
(SELECT feature FROM edi.item_feature WHERE item_id = ti.vbnProductCode AND presentation_order = 3 LIMIT 1) s3,
|
||||
(SELECT feature FROM edi.item_feature WHERE item_id = ti.vbnProductCode AND presentation_order = 4 LIMIT 1) s4,
|
||||
(SELECT feature FROM edi.item_feature WHERE item_id = ti.vbnProductCode AND presentation_order = 5 LIMIT 1) s5,
|
||||
(SELECT feature FROM edi.item_feature WHERE item_id = ti.vbnProductCode AND presentation_order = 6 LIMIT 1) s6,
|
||||
sl.deliveryPeriodStartDateTime,
|
||||
sl.deliveryPeriodEndDateTime,
|
||||
sl.orderPeriodStartDateTime,
|
||||
sl.orderPeriodEndDateTime,
|
||||
b.description bucketDescription,
|
||||
b.x_size,
|
||||
b.y_size,
|
||||
b.z_size,
|
||||
(b.x_size * b.y_size * b.z_size) / 1000000000 volume,
|
||||
slpc.piecesPerPackage,
|
||||
slpc.packagesPerLayer,
|
||||
slpc.layersPerLoadCarrier,
|
||||
slpc.transportHeightInCm,
|
||||
slpc.loadCarrierType,
|
||||
slpc.additionalPricePerPieceCurrency,
|
||||
slpc.additionalPricePerPieceValue,
|
||||
w.name warehouseName,
|
||||
tip.url,
|
||||
sl.lastSync
|
||||
FROM supplyLine sl
|
||||
JOIN supplyLineVolumePrice slvp ON slvp.supplyLineId = sl.supplyLineId
|
||||
JOIN organization o ON o.organizationId = sl.organizationId
|
||||
JOIN tradeItem ti ON ti.tradeItemId = sl.tradeItemId
|
||||
JOIN tradeItemPhoto tip ON tip.tradeItemId = ti.tradeItemId
|
||||
AND tip.primary
|
||||
WHERE sl.status = 'AVAILABLE'
|
||||
AND NOT sl.isDeleted
|
||||
AND NOW() BETWEEN sl.orderPeriodStartDateTime AND sl.orderPeriodEndDateTime
|
||||
GROUP BY sl.supplyLineId
|
||||
FROM supplyLine sl
|
||||
JOIN supplyLineVolumePrice slvp ON slvp.supplyLineId = sl.supplyLineId
|
||||
JOIN organization o ON o.organizationId = sl.organizationId
|
||||
JOIN tradeItem ti ON ti.tradeItemId = sl.tradeItemId
|
||||
JOIN tradeItemPhoto tip ON tip.tradeItemId = ti.tradeItemId
|
||||
AND tip.`primary`
|
||||
JOIN tradeItemCharacteristic tic ON tic.tradeItemId = ti.tradeItemId
|
||||
JOIN warehouse w ON w.warehouseId = sl.warehouseId
|
||||
JOIN supplyLinePackingConfiguration slpc ON slpc.supplyLineId = sl.supplyLineId
|
||||
JOIN edi.bucket b ON b.bucket_id = slpc.packageVbnPackageCode
|
||||
WHERE sl.status = 'AVAILABLE'
|
||||
AND NOT sl.isDeleted
|
||||
AND NOT ti.isDeleted
|
||||
AND NOW() BETWEEN sl.orderPeriodStartDateTime AND sl.orderPeriodEndDateTime
|
||||
AND sl.numberOfPieces > 0
|
||||
GROUP BY sl.supplyLineId
|
Loading…
Reference in New Issue