sigo-package 1.2.22 → 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[];
@@ -309,9 +309,10 @@ declare function obtenerTipoYCodigoMO(codigoOriginal: string): {
309
309
  interface IMateriales {
310
310
  id: string;
311
311
  cantidad: number;
312
- stockPersonal: StockPersonalENTITY;
312
+ item: ItemDetalleLogisticaDTO;
313
+ material: IMOAndMaterialsRules;
313
314
  }
314
- declare function buildMaterialsFromPersonalStock(Materiales: IMOAndMaterialsRules[], dataStockPersonal: StockPersonalENTITY[], id: string, CantidadPadre?: number): IMateriales[];
315
+ declare function checkAndBuildMaterialsFromPersonalStock(Materiales: IMOAndMaterialsRules[], dataStockPersonal: StockPersonalENTITY[], id: string): IMateriales[];
315
316
 
316
317
  declare function buildDataMaterialsRule(Materiales: Map<string, IMOAndMaterialsRules>, dataStockPersonal: Pick<StockPersonalENTITY, 'ID_StockPersonal' | 'Item' | 'Lote'>[]): {
317
318
  id: number;
@@ -494,4 +495,4 @@ declare function generateUniqueNumber(): number;
494
495
 
495
496
  declare function setContext(this: any, modules: __WebpackModuleApi.RequireContext): void;
496
497
 
497
- 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[];
@@ -309,9 +309,10 @@ declare function obtenerTipoYCodigoMO(codigoOriginal: string): {
309
309
  interface IMateriales {
310
310
  id: string;
311
311
  cantidad: number;
312
- stockPersonal: StockPersonalENTITY;
312
+ item: ItemDetalleLogisticaDTO;
313
+ material: IMOAndMaterialsRules;
313
314
  }
314
- declare function buildMaterialsFromPersonalStock(Materiales: IMOAndMaterialsRules[], dataStockPersonal: StockPersonalENTITY[], id: string, CantidadPadre?: number): IMateriales[];
315
+ declare function checkAndBuildMaterialsFromPersonalStock(Materiales: IMOAndMaterialsRules[], dataStockPersonal: StockPersonalENTITY[], id: string): IMateriales[];
315
316
 
316
317
  declare function buildDataMaterialsRule(Materiales: Map<string, IMOAndMaterialsRules>, dataStockPersonal: Pick<StockPersonalENTITY, 'ID_StockPersonal' | 'Item' | 'Lote'>[]): {
317
318
  id: number;
@@ -494,4 +495,4 @@ declare function generateUniqueNumber(): number;
494
495
 
495
496
  declare function setContext(this: any, modules: __WebpackModuleApi.RequireContext): void;
496
497
 
497
- 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,35 +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, id, CantidadPadre = 0) {
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, stockPersonal] of stocksPersonal.entries()) {
5912
- const disponible = stockPersonal.Despacho - stockPersonal.Devolucion - stockPersonal.Liquidacion + stockPersonal.DespachoTR - stockPersonal.DevolucionTR;
5913
- if (disponible < material.Cantidad && i === stocksPersonal.length - 1) {
5914
- throw new Error(`No tiene stock personal suficiente para el material '${codMaterial}' para este trabajo.`);
5915
- } else if (disponible < material.Cantidad) {
5916
- continue;
5917
- } else {
5918
- const _cantidad = material.CantidadPadre ? CantidadPadre : material.CantidadFija ? material.Cantidad : 0;
5919
- materiales.push({
5920
- stockPersonal,
5921
- id,
5922
- cantidad: _cantidad * material.Factor
5923
- });
5924
- break;
5925
- }
5926
- }
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;
5927
5929
  }
5928
5930
  return materiales;
5929
5931
  }
5930
- __name(buildMaterialsFromPersonalStock, "buildMaterialsFromPersonalStock");
5932
+ __name(checkAndBuildMaterialsFromPersonalStock, "checkAndBuildMaterialsFromPersonalStock");
5931
5933
 
5932
5934
  // src/Programados/Alemania/buildDataMaterialsRule.ts
5933
5935
  function buildDataMaterialsRule(Materiales, dataStockPersonal) {
@@ -6518,7 +6520,7 @@ var getNextID_Valorizacion = /* @__PURE__ */ __name((valorizaciones) => {
6518
6520
  SEGMENT_TY,
6519
6521
  UpdateNodosDocDP,
6520
6522
  buildDataMaterialsRule,
6521
- buildMaterialsFromPersonalStock,
6523
+ checkAndBuildMaterialsFromPersonalStock,
6522
6524
  codBalizaAL04,
6523
6525
  codClientes,
6524
6526
  codMOClientesAL02,
package/dist/index.mjs CHANGED
@@ -5776,35 +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, id, CantidadPadre = 0) {
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, stockPersonal] of stocksPersonal.entries()) {
5789
- const disponible = stockPersonal.Despacho - stockPersonal.Devolucion - stockPersonal.Liquidacion + stockPersonal.DespachoTR - stockPersonal.DevolucionTR;
5790
- if (disponible < material.Cantidad && i === stocksPersonal.length - 1) {
5791
- throw new Error(`No tiene stock personal suficiente para el material '${codMaterial}' para este trabajo.`);
5792
- } else if (disponible < material.Cantidad) {
5793
- continue;
5794
- } else {
5795
- const _cantidad = material.CantidadPadre ? CantidadPadre : material.CantidadFija ? material.Cantidad : 0;
5796
- materiales.push({
5797
- stockPersonal,
5798
- id,
5799
- cantidad: _cantidad * material.Factor
5800
- });
5801
- break;
5802
- }
5803
- }
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;
5804
5806
  }
5805
5807
  return materiales;
5806
5808
  }
5807
- __name(buildMaterialsFromPersonalStock, "buildMaterialsFromPersonalStock");
5809
+ __name(checkAndBuildMaterialsFromPersonalStock, "checkAndBuildMaterialsFromPersonalStock");
5808
5810
 
5809
5811
  // src/Programados/Alemania/buildDataMaterialsRule.ts
5810
5812
  function buildDataMaterialsRule(Materiales, dataStockPersonal) {
@@ -6394,7 +6396,7 @@ export {
6394
6396
  SEGMENT_TY,
6395
6397
  UpdateNodosDocDP,
6396
6398
  buildDataMaterialsRule,
6397
- buildMaterialsFromPersonalStock,
6399
+ checkAndBuildMaterialsFromPersonalStock,
6398
6400
  codBalizaAL04,
6399
6401
  codClientes,
6400
6402
  codMOClientesAL02,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sigo-package",
3
- "version": "1.2.22",
3
+ "version": "1.2.23",
4
4
  "description": "Funciones compartidas sigo",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",