sigo-package 1.2.21 → 1.2.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ManoObraENTITY, ReservaENTITY, HomePassDTO, FlujoDocDTO, NodoDocDTO, DocumentacionPEXENTITY, ManoObraGlobalENTITY, PrecioEspecialidadENTITY, ObraChile9512ENTITY, ValorizacionManoObraDTO, ValorizacionDTO, PrecioContratistaMOAL02ENTITY, StockPersonalENTITY, TrabajoENTITY, ActividadesDTO, PreciosVigentesDTO, ContratoOTENTITY } from 'sigo-entities';
1
+ import { ManoObraENTITY, ReservaENTITY, HomePassDTO, FlujoDocDTO, NodoDocDTO, DocumentacionPEXENTITY, ManoObraGlobalENTITY, PrecioEspecialidadENTITY, ObraChile9512ENTITY, ValorizacionManoObraDTO, ValorizacionDTO, PrecioContratistaMOAL02ENTITY, StockPersonalENTITY, ItemDetalleLogisticaDTO, TrabajoENTITY, ActividadesDTO, PreciosVigentesDTO, ContratoOTENTITY } from 'sigo-entities';
2
2
 
3
3
  interface IenvSIGO$1 {
4
4
  SISTEMAS_VALORIZACION_MANO_OBRA: string[];
@@ -306,7 +306,13 @@ declare function obtenerTipoYCodigoMO(codigoOriginal: string): {
306
306
  CodigoMO: string;
307
307
  };
308
308
 
309
- declare function buildMaterialsFromPersonalStock(Materiales: IMOAndMaterialsRules[], dataStockPersonal: Pick<StockPersonalENTITY, 'Despacho' | 'Item' | 'Devolucion' | 'Liquidacion' | 'DespachoTR' | 'DevolucionTR'>[]): Pick<StockPersonalENTITY, "Despacho" | "Item" | "Devolucion" | "Liquidacion" | "DespachoTR" | "DevolucionTR">[];
309
+ interface IMateriales {
310
+ id: string;
311
+ cantidad: number;
312
+ item: ItemDetalleLogisticaDTO;
313
+ material: IMOAndMaterialsRules;
314
+ }
315
+ declare function checkAndBuildMaterialsFromPersonalStock(Materiales: IMOAndMaterialsRules[], dataStockPersonal: StockPersonalENTITY[], id: string): IMateriales[];
310
316
 
311
317
  declare function buildDataMaterialsRule(Materiales: Map<string, IMOAndMaterialsRules>, dataStockPersonal: Pick<StockPersonalENTITY, 'ID_StockPersonal' | 'Item' | 'Lote'>[]): {
312
318
  id: number;
@@ -489,4 +495,4 @@ declare function generateUniqueNumber(): number;
489
495
 
490
496
  declare function setContext(this: any, modules: __WebpackModuleApi.RequireContext): void;
491
497
 
492
- export { ActualizarDataManoObra, ActualizarDataReserva, ActualizarDataResumenLiquidaciones, ActualizarDataResumenValorizacionesAlemania, ActualizarDataTrabajos, BuscarZonaContratista, CalcularResumenHPMOLiquidado, CalcularResumenLiquidaciones, CalcularResumenValorizacionesAlemania, CodigosMaterialDuctosAL02, CodigosMaterialDuctosAL04, CodigosMaterialSoplado, CodsMapeoMOMaterial, CodsMapeoMOMaterialNVT01, CodsMapeoMOMaterialSopladoClientes, CodsMapeoMOMaterialSopladoTroncal, CodsMapeoMO_Material_Arquertas, CompararFechas, CurrencyFormat, DocumentacionReplanteo, GemeindeChangeNomenclatura, GetCodigoFechaActual, type IDocumentacion, type IMOAndMaterialsRules, MOCantidadNVT01, MOHijasAL04, MOHijasDEPTH, MapeoMOBOMAL04, MapeoMatBOMAL04, type MatRetiradosType, type MatStockAlmacenType, type MatStockPersonalType$1 as MatStockPersonalType, type MatUtilizadosType$1 as MatUtilizadosType, type MoUoType$1 as MoUoType, ModelDataFlujosDocumentacionReplanteo, ObtenerMONoReservada, ObtenerPrecioContratistaVigente, ObtenerZonaAsignada, type ResumenLiquidacionesType, type ResumenLiquidacionesTypeChile, SEGMENT_TY, type TARGET, UpdateNodosDocDP, buildDataMaterialsRule, buildMaterialsFromPersonalStock, codBalizaAL04, codClientes, codMOClientesAL02, codMOClientesAL02Asfaltado, codMOClientesAL02OC, codMOClientesAL02Soplado, codMOClientes_ReglaLiquidacion1, codMODROPAL04, codMODROPAL04OC, codMODROPAL04Soplado, codMOFTTFAL04, codMONoClientesAL02, codMONoClientesAL02Asfaltado, codMONoClientesAL02OC, codMONoClientesAL02Soplado, codMONoClientes_ReglaLiquidacion1, codMOOcultosAL04, codMOPublico, codMOTroncalAL02, codMOTroncalAL02Asfaltado, codMOTroncalAL02OC, codMOTroncalAL02Soplado, codMOTroncalAL04, codMOTroncalAL04Asfaltado, codMOTroncalAL04OC, codMOTroncalAL04Soplado, codMOTroncal_ReglaLiquidacion1, codNoCliente, codSopladoRD, codigosMOT1_F2, codigosMaterialDuctos, codigosMaterialUGG, convertDates, dataFlujosHomePass, esCadenaFechaISOValida, esObjetoFecha, generateUniqueNumber, getChannelName, getDateInTimeZone, getKeyRedisSortedSet, getModelDataAdicional, getNextID_Valorizacion, getQueueName, getQueueNameSaveOneNotification, isValidDate, isValidPartialEntity, logTiempoProceso, mapaEstadoObraFaseAL02, mapaMOMaterialAL02, mapaMOMaterialAL04, mapaReglaSopladoClientes, mapaReglaSopladoTroncal, obtenerDocumentacionClientes, obtenerDocumentacionNoClientes, obtenerPrecioManoObraAL02, obtenerPrecioManoObraAL04, obtenerTipoYCodigoMO, paisMap, searchCurrentContractorSpecialtyPrice, setContext, updatePriceContractorMOAL02, updatePriceContractorMOAL04, updatePriceMOAL02, updatePriceMOAL04, validateNoLookup };
498
+ export { ActualizarDataManoObra, ActualizarDataReserva, ActualizarDataResumenLiquidaciones, ActualizarDataResumenValorizacionesAlemania, ActualizarDataTrabajos, BuscarZonaContratista, CalcularResumenHPMOLiquidado, CalcularResumenLiquidaciones, CalcularResumenValorizacionesAlemania, CodigosMaterialDuctosAL02, CodigosMaterialDuctosAL04, CodigosMaterialSoplado, CodsMapeoMOMaterial, CodsMapeoMOMaterialNVT01, CodsMapeoMOMaterialSopladoClientes, CodsMapeoMOMaterialSopladoTroncal, CodsMapeoMO_Material_Arquertas, CompararFechas, CurrencyFormat, DocumentacionReplanteo, GemeindeChangeNomenclatura, GetCodigoFechaActual, type IDocumentacion, type IMOAndMaterialsRules, MOCantidadNVT01, MOHijasAL04, MOHijasDEPTH, MapeoMOBOMAL04, MapeoMatBOMAL04, type MatRetiradosType, type MatStockAlmacenType, type MatStockPersonalType$1 as MatStockPersonalType, type MatUtilizadosType$1 as MatUtilizadosType, type MoUoType$1 as MoUoType, ModelDataFlujosDocumentacionReplanteo, ObtenerMONoReservada, ObtenerPrecioContratistaVigente, ObtenerZonaAsignada, type ResumenLiquidacionesType, type ResumenLiquidacionesTypeChile, SEGMENT_TY, type TARGET, UpdateNodosDocDP, buildDataMaterialsRule, checkAndBuildMaterialsFromPersonalStock, codBalizaAL04, codClientes, codMOClientesAL02, codMOClientesAL02Asfaltado, codMOClientesAL02OC, codMOClientesAL02Soplado, codMOClientes_ReglaLiquidacion1, codMODROPAL04, codMODROPAL04OC, codMODROPAL04Soplado, codMOFTTFAL04, codMONoClientesAL02, codMONoClientesAL02Asfaltado, codMONoClientesAL02OC, codMONoClientesAL02Soplado, codMONoClientes_ReglaLiquidacion1, codMOOcultosAL04, codMOPublico, codMOTroncalAL02, codMOTroncalAL02Asfaltado, codMOTroncalAL02OC, codMOTroncalAL02Soplado, codMOTroncalAL04, codMOTroncalAL04Asfaltado, codMOTroncalAL04OC, codMOTroncalAL04Soplado, codMOTroncal_ReglaLiquidacion1, codNoCliente, codSopladoRD, codigosMOT1_F2, codigosMaterialDuctos, codigosMaterialUGG, convertDates, dataFlujosHomePass, esCadenaFechaISOValida, esObjetoFecha, generateUniqueNumber, getChannelName, getDateInTimeZone, getKeyRedisSortedSet, getModelDataAdicional, getNextID_Valorizacion, getQueueName, getQueueNameSaveOneNotification, isValidDate, isValidPartialEntity, logTiempoProceso, mapaEstadoObraFaseAL02, mapaMOMaterialAL02, mapaMOMaterialAL04, mapaReglaSopladoClientes, mapaReglaSopladoTroncal, obtenerDocumentacionClientes, obtenerDocumentacionNoClientes, obtenerPrecioManoObraAL02, obtenerPrecioManoObraAL04, obtenerTipoYCodigoMO, paisMap, searchCurrentContractorSpecialtyPrice, setContext, updatePriceContractorMOAL02, updatePriceContractorMOAL04, updatePriceMOAL02, updatePriceMOAL04, validateNoLookup };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ManoObraENTITY, ReservaENTITY, HomePassDTO, FlujoDocDTO, NodoDocDTO, DocumentacionPEXENTITY, ManoObraGlobalENTITY, PrecioEspecialidadENTITY, ObraChile9512ENTITY, ValorizacionManoObraDTO, ValorizacionDTO, PrecioContratistaMOAL02ENTITY, StockPersonalENTITY, TrabajoENTITY, ActividadesDTO, PreciosVigentesDTO, ContratoOTENTITY } from 'sigo-entities';
1
+ import { ManoObraENTITY, ReservaENTITY, HomePassDTO, FlujoDocDTO, NodoDocDTO, DocumentacionPEXENTITY, ManoObraGlobalENTITY, PrecioEspecialidadENTITY, ObraChile9512ENTITY, ValorizacionManoObraDTO, ValorizacionDTO, PrecioContratistaMOAL02ENTITY, StockPersonalENTITY, ItemDetalleLogisticaDTO, TrabajoENTITY, ActividadesDTO, PreciosVigentesDTO, ContratoOTENTITY } from 'sigo-entities';
2
2
 
3
3
  interface IenvSIGO$1 {
4
4
  SISTEMAS_VALORIZACION_MANO_OBRA: string[];
@@ -306,7 +306,13 @@ declare function obtenerTipoYCodigoMO(codigoOriginal: string): {
306
306
  CodigoMO: string;
307
307
  };
308
308
 
309
- declare function buildMaterialsFromPersonalStock(Materiales: IMOAndMaterialsRules[], dataStockPersonal: Pick<StockPersonalENTITY, 'Despacho' | 'Item' | 'Devolucion' | 'Liquidacion' | 'DespachoTR' | 'DevolucionTR'>[]): Pick<StockPersonalENTITY, "Despacho" | "Item" | "Devolucion" | "Liquidacion" | "DespachoTR" | "DevolucionTR">[];
309
+ interface IMateriales {
310
+ id: string;
311
+ cantidad: number;
312
+ item: ItemDetalleLogisticaDTO;
313
+ material: IMOAndMaterialsRules;
314
+ }
315
+ declare function checkAndBuildMaterialsFromPersonalStock(Materiales: IMOAndMaterialsRules[], dataStockPersonal: StockPersonalENTITY[], id: string): IMateriales[];
310
316
 
311
317
  declare function buildDataMaterialsRule(Materiales: Map<string, IMOAndMaterialsRules>, dataStockPersonal: Pick<StockPersonalENTITY, 'ID_StockPersonal' | 'Item' | 'Lote'>[]): {
312
318
  id: number;
@@ -489,4 +495,4 @@ declare function generateUniqueNumber(): number;
489
495
 
490
496
  declare function setContext(this: any, modules: __WebpackModuleApi.RequireContext): void;
491
497
 
492
- export { ActualizarDataManoObra, ActualizarDataReserva, ActualizarDataResumenLiquidaciones, ActualizarDataResumenValorizacionesAlemania, ActualizarDataTrabajos, BuscarZonaContratista, CalcularResumenHPMOLiquidado, CalcularResumenLiquidaciones, CalcularResumenValorizacionesAlemania, CodigosMaterialDuctosAL02, CodigosMaterialDuctosAL04, CodigosMaterialSoplado, CodsMapeoMOMaterial, CodsMapeoMOMaterialNVT01, CodsMapeoMOMaterialSopladoClientes, CodsMapeoMOMaterialSopladoTroncal, CodsMapeoMO_Material_Arquertas, CompararFechas, CurrencyFormat, DocumentacionReplanteo, GemeindeChangeNomenclatura, GetCodigoFechaActual, type IDocumentacion, type IMOAndMaterialsRules, MOCantidadNVT01, MOHijasAL04, MOHijasDEPTH, MapeoMOBOMAL04, MapeoMatBOMAL04, type MatRetiradosType, type MatStockAlmacenType, type MatStockPersonalType$1 as MatStockPersonalType, type MatUtilizadosType$1 as MatUtilizadosType, type MoUoType$1 as MoUoType, ModelDataFlujosDocumentacionReplanteo, ObtenerMONoReservada, ObtenerPrecioContratistaVigente, ObtenerZonaAsignada, type ResumenLiquidacionesType, type ResumenLiquidacionesTypeChile, SEGMENT_TY, type TARGET, UpdateNodosDocDP, buildDataMaterialsRule, buildMaterialsFromPersonalStock, codBalizaAL04, codClientes, codMOClientesAL02, codMOClientesAL02Asfaltado, codMOClientesAL02OC, codMOClientesAL02Soplado, codMOClientes_ReglaLiquidacion1, codMODROPAL04, codMODROPAL04OC, codMODROPAL04Soplado, codMOFTTFAL04, codMONoClientesAL02, codMONoClientesAL02Asfaltado, codMONoClientesAL02OC, codMONoClientesAL02Soplado, codMONoClientes_ReglaLiquidacion1, codMOOcultosAL04, codMOPublico, codMOTroncalAL02, codMOTroncalAL02Asfaltado, codMOTroncalAL02OC, codMOTroncalAL02Soplado, codMOTroncalAL04, codMOTroncalAL04Asfaltado, codMOTroncalAL04OC, codMOTroncalAL04Soplado, codMOTroncal_ReglaLiquidacion1, codNoCliente, codSopladoRD, codigosMOT1_F2, codigosMaterialDuctos, codigosMaterialUGG, convertDates, dataFlujosHomePass, esCadenaFechaISOValida, esObjetoFecha, generateUniqueNumber, getChannelName, getDateInTimeZone, getKeyRedisSortedSet, getModelDataAdicional, getNextID_Valorizacion, getQueueName, getQueueNameSaveOneNotification, isValidDate, isValidPartialEntity, logTiempoProceso, mapaEstadoObraFaseAL02, mapaMOMaterialAL02, mapaMOMaterialAL04, mapaReglaSopladoClientes, mapaReglaSopladoTroncal, obtenerDocumentacionClientes, obtenerDocumentacionNoClientes, obtenerPrecioManoObraAL02, obtenerPrecioManoObraAL04, obtenerTipoYCodigoMO, paisMap, searchCurrentContractorSpecialtyPrice, setContext, updatePriceContractorMOAL02, updatePriceContractorMOAL04, updatePriceMOAL02, updatePriceMOAL04, validateNoLookup };
498
+ export { ActualizarDataManoObra, ActualizarDataReserva, ActualizarDataResumenLiquidaciones, ActualizarDataResumenValorizacionesAlemania, ActualizarDataTrabajos, BuscarZonaContratista, CalcularResumenHPMOLiquidado, CalcularResumenLiquidaciones, CalcularResumenValorizacionesAlemania, CodigosMaterialDuctosAL02, CodigosMaterialDuctosAL04, CodigosMaterialSoplado, CodsMapeoMOMaterial, CodsMapeoMOMaterialNVT01, CodsMapeoMOMaterialSopladoClientes, CodsMapeoMOMaterialSopladoTroncal, CodsMapeoMO_Material_Arquertas, CompararFechas, CurrencyFormat, DocumentacionReplanteo, GemeindeChangeNomenclatura, GetCodigoFechaActual, type IDocumentacion, type IMOAndMaterialsRules, MOCantidadNVT01, MOHijasAL04, MOHijasDEPTH, MapeoMOBOMAL04, MapeoMatBOMAL04, type MatRetiradosType, type MatStockAlmacenType, type MatStockPersonalType$1 as MatStockPersonalType, type MatUtilizadosType$1 as MatUtilizadosType, type MoUoType$1 as MoUoType, ModelDataFlujosDocumentacionReplanteo, ObtenerMONoReservada, ObtenerPrecioContratistaVigente, ObtenerZonaAsignada, type ResumenLiquidacionesType, type ResumenLiquidacionesTypeChile, SEGMENT_TY, type TARGET, UpdateNodosDocDP, buildDataMaterialsRule, checkAndBuildMaterialsFromPersonalStock, codBalizaAL04, codClientes, codMOClientesAL02, codMOClientesAL02Asfaltado, codMOClientesAL02OC, codMOClientesAL02Soplado, codMOClientes_ReglaLiquidacion1, codMODROPAL04, codMODROPAL04OC, codMODROPAL04Soplado, codMOFTTFAL04, codMONoClientesAL02, codMONoClientesAL02Asfaltado, codMONoClientesAL02OC, codMONoClientesAL02Soplado, codMONoClientes_ReglaLiquidacion1, codMOOcultosAL04, codMOPublico, codMOTroncalAL02, codMOTroncalAL02Asfaltado, codMOTroncalAL02OC, codMOTroncalAL02Soplado, codMOTroncalAL04, codMOTroncalAL04Asfaltado, codMOTroncalAL04OC, codMOTroncalAL04Soplado, codMOTroncal_ReglaLiquidacion1, codNoCliente, codSopladoRD, codigosMOT1_F2, codigosMaterialDuctos, codigosMaterialUGG, convertDates, dataFlujosHomePass, esCadenaFechaISOValida, esObjetoFecha, generateUniqueNumber, getChannelName, getDateInTimeZone, getKeyRedisSortedSet, getModelDataAdicional, getNextID_Valorizacion, getQueueName, getQueueNameSaveOneNotification, isValidDate, isValidPartialEntity, logTiempoProceso, mapaEstadoObraFaseAL02, mapaMOMaterialAL02, mapaMOMaterialAL04, mapaReglaSopladoClientes, mapaReglaSopladoTroncal, obtenerDocumentacionClientes, obtenerDocumentacionNoClientes, obtenerPrecioManoObraAL02, obtenerPrecioManoObraAL04, obtenerTipoYCodigoMO, paisMap, searchCurrentContractorSpecialtyPrice, setContext, updatePriceContractorMOAL02, updatePriceContractorMOAL04, updatePriceMOAL02, updatePriceMOAL04, validateNoLookup };
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ __export(index_exports, {
57
57
  SEGMENT_TY: () => SEGMENT_TY,
58
58
  UpdateNodosDocDP: () => UpdateNodosDocDP,
59
59
  buildDataMaterialsRule: () => buildDataMaterialsRule,
60
- buildMaterialsFromPersonalStock: () => buildMaterialsFromPersonalStock,
60
+ checkAndBuildMaterialsFromPersonalStock: () => checkAndBuildMaterialsFromPersonalStock,
61
61
  codBalizaAL04: () => codBalizaAL04,
62
62
  codClientes: () => codClientes,
63
63
  codMOClientesAL02: () => codMOClientesAL02,
@@ -5899,30 +5899,37 @@ function updatePriceMOAL04(valorizaciones, priceContractorMO) {
5899
5899
  }
5900
5900
  __name(updatePriceMOAL04, "updatePriceMOAL04");
5901
5901
 
5902
- // src/Programados/Alemania/buildMaterialsFromPersonalStock.ts
5903
- function buildMaterialsFromPersonalStock(Materiales, dataStockPersonal) {
5902
+ // src/Programados/Alemania/checkAndBuildMaterialsFromPersonalStock.ts
5903
+ function checkAndBuildMaterialsFromPersonalStock(Materiales, dataStockPersonal, id) {
5904
+ const errores = [];
5905
+ for (const element of Materiales) {
5906
+ const exist = dataStockPersonal.find((e) => e.Item.Codigo === element.Codigo);
5907
+ if (!exist) {
5908
+ errores.push(element.Codigo);
5909
+ }
5910
+ }
5911
+ if (errores.length) {
5912
+ throw new Error(`No se encontr\xF3 materiales ${errores.join(", ").trim()}, en el stock personal para este trabajo`);
5913
+ }
5904
5914
  const materiales = [];
5905
5915
  for (const material of Materiales) {
5906
5916
  const { Codigo: codMaterial } = material;
5907
- const stocksPersonal = dataStockPersonal.filter((e) => e.Item.Codigo === codMaterial);
5908
- if (stocksPersonal.length === 0) {
5917
+ const stocksPersonal = dataStockPersonal.find((e) => e.Item.Codigo === codMaterial);
5918
+ if (!stocksPersonal) {
5909
5919
  throw new Error(`No se encontr\xF3 el material ${codMaterial} en el stock personal para este trabajo.`);
5910
5920
  }
5911
- for (const [i, stock] of stocksPersonal.entries()) {
5912
- const disponible = stock.Despacho - stock.Devolucion - stock.Liquidacion + stock.DespachoTR - stock.DevolucionTR;
5913
- if (disponible < material.Cantidad && i === stocksPersonal.length - 1) {
5914
- throw new Error(`No hay stock suficiente para el material ${codMaterial} en el stock personal para este trabajo.`);
5915
- } else if (disponible < material.Cantidad) {
5916
- continue;
5917
- } else {
5918
- materiales.push(stock);
5919
- break;
5920
- }
5921
- }
5921
+ const cantidad = material.CantidadPadre ? 0 : material.CantidadFija ? material.Cantidad : 0;
5922
+ materiales.push({
5923
+ item: stocksPersonal.Item,
5924
+ id,
5925
+ cantidad: cantidad * material.Factor,
5926
+ material
5927
+ });
5928
+ break;
5922
5929
  }
5923
5930
  return materiales;
5924
5931
  }
5925
- __name(buildMaterialsFromPersonalStock, "buildMaterialsFromPersonalStock");
5932
+ __name(checkAndBuildMaterialsFromPersonalStock, "checkAndBuildMaterialsFromPersonalStock");
5926
5933
 
5927
5934
  // src/Programados/Alemania/buildDataMaterialsRule.ts
5928
5935
  function buildDataMaterialsRule(Materiales, dataStockPersonal) {
@@ -6513,7 +6520,7 @@ var getNextID_Valorizacion = /* @__PURE__ */ __name((valorizaciones) => {
6513
6520
  SEGMENT_TY,
6514
6521
  UpdateNodosDocDP,
6515
6522
  buildDataMaterialsRule,
6516
- buildMaterialsFromPersonalStock,
6523
+ checkAndBuildMaterialsFromPersonalStock,
6517
6524
  codBalizaAL04,
6518
6525
  codClientes,
6519
6526
  codMOClientesAL02,
package/dist/index.mjs CHANGED
@@ -5776,30 +5776,37 @@ function updatePriceMOAL04(valorizaciones, priceContractorMO) {
5776
5776
  }
5777
5777
  __name(updatePriceMOAL04, "updatePriceMOAL04");
5778
5778
 
5779
- // src/Programados/Alemania/buildMaterialsFromPersonalStock.ts
5780
- function buildMaterialsFromPersonalStock(Materiales, dataStockPersonal) {
5779
+ // src/Programados/Alemania/checkAndBuildMaterialsFromPersonalStock.ts
5780
+ function checkAndBuildMaterialsFromPersonalStock(Materiales, dataStockPersonal, id) {
5781
+ const errores = [];
5782
+ for (const element of Materiales) {
5783
+ const exist = dataStockPersonal.find((e) => e.Item.Codigo === element.Codigo);
5784
+ if (!exist) {
5785
+ errores.push(element.Codigo);
5786
+ }
5787
+ }
5788
+ if (errores.length) {
5789
+ throw new Error(`No se encontr\xF3 materiales ${errores.join(", ").trim()}, en el stock personal para este trabajo`);
5790
+ }
5781
5791
  const materiales = [];
5782
5792
  for (const material of Materiales) {
5783
5793
  const { Codigo: codMaterial } = material;
5784
- const stocksPersonal = dataStockPersonal.filter((e) => e.Item.Codigo === codMaterial);
5785
- if (stocksPersonal.length === 0) {
5794
+ const stocksPersonal = dataStockPersonal.find((e) => e.Item.Codigo === codMaterial);
5795
+ if (!stocksPersonal) {
5786
5796
  throw new Error(`No se encontr\xF3 el material ${codMaterial} en el stock personal para este trabajo.`);
5787
5797
  }
5788
- for (const [i, stock] of stocksPersonal.entries()) {
5789
- const disponible = stock.Despacho - stock.Devolucion - stock.Liquidacion + stock.DespachoTR - stock.DevolucionTR;
5790
- if (disponible < material.Cantidad && i === stocksPersonal.length - 1) {
5791
- throw new Error(`No hay stock suficiente para el material ${codMaterial} en el stock personal para este trabajo.`);
5792
- } else if (disponible < material.Cantidad) {
5793
- continue;
5794
- } else {
5795
- materiales.push(stock);
5796
- break;
5797
- }
5798
- }
5798
+ const cantidad = material.CantidadPadre ? 0 : material.CantidadFija ? material.Cantidad : 0;
5799
+ materiales.push({
5800
+ item: stocksPersonal.Item,
5801
+ id,
5802
+ cantidad: cantidad * material.Factor,
5803
+ material
5804
+ });
5805
+ break;
5799
5806
  }
5800
5807
  return materiales;
5801
5808
  }
5802
- __name(buildMaterialsFromPersonalStock, "buildMaterialsFromPersonalStock");
5809
+ __name(checkAndBuildMaterialsFromPersonalStock, "checkAndBuildMaterialsFromPersonalStock");
5803
5810
 
5804
5811
  // src/Programados/Alemania/buildDataMaterialsRule.ts
5805
5812
  function buildDataMaterialsRule(Materiales, dataStockPersonal) {
@@ -6389,7 +6396,7 @@ export {
6389
6396
  SEGMENT_TY,
6390
6397
  UpdateNodosDocDP,
6391
6398
  buildDataMaterialsRule,
6392
- buildMaterialsFromPersonalStock,
6399
+ checkAndBuildMaterialsFromPersonalStock,
6393
6400
  codBalizaAL04,
6394
6401
  codClientes,
6395
6402
  codMOClientesAL02,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sigo-package",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "description": "Funciones compartidas sigo",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",