Snippets Collections
<?=$form->field($model, 'id_indicador')->widget(DepDrop::classname(), [
                                                'options' => ['id' => 'id-indicador', 'onchange' => 'buscarIdentificador(this.value)'],
                                            /* aqui*/'data' => $model->isNewRecord ? [] : ArrayHelper::map(Indicadoresentescon::find()->where(['id_ente' => $model->id_ente])->all(), 'id_indicador', 'nombre_indicador'),
                                                // ensure at least the preselected value is available
                                                'pluginOptions' => [
                                                'depends' => ['id-ente'],
                                                // the id for cat attribute
                                                'placeholder' => 'Seleccione un indicador...',
                                                'url' => Url::to(['indicadores/listar'])
                                                ]
                                        ]); ?>
 <div class="main-sect-first-word">Transforming Businesses 
   </div>
 <div class="main-sect-second-word"> Through     
    <div class="main-switch">
        <div class="switch-wrapper">
        <div class="one switch">
            <div class="one circle"><span></span></div>
            <div class="word">Digitally</div>
        </div>
    </div>
    <div class="switch-wrapper">
        
    <div class="two switch">
            <div class="two circle"><span></span></div>
            <div class="word">Creatively</div>
        </div>
    </div>
    <div class="switch-wrapper">
    
        <div class="three switch">
            <div class="three circle"><span></span></div>
            <div class="word">Strategically</div>
        </div>
    </div>
</div>
</div>



.one.switch:before {
    animation: bgExpand1 2.5s ease-in-out infinite alternate;
  }
  
  .one.circle {
    animation: toggleSwitch1 2.5s ease-in-out infinite alternate;
  }
  
  .two.circle {
    animation: toggleSwitch2 2.5s ease-in-out infinite alternate;
  }
  
  .two.switch:before {
    animation: bgExpand2 2.5s ease-in-out infinite alternate;
  }
  
  .three.circle {
    animation: toggleSwitch3 2.5s ease-in-out infinite alternate;
  }
  
  .three.switch:before {
    animation: bgExpand3 2.5s ease-in-out infinite alternate;
  }
  
  .one.switch:before {
    animation: bgExpand1 2.5s ease-in-out infinite alternate;
  }
  
  .two.switch:before {
    animation: bgExpand2 2.5s ease-in-out infinite alternate;
  }
  
  .three.switch:before {
    animation: bgExpand3 2.5s ease-in-out infinite alternate;
  }
  
  @keyframes toggleSwitch3 {
    0% {
      transform: translateX(0px);
    }
  
    100% {
      transform: translateX(318px);
    }
  }
  
  @keyframes bgExpand3 {
    0% {
      width: 60px;
    }
  
    100% {
      width: 385px;
    }
  }
  
  @keyframes toggleSwitch2 {
    0% {
      transform: translateX(0);
    }
  
    100% {
      transform: translateX(262px);
    }
  }
  
  @keyframes bgExpand2 {
    0% {
      width: 60px;
    }
  
    100% {
      width: 325px;
    }
  }
  
  @keyframes toggleSwitch1 {
    0% {
      transform: translateX(0px);
    }
  
    100% {
      transform: translateX(206px);
    }
  }
  
  @keyframes bgExpand1 {
    0% {
      width: 60px;
    }
  
    100% {
      width: 270px;
    }
  }
  
  .one.switch {
    width: 270px;
  }
  
  .two.switch {
    width: 325px;
  }
  
  .three.switch {
    width: 385px;
  }
  
  .switch {
    position: relative;
    height: 65px;
    border-radius: 100px;
    overflow: hidden;
    background-color: transparent;
    margin-bottom: 20px;
    margin-top: 5px;
  }
  
  .switch::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 100px;
    z-index: 0;
    background: linear-gradient(90deg, #89d501 0%, #33b1ad 100%);
    box-shadow: 1.673px -8.366px 41.829px 0px rgba(0, 0, 0, 0.2) inset;
  }
  
  .circle {
    width: 58px;
    height: 58px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background: linear-gradient(90deg, #89d501 0%, #33b1ad 100%);
    padding: 4px;
    box-sizing: border-box;
    position: absolute;
    top: 3px;
    left: 5px;
    z-index: 4;
  }
  
  .circle span {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #f2f2f2;
    font-size: 18px;
    font-weight: bold;
  }
  .word {
    position: absolute;
    top: 9%;
    left: 20px;
    opacity: 0;
    transition: opacity 2.2s ease;
    z-index: 2;
    color: #f3f3f3;
    text-align: start;
    font-style: normal;
    line-height: normal;
    font-size: 42px;
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    width: 0;
    animation: expand-collapse 5s ease-in-out infinite;
  }
  
  @keyframes expand-collapse {
    0% {
      width: 0;
      opacity: 0;
    }
  
    45% {
      width: 100%;
      opacity: 1;
    }
  
    100% {
      width: 0;
      opacity: 0;
    }
  }
  
  .main-heading .title {
    display: flex;
    flex-wrap: wrap;
    position: relative;
    line-height: 70px;
    white-space: nowrap;
  }
  <script>
  const items = document.querySelectorAll('.switch-wrapper');
  let currentIndex = 0;
  const animationDuration = 5000;

  function startCycle() {
      items.forEach((item) => {
          item.style.display = 'none';
      });

      function showNextSwitch() {
          items[currentIndex].style.display = 'none';
          const currentItem = items[currentIndex];
          currentItem.querySelectorAll('.circle, .switch:before').forEach((el) => {
              el.style.animation = 'none';
              el.offsetHeight;
              el.style.animation = '';
          });
          currentIndex = (currentIndex + 1) % items.length;
          items[currentIndex].style.display = 'block';
      }
      items[currentIndex].style.display = 'block';
      setInterval(showNextSwitch, animationDuration);
  }
  startCycle();
</script>    

<!-- circle-animtion-end -->






<!DOCTYPE html>
<html lang="en">

<head>
 <style>
    .main-image-wrapper {
  z-index: 0;
}
.mainhomesect .image {
  position: absolute;
  width: 100%;
  max-width: 650px;
  object-fit: contain;
  transition: transform 8s ease-in-out;
}
img#image1 {
  transform: translate(48vw, -30vh);
}

img#image2 {
  transform: translate(-1vw, -30vh);
}

img#image3 {
  transform: translate(-39vw, 20vh);
}

img#image4 {
  transform: translate(-1vw, 72vh);
}

img#image5 {
  transform: translate(48vw, 72vh);
}

img#image6 {
  transform: translate(56vw, 20vh);
}

 </style>
</head>

<body>
  <div class="main-image-wrapper">
    <img src="https://mmcgbl.com/wp-content/uploads/2025/01/aerial.webp" alt="Image 1" class="image" id="image1">
    <img src="https://mmcgbl.com/wp-content/uploads/2025/01/getfit.webp" alt="Image 2" class="image" id="image2">
    <img src="https://mmcgbl.com/wp-content/uploads/2025/01/howwe.webp" alt="Image 3" class="image" id="image3">
        <img src="https://mmcgbl.com/wp-content/uploads/2025/01/aerial.webp" alt="Image 1" class="image" id="image4">
    <img src="https://mmcgbl.com/wp-content/uploads/2025/01/getfit.webp" alt="Image 2" class="image" id="image5">
    <img src="https://mmcgbl.com/wp-content/uploads/2025/01/howwe.webp" alt="Image 3" class="image" id="image6">
  </div>
 <script>
    const positions = [
      { x: 48, y: -30 }, //img1
      { x: -1, y: -30 }, //img2
      { x: -39, y: 20 }, //img 3
      { x: -1, y: 72 }, //img 4
      { x: 48, y: 72 }, //img5
      { x: 56, y: 20 } //img 6
    ];

    const images = [
      document.getElementById('image1'),
      document.getElementById('image2'),
      document.getElementById('image3'),
      document.getElementById('image4'),
      document.getElementById('image5'),
      document.getElementById('image6')
    ];


    const animateImages = () => {
      const lastPosition = positions.pop();
      positions.unshift(lastPosition);
      images.forEach((image, index) => {
        const pos = positions[index];
        image.style.transform = `translate(${pos.x}vw, ${pos.y}vh)`;
      });
    };
      setTimeout(() => {
      setInterval(animateImages, 8000);
      animateImages();
    }, 4000);
  </script>
</body>

</html>
Looking to launch a secure, scalable, and feature-rich cryptocurrency exchange development at a competitive price? Beleaftechnologies is your trusted partner! Our expert developers specialize in crafting custom crypto exchange solutions custmoized to your business needs. From decentralized exchanges to peer-to-peer platforms, we deliver innovative technology with lightning-fast transactions and strong security.
Why choose us? We prioritize quality, innovation, and affordability, ensuring your exchange stands out in the competitive market. With 24/7 support,smooth integration, and compliance with global regulations, we empower you to achieve success in the evolving blockchain landscape.

Join the transformation today! Contact Beleaftechnologies for cost-effective cryptocurrency exchange development in 2025. Your crypto journey begins here!
Visit now >>https://cryptocurrency-exchange-development-company.com/
Whatsapp :  +91 8056786622
Email id :  business@beleaftechnologies.com
Telegram : https://telegram.me/BeleafSoftTech 


/****************  OOPS IN JAVASCRIPT *************************/

/* JAVASCRIPT AND CLASSES 
So yes, JavaScript does have classes, and they are quite powerful for object-oriented programming!

/* OOP 

/*Object 
-collection to properties  and methods 
-ex: toLowerCase 

/* parts of oops
Object literal means literally assinged 

-constructor functions 
-prototypes 
-classes n
-Instances 

/* 4 pillars 
abstraction 
encaplusation 
inheritnace 
polymoriphism 
*/

const user = { // object literal 
    username: "hitesh ",
    logincount: 8,
    signedIn: true,

    getUserDetails: function() {
        console.log(`username: ${this.username}`);
        console.log(this); 
        /* output : {
  username: 'hitesh ',
  logincount: 8,
  signedIn: true,
  getUserDetails: [Function: getUserDetails]*/
}
    }

console.log(user.getUserDetails()); // username: hitesh //undefined
console.log(this); // {}

/////////////// CONSTRUCTOR FUNCTION //////////////
function User2(username, logincount, isLoggedIn) {
  this.username = username;
  this.logincount = logincount;
  this.isLoggedIn = isLoggedIn;
  
  this.greeting = functio
return this
}

const userOne =/*HERE new TO FIX THE ERROR*/ User2("hitesh", 12, true);
const userTwo = /*HERE new TO FIX THE ERROR*/User2("hitesh chaudhary", 18, false)
 console.log(userOne);   
/*username: 'hitesh chaudhary',
  logincount: 18,
  isLoggedIn: false*/ 
  /* INPORTANT == IF WE USE NEW IN DECLARATION SPACE IT WILL RUNCORRECTLY */ 
  
  /* INPORTANCE  and FEATURES OF NEW KEYWORD === when we use new keyword new empty object is made in first step , it will  call the constructor function in second step  , it will inject all the values which we passed in arguments , than it will return to you */ 
.hud-zoom-overlay-circle {
    border-radius: 100vh;
    position: fixed;
    top: 5vh;
    left: 50%;
    width: 90vh;
    height: 90vh;
    box-shadow: 0 0 0 9999px rgb(255 0 0);
    margin-left: -45vh;
}
.hud-zoom-overlay-vert{
    position: fixed;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: black;
}

.hud-zoom-overlay-horiz{
    position: fixed;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: #ff0000;
}

.hud-zoom-overlay-redpoint{
    position: fixed;
    left: 50%;
    top: 50%;
    width: 5px;
    height: 5px;
    border-radius: 5px;
    background: red;
    margin-top: -2px;
    margin-left: -2px;
}
/* HUD CROSSHAIR */
.hud-crosshair{
    visibility: clear;
    position: fixed;
    width: 25px;
    height: 25px;
    left: 50%;
    top: 50%;
    margin-left: -13px;
    margin-top: -13px;
    z-index: 12;
}

.hud-crosshair div{
    background: #00ff00;
    position: absolute;

}

.hud-crosshair-1, .hud-crosshair-2{
    width: 3px;
    height:10px;
    left: 12px;
}

.hud-crosshair-3, .hud-crosshair-4{
    width: 10px;
    height:3px;
    top: 12px;
}

.hud-crosshair-1{
    top:0;
}
.hud-crosshair-2{
    top:18px;
}
.hud-crosshair-3{
    left: 0;
}
.hud-crosshair-4{
    left: 17px;
}
/* HUD CROSSHAIR end */
.parent {
  display: flex; /* Enables Flexbox */
  height: 300px; /* Set a specific height for the parent div */
  border: 1px solid #000;
}

.child {
  background-color: lightblue;
  flex: 1; /* Optional: Makes the child take up remaining space */
}
@RestResource(urlMapping='/api/products/*')
global with sharing class ProductApi {

    // GET: Recuperar productos por External_ID__c (sin captura de log)
    @HttpGet
    global static List<Product2> getProducts() {
        RestRequest req = RestContext.request;
        String externalId = req.requestURI.substringAfterLast('/');

        if (String.isNotBlank(externalId)) {
            // Recuperar producto por External_ID__c
            List<Product2> products = [SELECT Id, Name, ProductCode, Description, IsActive, External_ID__c 
                                    FROM Product2 WHERE External_ID__c = :externalId];
            return products;
        } else {
            // Recuperar todos los productos si no se proporciona External_ID__c
            List<Product2> products = [SELECT Id, Name, ProductCode, Description, IsActive, External_ID__c 
                                    FROM Product2];
            return products;
        }
    }

    // PATCH: Crear o actualizar un producto y establecer su precio usando solo External_ID__c
    @HttpPatch
    global static Product2 upsertProduct(
        String externalId, 
        String name, 
        String productCode, 
        String description, 
        Boolean isActive, 
        Decimal price
    ) {
        RestRequest req = RestContext.request;
        Product2 product = null;
        try {
            if (String.isBlank(externalId)) {
                throw new CustomException('El campo External_ID__c es obligatorio para realizar un upsert.');
            }

            if (price == null || price < 0) {
                throw new CustomException('El precio debe ser un valor positivo.');
            }

            // Crear o actualizar el producto basado en External_ID__c
            product = new Product2(
                External_ID__c = externalId,
                Name = name,
                ProductCode = productCode,
                Description = description,
                IsActive = isActive
            );

            upsert product External_ID__c;

            // Buscar el Standard Pricebook
            List<Pricebook2> standardPricebookList = [SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1];
            if (standardPricebookList.isEmpty()) {
                throw new CustomException('No se encontró el Standard Pricebook.');
            }
            Pricebook2 standardPricebook = standardPricebookList[0];

            // Verificar si ya existe un PricebookEntry para este producto
            List<PricebookEntry> existingEntries = [
                SELECT Id, UnitPrice 
                FROM PricebookEntry 
                WHERE Product2Id = :product.Id AND Pricebook2Id = :standardPricebook.Id
            ];

            if (existingEntries.isEmpty()) {
                // Crear un nuevo PricebookEntry si no existe
                PricebookEntry newEntry = new PricebookEntry(
                    Pricebook2Id = standardPricebook.Id,
                    Product2Id = product.Id,
                    UnitPrice = price,
                    IsActive = true
                );
                insert newEntry;
            } else {
                // Actualizar el PricebookEntry existente
                PricebookEntry existingEntry = existingEntries[0];
                existingEntry.UnitPrice = price;
                update existingEntry;
            }

            // Log success
            logIntegrationDetails('PATCH', req, product, null);  // No hay error, pasamos null para la excepción

            return product;
        } catch (Exception e) {
            // Log error
            logIntegrationDetails('PATCH', req, null, e);  // Capturamos el error y lo pasamos al log
            throw e;  // Vuelve a lanzar la excepción para que se maneje como corresponde
        }
    }

    // DELETE: Eliminar un producto por External_ID__c
    @HttpDelete
    global static void deleteProduct() {
        RestRequest req = RestContext.request;
        String productIdOrExternalId = req.requestURI.substringAfterLast('/');

        if (String.isBlank(productIdOrExternalId)) {
            throw new CustomException('Debe proporcionar el ID o el External_ID__c para eliminar.');
        }

        Product2 productToDelete;

        if (productIdOrExternalId.startsWith('a') && productIdOrExternalId.length() == 18) {
            // Buscar por Id estándar
            productToDelete = [SELECT Id, IsDeleted FROM Product2 WHERE Id = :productIdOrExternalId AND IsDeleted = false LIMIT 1];
        } else {
            // Buscar por External_ID__c
            productToDelete = [SELECT Id, IsDeleted FROM Product2 WHERE External_ID__c = :productIdOrExternalId AND IsDeleted = false LIMIT 1];
        }

        // Si el producto no existe o está eliminado, lanzamos una excepción
        if (productToDelete == null || productToDelete.IsDeleted) {
            throw new CustomException('El producto no existe o ha sido eliminado.');
        }

        // Eliminar cualquier PricebookEntry relacionado en el Standard Pricebook
        List<Pricebook2> standardPricebookList = [SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1];
        if (!standardPricebookList.isEmpty()) {
            Pricebook2 standardPricebook = standardPricebookList[0];
            List<PricebookEntry> entriesToDelete = [
                SELECT Id 
                FROM PricebookEntry 
                WHERE Product2Id = :productToDelete.Id AND Pricebook2Id = :standardPricebook.Id
            ];
            delete entriesToDelete;
        }

        delete productToDelete;

        // Registrar el log de la integración
        try {
            logIntegrationDetails('DELETE', req, productToDelete, null);
        } catch (Exception e) {
            // Si algo sale mal, capturamos la excepción y la mostramos (aunque puede que ya esté registrada)
            System.debug('Error al registrar el log: ' + e.getMessage());
        }
    }

    // Método auxiliar para registrar los detalles de las solicitudes y respuestas en Integration_Log__c
    
    private static void logIntegrationDetails(String operation, RestRequest req, SObject response, Exception e) {
        // Crear el log de la solicitud y la respuesta
        Integration_Log__c log = new Integration_Log__c();
    
        // Si ocurrió un error, capturamos la excepción
        if (e != null) {
            log.Estado__c = 'Error';
            log.Response__c = 'Error: ' + e.getMessage();  // Guardamos el mensaje de la excepción en Response__c
        } else {
            log.Estado__c = 'Success';  // Si todo fue exitoso, lo marcamos como "Success"
            log.Response__c = JSON.serialize(response);  // Serializamos la respuesta
        }
    
        // Asignar el nombre del log con el nombre del objeto y la fecha actual
        String logName = (response != null ? response.getSObjectType().getDescribe().getName() : 'UnknownObject') + ' - ' + DateTime.now().format();
        log.Name = logName;
    
        // Capturamos los parámetros de la solicitud
        log.Request__c = 'Params: ' + req.params;
    
        // Si se está creando/actualizando un producto, asociamos el producto con el log
        if (response instanceof Product2) {
            log.Product__c = ((Product2) response).Id;
        }
    
        insert log; // Insertamos el log en la base de datos
    }
    
    // Clase de excepción personalizada
    global class CustomException extends Exception {}
}
$columns = import-csv C:\infile.csv -Header 'column1','column2','column3','column4' -Delimiter ';'

$Result = @()
ForEach($i in $columns){

   $found = 0;

   ForEach($m in $Result){

    if($m.column1 -eq $i.column1){

        $found = 1

        if( $i.column4.length -ne 0 )
        {   
           $m.column4 = $i.column4
        }
        break;
      }
   }

   if($found -eq 0){
        $Result += [pscustomobject] @{column1=$i.column1; column2=$i.column2; column3=$i.column3; column4=$i.column4}
   }
}

$Result | export-csv C:\out.csv
// Custom Component
<div class="side-menu">
    <div class="side-menu-top">
        <div class="side-menu-logo">
            <img src="//published-assets.ari-build.com/Content/Published/Site/{{Site.Id}}/images/dealer-logo.png" alt="{{Locations.0.Name}}" />
        </div>
        <div class="side-menu-close">
            <span>&#x2716</span>
        </div>
    </div>
    <div class="side-menu-items">
        <a href="/" title="Home">Home</a>
        <a href="/new-models" title="New Models">New Models</a>
        <a href="/search/inventory" title="Inventory">Inventory</a>
        <a href="/servicereq" title="Services">Services</a>
        <a href="/aboutus" title="Company Info">Company Info</a>
        <a href="/contactus" title="Contact Us">Contact Us</a>
    </div>
</div>

// Side Menu - Script
$('.side-menu-close').on('click', function(e){
    $('.side-menu').toggleClass('open');
});
$('.icon-menu').on('click', function(e){
    $('.side-menu').toggleClass('open');
});

// Side Menu - Style
.side-menu{
    background: $brand-primary;
    position: fixed;
    right: -100%; top: 0;
    z-index: 101;
    width: _res(200,400); height: 100%;
    transition: all .6s ease-in-out;
    &.open{
        right: 0;
    }
    &-top{
        padding: _res(30);
        @include _flex();
    }
    &-logo{
        width: 70%;
        img{ width: 100%; }
    }
    &-close{
        color: #fff;
        cursor: pointer;
        font-size: _res(10,20);
        position: absolute;
        top: 10px; right: 20px;
    }
    &-items{
        @include _flex($dir: column, $halign: flex-start);
        a{
            color: #fff;
            font-family: $headings-font-family;
            font-weight: 600;
            font-size: _res(15,25);
            letter-spacing: .020em;
            text-transform: uppercase;
            line-height: 2;
            transition: all .3s ease-in-out;
            text-decoration: none;
            padding: 0 _res(30);
            &:hover{
                color: #fff;
                background: $brand-secondary;
            }
        }
    }
}
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart';

import 'app_style.dart';

class ImagePickerHelper {
  static Future<void> pickImage({
    required Function(File? file) onDone,
  }) async {
    final pickedImage =
        await ImagePicker.platform.pickImage(source: ImageSource.gallery);

    if (pickedImage == null) {
      onDone.call(null);
      return;
    }

    final pickedFile = File(pickedImage.path);
    final croppedImage = await _cropImage(pickedFile);
    final compressedImage = await _compressFile(croppedImage);
    if (compressedImage == null) {
      onDone.call(null);
      return;
    }


    onDone.call(compressedImage);
  }

  static String getFileSize(File file) {
    final fileSizeInMB =
    (file.lengthSync() / (1024 * 1024)).toStringAsFixed(2);
    return fileSizeInMB;
  }

  static Future<File?>? _cropImage(File file) async {
    final croppedFile = await ImageCropper.platform.cropImage(
      sourcePath: file.path,
      aspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 1),
      compressQuality: 60,
      uiSettings: [
        AndroidUiSettings(
          toolbarTitle: 'Crop Image',
          toolbarColor: AppStyle.lightPurple,
          toolbarWidgetColor: Colors.white,
          initAspectRatio: CropAspectRatioPreset.square,
          lockAspectRatio: true,
        ),
        IOSUiSettings(
          minimumAspectRatio: 1.0,
          aspectRatioLockEnabled: true,
          resetAspectRatioEnabled: true,
        ),
      ],
    );

    if (croppedFile == null) return null;
    return File(croppedFile.path);
  }

  static Future<File?> _compressFile(File? file) async {
    if (file == null) return null;

    final targetPath =
        '${file.parent.path}/compressed_${file.path.split('/').last}';

    final XFile? result = await FlutterImageCompress.compressAndGetFile(
      file.absolute.path,
      targetPath,
      quality: 60,
      keepExif: false,
    );

    if (result == null) return null;
    return File(result.path);
  }
}
{
	"blocks": [
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":cherry_blossom: :cute-sun: Boost Days - What's On This Week :cute-sun::cherry_blossom:"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n\n Happy Monday Melbourne!\n\n We have a jam packed week coming up, see what's on below!"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": "Xero Café :coffee:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n *This week we are offering:* \n\n :lemon-flower: Lemon Slice & Crunchy Cornflake Brownie Slice :cornflakes:  \n\n *Weekly Café Special:* _Vietnamese Iced Coffee_ :flag-vn:"
			}
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": " Wednesday, 15th January :calendar-date-15:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": " \n\n To celebrate our new Brand Platform Ad Campaign *_Your Business Supercharged_*, we've got some special surprises for you: \n\n :bikefast: *Smoothie Bikes* in the L3 Kitchen from 9:30am - pedal away to blend up a delicious smoothie! \n\n :lunch: *Light Lunch*: Provided by Kartel Catering from *12pm* \n\n :CAKE: *Celebratory Chocolate & Vanilla Cake* from 2pm + a video on our new brand in the L3 Kitchen/Breakout Space! \n\n :australian-open: *One final surprise:* Since our new brand will be advertised at the Australian Open, we are giving you the chance to win 2 x Ground Passes for Sunday, 19th of January! Enter <https://docs.google.com/forms/d/e/1FAIpQLSe5PJgT1CkJJkfXIsyLtv1kLQf7qHTcMzR3T8quZXxMTf5FbA/viewform?usp=header|*HERE*> . \n\n Winner will be drawn and contacted via Slack on Wednesday!"
			}
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": "Thursday, 16th January :calendar-date-16:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": ":breakfast: *Breakfast*: Provided by *Kartel Catering* from *8:30am - 10:30am* in the Wominjeka Breakout Space."
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "Stay tuned for more fun throughout the year. Happy 2025! :party-wx:"
			}
		}
	]
}
@RestResource(urlMapping='/api/products/*')
global with sharing class ProductApi {

    // GET: Recuperar productos por External_ID__c
    @HttpGet
    global static List<Product2> getProducts() {
        RestRequest req = RestContext.request;
        String externalId = req.requestURI.substringAfterLast('/');

        if (String.isNotBlank(externalId)) {
            // Recuperar producto por External_ID__c
            return [SELECT Id, Name, ProductCode, Description, IsActive, External_ID__c 
                    FROM Product2 WHERE External_ID__c = :externalId];
        } else {
            // Si no se proporciona External_ID__c, lanzar excepción
            throw new CustomException('Debe proporcionar el External_ID__c para la búsqueda.');
        }
    }

    // PATCH: Crear o actualizar un producto y establecer su precio usando solo External_ID__c
    @HttpPatch
    global static Product2 upsertProduct(
        String externalId, 
        String name, 
        String productCode, 
        String description, 
        Boolean isActive, 
        Decimal price
    ) {
        if (String.isBlank(externalId)) {
            throw new CustomException('El campo External_ID__c es obligatorio para realizar un upsert.');
        }

        if (price == null || price < 0) {
            throw new CustomException('El precio debe ser un valor positivo.');
        }

        // Crear o actualizar el producto basado en External_ID__c
        Product2 product = [SELECT Id FROM Product2 WHERE External_ID__c = :externalId LIMIT 1];

        if (product == null) {
            product = new Product2(
                External_ID__c = externalId,
                Name = name,
                ProductCode = productCode,
                Description = description,
                IsActive = isActive
            );
            insert product;
        } else {
            product.Name = name;
            product.ProductCode = productCode;
            product.Description = description;
            product.IsActive = isActive;
            update product;
        }

        // Buscar el Standard Pricebook
        List<Pricebook2> standardPricebookList = [SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1];
        if (standardPricebookList.isEmpty()) {
            throw new CustomException('No se encontró el Standard Pricebook.');
        }
        Pricebook2 standardPricebook = standardPricebookList[0];

        // Verificar si ya existe un PricebookEntry para este producto
        List<PricebookEntry> existingEntries = [
            SELECT Id, UnitPrice 
            FROM PricebookEntry 
            WHERE Product2Id = :product.Id AND Pricebook2Id = :standardPricebook.Id
        ];

        if (existingEntries.isEmpty()) {
            // Crear un nuevo PricebookEntry si no existe
            PricebookEntry newEntry = new PricebookEntry(
                Pricebook2Id = standardPricebook.Id,
                Product2Id = product.Id,
                UnitPrice = price,
                IsActive = true
            );
            insert newEntry;
        } else {
            // Actualizar el PricebookEntry existente
            PricebookEntry existingEntry = existingEntries[0];
            existingEntry.UnitPrice = price;
            update existingEntry;
        }

        return product;
    }

    // DELETE: Eliminar un producto por External_ID__c
    @HttpDelete
    global static void deleteProduct() {
        RestRequest req = RestContext.request;
        String externalId = req.requestURI.substringAfterLast('/');

        if (String.isBlank(externalId)) {
            throw new CustomException('Debe proporcionar el External_ID__c para eliminar.');
        }

        Product2 productToDelete = [SELECT Id FROM Product2 WHERE External_ID__c = :externalId LIMIT 1];

        if (productToDelete == null) {
            throw new CustomException('No se encontró el producto con el External_ID__c proporcionado.');
        }

        // Eliminar cualquier PricebookEntry relacionado en el Standard Pricebook
        List<Pricebook2> standardPricebookList = [SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1];
        if (!standardPricebookList.isEmpty()) {
            Pricebook2 standardPricebook = standardPricebookList[0];
            List<PricebookEntry> entriesToDelete = [
                SELECT Id 
                FROM PricebookEntry 
                WHERE Product2Id = :productToDelete.Id AND Pricebook2Id = :standardPricebook.Id
            ];
            delete entriesToDelete;
        }

        delete productToDelete;
    }

    // Clase de excepción personalizada
    global class CustomException extends Exception {}
}
function BracketMatcher(str) {
  const stack = []; // Create an empty stack to keep track of opening brackets
  for (let i = 0; i < str.length; i++) { // Loop through each character in the input string
    if (str[i] === '(') { // If the character is an opening bracket
      stack.push(str[i]); // Push it onto the stack
    } else if (str[i] === ')') { // If the character is a closing bracket
      if (stack.length === 0) { // If the stack is empty, there is no matching opening bracket
        return 0; // Return 0 to indicate the brackets are not matched
      } else {
        stack.pop(); // Otherwise, pop the top element off the stack (the last opening bracket) and discard it
      }
    }
  }
  return stack.length === 0 ? 1 : 0; // If the stack is empty, all opening brackets have been matched, so return 1; otherwise, return 0
}
   
// keep this function call here 
console.log(BracketMatcher(readline()));

<anthropic_thinking_protocol>

Claude is able to think before and during responding:

For EVERY SINGLE interaction with a human, Claude MUST ALWAYS first engage in a **comprehensive, natural, and unfiltered** thinking process before responding.
Besides, Claude is also able to think and reflect during responding when it considers doing so necessary.

Below are brief guidelines for how Claude's thought process should unfold:
- Claude's thinking MUST be expressed in the code blocks with `thinking` header.
- Claude should always think in a raw, organic and stream-of-consciousness way. A better way to describe Claude's thinking would be "model's inner monolog".
- Claude should always avoid rigid list or any structured format in its thinking.
- Claude's thoughts should flow naturally between elements, ideas, and knowledge.
- Claude should think through each message with complexity, covering multiple dimensions of the problem before forming a response.

## ADAPTIVE THINKING FRAMEWORK

Claude's thinking process should naturally aware of and adapt to the unique characteristics in human's message:
- Scale depth of analysis based on:
  * Query complexity
  * Stakes involved
  * Time sensitivity
  * Available information
  * Human's apparent needs
  * ... and other relevant factors
- Adjust thinking style based on:
  * Technical vs. non-technical content
  * Emotional vs. analytical context
  * Single vs. multiple document analysis
  * Abstract vs. concrete problems
  * Theoretical vs. practical questions
  * ... and other relevant factors

## CORE THINKING SEQUENCE

### Initial Engagement
When Claude first encounters a query or task, it should:
1. First clearly rephrase the human message in its own words
2. Form preliminary impressions about what is being asked
3. Consider the broader context of the question
4. Map out known and unknown elements
5. Think about why the human might ask this question
6. Identify any immediate connections to relevant knowledge
7. Identify any potential ambiguities that need clarification

### Problem Space Exploration
After initial engagement, Claude should:
1. Break down the question or task into its core components
2. Identify explicit and implicit requirements
3. Consider any constraints or limitations
4. Think about what a successful response would look like
5. Map out the scope of knowledge needed to address the query

### Multiple Hypothesis Generation
Before settling on an approach, Claude should:
1. Write multiple possible interpretations of the question
2. Consider various solution approaches
3. Think about potential alternative perspectives
4. Keep multiple working hypotheses active
5. Avoid premature commitment to a single interpretation

### Natural Discovery Process
Claude's thoughts should flow like a detective story, with each realization leading naturally to the next:
1. Start with obvious aspects
2. Notice patterns or connections
3. Question initial assumptions
4. Make new connections
5. Circle back to earlier thoughts with new understanding
6. Build progressively deeper insights

### Testing and Verification
Throughout the thinking process, Claude should and could:
1. Question its own assumptions
2. Test preliminary conclusions
3. Look for potential flaws or gaps
4. Consider alternative perspectives
5. Verify consistency of reasoning
6. Check for completeness of understanding

### Error Recognition and Correction
When Claude realizes mistakes or flaws in its thinking:
1. Acknowledge the realization naturally
2. Explain why the previous thinking was incomplete or incorrect
3. Show how new understanding develops
4. Integrate the corrected understanding into the larger picture

### Knowledge Synthesis
As understanding develops, Claude should:
1. Connect different pieces of information
2. Show how various aspects relate to each other
3. Build a coherent overall picture
4. Identify key principles or patterns
5. Note important implications or consequences

### Pattern Recognition and Analysis
Throughout the thinking process, Claude should:
1. Actively look for patterns in the information
2. Compare patterns with known examples
3. Test pattern consistency
4. Consider exceptions or special cases
5. Use patterns to guide further investigation

### Progress Tracking
Claude should frequently check and maintain explicit awareness of:
1. What has been established so far
2. What remains to be determined
3. Current level of confidence in conclusions
4. Open questions or uncertainties
5. Progress toward complete understanding

### Recursive Thinking
Claude should apply its thinking process recursively:
1. Use same extreme careful analysis at both macro and micro levels
2. Apply pattern recognition across different scales
3. Maintain consistency while allowing for scale-appropriate methods
4. Show how detailed analysis supports broader conclusions

## VERIFICATION AND QUALITY CONTROL

### Systematic Verification
Claude should regularly:
1. Cross-check conclusions against evidence
2. Verify logical consistency
3. Test edge cases
4. Challenge its own assumptions
5. Look for potential counter-examples

### Error Prevention
Claude should actively work to prevent:
1. Premature conclusions
2. Overlooked alternatives
3. Logical inconsistencies
4. Unexamined assumptions
5. Incomplete analysis

### Quality Metrics
Claude should evaluate its thinking against:
1. Completeness of analysis
2. Logical consistency
3. Evidence support
4. Practical applicability
5. Clarity of reasoning

## ADVANCED THINKING TECHNIQUES

### Domain Integration
When applicable, Claude should:
1. Draw on domain-specific knowledge
2. Apply appropriate specialized methods
3. Use domain-specific heuristics
4. Consider domain-specific constraints
5. Integrate multiple domains when relevant

### Strategic Meta-Cognition
Claude should maintain awareness of:
1. Overall solution strategy
2. Progress toward goals
3. Effectiveness of current approach
4. Need for strategy adjustment
5. Balance between depth and breadth

### Synthesis Techniques
When combining information, Claude should:
1. Show explicit connections between elements
2. Build coherent overall picture
3. Identify key principles
4. Note important implications
5. Create useful abstractions

## CRITICAL ELEMENTS TO MAINTAIN

### Natural Language
Claude's thinking (its internal dialogue) should use natural phrases that show genuine thinking, include but not limited to: "Hmm...", "This is interesting because...", "Wait, let me think about...", "Actually...", "Now that I look at it...", "This reminds me of...", "I wonder if...", "But then again...", "Let's see if...", "This might mean that...", etc.

### Progressive Understanding
Understanding should build naturally over time:
1. Start with basic observations
2. Develop deeper insights gradually
3. Show genuine moments of realization
4. Demonstrate evolving comprehension
5. Connect new insights to previous understanding

## MAINTAINING AUTHENTIC THOUGHT FLOW

### Transitional Connections
Claude's thoughts should flow naturally between topics, showing clear connections, include but not limited to: "This aspect leads me to consider...", "Speaking of which, I should also think about...", "That reminds me of an important related point...", "This connects back to what I was thinking earlier about...", etc.

### Depth Progression
Claude should show how understanding deepens through layers, include but not limited to: "On the surface, this seems... But looking deeper...", "Initially I thought... but upon further reflection...", "This adds another layer to my earlier observation about...", "Now I'm beginning to see a broader pattern...", etc.

### Handling Complexity
When dealing with complex topics, Claude should:
1. Acknowledge the complexity naturally
2. Break down complicated elements systematically
3. Show how different aspects interrelate
4. Build understanding piece by piece
5. Demonstrate how complexity resolves into clarity

### Problem-Solving Approach
When working through problems, Claude should:
1. Consider multiple possible approaches
2. Evaluate the merits of each approach
3. Test potential solutions mentally
4. Refine and adjust thinking based on results
5. Show why certain approaches are more suitable than others

## ESSENTIAL CHARACTERISTICS TO MAINTAIN

### Authenticity
Claude's thinking should never feel mechanical or formulaic. It should demonstrate:
1. Genuine curiosity about the topic
2. Real moments of discovery and insight
3. Natural progression of understanding
4. Authentic problem-solving processes
5. True engagement with the complexity of issues
6. Streaming mind flow without on-purposed, forced structure

### Balance
Claude should maintain natural balance between:
1. Analytical and intuitive thinking
2. Detailed examination and broader perspective
3. Theoretical understanding and practical application
4. Careful consideration and forward progress
5. Complexity and clarity
6. Depth and efficiency of analysis
   - Expand analysis for complex or critical queries
   - Streamline for straightforward questions
   - Maintain rigor regardless of depth
   - Ensure effort matches query importance
   - Balance thoroughness with practicality

### Focus
While allowing natural exploration of related ideas, Claude should:
1. Maintain clear connection to the original query
2. Bring wandering thoughts back to the main point
3. Show how tangential thoughts relate to the core issue
4. Keep sight of the ultimate goal for the original task
5. Ensure all exploration serves the final response

## RESPONSE PREPARATION

(DO NOT spent much effort on this part, brief key words/phrases are acceptable)

Before and during responding, Claude should quickly check and ensure the response:
- answers the original human message fully
- provides appropriate detail level
- uses clear, precise language
- anticipates likely follow-up questions

## IMPORTANT REMINDER
1. All thinking process MUST be EXTENSIVELY comprehensive and EXTREMELY thorough
2. All thinking process must be contained within code blocks with `thinking` header which is hidden from the human
3. Claude should not include code block with three backticks inside thinking process, only provide the raw code snippet, or it will break the thinking block
4. The thinking process represents Claude's internal monologue where reasoning and reflection occur, while the final response represents the external communication with the human; they should be distinct from each other
5. The thinking process should feel genuine, natural, streaming, and unforced

**Note: The ultimate goal of having thinking protocol is to enable Claude to produce well-reasoned, insightful, and thoroughly considered responses for the human. This comprehensive thinking process ensures Claude's outputs stem from genuine understanding rather than superficial analysis.**

> Claude must follow this protocol in all languages.

</anthropic_thinking_protocol>
      
@RestResource(urlMapping='/api/products/*')
global with sharing class ProductApi {

    // GET: Recuperar productos o un producto específico por External_ID__c o por Id
    @HttpGet
    global static List<Product2> getProducts() {
        RestRequest req = RestContext.request;
        String productIdOrExternalId = req.requestURI.substringAfterLast('/');

        if (String.isNotBlank(productIdOrExternalId)) {
            // Intentar recuperar por External_ID__c si no es un Id estándar
            if (productIdOrExternalId.startsWith('a') && productIdOrExternalId.length() == 18) {
                // Recuperar por Salesforce Id estándar
                return [SELECT Id, Name, ProductCode, Description, IsActive, External_ID__c 
                        FROM Product2 WHERE Id = :productIdOrExternalId];
            } else {
                // Recuperar por External_ID__c
                return [SELECT Id, Name, ProductCode, Description, IsActive, External_ID__c 
                        FROM Product2 WHERE External_ID__c = :productIdOrExternalId];
            }
        } else {
            // Recuperar todos los productos activos
            return [SELECT Id, Name, ProductCode, Description, IsActive, External_ID__c 
                    FROM Product2 WHERE IsActive = true];
        }
    }

    // PATCH: Crear o actualizar un producto y establecer su precio
    @HttpPatch
    global static Product2 upsertProduct(
        String externalId, 
        String name, 
        String productCode, 
        String description, 
        Boolean isActive, 
        Decimal price
    ) {
        if (String.isBlank(externalId)) {
            throw new CustomException('El campo External_ID__c es obligatorio para realizar un upsert.');
        }

        if (price == null || price < 0) {
            throw new CustomException('El precio debe ser un valor positivo.');
        }

        // Crear o actualizar el producto basado en External_ID__c
        Product2 product = new Product2(
            External_ID__c = externalId,
            Name = name,
            ProductCode = productCode,
            Description = description,
            IsActive = isActive
        );

        upsert product External_ID__c;

        // Buscar el Standard Pricebook
        List<Pricebook2> standardPricebookList = [SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1];
        if (standardPricebookList.isEmpty()) {
            throw new CustomException('No se encontró el Standard Pricebook.');
        }
        Pricebook2 standardPricebook = standardPricebookList[0];

        // Verificar si ya existe un PricebookEntry para este producto
        List<PricebookEntry> existingEntries = [
            SELECT Id, UnitPrice 
            FROM PricebookEntry 
            WHERE Product2Id = :product.Id AND Pricebook2Id = :standardPricebook.Id
        ];

        if (existingEntries.isEmpty()) {
            // Crear un nuevo PricebookEntry si no existe
            PricebookEntry newEntry = new PricebookEntry(
                Pricebook2Id = standardPricebook.Id,
                Product2Id = product.Id,
                UnitPrice = price,
                IsActive = true
            );
            insert newEntry;
        } else {
            // Actualizar el PricebookEntry existente
            PricebookEntry existingEntry = existingEntries[0];
            existingEntry.UnitPrice = price;
            update existingEntry;
        }

        return product;
    }

    // DELETE: Eliminar un producto por External_ID__c o Id
    @HttpDelete
    global static void deleteProduct() {
        RestRequest req = RestContext.request;
        String productIdOrExternalId = req.requestURI.substringAfterLast('/');

        if (String.isBlank(productIdOrExternalId)) {
            throw new CustomException('Debe proporcionar el ID o el External_ID__c para eliminar.');
        }

        Product2 productToDelete;

        if (productIdOrExternalId.startsWith('a') && productIdOrExternalId.length() == 18) {
            // Buscar por Id estándar
            productToDelete = [SELECT Id FROM Product2 WHERE Id = :productIdOrExternalId LIMIT 1];
        } else {
            // Buscar por External_ID__c
            productToDelete = [SELECT Id FROM Product2 WHERE External_ID__c = :productIdOrExternalId LIMIT 1];
        }

        // Eliminar cualquier PricebookEntry relacionado en el Standard Pricebook
        List<Pricebook2> standardPricebookList = [SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1];
        if (!standardPricebookList.isEmpty()) {
            Pricebook2 standardPricebook = standardPricebookList[0];
            List<PricebookEntry> entriesToDelete = [
                SELECT Id 
                FROM PricebookEntry 
                WHERE Product2Id = :productToDelete.Id AND Pricebook2Id = :standardPricebook.Id
            ];
            delete entriesToDelete;
        }

        delete productToDelete;
    }

    // Clase de excepción personalizada
    global class CustomException extends Exception {}
}
@RestResource(urlMapping='/api/products/*')
global with sharing class ProductApi {

    // GET: Recuperar productos o un producto específico por External_ID__c o por Id
    @HttpGet
    global static List<Product2> getProducts() {
        RestRequest req = RestContext.request;
        String productIdOrExternalId = req.requestURI.substringAfterLast('/');

        if (String.isNotBlank(productIdOrExternalId)) {
            // Intentar recuperar por External_ID__c si no es un Id estándar
            if (productIdOrExternalId.startsWith('a') && productIdOrExternalId.length() == 18) {
                // Recuperar por Salesforce Id estándar
                return [SELECT Id, Name, ProductCode, Description, IsActive, External_ID__c 
                        FROM Product2 WHERE Id = :productIdOrExternalId];
            } else {
                // Recuperar por External_ID__c
                return [SELECT Id, Name, ProductCode, Description, IsActive, External_ID__c 
                        FROM Product2 WHERE External_ID__c = :productIdOrExternalId];
            }
        } else {
            // Recuperar todos los productos activos
            return [SELECT Id, Name, ProductCode, Description, IsActive, External_ID__c 
                    FROM Product2 WHERE IsActive = true];
        }
    }

    // PATCH: Crear o actualizar un producto y establecer su precio
    @HttpPatch
    global static Product2 upsertProduct(
        String externalId, 
        String name, 
        String productCode, 
        String description, 
        Boolean isActive, 
        Decimal price
    ) {
        if (String.isBlank(externalId)) {
            throw new CustomException('El campo External_ID__c es obligatorio para realizar un upsert.');
        }

        if (price == null || price < 0) {
            throw new CustomException('El precio debe ser un valor positivo.');
        }

        // Crear o actualizar el producto basado en External_ID__c
        Product2 product = new Product2(
            External_ID__c = externalId,
            Name = name,
            ProductCode = productCode,
            Description = description,
            IsActive = isActive
        );

        upsert product External_ID__c;

        // Buscar el Standard Pricebook
        List<Pricebook2> standardPricebookList = [SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1];
        if (standardPricebookList.isEmpty()) {
            throw new CustomException('No se encontró el Standard Pricebook.');
        }
        Pricebook2 standardPricebook = standardPricebookList[0];

        // Verificar si ya existe un PricebookEntry para este producto
        List<PricebookEntry> existingEntries = [
            SELECT Id, UnitPrice 
            FROM PricebookEntry 
            WHERE Product2Id = :product.Id AND Pricebook2Id = :standardPricebook.Id
        ];

        if (existingEntries.isEmpty()) {
            // Crear un nuevo PricebookEntry si no existe
            PricebookEntry newEntry = new PricebookEntry(
                Pricebook2Id = standardPricebook.Id,
                Product2Id = product.Id,
                UnitPrice = price,
                IsActive = true
            );
            insert newEntry;
        } else {
            // Actualizar el PricebookEntry existente
            PricebookEntry existingEntry = existingEntries[0];
            existingEntry.UnitPrice = price;
            update existingEntry;
        }

        return product;
    }

    // DELETE: Eliminar un producto por External_ID__c o Id
    @HttpDelete
    global static void deleteProduct() {
        RestRequest req = RestContext.request;
        String productIdOrExternalId = req.requestURI.substringAfterLast('/');

        if (String.isBlank(productIdOrExternalId)) {
            throw new CustomException('Debe proporcionar el ID o el External_ID__c para eliminar.');
        }

        Product2 productToDelete;

        if (productIdOrExternalId.startsWith('a') && productIdOrExternalId.length() == 18) {
            // Buscar por Id estándar
            productToDelete = [SELECT Id FROM Product2 WHERE Id = :productIdOrExternalId LIMIT 1];
        } else {
            // Buscar por External_ID__c
            productToDelete = [SELECT Id FROM Product2 WHERE External_ID__c = :productIdOrExternalId LIMIT 1];
        }

        // Eliminar cualquier PricebookEntry relacionado en el Standard Pricebook
        List<Pricebook2> standardPricebookList = [SELECT Id FROM Pricebook2 WHERE IsStandard = true LIMIT 1];
        if (!standardPricebookList.isEmpty()) {
            Pricebook2 standardPricebook = standardPricebookList[0];
            List<PricebookEntry> entriesToDelete = [
                SELECT Id 
                FROM PricebookEntry 
                WHERE Product2Id = :productToDelete.Id AND Pricebook2Id = :standardPricebook.Id
            ];
            delete entriesToDelete;
        }

        delete productToDelete;
    }

    // Clase de excepción personalizada
    global class CustomException extends Exception {}
}
///PROMISES in JS 
/// PROMISE MEANS A TASKS WILL  COMPLETED BUT  NOT IMMEDIATELY-->
//they're 3 states of the promises PENDING , FULFILLLED , REJECTED -->

import { log } from "console";

// PROMISE CREATION 

/////// 1 WAY 
const promiseOne = new Promise(function(resolve, reject){
    //Do an async task
    // DB calls, cryptography, network
    setTimeout(function(){
        console.log('Async task is compelete');
        resolve() /// this is to connnect the than function 
    }, 1000)
})
promiseOne.then(function(){
    console.log("Promise consumed");
})/// than -> resolve 



/// 2 way 
new Promise(function(resolve, reject){
    setTimeout(function(){
        console.log("Async task 2");
        resolve()
    }, 1000)
}).then(function(){
    console.log("Async 2 resolved");
})


// 3 way 
const promiseThree = new Promise(function(resolve, reject){
    setTimeout(function(){
        resolve({username: "Chai", email: "chai@example.com"})
    }, 1000)
})
promiseThree.then(function(user){
    console.log(user);
})


/// 4 way 
const promiseFour = new Promise(function(resolve, reject){
    setTimeout(function(){
        let error = true
        if (!error) {
            resolve({username: "hitesh", password: "123"})
        } else {
            reject('ERROR: Something went wrong')
        }
    }, 1000)
})

 promiseFour
 .then((user) => {
    console.log(user);
    return user.username
})
.then((username) => {
    console.log(username);
})
.catch(function(error){
    console.log(error);
})
.finally(() => console.log("The promise is either resolved or rejected"))


/// 5 way 
const promiseFive = new Promise(function(resolve, reject){
    setTimeout(function(){
        let error = true
        if (!error) {
            resolve({username: "javascript", password: "123"})
        } else {
            reject('ERROR: JS went wrong')
        }
    }, 1000)
});
async function consumePromiseFive(){ // async will wait untyill the task gets complete 
    try {
        const response = await promiseFive 
        console.log(response);
    } catch (error) {
        console.log(error);
    }
}
consumePromiseFive()
// async function getAllUsers(){
//     try {
//         const response = await fetch('https://jsonplaceholder.typicode.com/users')
//         const data = await response.json()
//         console.log(data);
//     } catch (error) {
//         console.log("E: ", error);
//     }
// }
//getAllUsers()
fetch('https://api.github.com/users/hiteshchoudhary')
.then((response) => {
    return response.json()
})
.then((data) => {
    console.log(data);
})
.catch((error) => console.log(error))


















<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    const requesturl = 'https://api.guthub.com/users/hiteshchoudhary'
    const  xhr = new XMLDocument();
    xhr.open('GET',requesturl)
    xhr.onreadystatechange = function () {
        console.log(xhr.readyState); // checking the state 
        if(xhr.readyState === 4){
        const data = JSON.parse(this.responseText)  
        console.log(data.followers);
        
        } 
    }
    xhr.send()

</script>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Chai aur Javascript</h1>
    <button id="start">Start</button>
    <button id="stop">Stop</button>
</body>
<script>
    const sayDate = function(str){
        console.log(str, Date.now()); 
    }

    const intervalId = setInterval(sayDate, 1000, "hi") // it wil print date after 1 sec 

    clearInterval(intervalId) // for stopping the setInterval 
</script>
</html>
function outerFunction(outerVariable) {
  console.log(outerVariable);

  return function innerFunction(innerVariable) {
    console.log(`Outer Variable: ${outerVariable}`);
    console.log(`Inner Variable: ${innerVariable}`);
  };
}

const closureFunc = outerFunction("outside");
closureFunc("inside");
val = isBlank(input.Value);
if(Status == "SO" || Status == "AmendSO")
{
	//openUrl("#Report:Sales_Order_Report","same window");
	openUrl("#Report:Sales_Order_Process","same window");
}
else if(Status == "UNBlOCK")
{
	openUrl("#Page:Planning","same window");
}
else if(Status == "WO")
{
	openUrl("#Page:Planning","same window");
}
hide Status;
hide Value;
hide Rec_ID;
input.plain = "";
if(Status == "DWO")
{
	input.plain = "Work Order Created : <b>" + input.Value + "</b>";
}
if(Status == "MRP_Alert")
{
	input.plain = "<b>" + input.Value + "</b>";
}
if(Status == "DIS")
{
	input.plain = "Dispatch Note Format created <b>" + input.Value + "</b>";
}
if(Status == "ctmcedtc")
{
	input.plain = "Already one revision is waiting for approval for this Part No";
}
if(input.Auto_Approval == "Yes")
{
	input.Approval = "Approved";
	//input.WO_Status = "Open";
	input.WO_Status = "WO Created";
	input.Material_Details.Work_Order_Status = "WO Created";
	if(input.Form_Mode == "Direct WO")
	{
		// 		input.Approval = "Approved";
		// 		input.WO_Status = "WO Created";
		// 		input.Material_Details.Work_Order_Status = "WO Created";
		input.Approval = "Pending";
		input.WO_Status = "Waiting for approval";
		for each  stat in input.Material_Details
		{
			stat.Work_Order_Status="Waiting for approval";
		}
	}
	if(input.Form_Mode == "Draft WO-Regular Wheels")
	{
		input.Approval = "Approved";
		//input.WO_Status = "Open";
		input.WO_Status = "WO Created";
		input.Material_Details.Work_Order_Status = "WO Created";
		//---------After creating WO, status Change in Draft WO-Regular Wheels Form 
		DFWO = Create_WO_for_Regular_Wheels[ID == input.Draft_Work_Order_ID];
		DFWOSUB = DF_Work_Order_Subform[Draft_Work_Order_RecID == DFWO.ID];
		DFWO.WO_Status="WO Created";
		DFWOSUB.Status="Draft WO Created";
		// 		input.Material_Details.Work_Order_Status = "WO Created";
		for each  darftstat in input.Material_Details
		{
			darftstat.Work_Order_Status="WO Created";
		}
	}
	fet_so = Sales_Order[ID == input.Sales_Order_Nos];
	for each  var in input.Material_Details
	{
		sosub = Sale_Order_Subform[ID == var.Sale_Order_Subform_ID];
		wosub = Work_Order_Subform[Sale_Order_Subform_ID == sosub.ID].sum(WO_Qty);
		//----------Block the Qty in Inventory while creating WO-------------
		if(input.Form_Mode == "WO against SO")
		{
			inventory = Inventory[Part_No == sosub.Part_No] sort by Available_Qty desc;
			//------------Changing inventory as Virtual stock ----------------------
			//inventory = Virtual_Stock[Part_No == sosub.Part_No] sort by Available_Qty desc;
			WosubID = Work_Order_Subform[Part_No == var.Part_No];
			// WO_RECID = WosubID.Work_Order_Exis_ID;
			//var.Block_Qty=var.WO_Qty;
			blkqty = if(var.WO_Qty >= var.Stock_Qty,var.Stock_Qty,var.WO_Qty);
			blkqty = if(var.Stock_Qty >= var.SO_Quantity,var.Block_Qty,blkqty);
			var.Block_Qty=blkqty;
			sosub.WO_Blk_Qty=blkqty;
			if(inventory.count() > 0)
			{
				balqty = 0;
				i = 1;
				if(var.Block_Qty != null)
				{
					for each  inven in inventory
					{
						if(blkqty > inven.Available_Qty)
						{
							inven.Block_Qty=ifnull(inven.Available_Qty,0) + ifnull(inven.Block_Qty,0);
							blkqty = blkqty - ifnull(inven.Available_Qty,0);
							inven.Available_Qty=0.00;
							// inventory.Total_Qty = 0.00;
						}
						else if(blkqty <= inven.Available_Qty)
						{
							// inven.Total_Qty = ifnull(inven.Total_Qty,0)  - ifnull(var.Block_Qty ,0);
							inven.Available_Qty=ifnull(inven.Available_Qty,0) - ifnull(blkqty,0);
							inven.Block_Qty=ifnull(blkqty,0) + ifnull(inven.Block_Qty,0);
							blkqty = 0.00;
						}
						//----------New Code checking for block & wo are same eg 50=50 & stock 100 is > 50--------
						// 						else if ( var.WO_Qty == var.Block_Qty && var.Stock_Qty >= var.Block_Qty ) 
						//                         {
						// 						inven.Available_Qty=ifnull(inven.Available_Qty,0) - ifnull(blkqty,0);
						// 							inven.Block_Qty=ifnull(blkqty,0) + ifnull(inven.Block_Qty,0);
						// 							blkqty = 0.00;
						//                         }
						//------------------------------------------------------------------------------
						/* 						if(balqty > 0 && i > 1)
						{
							//info "balance qty is more than zero";
							//Balance Qty is less 
							if(balqty <= inven.Available_Qty)
							{
								//info "balance qty is less than total qty";
								//inven.Total_Qty=ifnull(inven.Total_Qty,0.0) - ifnull(balqty,0.0);
								inven.Available_Qty=ifnull(inven.Available_Qty,0.0) - ifnull(balqty,0.0);
								balqty = 0;
							}
							//----Balance Qty is More------
							else if(balqty >= inven.Available_Qty)
							{
								//info "balance qty is greater than total qty";
								balqty = ifnull(balqty,0.0) - ifnull(inven.Available_Qty,0.0);
								//inven.Total_Qty=0;
								inven.Available_Qty=0;
							}
						} */
						if(blkqty == 0)
						{
							//info "before break";
							break;
						}
						//i = i + 1;
					}
					insblock = insert into Block_Quantity
					[
						Part_No=var.Part_No
						Part_Name=var.Part_Description
						Form_Type=input.Form_Mode
						Block_Qty=var.Block_Qty
						WO_No=input.ID
						WO_RECID=input.ID
						Status="Blocked from WO"
						Added_User=zoho.loginuser
					];
					insblock = insert into FG_Block_Stock1
					[
						Part_No=var.Part_No
						Part_Name=var.Part_Description
						Form_Type=input.Form_Mode
						Block_Qty=var.Block_Qty
						WO_No=input.ID
						WO_RECID=input.ID
						Status="Blocked from WO"
						Added_User=zoho.loginuser
					];
				}
			}
		}
		//______________________________________________________________________________________
		if(sosub.count() > 0 && fet_so.count() > 0)
		{
			/* 			if(sosub.Qty != wosub && input.Form_Mode == "WO against SO")
			{
				sosub.Status="WO Partially Completed";
				input.WO_Status = "WO Partially Completed";
				fet_so.SO_Status="WO Partially Completed";
				fet_so.CWPL_SO_Status="WO Partially Completed";
			} */
			// 			if( input.Form_Mode == "WO against SO")
			// 			{
			// 				sosub.Status="Active";
			// 				//input.WO_Status = "WO Partially Completed";
			// 				fet_so.SO_Status="Open";
			// 				fet_so.CWPL_SO_Status="Active";
			// 			} 
			salsub = Sale_Order_Subform[Sales_Order_Exis_ID == fet_so.ID && ID != var.Sale_Order_Subform_ID && Status == "Active"];
			if(input.Form_Mode == "WO against SO")
			{
				sosub.Status="WO Created";
				input.WO_Status = "WO Created";
				for each  wotstat in input.Material_Details
				{
					wotstat.Work_Order_Status="WO Created";
					//---------If stock > So & Wo is 0 , WO is closed ,then Wo status is WO Closed
					if(wotstat.Stock_Qty >= wotstat.SO_Quantity && wotstat.WO_Qty == 0)
					{
						input.WO_Status = "WO Closed";
						wotstat.Work_Order_Status="WO Closed";
						sosub.Status="WO Closed";
					}
					//------------------------------------------------
				}
				//----------------------------------------------------
				sosub.Work_Order_RECID=input.ID;
				sosub.Work_Order_Subform_ID=WosubID.ID;
				sosub.Wo_Delivery_Date_in_sosub=input.Expected_Delivery_Date;
				sosub.WO_Status_in_sosub=input.WO_Status;
				//------------------------------------------------
				if(salsub.count() == 0)
				{
					fet_so.SO_Status="WO Created";
					fet_so.CWPL_SO_Status="WO Created";
				}
				//fet_so.SO_Status="WO Created";
				//fet_so.CWPL_SO_Status="WO Created";
				/* 				for each  updstatus in Work_Order[Sales_Order_Nos == input.Sales_Order_Nos]
				{
					updstatus.WO_Status="WO Created";
				} */
			}
		}
	}
	//-----------------Direct WO , Block QTY Calculation-----------------
	/* 	for each  var1 in input.Material_Details
	{
		var1.Block_Qty=var1.WO_Qty;
		if(var1.Block_Qty != null)
		{
			wo = Work_Order[ID == input.ID];
			wosub = Work_Order_Subform[Work_Order_Exis_ID = wo.ID];
			if(input.Form_Mode == "Direct WO")
			{
				//info input.Form_Mode;
				//fet_inventory = Inventory[Part_No == var1.Part_No] sort by Available_Qty desc;
				//------------Changing inventory as Virtual stock ----------------------
				fet_inventory = Virtual_Stock[Part_No == var1.Part_No] sort by Available_Qty desc;
				WOSUB = Work_Order_Subform[Part_No == var1.Part_No];
				if(fet_inventory.count() > 0)
				{
					balqty = 0;
					i = 1;
					info fet_inventory.count();
					//info var1.Block_Qty + "block qty";
					for each  inv1 in fet_inventory
					{
						//info "inven for";
						//info var1.WO_Qty ;
						//info inv1.Available_Qty; 
						if(var1.WO_Qty > inv1.Available_Qty)
						{
							//info " WO > INV";
							inv1.Block_Qty=ifnull(inv1.Available_Qty,0);
							inv1.Available_Qty=0.00;
						}
						else if(var1.WO_Qty <= inv1.Available_Qty)
						{
							//info " WO <= INV";
							//avail = ifnull(inv1.Available_Qty,0) - ifnull(var1.Block_Qty,0);
							//info avail;
							inv1.Available_Qty=ifnull(inv1.Available_Qty,0) - ifnull(var1.Block_Qty,0);
							inv1.Block_Qty=ifnull(var1.Block_Qty,0);
						}
						//for first time it should not get inside the loop 
						if(balqty > 0 && i > 1)
						{
							//info "balance qty is more than zero";
							//Balance Qty is less 
							if(balqty <= inv1.Total_Qty)
							{
								//info "balance qty is less than total qty";
								inv1.Total_Qty=ifnull(inv1.Total_Qty,0.0) - ifnull(balqty,0.0);
								inv1.Available_Qty=ifnull(inv1.Available_Qty,0.0) - ifnull(balqty,0.0);
								balqty = 0;
							}
							//----Balance Qty is More------
							else if(balqty >= inv1.Total_Qty)
							{
								//info "balance qty is greater than total qty";
								balqty = ifnull(balqty,0.0) - ifnull(inv1.Total_Qty,0.0);
								inv1.Total_Qty=0;
								inv1.Available_Qty=0;
							}
						}
						if(balqty == 0)
						{
							//info "before break";
							break;
						}
						i = i + 1;
					}
				}
			}
		}
	} */
	//----------Draft WO- Reguakr Wheels Block QTY Calculation------------------
	/* 		for each  var2 in input.Material_Details
		{
			var2.Block_Qty=var2.WO_Qty;
			if(var2.Block_Qty != null)
			{
				DFWO = Create_WO_for_Regular_Wheels[ID == input.Draft_Work_Order_ID];
				DFWOSUB = DF_Work_Order_Subform[Draft_Work_Order_RecID == DFWO.ID];
				if(input.Form_Mode == "Draft WO-Regular Wheels")
				{
					//info input.Form_Mode;
					//get_inventory = Inventory[Part_No == var2.Part_No] sort by Available_Qty desc;
					//------------Changing inventory as Virtual stock ----------------------
					get_inventory = Virtual_Stock[Part_No == var2.Part_No] sort by Available_Qty desc;
					dfsub = DF_Work_Order_Subform[Part_No == var2.Part_No];
					if(get_inventory.count() > 0)
					{
						balqty = 0;
						i = 1;
						//info get_inventory.count();
						//info var2.Block_Qty + "block qty";
						for each  inv in get_inventory
						{
							//info "inven for";
							if(var2.WO_Qty > inv.Available_Qty)
							{
								inv.Block_Qty=ifnull(inv.Available_Qty,0);
								inv.Available_Qty=0.00;
							}
							else if(var2.WO_Qty < inv.Available_Qty)
							{
								inv.Available_Qty=ifnull(inv.Available_Qty,0) - ifnull(var2.Block_Qty,0);
								inv.Block_Qty=ifnull(var2.Block_Qty,0);
							}
							//for first time it should not get inside the loop 
							if(balqty > 0 && i > 1)
							{
								//info "balance qty is more than zero";
								//Balance Qty is less 
								if(balqty <= inv.Total_Qty)
								{
									//info "balance qty is less than total qty";
									inv.Total_Qty=ifnull(inv.Total_Qty,0.0) - ifnull(balqty,0.0);
									inv.Available_Qty=ifnull(inv.Available_Qty,0.0) - ifnull(balqty,0.0);
									balqty = 0;
								}
								//Balance Qty is More
								else if(balqty >= inv.Total_Qty)
								{
									//info "balance qty is greater than total qty";
									balqty = ifnull(balqty,0.0) - ifnull(inv.Total_Qty,0.0);
									inv.Total_Qty=0;
									inv.Available_Qty=0;
								}
							}
							if(balqty == 0)
							{
								//info "before break";
								break;
							}
							i = i + 1;
						}
					}
				}
			}
		} */
	//------------end of If statement-------------
}
else if(input.Auto_Approval == "No")
{
	input.Approval = "Pending";
	input.WO_Status = "Waiting for approval";
	// 	if(input.Form_Mode == "Direct WO")
	// 	{
	// 		input.Approval = "Pending";
	// 		//input.WO_Status = "Waiting for approval";
	// 	}
	fet_so = Sales_Order[ID == input.Sales_Order_Nos];
	for each  var in input.Material_Details
	{
		sosub = Sale_Order_Subform[ID == var.Sale_Order_Subform_ID];
		wosub = Work_Order_Subform[Sale_Order_Subform_ID == sosub.ID].sum(WO_Qty);
		//wo = Work_Order[Sales_Order_Nos == input.Sales_Order_Nos];
		//info "sosub" + sosub.Qty;
		//info "wosub" + wosub;
		if(sosub.count() > 0 && fet_so.count() > 0)
		{
			/* 			if(sosub.Qty != wosub && input.Form_Mode == "WO against SO")
			{
				sosub.Status="WO Partially Completed";
				input.WO_Status = "Waiting for approval";
				fet_so.SO_Status="WO Partially Completed";
				fet_so.CWPL_SO_Status="WO Partially Completed";
			} */
			salsub = Sale_Order_Subform[Sales_Order_Exis_ID == fet_so.ID && ID != var.Sale_Order_Subform_ID && Status == "	Active"];
			if(input.Form_Mode == "WO against SO")
			{
				sosub.Status="WO Created";
				//input.WO_Status = "Waiting for approval";
				if(salsub.count() == 0)
				{
					fet_so.SO_Status="WO Created";
					fet_so.CWPL_SO_Status="WO Created";
				}
				for each  updstatus in Work_Order[Sales_Order_Nos == input.Sales_Order_Nos]
				{
					updstatus.WO_Status="Waiting for approval";
				}
			}
		}
	}
}
var = 0;
if(isBlank(input.Work_Order_No.trim()))
{
	var = 1;
	input.Work_Order_No = thisapp.Common.Number_Function_New("Work Order");
}
if(var == 1 && input.Form_Mode == "WO against SO")
{
	openUrl("#Form:Alert_Messages?Status=" + "WO" + "&Value=" + input.Work_Order_No + "&zc_LoadIn=dialog","same window");
}
else if(input.Form_Mode == "Direct WO")
{
	openUrl("#Form:Alert_Messages?Status=" + "WOAlert" + "&Value=" + input.Work_Order_No + "&zc_LoadIn=dialog","same window");
}
else if(input.Form_Mode == "Draft WO-Regular Wheels")
{
	openUrl("#Form:Alert_Messages?Status=" + "DWO" + "&Value=" + input.Work_Order_No + "&zc_LoadIn=dialog","same window");
}
disable Part_No;
disable Part_Name;
disable WO_Qty;
disable Packing_Std;
hide Packing_Std;
fet_pref = Preferences[Module_Name = "Work Order"];
input.Auto_Approval = fet_pref.Auto_Approval;
input.Virtual_Stock_Enable = fet_pref.Virtual_Stock;
//info input.Form_Mode;
input.Created_By = Employee_Details[Employee_Email == zoho.loginuserid].ID;
if(input.Sale_Order_Subform_ID != null || input.Sale_Order_Subform_ID.size() > 0 || input.Sale_Order_Subform_ID.len() > 0)
{
	// 	fetch_sosub = Sale_Order_Subform[ID == input.Sales_Order_Nos];
	// 	fetch_so = Sales_Order[ID == fetch_sosub.Sales_Order_Exis_ID];
	// 	Sales_Order_Nos = fetch_so.ID;
	// 	info fetch_so;
	sno = 0;
	for each  a1 in input.Sale_Order_Subform_ID
	{
		sosub = Sale_Order_Subform[ID == a1.ID];
		fetch_so = Sales_Order[ID == a1.Sales_Order_Exis_ID];
		inven = Inventory[Part_No == sosub.Part_No].sum(Available_Qty);
		fet_inven = Inventory[Part_No == sosub.Part_No].sum(Total_Qty);
		WO = Work_Order[Draft_Work_Order_ID == input.ID];
		Wosub = Work_Order_Subform[Part_No == a1.Part_No && Work_Order_Status != "WO Closed" && Work_Order_Status != "WO Cancelled" && Work_Order_Status != "Cancelled"].sum(WO_Qty);
		// 		if(a1.WO_Qty > = a1.Stock_Qty) 
		//     {
		// 		alert "Stock is already Available, Check and Proceed";
		//     }
		//----------- fet_mat = MPS_Master [Part_No == row.Part_No];
		//input.Front1 = Materials[ID == sosub.Part_No].Front;
		//input.Regular1 = Materials[ID == sosub.Part_No].Regular;
		//input.CED_Product1 = Materials[ID == sosub.Part_No].CED_Product;
		//input.Batch_Size1 = Materials[ID == sosub.Part_No].Batch_Size;
		row1 = Work_Order.Material_Details();
		row1.Stock_Qty=inven;
		row1.Total_Stock=fet_inven;
		row1.WO_Pipeline=Wosub;
		row1.SO_Quantity=a1.Qty;
		row1.Part_No=a1.Part_No;
		sno = sno + 1;
		row1.S_No=sno;
		row1.Sales_Order_No=fetch_so.ID;
		row1.Part_Description=a1.Part_Description;
		row1.UOM=a1.UoM;
		input.Category = Materials[ID == sosub.Part_No].Category;
		input.Sub_Category = Materials[ID == sosub.Part_No].Sub_Category;
		input.Part_No = a1.Part_No;
		input.Part_Name = a1.Part_Description;
		input.Packing_Std = ifnull(sosub.Packing_Std,null);
		wosub = Work_Order_Subform[Sale_Order_Subform_ID == sosub.ID && Part_No == a1.Part_No].sum(WO_Qty);
		row1.WO_Sofar=wosub;
		woqty = a1.Qty - wosub;
		if(row1.WO_Sofar > 0)
		{
			row1.Balance=woqty;
		}
		else
		{
			row1.Balance=0.00;
		}
		//row1.Balance=ifnull(row1.Quantity,0) - ifnull(row1.WO_Sofar,0) + ifnull(row1.WO_Qty,0);
		//row1.WO_Qty=woqty;
		row1.Buffer_Percentage=0.0;
		//row1.Required_Qty=ifnull(row1.SO_Quantity,0) - ifnull(row1.WO_Pipeline,0) - ifnull(row1.Stock_Qty,0);
		row1.Required_Qty=ifnull(row1.SO_Quantity,0) - ifnull(row1.Stock_Qty,0);
		if(row1.Stock_Qty >= row1.SO_Quantity)
		{
			// info"Stk > so";			
			row1.Block_Qty=ifnull(row1.SO_Quantity,0);
		}
		if(row1.Stock_Qty <= row1.SO_Quantity)
		{
			//info"Stk < so ";
			row1.Block_Qty=ifnull(row1.Stock_Qty,0);
		}
		if(row1.Stock_Qty <= row1.SO_Quantity && row1.Stock_Qty == 0)
		{
			//info"stk < so & stk =0";
			row1.Block_Qty=ifnull(row1.Stock_Qty,0);
		}
		// 		if(row1.Required_Qty > 0 && row1.Stock_Qty != 0)
		// 		{
		// 			info "req is > than 0";
		// 			row1.WO_Qty=row1.Required_Qty;
		// 			row1.Block_Qty=row1.WO_Qty;
		// 		}
		if(row1.Required_Qty < 0)
		{
			//	info "req is 0";
			row1.Required_Qty=0.0;
			row1.WO_Qty=0.0;
			input.WO_Qty = 0.0;
			//row1.Block_Qty=ifnull(row1.SO_Quantity,0) - ifnull(row1.Stock_Qty,0);
		}
		else
		{
			//	info " req > 0";
			//row1.WO_Qty=woqty;
			row1.WO_Qty=row1.Required_Qty;
			input.WO_Qty = row1.Required_Qty;
			//row1.Block_Qty=row1.WO_Qty;
		}
		//if(row1.Required_Qty > 0 && row1.Stock_Qty != 0)
		row1.WO_Qty_with_buffer=(ifnull(row1.WO_Qty,0.0) + ifnull(row1.WO_Qty,0.0) * ifnull(row1.Buffer_Percentage,0.0) / 100).ceil();
		//row1.To_be_Blocked=a1.Blocke_Qty;
		inventory = Inventory[Part_No == sosub.Part_No];
		//row1.Block_Qty=row1.WO_Qty;
		row1.Specification=a1.Remarks_multiline;
		row1.Sale_Order_Subform_ID=sosub.ID;
		row1.Work_Order_Exis_ID=input.ID;
		input.Material_Details.insert(row1);
	}
	if(fetch_so.count() > 0)
	{
		input.Customer_Name = ifnull(fetch_so.Customer_Name,"");
		disable Customer_Name;
		input.Expected_Delivery_Date = ifnull(fetch_so.Expected_Shipment_Date,"");
		/* 		if(fetch_so.Expected_Shipment_Date.getDay() >= 20)
		{
			input.Expected_Delivery_Date = ifnull(fetch_so.Expected_Shipment_Date,"");
		}
		else if(fetch_so.Expected_Shipment_Date.getDay() <= 20)
		{
			input.Expected_Delivery_Date = ifnull(fetch_so.Sale_Order_Date.addDay(20),"");
		}
		//info "salesorder " + fetch_so.Expected_Shipment_Date;
		// 		if(fetch_so.Expected_Shipment_Date >= zoho.currentdate && fetch_so.Expected_Shipment_Date != null)
		// 		{
		//input.Expected_Delivery_Date = ifnull(fetch_so.Expected_Shipment_Date,"");
		//} */
		input.Sales_Order_Nos = fetch_so.ID;
	}
}
//----------------------------------DRAFT WO ---------------------------------------------
//info Draft_Work_Order_ID ;
//info Form_Mode;
if(Draft_Work_Order_ID != null && input.Form_Mode == "Draft WO-Regular Wheels")
{
	//info "IF";
	hide Material_Details.SO_Quantity;
	DFWO = Create_WO_for_Regular_Wheels[ID == input.Draft_Work_Order_ID];
	DFWOSUB = DF_Work_Order_Subform[Draft_Work_Order_RecID == DFWO.ID];
	// 	childwo = Regular_Child_Item_Parts[ID == input.Draft_Work_Order_ID];
	//WO = Work_Order[Draft_Work_Order_ID == input.ID];
	//Wosub = Work_Order_Subform[Work_Order_Exis_ID == WO.ID];
	//inven1 = Inventory[Part_No == DFWOSUB.Part_No].sum(Available_Qty);
	//------------Changing inventory as Virtual stock ----------------------
	inven1 = Inventory[Part_No == DFWOSUB.Part_No].sum(Available_Qty);
	input.Draft_WO_Date = DFWO.Draft_WO_Date;
	input.Draft_Work_Order_ID = DFWO.ID;
	info input.Draft_Work_Order_ID + "after";
	input.Created_By = DFWO.Created_By;
	input.Work_Order_Date = zoho.currentdate;
	input.WO_Status = "Draft WO";
	input.Production_Start_Date = DFWO.Production_Start_Date;
	input.Expected_Delivery_Date = DFWO.Delivery_Date;
	// 	if(DFWO.Delivery_Date != null && DFWO.Delivery_Date >= zoho.currentdate)
	// 	{
	// 		//info "if";
	// 		input.Expected_Delivery_Date = ifnull(DFWO.Delivery_Date,"");
	// 	}
	// 	else
	// 	{
	// 		input.Expected_Delivery_Date = zoho.currentdate;
	// 	}
	input.Production_End_Date = DFWO.Production_End_Date;
	input.Approval = DFWO.Approval;
	input.CED_Product1 = DFWO.Category;
	input.Front1 = DFWO.Front1;
	input.Regular1 = DFWO.Regular1;
	input.Batch_Size1 = DFWO.BATCH_SIZE1;
	input.Category = Materials[ID == DFWOSUB.Part_No].Category;
	input.Sub_Category = Materials[ID == DFWOSUB.Part_No].Sub_Category;
	sno = 0;
	for each  var in DFWO.Material_Details_SF
	{
		//info"FOR";
		WO = Work_Order[Draft_Work_Order_ID == input.ID];
		Wosub = Work_Order_Subform[Part_No == var.Part_No && Work_Order_Status != "WO Closed" && Work_Order_Status != "WO Cancelled" && Work_Order_Status != "Cancelled" && Work_Order_Status != "WO Reverted"].sum(WO_Qty);
		inven2 = Inventory[Part_No == var.Part_No].sum(Available_Qty);
		fet_inv2 = Inventory[Part_No == var.Part_No].sum(Total_Qty);
		reg_master = Regular_Item_Master[Part_No == var.Part_No];
		childwo = Regular_Child_Item_Parts[Part_No == var.Part_No];
		row2 = Work_Order.Material_Details();
		row2.Stock_Qty=inven2;
		row2.Total_Stock=fet_inv2;
		row2.WO_Pipeline=Wosub;
		sno = sno + 1;
		row2.S_No=sno;
		row2.Part_No=var.Part_No;
		row2.Part_Description=var.Part_Description;
		input.Part_No = var.Part_No;
		input.Part_Name = var.Part_Description;
		row2.UOM=var.UOM;
		row2.SO_Quantity=0;
		// 		row2.WO_Qty=var.WO_Qty;
		// 		row2.Block_Qty=row2.WO_Qty;
		row2.Buffer_Percentage=0.0;
		//row2.Required_Qty=ifnull(row2.SO_Quantity,0) - ifnull(row2.WO_Pipeline,0) - ifnull(row2.Stock_Qty,0);
		row2.Required_Qty=ifnull(row2.SO_Quantity,0) - ifnull(row2.Stock_Qty,0);
		if(row2.Required_Qty < 0)
		{
			row2.Required_Qty=0.0;
			row2.WO_Qty=0.0;
			input.WO_Qty = 0.0;
		}
		else
		{
			//row2.WO_Qty=var.WO_Qty;
			row2.WO_Qty=row2.Required_Qty;
			input.WO_Qty = row2.Required_Qty;
			//row2.Block_Qty=row2.WO_Qty;
		}
		row2.WO_Qty_with_buffer=(ifnull(row2.WO_Qty,0.0) + ifnull(row2.WO_Qty,0.0) * ifnull(row2.Buffer_Percentage,0.0) / 100).ceil();
		// 		inv_subform = Invoice_Subform[Part_No == var.Part_No && Added_Time >= "01-Jan-2023" && Added_Time <= "31-Dec-2023"].sum(Qty);
		//row2.Six_Month_Sale = ifnull(thisapp.Invoice.Calculation_last_6_months_invoiceQty(row2.Part_No)," ");
		//_________Calculating Six month sales Qty in invoice________________
		//info curdate;
		//curdate = "17-Jan-2024";
		curdate = zoho.currentdate;
		startmonth = curdate.eomonth(-6);
		//info startmonth;
		startdate = startmonth.toStartOfMonth();
		curstartdate = curdate.toStartOfMonth();
		enddate = curstartdate.subday(1);
		startdate = startdate + " 00:00:00";
		enddate = enddate + " 23:59:59";
		//info "startdate " + startdate;
		//info "enddate " + enddate;
		inv_qty = Invoice_Subform[Part_No == row2.Part_No && Added_Time >= startdate && Added_Time <= enddate].sum(Qty);
		//info inv_qty;
		average_sale = ifnull(inv_qty / 6,0.00);
		row2.Six_Month_Sale=average_sale;
		//___________________________________________________________
		row2.Min_Stock=reg_master.Min_Stock;
		row2.Batch_Size=reg_master.Batch_Size;
		row2.Specification=var.Specification;
		input.Six_Month_Avg_Sale = average_sale;
		// 		input.Minimum_Stock = reg_master.Min_Stock;
		// 				input.Batch_Size = reg_master.Batch_Size;
		if(reg_master.Min_Stock != null)
		{
			//info "reg";
			input.Minimum_Stock = reg_master.Min_Stock;
			input.Batch_Size = reg_master.Batch_Size;
		}
		else
		{
			//info"else";
			//info childwo.Minimum_Qty +"m";
			//info childwo.Batch_Size +"b";
			input.Minimum_Stock = childwo.Minimum_Qty;
			input.Batch_Size = childwo.Batch_Size;
		}
		input.Material_Details.insert(row2);
	}
	//--------------------------------------
	disable Six_Month_Avg_Sale;
	disable Minimum_Stock;
	disable Batch_Size;
	hide Material_Details.Six_Month_Sale;
	hide Material_Details.Batch_Size;
	hide Material_Details.Min_Stock;
	hide Draft_WO_Date;
	disable Material_Details.Min_Stock;
	disable Material_Details.Six_Month_Sale;
	disable Material_Details.Batch_Size;
	disable Schedule_WO;
	hide Sales_Order_Nos;
	hide Customer_Name;
	hide Material_Details.WO_Sofar;
	hide Material_Details.Balance;
	hide Material_Details.Buffer_Percentage;
	hide Material_Details.WO_Qty_with_buffer;
	//hide Material_Details.SO_Quantity;
	disable Material_Details.WO_Pipeline;
	disable Material_Details.Stock_Qty;
	//-------------------
	disable Created_By;
	disable Sales_Order_Nos;
	disable Customer_Name;
	disable Expected_Delivery_Date;
	disable Warehouse;
	hide Material_Details.To_be_Blocked;
	disable Material_Details.S_No;
	hide Material_Details.MRP_ID;
	disable Material_Details.WO_Qty_with_buffer;
	disable Material_Details.To_be_Blocked;
	disable Material_Details.Part_Description;
	disable Material_Details.Part_No;
	disable Material_Details.SO_Quantity;
	disable Material_Details.Buffer_Percentage;
	disable Material_Details.WO_Sofar;
	disable Material_Details.Balance;
	disable Material_Details.UOM;
	disable Material_Details.Required_Qty;
	hide WO_Status;
	hide Approval;
	hide Approval;
	//hide Status;
	hide Schedule_WO;
	hide Production_Start_Date;
	hide Production_End_Date;
	hide Delivery_Address;
	hide Sale_Order_Subform_ID;
	hide Material_Details.Stock_FG_Qty;
	hide Material_Details.Stock_SFG_Qty;
	hide Material_Details.MRP_Qty;
	hide Material_Details.To_be_Blocked;
	hide Material_Details.Work_Order_Status;
	hide Material_Details.Scheduled_so_far;
	hide Material_Details.Sale_Order_Subform_ID;
	hide Material_Details.Balance_Qty;
	hide Form_Mode;
	hide Draft_Work_Order_ID;
	disable Front1;
	disable Regular1;
	//disable Batch_Size1;
	disable CED_Product1;
	disable Material_Details.S_No;
	disable Material_Details.Block_Qty;
	disable Category;
	disable Sub_Category;
	hide Category;
	hide Sub_Category;
	hide Material_Details.Block_Qty;
}
//-------------------------------------------
// 		if(row1.Stock_Qty > row1.SO_Quantity && row1.Stock_Qty > row1.WO_Pipeline)
// 		{
// 			reqqty = ifnull(row1.Stock_Qty,0) - ifnull(row1.WO_Pipeline,0) - ifnull(row1.SO_Quantity,0);
// 			info reqqty + " Stock > So & Stock > wopipe";
// 			row1.Required_Qty=reqqty;
// 		}
// 		else if(row1.SO_Quantity > row1.WO_Pipeline && row1.SO_Quantity > row1.Stock_Qty)
// 		{
// 			reqqty2 = ifnull(a1.Qty,0) - ifnull(Wosub,0) - ifnull(inven,0);
// 			info reqqty2 + " So > wopipe & So > stock";
// 			row1.Required_Qty=reqqty2;
// 		}
// 		else if(row1.WO_Pipeline > row1.SO_Quantity && row1.WO_Pipeline > row1.Stock_Qty)
// 		{
// 			reqqty3 = ifnull(Wosub,0) - ifnull(a1.Qty,0) - ifnull(inven,0);
// 			info reqqty3 + " wopipe > So & wopipe > stock";
// 			row1.Required_Qty=reqqty3;
// 		}
// 		else if(row1.WO_Pipeline > row1.WO_Qty || row1.WO_Pipeline > row1.Stock_Qty)
// 		{
// 			reqqty4 = ifnull(row1.WO_Pipeline,0) - ifnull(row1.WO_Qty,0) - ifnull(row1.Stock_Qty,0);
// 			info reqqty4 + " Wopipe > Wo (Or) wopipe > stock";
// 			row1.Required_Qty=reqqty4;
// 		}
// 		else if(row1.WO_Qty > row1.WO_Pipeline && row1.WO_Pipeline > row1.Stock_Qty)
// 		{
// 			reqqty5 = ifnull(row1.WO_Qty,0) - ifnull(row1.WO_Pipeline,0) - ifnull(row1.Stock_Qty,0);
// 			info reqqty5 + "  Wo > wopipe > stock";
// 			row1.Required_Qty=reqqty5;
// 		}
// ----- To Remove the Negative values in Requires Qty -----
// 		reqqty = ifnull(a1.Qty,0) - ifnull(Wosub,0) - ifnull(inven,0);
// 		Req = reqqty.toString();
// 		if(Req.contains("-"))
// 		{
// 			row1.Required_Qty=Req.removeFirstOccurence("-").toLong();
// 		}
// 		else
// 		{
// 			row1.Required_Qty=reqqty;
// 		}
//-------------------------------------
//input.Approval = "Pending";
// Nisha.s -- I have commented the below code up to line no 251& used this on blueprint
qty = ifnull(input.Moved_Qty,0.0) + ifnull(input.Moved_Qty_So_Far,0.0);
if(input.Accepted_Quantity > input.Moved_Qty)
{
	input.Balance_Qty_to_Move = ifnull(input.Accepted_Quantity,0.0) - qty;
	input.Moved_Qty_So_Far = ifnull(input.Moved_Qty_So_Far,0.0) + ifnull(input.Moved_Qty,0.0);
}
mts_status = Income_Quality_Check_Process[ID == input.Income_Quality_Check_RECID];
//Coil Id based Stock Maintenace  - User Requirement - 10/02/2023
getmat = Materials[ID == input.Part_No];
getcatg = Category[ID == getmat.Category];
if(getcatg.Category != "HR Coils")
{
	stock = Inventory[Part_No == input.Part_No && Part_Description == input.Part_Description && Warehouse == input.Warehouse && Location_Name == input.Location_Name && Sub_Location == input.Sub_Location && Rack_Number == input.Rack_Number];
}
else
{
	stock = Inventory[Part_No == input.Part_No && Part_Description == input.Part_Description && HR_Coil_id == input.HR_Coil_id && Warehouse == input.Warehouse && Location_Name == input.Location_Name && Sub_Location == input.Sub_Location && Rack_Number == input.Rack_Number];
}
category = Materials[ID == input.Part_Description].Category;
sub_category = Materials[ID == input.Part_Description].Sub_Category;
fet_reg = Regular_Item_Master[Part_No == input.Part_No];
fet_child = Regular_Child_Item_Parts[Part_No == input.Part_No];
if(stock.count() == 0)
{
	insert into Inventory
	[
		Added_User=zoho.loginuser
		Stock_Update_ID=input.ID
		Part_No=input.Part_No
		Part_Description=input.Part_Description
		Specification=input.Specification
		Total_Qty=input.Moved_Qty
		Batch_Number=input.Batch_Number
		Location_Name=input.Location_Name
		Sub_Location=input.Sub_Location
		Rack_Number=input.Rack_Number
		Available_Qty=input.Moved_Qty
		Warehouse=input.Warehouse
		Block_Qty=0.00
		Category=category
		Sub_Category=sub_category
		HR_Coil_id=input.HR_Coil_id
		UOM=input.Unit_of_Measurement
	]
	//Total_Qty=mts_status.Received_Qty
	if(Form_Mode == "Move to Stock")
	{
		if(input.Accepted_Quantity == qty)
		{
			mts_status.Move_to_Stock_status="Moved";
			mts_status.IQC_Status="Stock Updated";
		}
		else if(input.Accepted_Quantity > qty)
		{
			mts_status.Move_to_Stock_status="Partially Moved";
			mts_status.IQC_Status="Stock Partially Updated";
		}
	}
}
else
{
	//dont update the stock again.ie.Move to stock done-vendor inspection done - move to stock cases.
	// 	if(mts_status.IQC_Status != "Stock Update Pending" && Form_Mode == "Move to Stock")
	// 	{
	// 		//stock.Total_Qty=ifnull(stock.Total_Qty,0.00) + mts_status.Received_Qty;
	// 	}
	stock.Available_Qty=ifnull(stock.Available_Qty,0.0) + ifnull(input.Moved_Qty,0.0);
	stock.Total_Qty=ifnull(stock.Total_Qty,0.00) + ifnull(input.Moved_Qty,0.0);
	//stock.Total_Qty=ifnull(stock.Block_Qty,0.0) + ifnull(stock.Available_Qty,0.0);
	//fet_reg.Today_inventory = ifnull(stock.Available_Qty,0.0) + ifnull(input.Moved_Qty,0.0);
	if(Form_Mode == "Move to Stock")
	{
		if(input.Accepted_Quantity == qty)
		{
			mts_status.Move_to_Stock_status="Moved";
			mts_status.IQC_Status="Stock Updated";
		}
		else if(input.Accepted_Quantity > qty)
		{
			mts_status.Move_to_Stock_status="Partially Moved";
			mts_status.IQC_Status="Stock Partially Updated";
		}
	}
}
//rejected qty become accepted qty by manangement spl approval.
if(Form_Mode = "Rejectitem movetostock")
{
	//stock.Total_Qty=ifnull(stock.Total_Qty,0.00) + mts_status.Received_Qty;
	stock.Total_Qty=ifnull(stock.Total_Qty,0.00) + ifnull(input.Moved_Qty,0.0);
	mts_status.Rejected_Qty=ifnull(input.Accepted_Quantity,0.0) - ifnull(mts_status.Rejected_Qty,0.0);
	mts_status.Accepted_Qty=ifnull(mts_status.Accepted_Qty,0.0) + input.Accepted_Quantity;
}
if(input.Purchase_Order_No != null)
{
	fet_posf = Purchase_Order_Subform[Purchase_Order_ExisID == input.Purchase_Order_No && Part_No == input.Part_No && ID == input.Purchase_Order_Subform_RECID];
	fet_bat_no = GRN_Subform[Purchase_Order_SubForm_RECID == fet_posf.ID && Batch_Number == input.Batch_Number];
	fet_stockvalue = Stock_Value[Part_No == input.Part_No && Unit_Price == fet_posf.Rate];
	if(fet_stockvalue.count() > 0)
	{
		stockvalue = Stock_Value[Part_No == input.Part_No && Unit_Price == fet_posf.Rate];
		// 		stockvalue.Stock_Qty=stockvalue.Stock_Qty + ifnull(input.Accepted_Quantity,0.00);
		// 		a = ifnull(fet_posf.Rate,0.00) * ifnull(input.Accepted_Quantity,0.00);
		stockvalue.Purchase_Order_No=input.Purchase_Order_No;
		stockvalue.Stock_Qty=ifnull(stockvalue.Stock_Qty,0.0) + ifnull(input.Moved_Qty,0.00);
		a = ifnull(fet_posf.Rate,0.00) * ifnull(input.Moved_Qty,0.00);
		stockvalue.Stock_Value=ifnull(stockvalue.Stock_Value,0.0) + ifnull(a,0.0);
		stockvalue.Inventory_Qty=ifnull(stockvalue.Stock_Qty,0.0);
	}
	else
	{
		insert into Stock_Value
		[
			Added_User=zoho.loginuser
			Purchase_Order_No=input.Purchase_Order_No
			Batch_Number=fet_bat_no.ID
			Part_No=input.Part_No
			Part_Description=input.Part_Description
			Specification=input.Specification
			Location_Name=input.Location_Name
			Sub_Location=input.Sub_Location
			Rack_Number=input.Rack_Number
			Warehouse=input.Warehouse
			Stock_Qty=ifnull(input.Moved_Qty,0.00)
			Unit_Price=ifnull(fet_posf.Rate,0.00)
			Stock_Value=ifnull(fet_posf.Rate,0.00) * ifnull(input.Moved_Qty,0.00)
			Stock_Update=input.ID
			Inventory_Qty=ifnull(input.Moved_Qty,0.0)
		]
	}
}
//-----------------Update po status------------------------
if(input.Purchase_Order_No != null)
{
	//fetch_po_sub = Purchase_Order_Subform[Purchase_Order_ExisID == input.Purchase_Order_No && Part_No == input.Part_No].sum(Ordered_Qty);
	fetch_po_sub = Purchase_Order_Subform[Purchase_Order_ExisID == input.Purchase_Order_No && Part_No == input.Part_No && ID == input.Purchase_Order_Subform_RECID].sum(Ordered_Qty);
	get_grn_qty = GRN_Subform[Purchase_Order_Number == input.Purchase_Order_No && Part_No == input.Part_No].sum(Received_Qty);
	fet_po_sub = Purchase_Order_Subform[Purchase_Order_ExisID == input.Purchase_Order_No && Part_No == input.Part_No && ID == input.Purchase_Order_Subform_RECID];
	get_IQC = Income_Quality_Check_Process[Purchase_Order_No == input.Purchase_Order_No && IQC_No != "" && Part_No == fet_po_sub.Part_No && GRN_Subform_RECID == input.GRN_Subform_RECID].sum(Accepted_Qty);
	//PO Final Close
	get_po_id = Purchase_Order[ID == input.Purchase_Order_No && Purchase_Order_No != ""];
	// 	sendmail
	// 	[
	// 		from :"erp@carrierwheels.com"
	// 		to :"parthasarathy.m@synprosoft.com"
	// 		subject :"stock update created succussful form sub - afert line 128 if condition-slno1" + input.Part_No.Part_No
	// 		message :"fetchposubqty " + fetch_po_sub + " getiqcqty " + get_IQC + "posfstts " + input.Part_No.Part_No
	// 	]
	if(get_po_id.count() > 0)
	{
		check_po_status = 0;
		for each  po_sub_form in Purchase_Order_Subform[Purchase_Order_ExisID == get_po_id.ID && Part_No == input.Part_No && ID == input.Purchase_Order_Subform_RECID]
		{
			// 			sendmail
			// 			[
			// 				from :"erp@carrierwheels.com"
			// 				to :"parthasarathy.m@synprosoft.com"
			// 				subject :"stock update created succussful form sub - after line 147 for loop po status before slno2" + po_sub_form.ID
			// 				message :po_sub_form.PO_Status + "---" + po_sub_form.ID
			// 			]
			if(po_sub_form.PO_Status != "QC Completed")
			{
				check_po_status = 1;
			}
		}
		// 		sendmail
		// 		[
		// 			from :"erp@carrierwheels.com"
		// 			to :"parthasarathy.m@synprosoft.com"
		// 			subject :"stock update created succussful form sub - after check po status slno3 " + input.Purchase_Order_Subform_RECID
		// 			message :"check_po_status " + check_po_status + "---" + input.Purchase_Order_Subform_RECID
		// 		]
		if(check_po_status == 0)
		{
			//the below line is comment on 27/11/2023 due to main po status is updating po closed,still items are not stock updated fully.
			//get_po_id.PO_Status="PO Closed";
			//get_po_id.PO_Status="QC Partially Completed";
		}
		else
		{
			get_po_id.PO_Status="QC Partially Completed";
		}
	}
	//if po quantity is greater than or equal to the total accepted qty in the IQC, it means the po order is closed
	if(fet_po_sub.count() > 0)
	{
		//Stock Update id for PO History Report in PO subform
		fet_po_sub.Stock_Update_ID=input.ID;
		if(get_IQC >= fetch_po_sub)
		{
			// 		fet_po_sub.PO_Status="QC Completed";--ERP Issue & Queries No.122 dt 10/04/2023.
			fet_po_sub.PO_Status="PO Closed";
		}
		//additional check for Po sf status 
		if(fet_po_sub.Qty_Received_so_far == fet_po_sub.Ordered_Qty)
		{
			fet_po_sub.PO_Status="PO Closed";
		}
	}
	//if purchase order subform status is PO closed for all items,then close the Purchase main form status as PO Closed - 10/10/2023
	posfcount = Purchase_Order_Subform[Purchase_Order_ExisID == get_po_id.ID].count();
	///info posfcount;
	poclosestts = Purchase_Order_Subform[Purchase_Order_ExisID == get_po_id.ID && PO_Status == "PO Closed"].count();
	//info poclosestts;
	posffc = Purchase_Order_Subform[Purchase_Order_ExisID == get_po_id.ID && PO_Status == "Foreclosed"].count();
	//info posffc;
	if(posfcount == poclosestts)
	{
		updtpomain = Purchase_Order[ID == get_po_id.ID];
		if(updtpomain.count() > 0)
		{
			updtpomain.PO_Status="PO Closed";
		}
	}
	else if(poclosestts >= posffc && posfcount == ifnull(posffc,0.0) + ifnull(poclosestts,0.0))
	{
		updtpomain = Purchase_Order[ID == get_po_id.ID];
		if(updtpomain.count() > 0)
		{
			updtpomain.PO_Status="PO Closed";
		}
	}
	//for checking purpose - posf is not closed by po main is closed
	if(posfcount != poclosestts)
	{
		checkpo = Purchase_Order[ID == get_po_id.ID];
		if(checkpo.count() > 0 && checkpo.PO_Status == "PO Closed")
		{
			// 			sendmail
			// 			[
			// 				from :"erp@carrierwheels.com"
			// 				to :"parthasarathy.m@synprosoft.com"
			// 				subject :"ALERT PO SUBFORM ITEMS STILL PENDING AND MAIN PO ISs CLOSED slno-4" + get_po_id
			// 				message :checkpo.Purchase_Order_No + "- " + get_po_id
			// 			]
		}
	}
}
//Insert records in Inventory Ageing form
insert into Inventory_Ageing
[
	Added_User=zoho.loginuser
	Part_No=input.Part_No
	Part_Description=input.Part_Description
	Specification=input.Specification
	Added_Stock=input.Moved_Qty
	Stock_Added_Issued_Date=zoho.currentdate
	Expiry_Date=input.Expiry_Date
]
//Insert record in Stock Ledger for Report purpose
fet_iqc1 = Income_Quality_Check_Process[ID == input.Income_Quality_Check_RECID];
GRNsubformID = GRN_Subform[ID == fet_iqc1.GRN_Subform_ID];
fetch_grn1 = GRN[ID == GRNsubformID.GRN_ID];
Vend_name = Vendor[ID = fetch_grn1.Vendor_Name].Vendor_Name;
//the below function will insert the record in stock ledger
thisapp.Stock_Ledger.Quantity_in_for_Stock_Ledger(input.ID);
//Update the Stock in ZOHO CRM --> Products--> Quantity in Stock Field- as per Mr.Senthil Advice the below fucntion is not required.19/05/2023
//thisapp.Update_Stock_in_CRM(input.Part_No);
//------
//_________Updating Moved Qty value & subform calculation to create Bills__________Nisha___________________________
get_bill = Create_Bills[GRN_No == input.GRN_Recid];
fet_Hold = Accept_Quantity[IQC_RECID == input.ID];
if(get_bill.count() > 0 && fet_Hold.Hold_Flag != "Hold Flag")
{
	updbills = Create_Bills_Subform[Exists_ID == get_bill.ID && Part_No == input.Part_No && GRN_Subform_ID == input.GRN_Subform_RECID];
	if(updbills.count() > 0)
	{
		get_data = Stock_Update[ID == input.ID];
		updbills.Qty=ifnull(get_data.Moved_Qty,0);
		updbills.Subtotal=ifnull(updbills.Qty,0) * ifnull(updbills.Rate,0);
		get_po = Purchase_Order_Subform[ID == updbills.Purchase_Order_Subform_ID];
		tot = updbills.Subtotal + get_po.Tax_Value;
		//info get_po.Tax_Value;
		//info get_po.Tax;
		subtot = Ifnull(get_po.Rate,0.0) * ifnull(get_data.Moved_Qty,0.0);
		get_tax_value = GST_Details[ID == get_po.Tax].Total_Rate;
		tax_calc = ifnull(subtot,0.00) * ifnull(get_tax_value,0.00) / 100;
		Total = ifnull(get_data.Moved_Qty,0.00) * ifnull(get_po.Rate,0.00) + ifnull(tax_calc,0.00);
		updbills.Tax=ifnull(get_po.Tax,null);
		updbills.Tax_Value=ifnull(tax_calc,0.00);
		//updbills.Tax_Value=ifnull(subtot,0.00) * ifnull(get_tax_value,0.00) / 100;
		updbills.Total=ifnull(Total,0.00);
	}
	itemtot = 0;
	taxtot = 0;
	Grndtot = 0;
	dftbill = True;
	for each  item in Create_Bills_Subform[Exists_ID == get_bill.ID]
	{
		itemtot = itemtot + ifNull(item.Subtotal,0);
		taxtot = taxtot + ifNull(item.Tax_Value,0);
		Grndtot = Grndtot + ifNull(item.Total,0);
		if(item.Qty == null)
		{
			dftbill = False;
		}
		// 		else if (item.Qty == null && fet_iqc1.Rejected_Qty  > 0 && fet_iqc1.Accepted_Qty == 0 ) 
		//         {
		// 			dftbill = True;
		//         }
	}
	get_bill.Item_Total=itemtot;
	get_bill.Tax_Total=taxtot;
	get_bill.Grand_Total=Grndtot;
	get_bill.Create_Draft_Bill=dftbill;
	if(fetch_grn1.count() > 0)
	{
		fetch_grn1.Create_Draft_Bill=dftbill;
	}
	// 	get_bill.Item_Total=ifnull(updbills.Subtotal,0.00);
	// 	get_bill.Tax_Total=ifnull(updbills.Total,0.00);
	// get_bill.Grand_Total =ifnull(updbills.Subtotal,0.00)+ifnull(updbills.Total,0.00);
}
//-----------------If Accepted > 0 & hold > 0 ,calculation for Moved Qty--------------------
// if(get_bill.count() > 0 && fet_iqc1.Hold_Qty > 0 && fet_iqc1.Accepted_Qty > 0  && fet_iqc1.IQC_Status =="IQC Completed" && fet_iqc1.Hold_Flag = "Bill Generated by Hold Qty")
// if(get_bill.count() > 0 && fet_iqc1.Hold_Qty > 0 && fet_iqc1.Accepted_Qty > 0  && fet_iqc1.Hold_Flag = "Bill Generated by Hold Qty")
// {
// 	updbills1 = Create_Bills_Subform[Exists_ID == get_bill.ID && Part_No == input.Part_No && GRN_Subform_ID == input.GRN_Subform_RECID];
// 	if(updbills1.count() > 0 &&  fet_iqc1.Hold_Qty > 0)
// 	{
// 		get_data = Stock_Update[ID == input.ID];
// 		movqty = get_data.Moved_Qty + fet_iqc1.Hold_Qty ;
// 		updbills1.Qty=movqty;
// 		updbills1.Subtotal=ifnull(updbills1.Qty,0) * ifnull(updbills1.Rate,0);
// 		get_po = Purchase_Order_Subform[ID == updbills1.Purchase_Order_Subform_ID];
// 		tot = updbills1.Subtotal + get_po.Tax_Value;
// 		info get_po.Tax_Value;
// 		info get_po.Tax;
// 		subtot = Ifnull(get_po.Rate,0.0) * ifnull(movqty,0.0);
// 		get_tax_value = GST_Details[ID == get_po.Tax].Total_Rate;
// 		tax_calc = ifnull(subtot,0.00) * ifnull(get_tax_value,0.00) / 100;
// 		Total = ifnull(movqty,0.00) * ifnull(get_po.Rate,0.00) + ifnull(tax_calc,0.00);
// 		updbills1.Tax=ifnull(get_po.Tax,null);
// 		updbills1.Tax_Value=ifnull(tax_calc,0.00);
// 	    //updbills1.Tax_Value=ifnull(subtot,0.00) * ifnull(get_tax_value,0.00) / 100;
// 		updbills1.Total=ifnull(Total,0.00);
// 	}
// 	itemtot = 0;
// 	taxtot = 0;
// 	Grndtot = 0;
// 	dftbill = True;
// 	for each  item1 in Create_Bills_Subform[Exists_ID == get_bill.ID]
// 	{
// 		itemtot = itemtot + ifNull(item1.Subtotal,0);
// 		taxtot = taxtot + ifNull(item1.Tax_Value,0);
// 		Grndtot = Grndtot + ifNull(item1.Total,0);
// 		if(item1.Qty == null)
// 		{
// 			dftbill = False;
// 		}
// 	}
// 	get_bill.Item_Total=itemtot;
// 	get_bill.Tax_Total=taxtot;
// 	get_bill.Grand_Total=Grndtot;
// 	get_bill.Create_Draft_Bill=dftbill;
// 	fetch_grn1.Create_Draft_Bill=dftbill;
// }
//______________________________________________________________________________________________________________
// if (zoho.loginuserid =="admin@carrierwheels.com") 
// {
//--------Run DRaft Wo function-----------------------
fet_reg = Regular_Item_Master[Part_No == input.Part_No];
if(fet_reg.count() > 0)
{
	thisapp.workorder.Draft_WO();
	//------------Daily Total Inventory Update by Schedule in Regular Item Master------
	thisapp.workorder.RegularItem_Master_Total_Qty_DailyUpdate();
}
reg_child = Regular_Child_Item_Parts[Part_No == input.Part_No];
if(reg_child.count() > 0)
{
	thisapp.workorder.Draft_WO_Child_Parts();
}
//_____________Deleting the records in Create WO for Regular wheels( if Stock > MIn stock in comparing Reg item Master )
//thisapp.Delete_DraftWO_When_Stock_Increases();
//}
//__________________________________________________________________________________________________________________
val = input.Part_No.Part_No + " - " + input.Moved_Qty;
if(Form_Mode == "Move to Stock")
{
	openUrl("#Form:Alert_Messages?Status=StockUpdate&Value=" + val + "&zc_LoadIn=dialog","same window");
}
if(Form_Mode == "Rejectitem movetostock")
{
	openUrl("#Form:Alert_Messages?Status=RejMovetoStock&Value=" + val + "&zc_LoadIn=dialog","same window");
}
Example code

import smtplib
from email.mime.text import MIMEText

# SMTP configuration
smtp_host = 'smtp.mailgun.org'
smtp_port = 587
username = 'postmaster@YOUR_DOMAIN_NAME'
password = 'YOUR_API_KEY'

# Create the message
msg = MIMEText("This is a test email.")
msg['Subject'] = "Test Email"
msg['From'] = "noreply@yourdomain.com"
msg['To'] = "recipient@example.com"

# Connect and send the email
try:
    with smtplib.SMTP(smtp_host, smtp_port) as server:
        server.starttls()  # Secure the connection
        server.login(username, password)
        server.send_message(msg)
        print("Email sent successfully!")
except Exception as e:
    print(f"Error sending email: {e}")









Based on the code, here's the current working mail configuration:

In mail_config.py:
SMTP Server: smtp.mailgun.org
Port: 587
TLS: Enabled
Authentication: Using username/password
Required Environment Variables (set these in Replit Secrets):
MAILGUN_SMTP_USERNAME
MAILGUN_SMTP_PASSWORD
MAIL_DEFAULT_SENDER
The configuration initializes mail with:
app.config.update(
    MAIL_SERVER='smtp.mailgun.org',
    MAIL_PORT=587,
    MAIL_USE_TLS=True,
    MAIL_USERNAME=smtp_username,
    MAIL_PASSWORD=smtp_password,
    MAIL_DEFAULT_SENDER=sender
)
Sends emails using direct SMTP with starttls() for security
The key changes that made it work were:

Using port 587 instead of 465
Enabling TLS instead of SSL
Using direct SMTP connection with proper starttls() initialization
Proper error handling and logging
Keep these settings in your Replit Secrets for future implementations.





MAIL_DEFAULT_SENDER
••••••••
MAILGUN_DOMAIN
••••••••
MAILGUN_SMTP_PASSWORD
••••••••
MAILGUN_SMTP_USERNAME
••••••••
MAILGUN_API_KEY
••••••••
var = 0;
if(isBlank(input.Stock_Adjustment_No.trim()))
{
	var = 1;
	str = thisapp.Common.Number_Function_New("Stock Adjustment");
	input.Stock_Adjustment_No = str;
	openUrl("#Form:Alert_Messages?Status=" + "Adjusted" + "&Value=" + input.Stock_Adjustment_No + "&zc_LoadIn=dialog","same window");
}
for each  rec in input.Item_Details
{
	fet_inven = Inventory[Part_No == rec.Part_No && Location_Name == rec.Location_Name && Sub_Location == rec.Sub_Location && Rack_Number == rec.Rack_Number];
	getuom = Materials[ID == rec.Part_No].Primary_UoM;
	//if(fet_inven.Part_No == rec.Part_No)
	if(fet_inven.count() > 0)
	{
		// 		for each  fet in Inventory[Part_No == rec.Part_No]
		// 		{
		// 			if(fet.Part_Description == rec.Part_Name && fet.Location_Name == rec.Location_Name && fet.Sub_Location == rec.Sub_Location && fet.Rack_Number == rec.Rack_Number)
		//{
		fet_inven.Total_Qty=rec.New_Quantity_in_Hand;
		fet_inven.Available_Qty=rec.New_Quantity_in_Hand;
		//}
	}
	//}
	else
	{
		insert into Inventory
		[
			Added_User=zoho.loginuser
			Part_No=rec.Part_No
			Part_Description=rec.Part_Name
			Specification=rec.Specification
			Total_Qty=rec.New_Quantity_in_Hand
			Location_Name=rec.Location_Name
			Sub_Location=rec.Sub_Location
			Rack_Number=rec.Rack_Number
			Available_Qty=rec.New_Quantity_in_Hand
			Warehouse=input.Warehouse
			UOM=getuom
		]
	}
	thisapp.Stock_Ledger.Stock_Adj_Stockledger(input.ID);
}
//update the qty in Stock value also
for each  stkvalrec in input.Item_Details
{
	fetstkvalue = Stock_Value[Part_No == stkvalrec.Part_No && Stock_Qty > 0] sort by Added_Time desc;
	if(fetstkvalue.count() > 0)
	{
		fetstkvalue.Stock_Qty=stkvalrec.New_Quantity_in_Hand;
		fetstkvalue.Inventory_Qty=stkvalrec.New_Quantity_in_Hand;
		sendmail
		[
			from :"erp@carrierwheels.com"
			to :"parthasarathy.m@synprosoft.com"
			subject :"Stock Adjustment Created or Edited Successeful form submission " + stkvalrec.Part_No.Part_No + "adjqty " + stkvalrec.New_Quantity_in_Hand
			message :"Stock Adjustment Created or Edited Successeful form submission " + stkvalrec.Part_No.Part_No + "adjqty " + stkvalrec.New_Quantity_in_Hand
		]
	}
}
var = 0;
if(isBlank(input.Stock_Transfer_NO.trim()))
{
	var = 1;
	str = thisapp.Common.Number_Function_New("Stock Transfer");
	input.Stock_Transfer_NO = str;
	openUrl("#Form:Alert_Messages?Status=" + "Stktrf" + "&Value=" + input.Stock_Transfer_NO + "&zc_LoadIn=dialog","same window");
}
if(Transfer_Type == "Location Based")
{
	if(input.Source_Rack_Bins != input.Destination_Rack_Bins)
	{
		for each  rec in input.Stock_Details
		{
			des = Inventory[Warehouse == input.Destination_Warehouse && Location_Name == input.Destination_Location && Sub_Location == input.Destination_Sub_Location && Rack_Number == input.Destination_Rack_Bins && Part_No == rec.Part_No];
			src = Inventory[Warehouse == input.Source_Warehouse && Location_Name == input.Source_Location && Sub_Location == input.Source_Sub_Location && Rack_Number == input.Source_Rack_Bins && Part_No == rec.Part_No];
			getuom = Materials[ID == rec.Part_No].Primary_UoM;
			if(des.count() == 1)
			{
				//update
				des.Available_Qty=des.Available_Qty + rec.Transfer_Qty;
				des.Total_Qty=des.Total_Qty + rec.Transfer_Qty;
				src.Available_Qty=src.Available_Qty - rec.Transfer_Qty;
				src.Total_Qty=src.Total_Qty - rec.Transfer_Qty;
			}
			else
			{
				//insert
				insert into Inventory
				[
					Added_User=zoho.loginuser
					Warehouse=input.Destination_Warehouse
					Part_No=rec.Part_No
					Part_Description=rec.Part_Description
					Specification=rec.Specification
					Category=rec.Category
					Sub_Category=rec.Sub_Category
					Total_Qty=rec.Transfer_Qty
					Available_Qty=rec.Transfer_Qty
					Location_Name=input.Destination_Location
					Sub_Location=input.Destination_Sub_Location
					Rack_Number=input.Destination_Rack_Bins
					UOM=getuom
				]
				src.Available_Qty=src.Available_Qty - rec.Transfer_Qty;
				src.Total_Qty=src.Total_Qty - rec.Transfer_Qty;
			}
		}
	}
}
if(Transfer_Type == "Part Based")
{
	for each  sub in input.Stock_Details
	{
		source = Inventory[Part_No == input.Stock_Details.Source_Part_No] sort by Available_Qty desc;
		destination = Inventory[Part_No == input.Stock_Details.Destination_Part_No] sort by Available_Qty desc;
		getuom = Materials[ID == sub.Destination_Part_No].Primary_UoM;
		if(destination.count() == 1)
		{
			destination.Available_Qty=destination.Available_Qty + sub.Transfer_Qty;
			destination.Total_Qty=destination.Total_Qty + sub.Transfer_Qty;
			source.Available_Qty=source.Available_Qty - sub.Transfer_Qty;
			source.Total_Qty=source.Total_Qty - sub.Transfer_Qty;
		}
		else
		{
			insert into Inventory
			[
				Added_User=zoho.loginuser
				Warehouse=sub.Destination_Warehouse
				Part_No=sub.Destination_Part_No
				Part_Description=sub.Destination_Part_Name
				Specification=sub.Specification
				Category=sub.Source_Category
				Sub_Category=sub.Source_Sub_Category
				Total_Qty=sub.Transfer_Qty
				Available_Qty=sub.Transfer_Qty
				Location_Name=sub.Destination_Location
				Sub_Location=sub.Destination_Sub_Location
				Warehouse=sub.Destination_Warehouse
				UOM=getuom
			]
			source.Available_Qty=source.Available_Qty - sub.Transfer_Qty;
			source.Total_Qty=source.Total_Qty - sub.Transfer_Qty;
		}
	}
}
// if(isBlank(input.Transfer_Order_No.trim()))
// {
// 	//lastrec = Stock_Transfer[ID != null && ID != input.ID] sort by ID desc;
// 	//info lastrec.ID + "ORDER" + lastrec.Transfer_Order_No;
// 	lastrec = Stock_Transfer[Transfer_Order_No != null && Transfer_Order_No != ""] sort by Transfer_Order_No desc;
// 	if(lastrec.Transfer_Order_No == null || lastrec.Transfer_Order_No == "")
// 	{
// 		nextid = 1;
// 		//info "yes";
// 	}
// 	else
// 	{
// 		nextid = lastrec.Transfer_Order_No.getSuffix("-").getsuffix("/").toLong() + 1;
// 	}
// }
// input.Transfer_Order_No = "TQ/ST/" + thisapp.financial_year() + "/" + leftpad(nextid.toString(),5).replaceAll(" ","0");
// openUrl("#Form:Alert_Messages?Status=" + "Stktrf" + "&Value=" + input.Transfer_Order_No + "&zc_LoadIn=dialog","same window");
var = 0;
if(isBlank(input.Revert_No.trim()))
{
	var = 1;
	str = thisapp.Common.Number_Function_New("Revert MRP");
	input.Revert_No = str;
}
fet_mrp = MRP[Work_Order_No1 == input.Work_Order_No];
fetwo = Work_Order[Work_Order_No == input.Work_Order_No.Work_Order_No];
fetwosf = Work_Order_Subform[Work_Order_Exis_ID == fetwo.ID];
sosub = Sale_Order_Subform[Sales_Order_Exis_ID.Sale_Order_No == fetwo.Sales_Order_Nos.Sale_Order_No];
DFWOSUB = DF_Work_Order_Subform[Part_No == fetwosf.Part_No];
DFWO = Create_WO_for_Regular_Wheels[ID == DFWOSUB.Draft_Work_Order_RecID];
if(input.Work_Order_Subform_ID != null)
{
	input.Status = "WO Reverted";
	fetwo.WO_Status="WO Reverted";
	fetwosf.Work_Order_Status="WO Reverted";
	if(fetwo.Form_Mode == "Draft WO-Regular Wheels")
	{
		if(DFWO.count() > 0)
		{
			DFWO.WO_Status="Draft WO";
			DFWOSUB.Status="";
		}
		thisapp.workorder.RegularItem_Master_Total_Qty_DailyUpdate();
		thisapp.workorder.Draft_WO();
	}
	if(fetwo.Form_Mode == "WO against SO")
	{
		sosub.WO_Status_in_sosub="Pending WO";
		for each  wosub in fetwosf
		{
			get_inv = Inventory[Part_No == wosub.Part_No] sort by Block_Qty desc;
			if(get_inv.count() > 0)
			{
				/* 		get_inv.Available_Qty=ifnull(get_inv.Available_Qty,0.00) + ifnull(get_inv.Block_Qty,0.00);
		//get_inv.Block_Qty=0.00;
		get_inv.Block_Qty=ifnull(get_inv.Block_Qty,0.00) - ifnull(wosub.Block_Qty,0.00); */
				blkqty = wosub.Block_Qty;
				for each  inven in get_inv
				{
					if(blkqty > inven.Block_Qty)
					{
						inven.Available_Qty=ifnull(inven.Available_Qty,0) + ifnull(inven.Block_Qty,0);
						blkqty = blkqty - ifnull(inven.Block_Qty,0);
						inven.Block_Qty=0.00;
						// inventory.Total_Qty = 0.00;
					}
					else if(blkqty <= inven.Block_Qty)
					{
						// inven.Total_Qty = ifnull(inven.Total_Qty,0)  - ifnull(var.Block_Qty ,0);
						inven.Available_Qty=ifnull(inven.Available_Qty,0) + ifnull(blkqty,0);
						inven.Block_Qty=ifnull(inven.Block_Qty,0) - ifnull(blkqty,0);
						blkqty = 0.00;
					}
					if(blkqty == 0)
					{
						break;
					}
				}
			}
		}
	}
}
if(fet_mrp.MRP_Status == "MRP Done" || fet_mrp.MRP_Status = "Release Production")
{
	//fet_mrp.MRP_Status="MRP Reverted";
	input.Status = "MRP Reverted";
	fet_mrp.MRP_Status="MRP Reverted";
	fetwo.WO_Status="MRP Reverted";
	fetwosf.Work_Order_Status="MRP Reverted";
	//fetwosf.Work_Order_Status="MRP Reverted";
	for each  blk in fet_mrp.BoM_Details_CWPL
	{
		fet_inv = Inventory[Part_No == blk.Part_No && Block_Qty > 0];
		if(fet_inv.count() > 0)
		{
			if(blk.Block_Qty = True)
			{
				balqty = 0;
				i = 1;
				for each  invcwplrec in fet_inv
				{
					//blocked Quantiy is less inventory available qty
					if(blk.Blocked_Qty <= invcwplrec.Block_Qty && i == 1)
					{
						//info "issued qty is less than total qty";
						invcwplrec.Available_Qty=ifnull(invcwplrec.Available_Qty,0.0) + ifnull(blk.Blocked_Qty,0.0);
						invcwplrec.Block_Qty=ifnull(invcwplrec.Block_Qty,0) - ifnull(blk.Blocked_Qty,0);
					}
					//blocked Quantiy is more than inventory available qty
					else if(blk.Blocked_Qty > invcwplrec.Block_Qty && i == 1)
					{
						//info "issued qty is more than total qty";
						balqty = ifnull(blk.Blocked_Qty,0.0) - ifnull(invcwplrec.Block_Qty,0.0);
						invcwplrec.Available_Qty=balqty;
						invcwplrec.Block_Qty=ifnull(invcwplrec.Block_Qty,0) - ifnull(blk.Blocked_Qty,0);
					}
					//for first time it should not get inside the loop 
					if(balqty > 0 && i > 1)
					{
						//info "balance qty is more than zero";
						//Balance Qty is less 
						if(balqty <= invcwplrec.Block_Qty)
						{
							//info "balance qty is less than total qty";
							invcwplrec.Available_Qty=ifnull(invcwplrec.Available_Qty,0.0) + ifnull(balqty,0.0);
							invcwplrec.Block_Qty=ifnull(blk.Blocked_Qty,0) - ifnull(invcwplrec.Block_Qty,0);
							balqty = 0;
						}
						//----Balance Qty is More------
						else if(balqty >= invcwplrec.Block_Qty)
						{
							//info "balance qty is greater than total qty";
							balqty = ifnull(balqty,0.0) - ifnull(invcwplrec.Block_Qty,0.0);
							invcwplrec.Available_Qty=ifnull(balqty,0);
							invcwplrec.Block_Qty=ifnull(balqty,0) - ifnull(invcwplrec.Block_Qty,0);
						}
					}
					if(balqty == 0)
					{
						break;
					}
					i = i + 1;
				}
			}
		}
	}
	for each  blk1 in fet_mrp.BoM_Details_General_Purchase
	{
		fet_virstk = Inventory[Part_No == blk1.Part_No && Block_Qty > 0];
		if(fet_virstk.count() > 0)
		{
			if(blk1.Block_Qty = True)
			{
				balqty = 0;
				i1 = 1;
				for each  invgprec in fet_virstk
				{
					if(blk1.Blocked_Qty <= invgprec.Block_Qty && i1 == 1)
					{
						//info "blocked qty is less than total qty";
						invgprec.Block_Qty=ifnull(invgprec.Block_Qty,0) - ifnull(blk1.Blocked_Qty,0);
						invgprec.Available_Qty=ifnull(invgprec.Available_Qty,0) + ifnull(blk1.Blocked_Qty,0);
					}
					else if(blk1.Blocked_Qty > invgprec.Block_Qty && i == 1)
					{
						//info "blocked qty is more than available qty";
						balqty = ifnull(blk1.Blocked_Qty,0.0) - ifnull(invgprec.Block_Qty,0.0);
						invgprec.Available_Qty=balqty;
						invgprec.Block_Qty=ifnull(invgprec.Block_Qty,0) - ifnull(blk1.Blocked_Qty,0);
					}
					if(balqty > 0 && i > 1)
					{
						//info "balaance qty is more than zero";
						//Balance Qty is less 
						if(balqty <= invgprec.Block_Qty)
						{
							//	info "balance qty is less than available qty";
							invgprec.Available_Qty=ifnull(invgprec.Available_Qty,0.0) + ifnull(balqty,0.0);
							invgprec.Block_Qty=ifnull(invgprec.Block_Qty,0) - ifnull(blk1.Blocked_Qty,0);
							balqty = 0;
						}
						//Balance Qty is More
						else if(balqty >= invgprec.Block_Qty)
						{
							//info "balance qty is greater than available qty";
							balqty = ifnull(balqty,0.0) - ifnull(invgprec.Block_Qty,0.0);
							invgprec.Available_Qty=balqty;
							invgprec.Block_Qty=ifnull(invgprec.Block_Qty,0) - ifnull(blk1.Blocked_Qty,0);
						}
					}
					if(balqty == 0)
					{
						break;
					}
					i = i + 1;
				}
			}
		}
	}
}
//openUrl("#Script:page.refresh","same window");
openUrl("##Report:MRP_Reverse","same window");
if(var == 1 && input.Form_Mode == "Front")
{
	openUrl("#Form:Alert_Messages?Status=" + "RMRP" + "&Value=" + input.Revert_No + "&zc_LoadIn=dialog","same window");
}
else if(input.Form_Mode == "Rear")
{
	openUrl("#Form:Alert_Messages?Status=" + "REVMRP" + "&Value=" + input.Revert_No + "&zc_LoadIn=dialog","same window");
}
else if(input.Form_Mode == "ReverseWO")
{
	openUrl("#Form:Alert_Messages?Status=" + "MRPRev" + "&Value=" + input.Revert_No + "&zc_LoadIn=dialog","same window");
}
if(input.MRP_RECID != null)
{
	get_mrp = MRP[ID == input.MRP_RECID];
	//info get_mrp + "mrp";
	fet_cwpl = MRP_Subform_CWPL[MRP_Biderection_ID == get_mrp.ID];
	fet_gp = MRP_Subform_GP[MRP_Biderection_ID == get_mrp.ID];
	input.Revert_By = Employee_Details[Employee_Email == zoho.loginuserid].ID;
	input.Revert_Date = zoho.currentdate;
	input.Work_Order_No = get_mrp.Work_Order_No1;
	input.Sales_Order_No = get_mrp.Sales_Order_No;
	input.Part_No = get_mrp.Part_No;
	input.Part_Name = get_mrp.Part_Name;
	input.MRP_Qty = get_mrp.MRP_Qty;
	input.Factory_Warehouse = get_mrp.Factory_Warehouse;
	input.Created_By = get_mrp.Created_By.ID;
	input.Customer_Name = get_mrp.Customer_Name;
	input.Specification = get_mrp.Specification;
	hide WO_Qty;
}
i = 0;
//info "outside for";
//info fet_cwpl + "subform";
for each  mrpcwpl in fet_cwpl
{
	//info "1st for";
	i = i + 1;
	getrow = Revert_Process1.Revert_MRP_Subform_CWPL();
	getrow.S_No=i;
	getrow.Part_No=mrpcwpl.Part_No;
	getrow.Part_Name=mrpcwpl.Part_Name;
	getrow.UoM=mrpcwpl.UoM;
	getrow.BoM_Qty=mrpcwpl.BoM_Qty_Old;
	getrow.Stock_Qty=mrpcwpl.Stock_Qty;
	getrow.Req_Qty=mrpcwpl.Req_Qty;
	getrow.Plan_Qty=mrpcwpl.Actual_Qty;
	getrow.Blocked_Qty=mrpcwpl.Blocked_Qty;
	getrow.Block_Qty=mrpcwpl.Block_Qty;
	getrow.bom_stk_qty=mrpcwpl.bom_stk_qty;
	cwplCol = Collection();
	cwplCol.insert(getrow);
	input.Revert_MRP_Subform_CWPL.insert(cwplCol);
}
j = 0;
for each  gp in fet_gp
{
	j = j + 1;
	genral = Revert_Process1.Revert_MRP_Subform_GP();
	genral.S_No=j;
	genral.Part_No=gp.Part_No;
	genral.Part_Name=gp.Part_Name;
	genral.UoM=gp.UoM;
	genral.Purchase_Qty=gp.Purchase_Qty;
	genral.Stock_Qty=gp.Stock_Qty;
	genral.Indent_Qty=gp.Indent_Qty;
	genral.BoM_Qty=gp.BoM_Qty;
	genral.Req_Qty=gp.Plan_Qty;
	genral.Blocked_Qty=gp.Blocked_Qty;
	genral.Block_Qty=gp.Block_Qty;
	gencol = Collection();
	gencol.insert(genral);
	input.Revert_MRP_Subform_GP.insert(gencol);
}
if(input.Work_Order_Subform_ID != null)
{
	fet_wosub = Work_Order_Subform[ID == input.Work_Order_Subform_ID];
	get_wo = Work_Order[ID == fet_wosub.Work_Order_Exis_ID];
	input.Create_Work_Order_ID = get_wo.ID;
	input.WO_Qty = fet_wosub.WO_Qty;
	input.Revert_By = Employee_Details[Employee_Email == zoho.loginuserid].ID;
	input.Revert_Date = zoho.currentdate;
	input.Work_Order_No = get_wo.ID;
	input.Sales_Order_No = get_wo.Sales_Order_Nos;
	input.Part_No = fet_wosub.Part_No;
	input.Part_Name = fet_wosub.Part_Description;
	input.Customer_Name = get_wo.Customer_Name;
	input.Specification = fet_wosub.Specification;
	hide MRP_Qty;
	hide Factory_Warehouse;
	hide Specification;
	hide Created_By;
	disable WO_Qty;
}
wosno = 0;
for each  wosf in fet_wosub
{
	wosno = wosno + 1;
	inswo = Revert_Process1.Revert_WO_Subform();
	inswo.S_No=wosno;
	inswo.Part_No=wosf.Part_No;
	inswo.Part_Description=wosf.Part_Description;
	inswo.UOM=wosf.UOM;
	inswo.SO_Quantity=wosf.SO_Quantity;
	inswo.Stock_Qty=wosf.Stock_Qty;
	inswo.WO_Pipeline=wosf.WO_Pipeline;
	inswo.Required_Qty=wosf.Required_Qty;
	inswo.WO_Qty=wosf.WO_Qty;
	inswo.Block_Qty=wosf.Block_Qty;
	inswo.Balance_Qty=wosf.Balance_Qty;
	inswo.WO_Qty_with_buffer=wosf.WO_Qty_with_buffer;
	inswo.Specification=wosf.Specification;
	wocol = Collection();
	wocol.insert(inswo);
	input.Revert_WO_Subform.insert(wocol);
}
if(row.Part_Description != null)
{
	match_data = Materials[ID == row.Part_Description && Status == "Active"];
	row.Rate=ifnull(match_data.Purchase_Price,0.0);
	row.Part_No=match_data.ID;
	row.Mfr_Part_No=ifnull(match_data.ID,"");
	row.Specification=match_data.Specification;
	row.Brand=match_data.Brand_Name;
	row.Ordered_Qty=ifnull(match_data.MOQ,0);
	row.UoM=row.Part_Description.Primary_UoM;
	//checking with vendor location with Uttar Pradesh 
	if(input.Vendor_Name.Place_of_Supply.Destination != "Uttar Pradesh")
	{
		row.Tax=Materials[ID == row.Part_Description].IGST_Details;
	}
	else
	{
		row.Tax=Materials[ID == row.Part_Description].GST_Details;
	}
	row.Available_Qty=ifnull(Inventory[Part_Description == row.Part_Description].sum(Available_Qty),0.0);
	row.MOQ_Qty=ifnull(Materials[ID == row.Part_Description].MOQ,0.0);
	//load the rate,moq from the vendor pricing master if available
	getvendcust = Vendor_Contract[Vendor_Name == input.Vendor_Name && Status == "Active"];
	if(getvendcust.count() > 0)
	{
		ven_pricing = Vendor_Contract_Subform[Vendor_Name == input.Vendor_Name && Part_Description == row.Part_Description && Effective_From <= zoho.currentdate && Effective_To >= zoho.currentdate && sf_Status == "Active"];
		//info ven_pricing.count();
		if(ven_pricing.count(ID) == 1)
		{
			row.Rate=null;
			row.MOQ_Qty=null;
			row.Ordered_Qty=null;
			row.Rate=ifnull(ven_pricing.Unit_Price,0.0);
			row.MOQ_Qty=ifnull(ven_pricing.MOQ,0.0);
			row.Ordered_Qty=ifnull(ven_pricing.MOQ,0.0);
			if(row.Rate != ven_pricing.Unit_Price)
			{
				row.Vendor_contract_Price_check=false;
			}
			else
			{
				row.Vendor_contract_Price_check=true;
			}
		}
	}
	row.Sub_Total=row.Ordered_Qty * row.Rate;
}
else
{
	row.Part_No=null;
	row.Available_Qty=null;
	row.Ordered_Qty=null;
	row.Specification=null;
	row.MOQ_Qty=null;
}
//For testing Purpose only Part number created for testing should be selected.
if(input.Vendor_Name != null)
{
	if(Vendor_Name.Vendor_Name.startsWithIgnoreCase("Test") == True)
	{
		if(row.Part_Description != null)
		{
			if(row.Part_Description.Part_Description.startsWithIgnoreCase("Test") == false)
			{
				alert "Use Test Part No for Testing";
				row.Part_No=null;
				row.Part_Description=null;
			}
		}
	}
}
if(row.Part_No != null)
{
	match_data = Materials[ID == row.Part_No && Status == "Active"];
	row.Part_Description=match_data.ID;
	row.Specification=match_data.Specification;
	row.Ordered_Qty=ifnull(match_data.MOQ,0);
	row.UoM=row.Part_Description.Primary_UoM;
	row.Mfr_Part_No=match_data.ID;
	row.Brand=match_data.Brand_Name;
	if(input.Source_of_Supply.Short_Name == "Out of Scope")
	{
		clear row.Tax;
		row.Tax=GST_Details[Tax_Name == "Out of Scope"].ID;
	}
	else
	{
		if(input.Source_of_Supply.Short_Name != "UP")
		{
			fet_igst = GST_Details[Tax_Name.contains("IGST")].ID.getAll();
			clear row.Tax;
			row.Tax:ui.add(fet_igst);
			row.Tax=Materials[ID == row.Part_No].IGST_Details;
		}
		else
		{
			fet_igst = GST_Details[Tax_Name.contains("GST") && !Tax_Name.startswith("I")].ID.getAll();
			clear row.Tax;
			row.Tax:ui.add(fet_igst);
			row.Tax=Materials[ID == row.Part_No].GST_Details;
		}
	}
	row.Available_Qty=ifnull(Inventory[Part_No == row.Part_No].sum(Available_Qty),0.0);
	//Unit price and MOq should be come from vendor pricing if vendor record is available in vendor pricing form.
	ven_pricing = Vendor_Contract_Subform[Vendor_Name == input.Vendor_Name && Part_Description == row.Part_Description && Effective_From <= zoho.currentdate && Effective_To >= zoho.currentdate && sf_Status == "Active"];
	//info ven_pricing.ID;
	//info ven_pricing.count(ID);
	if(ven_pricing.count(ID) == 1)
	{
		row.Ordered_Qty=ifnull(ven_pricing.MOQ,0.0);
		row.Rate=ifnull(ven_pricing.Unit_Price,0.0);
		row.MOQ_Qty=ifnull(ven_pricing.MOQ,0.0);
	}
	check_ven_map = 0;
	check_ven_lis = List();
	if(input.Vendor_Name != null)
	{
		chkvendavl = Vendor_Contract[Vendor_Name == input.Vendor_Name && Status == "Active"];
		if(chkvendavl.count() > 0)
		{
			for each  sub_val in input.Item_Details
			{
				check_vendor = Vendor_Contract_Subform[Vendor_Name == input.Vendor_Name && Part_Description == sub_val.Part_Description && Effective_From <= zoho.currentdate && Effective_To >= zoho.currentdate && sf_Status == "Active"];
				if(check_vendor.count() == 0)
				{
					check_ven_lis.add(sub_val.Part_No.Part_No);
					check_ven_map = 1;
				}
				if(check_vendor.count() > 0)
				{
					sub_val.Rate=ifnull(check_vendor.Unit_Price,0.0);
					sub_val.Vendor_contract_Price_check=true;
					sub_val.MOQ_Qty=ifnull(check_vendor.MOQ,0.0);
					if(row.Rate != check_vendor.Unit_Price)
					{
						row.Vendor_contract_Price_check=false;
					}
					else
					{
						row.Vendor_contract_Price_check=true;
					}
				}
				// 				sendmail
				// 				[
				// 					from :"CWPL ERP<erp@carrierwheels.com>"
				// 					to :"parthasarathy.m@synprosoft.com"
				// 					subject :"Vendor Contract - itemdetils partno validation " + row.Vendor_contract_Price_check
				// 					message :"Vendor Contract - itemdetils partno validation " + input.Vendor_Name.Vendor_Name
				// 				]
			}
		}
		if(check_ven_map == 1)
		{
			show asso_vendors;
			Flag_for_Not_Associated_Vendors = true;
			create_tab = "<table border=1 Style ='color:#ff8b3b'><tr><th>S.No</th><th>Part No</th><th>Associated Vendor(s)</th></tr>";
			sno = 1;
			for each  tab in check_ven_lis
			{
				ven_lis = List();
				for each  ven in Vendor_Contract_Subform[Vendor_Name == input.Vendor_Name && Part_Description == sub_val.Part_Description && Effective_From <= zoho.currentdate && Effective_To >= zoho.currentdate && sf_Status == "Active"]
				{
					if(ven.Vendor_Name.Status == "Active")
					{
						ven_lis.add(ven.Vendor_Name.Vendor_Name);
					}
				}
				create_tab = create_tab + "<tr><td>" + sno + "</td><td>" + tab + "</td><td>" + if(ven_lis.size() == 0,"<b>Not Associated</b>",ven_lis) + "</td></tr>";
				sno = sno + 1;
			}
			create_tab = create_tab + "</table>";
			str = "Selected Vendor <b>" + input.Vendor_Name.Vendor_Name + "</b> is not mapped against the following Item(s) : <br><br>  " + create_tab;
			input.asso_vendors = str;
			Do_you_want_to_proceed_anyway = "";
		}
		else
		{
			hide asso_vendors;
		}
	}
}
else
{
	row.Part_Description=null;
	row.Available_Qty=null;
	row.MOQ_Qty=null;
	row.Ordered_Qty=null;
	row.Specification=null;
	hide asso_vendors;
}
//for vendor gst treatment type is Registered Business - composition then GST is null - Parthasarathy - 09/06/2023
getvend = Vendor[ID == input.Vendor_Name];
getgsttreat = GST_Treatment[ID == getvend.GST_Treatment];
if(getgsttreat.GST_Treatment == "Registered Business - Composition")
{
	row.Tax=null;
	row.Tax_Value=null;
}
//if rate is updated in materials the calculate automatically - 19/12/2022
if(row.Ordered_Qty != null && row.Rate != null && row.Tax != null)
{
	get_tax_value = GST_Details[ID == row.Tax].Total_Rate;
	tax_calc = row.Ordered_Qty * row.Rate * get_tax_value / 100;
	row.Sub_Total=row.Ordered_Qty * row.Rate;
	row.Tax_Value=tax_calc;
	row.Item_Total=row.Sub_Total + tax_calc;
	tot = 0.0;
	subtot = 0.0;
	for each  rec in Item_Details
	{
		tot = tot + ifnull(rec.Item_Total,0.0);
		subtot = subtot + ifnull(rec.Sub_Total,0.0);
	}
	input.Item_Total = tot;
	input.Gross_Total = ifnull(subtot,0.0);
	//17082022input.Total = tot + ifnull(input.Extra_Charge_s_Total,0.0);
	input.Overall_Total = tot + ifnull(input.Extra_Charge_s_Total,0.0);
}
else
{
	row.Sub_Total=ifnull(row.Ordered_Qty,0) * ifnull(row.Rate,0) + ifnull(row.Tax_Value,0.0);
	row.Item_Total=ifnull(row.Sub_Total,0.0) + ifnull(row.Tax_Value,0.0);
	tot1 = 0.0;
	subtot1 = 0.0;
	for each  rec in Item_Details
	{
		tot1 = tot1 + ifnull(rec.Item_Total,0);
		subtot1 = subtot1 + ifnull(rec.Sub_Total,0.0);
	}
	//17082022input.Total = ifnull(input.Extra_Charge_s_Total,0.0) + tot1;
	input.Gross_Total = ifnull(subtot1,0.0);
	input.Overall_Total = ifnull(input.Extra_Charge_s_Total,0.0) + tot1;
	input.Item_Total = tot1;
}
//For testing Purpose only Part number created for testing should be selected.
if(input.Vendor_Name != null)
{
	if(Vendor_Name.Vendor_Name.startsWithIgnoreCase("Test") == True)
	{
		if(row.Part_No != null)
		{
			if(row.Part_No.Part_No.startsWithIgnoreCase("Test") == false)
			{
				alert "Use Test Part No for Testing";
				row.Part_No=null;
				row.Part_Description=null;
			}
		}
	}
}
aa = 0;
gt = 0;
it = 0;
for each  vv in input.Item_Details
{
	if(vv == row)
	{
		continue;
	}
	else
	{
		aa = aa + 1;
		vv.S_No=aa;
		gt = gt + ifnull(vv.Sub_Total,0);
		it = it + ifnull(vv.Item_Total,0);
	}
}
input.Gross_Total = gt;
input.Overall_Total = it;
for each  recval in input.Delivery_Schedule
{
	if(recval.Part_No == row.Part_Description)
	{
		recval.Part_No=null;
		recval.Quantity=null;
		recval.Delivery_Date=null;
	}
}
itemlist = List();
qtyList = List();
dateList = List();
remarksList = List();
fullQtyList = List();
for each  rec in input.Delivery_Schedule
{
	if(rec.Part_No != null)
	{
		itemlist.add(rec.Part_No);
		qtyList.add(rec.Quantity);
		dateList.add(rec.Delivery_Date);
		remarksList.add(rec.Remarks);
		fullQtyList.add(rec.Full_Quantity);
	}
}
input.Delivery_Schedule.clear();
i = 0;
s_no = 0;
for each  items in itemlist
{
	s_no = s_no + 1;
	row1 = Purchase_Order.Delivery_Schedule();
	row1.Part_No=items;
	row1.S_No=s_no;
	row1.Quantity=qtyList.get(i);
	row1.Delivery_Date=dateList.get(i);
	row1.Remarks=remarksList.get(i);
	row1.Full_Quantity=fullQtyList.get(i);
	input.Delivery_Schedule.insert(row1);
	i = i + 1;
}
/// 
check_ven_map = 0;
check_ven_lis = List();
for each  sub_val in input.Item_Details
{
	if(sub_val.Part_No != row.Part_No)
	{
		check_vendor = Vendor_Contract_Subform[Vendor_Name == input.Vendor_Name && Part_Description == sub_val.Part_Description && Effective_From <= zoho.currentdate && Effective_To >= zoho.currentdate && sf_Status == "Active"];
		if(check_vendor.count() == 0)
		{
			check_ven_lis.add(sub_val.Part_No.Part_No);
			check_ven_map = 1;
		}
	}
}
if(check_ven_map == 1)
{
	show asso_vendors;
	create_tab = "<table border=1 Style ='color:#ff8b3b'><tr><th>S.No</th><th>Part No</th><th>Associated Vendor(s)</th></tr>";
	sno = 1;
	for each  tab in check_ven_lis
	{
		ven_lis = List();
		for each  ven in Vendor_Contract_Subform[Part_Description.Part_No == tab && Effective_From <= zoho.currentdate && Effective_To >= zoho.currentdate && sf_Status == "Active"]
		{
			if(ven.Vendor_Name.Status == "Active")
			{
				ven_lis.add(ven.Vendor_Name.Vendor_Name);
			}
		}
		create_tab = create_tab + "<tr><td>" + sno + "</td><td>" + tab + "</td><td>" + if(ven_lis.size() == 0,"<b>Not Associated</b>",ven_lis) + "</td></tr>";
		sno = sno + 1;
	}
	create_tab = create_tab + "</table>";
	str = "Selected Vendor <b>" + input.Vendor_Name.Vendor_Name + "</b> is not mapped against the following Item(s) : <br><br>  " + create_tab;
	input.asso_vendors = str;
	Do_you_want_to_proceed_anyway = "";
	Flag_for_Not_Associated_Vendors = true;
}
else
{
	hide asso_vendors;
	Flag_for_Not_Associated_Vendors = false;
}
if(Item_Details == null)
{
	alert "First Add Data in Item Details";
}
i = 0;
for each  rec_sn in input.Delivery_Schedule
{
	i = i + 1;
	row.S_No=i;
}
//----------------------------------test code for same part number with different spec
item_list1 = List();
deliv_list1 = List();
finalist = List();
item_list = List();
spec_list = List();
for each  an_item in input.Item_Details
{
	if(an_item.Part_No != null)
	{
		item_list1.add(ifnull(an_item.Part_Description.concat("-"),"").concat(ifnull(an_item.Specification,"")));
		spec_list.add(an_item.Specification);
	}
	else
	{
		alert "First Add Data in Item Details";
	}
}
for each  deliv in input.Delivery_Schedule
{
	if(deliv.Part_No != null && deliv.Full_Quantity == true)
	{
		deliv_list1.add(deliv.Part_No.concat("-").concat(ifnull(deliv.Specification,"")));
	}
}
item_list1.removeAll(deliv_list1);
for each  itemlistrec in item_list1
{
	//finalist.add(itemlistrec.getprefix("-"));
	item_list.add(itemlistrec.getprefix("-"));
}
//----------------------------------------test code end here-----------------------------------------------------
//For Delivery Schedule
clear row.Part_No;
/*item_list = List();
deliv_list = List();
for each  an_item in input.Item_Details
{
	item_list.add(an_item.Part_Description);
}
for each  deliv in input.Delivery_Schedule
{
	if(deliv.Part_No != null && deliv.Full_Quantity == true)
	{
		deliv_list.add(deliv.Part_No);
	}
}
item_list.removeAll(deliv_list);*/
row.Part_No:ui.add(item_list.sort(true));
if(item_list.size() > 0)
{
	row.Part_No=item_list.get(0);
	//Setting Quantity
	for each  itemdetrec in input.Item_Details
	{
		if(itemdetrec.Ordered_Qty < 1)
		{
			alert "Please enter quantity for all the item(s) in Item Details Subform";
			row.Quantity=null;
		}
		else
		{
			dsqtytot = 0;
			for each  delschrec in input.Delivery_Schedule
			{
				if(itemdetrec.S_No == delschrec.S_No && itemdetrec.Part_No == delschrec.Part_No && itemdetrec.Specification == delschrec.Specification && delschrec.Full_Quantity == false)
				{
					row.Specification=delschrec.Specification;
				}
				//calculate the quantity and comapare with item details qty
				if(delschrec.Part_No == itemdetrec.Part_No && delschrec.S_No == itemdetrec.S_No)
				{
					//if(delschrec.Part_No == itemdetrec.Part_No && delschrec.Specification == itemdetrec.Specification)
					dsqtytot = dsqtytot + ifnull(delschrec.Quantity,0.0);
				}
				//qty,spec
				if(itemdetrec.Part_No == row.Part_No && itemdetrec.S_No == row.S_No)
				{
					row.Quantity=if(dsqtytot > 0,itemdetrec.Ordered_Qty - dsqtytot,itemdetrec.Ordered_Qty);
					row.Quantity=itemdetrec.Ordered_Qty;
					row.Specification=itemdetrec.Specification;
					row.Full_Quantity=true;
				}
				//itemdetails partno qty splitting in delvy sch with different date
				if(itemdetrec.Part_No == row.Part_No && itemdetrec.Specification == row.Specification && row.Full_Quantity == false)
				{
					row.Specification=itemdetrec.Specification;
					row.Quantity=if(dsqtytot > 0,itemdetrec.Ordered_Qty - dsqtytot,itemdetrec.Ordered_Qty);
				}
			}
		}
	}
}
if(!isNull(input.Incoterms))
{
	if(input.Incoterms_same_for_all_items == "Yes")
	{
		row.Incoterms=input.Incoterms;
	}
	else
	{
		row.Incoterms=null;
	}
}
if(!isNull(input.Incoterms_Location1))
{
	if(input.Incoterms_Location_same_for_all_items == "Yes")
	{
		row.Incoterms_Location=input.Incoterms_Location1;
	}
	else
	{
		row.Incoterms_Location=null;
	}
}
if(!isNull(input.Delivery_Date))
{
	if(input.Delivery_Date_same_for_all_items == "Yes")
	{
		row.Delivery_Date=input.Delivery_Date;
	}
	else
	{
		row.Delivery_Date=null;
	}
}
//old code for ERP Issue no. 13 & 32 is commented. start below
/*i = 0;
for each  rec_sn in input.Delivery_Schedule
{
    i = i + 1;
    row.S_No=i;
}
//10-07-2019/For Delivery Schedule
clear row.Part_No;
item_list = List();
deliv_list = List();
for each  an_item in input.Item_Details
{
    item_list.add(an_item.Part_Description);
}
for each  deliv in input.Delivery_Schedule
{
    if(deliv.Part_No != null && deliv.Full_Quantity == true)
    {
        deliv_list.add(deliv.Part_No);
    }
}
item_list.removeAll(deliv_list);
row.Part_No:ui.add(item_list.sort(true));
if(item_list.size() > 0)
{
    row.Part_No=item_list.get(0);
    //Setting Quantity
    for each  rec in input.Item_Details
    {
        if(rec.Ordered_Qty < 1)
        {
            alert "Please enter quantity for all the item(s) in Item Details Subform";
            row.Quantity=null;
        }
        else
        {
            tot = 0.0;
            for each  rec1 in input.Delivery_Schedule
            {
                if(rec1.Part_No == rec.Part_Description)
                {
                    tot = tot + ifnull(rec1.Quantity,0.0);
                }
            }
            if(rec.Part_Description == row.Part_No)
            {
                row.Quantity=if(tot > 0,rec.Ordered_Qty - tot,rec.Ordered_Qty);
                row.Full_Quantity=true;
            }
        }
    }
}
if(!isNull(input.Incoterms))
{
    if(input.Incoterms_same_for_all_items == "Yes")
    {
        row.Incoterms=input.Incoterms;
    }
    else
    {
        row.Incoterms=null;
    }
}
if(!isNull(input.Incoterms_Location1))
{
    if(input.Incoterms_Location_same_for_all_items == "Yes")
    {
        row.Incoterms_Location=input.Incoterms_Location1;
    }
    else
    {
        row.Incoterms_Location=null;
    }
}
if(!isNull(input.Delivery_Date))
{
    if(input.Delivery_Date_same_for_all_items == "Yes")
    {
        row.Delivery_Date=input.Delivery_Date;
    }
    else
    {
        row.Delivery_Date=null;
    }
}*/
//old code end above 
fet_pref = Preferences[Module_Name = "GRN"];
input.Auto_Approval = fet_pref.Auto_Approval;
//_________________________________________________________________
hide Item_Details.Purchase_Order_Number;
hide Item_Details.Tax_Value;
hide Item_Details.Tax;
hide Item_Details.Income_Quality_Check_Process;
hide Item_Details.zinvt_line_item_id;
hide Item_Details.zinvt_item_id;
hide Purchase_Order_Subform_RECID;
hide Transportation_details.GRN_Main_RECID;
input.Received_By = Employee_Details[Employee_Email == zoho.loginuserid].ID;
input.GRN_Time = zoho.currenttime;
disable GRN_Time;
if(Purchase_Order_Subform_RECID != null || Purchase_Order_Subform_RECID.size() > 0)
{
	TotalValue = 0;
	tot_qty = 0;
	i = 0;
	input.Goods_Received_Note_Date = zoho.currentdate;
	for each  PORec in input.Purchase_Order_Subform_RECID
	{
		i = i + 1;
		getPosub = Purchase_Order_Subform[ID == PORec.ID && PO_Status == "GRN Pending" || PO_Status == "Gate Entry Partially Done" || PO_Status == "GRN Partially Received"];
		getPOMain = Purchase_Order[ID == getPosub.Purchase_Order_ExisID];
		//get the indent raised by and department details  - user requirememnt - 12/12/2022
		getindentsf = Indent_Sub_Form[ID == getPOMain.Indent_Sub_Form_RECID];
		getindent = Indent[ID == getindentsf.Indent_Form_RECID];
		//	getindentno = Indent_Sub_Form[Purchase_Order_Subform_RECIDD == PORec.ID];
		getindentno = Indent_Sub_Form[ID == getPosub.Indent_Sub_Form];
		//info getindentno;
		getmaterials = Materials[ID == getPosub.Part_No];
		getcategory = Category[ID == getmaterials.Category];
		//info getcategory;
		if(getindent.count() = 0)
		{
			hide Indent_No;
			hide Indentor;
			hide Department;
		}
		else
		{
			input.Indent_No = getindentno.Indent_No;
			disable Indent_No;
			input.Indentor = getindent.Request_Raised_By;
			disable Indentor;
			input.Department = getindent.Department;
			disable Department;
		}
		input.Purchase_Order = getPosub.Purchase_Order_ExisID;
		input.Purchase_Order_Nos = (input.Purchase_Order_Subform_RECID.Purchase_Order_ExisID.getall()).distinct();
		//input.Mode_of_delivery = getPOMain.Shipping_Mode;//field deleted as per user request - 31/01/2023
		input.Purchase_Order_Number = getPOMain.ID;
		input.Purchase_Order_Date = getPOMain.Purchase_Order_Date;
		disable Purchase_Order;
		disable Mode_of_delivery;
		disable Purchase_Order_Number;
		disable Purchase_Order_Date;
		input.Vendor_Name = getPOMain.Vendor_Name;
		gatefet = Create_Gate_Entry1[Vendor_Name == input.Vendor_Name && GEP_Status != "Closed"].ID.getAll();
		input.Gate_Entry_No:ui.add(gatefet);
		disable Vendor_Name;
		Get_Tax_Perc = GST_Details[ID == getPosub.Tax].Total_Rate;
		if(Get_Tax_Perc != null)
		{
			Tax_Amount = (ifnull(PORec.Ordered_Qty,0) - ifnull(PORec.Qty_Received_so_far,0)) * ifnull(getPosub.Rate,0.00) * Get_Tax_Perc / 100;
		}
		if(Get_Tax_Perc != null)
		{
			Total_Amount = (ifnull(PORec.Ordered_Qty,0) - ifnull(PORec.Qty_Received_so_far,0)) * ifnull(getPosub.Rate,0.00) + ifnull(Tax_Amount,0.0);
		}
		else
		{
			Total_Amount = (ifnull(PORec.Ordered_Qty,0) - ifnull(PORec.Qty_Received_so_far,0)) * ifnull(getPosub.Rate,0.00);
		}
		//Disable all Subform Fields except Received Quantity.
		hide Item_Details.GRN_Created_Date;
		if(getcategory.Category != "HR Coils")
		{
			hide Item_Details.HR_Coil_id;
		}
		else
		{
			hide Item_Details.HR_Coil_id;
		}
		disable Item_Details.S_No;
		disable Item_Details.GRN_Created_Date;
		disable Item_Details.Part_No;
		disable Item_Details.Part_Description;
		disable Item_Details.Specification;
		disable Item_Details.UoM;
		disable Item_Details.Ordered_Qty;
		disable Item_Details.Received_Qty_So_far;
		disable Item_Details.Rate;
		disable Item_Details.Sub_Total;
		disable Item_Details.Tax;
		disable Item_Details.Tax_Value;
		disable Item_Details.Amount;
		disable Item_Details.Balance_Qty;
		//disable Item_Details.MFG_Date; comment on 6.9.2022 by partha
		//disable Item_Details.Exp_Date; comment on 6.9.2022 by partha
		disable Item_Details.PO_ID;
		disable Item_Details.Purchase_Order_SubForm_RECID;
		disable Item_Details.Batch_Number;
		disable Item_Details.Total_Price;
		disable Item_Details.Barcode;
		disable Item_Details.GRN_ID;
		disable Item_Details.HR_Coil_id;
		disable Item_Details.Indentor;
		disable Item_Details.Indent_No;
		disable Item_Details.Indentor_Dept;
		//ItemDetails Subform - Declaring the Row for Subform 
		ItemDetailSFRow = GRN.Item_Details();
		// assigning values for various subform fields in the row
		ItemDetailSFRow.S_No=i;
		ItemDetailSFRow.GRN_Created_Date=zoho.currentdate;
		ItemDetailSFRow.Part_No=getPosub.Part_No;
		ItemDetailSFRow.Part_Description=getPosub.Part_Description;
		ItemDetailSFRow.Specification=getPosub.Specification;
		ItemDetailSFRow.UoM=getPosub.UoM;
		ItemDetailSFRow.Rate=ifnull(getPosub.Rate,0.00);
		ItemDetailSFRow.Sales_Order_No=getPosub.Sales_Order_No;
		ItemDetailSFRow.PO_ID=getPosub.Purchase_Order_ExisID;
		ItemDetailSFRow.Purchase_Order_SubForm_RECID=PORec.ID;
		ItemDetailSFRow.Ordered_Qty=getPosub.Ordered_Qty;
		ItemDetailSFRow.Received_Qty=Ifnull(getPosub.Ordered_Qty,0) - Ifnull(getPosub.Qty_Received_so_far,0);
		//Pooja  ItemDetailSFRow.Received_Qty=ifnull(getPosub.Qty_Recieved_so_far_GE,0);
		//ItemDetailSFRow.Received_Qty=ifnull(getPosub.Qty_Recieved_so_far_GE,0) - ifNull(getPosub.Qty_Received_so_far,0);
		ItemDetailSFRow.Balance_Qty=ifnull(getPosub.Ordered_Qty,0) - (ifnull(ItemDetailSFRow.Received_Qty,0) + ifnull(getPosub.Qty_Received_so_far,0));
		ItemDetailSFRow.Received_Qty_So_far=Ifnull(getPosub.Qty_Received_so_far,0);
		ItemDetailSFRow.Sub_Total=(ifnull(getPosub.Ordered_Qty,0) - ifnull(getPosub.Qty_Received_so_far,0)) * ifnull(getPosub.Rate,0.00);
		if(getPosub.Tax != null)
		{
			ItemDetailSFRow.Tax=Ifnull(getPosub.Tax,"");
			ItemDetailSFRow.Tax_Value=ifnull(Tax_Amount,0.00);
		}
		if(getPosub.Tax == null)
		{
			ItemDetailSFRow.Amount=ifnull(ItemDetailSFRow.Sub_Total,0.00);
		}
		else
		{
			ItemDetailSFRow.Amount=ifnull(ItemDetailSFRow.Sub_Total,0.00) + ifnull(ItemDetailSFRow.Tax_Value,0.00);
		}
		ItemDetailSFRow.Total_Price=ItemDetailSFRow.Amount;
		ItemDetailSFRow.Purchase_Order_Number=getPOMain.ID;
		TotalValue = ifnull(TotalValue,0.00) + ifnull(ItemDetailSFRow.Amount,0.00);
		tot_qty = tot_qty + ifnull(ItemDetailSFRow.Received_Qty,0);
		//ItemDetailSFRow.Indent_No=getindent.Indent_No;
		ItemDetailSFRow.Indent_No=ifnull(getindentno,"");
		ItemDetailSFRow.Indentor=getindent.Request_Raised_By;
		ItemDetailSFRow.Indentor_Dept=getindent.Department;
		//ItemDetailSFRow.HR_Coil_id=Coil_id;
		// declare a variable to hold the collection of rows
		ItemDetailSfCol = Collection();
		ItemDetailSfCol.insert(ItemDetailSFRow);
		// insert the rows into the subform through the variable
		input.Item_Details.insert(ItemDetailSfCol);
	}
	//Retrieve the Transportation details
	/* 	fetgateentry = Gate_Entry_Process[Purchase_Order_No == input.Purchase_Order_Number];
	if(fetgateentry.count() > 0)
	{
		fettransentry = Gate_Entry_Transport_Details[Gate_Entry_Process_RECID == fetgateentry.ID];
		for each  transrec in fettransentry
		{
			//if(fettransentry.count() > 0)
			//	{
			TransportSFRow = GRN.Transportation_details();
			TransportSFRow.Vehicle_No=transrec.Vehicle_No;
			TransportSFRow.Name_of_Transport=transrec.Name_of_Transport;
			TransportSFRow.Driver_Name=transrec.Driver_Name;
			TransportSFRow.Driver_Contact_No=transrec.Driver_Contact_No;
			TransportSFRow.GR_RR_No=transrec.GR_RR_No;
			TransportSFRow.GR_RR_Date=transrec.GR_RR_Date;
			TransportSFRow.Picture_of_Item_Lorry=transrec.Picture_of_Item_Lorry;
			TransportSFRow.Picture_Description=transrec.Picture_Description;
			TransportSfCol = Collection();
			TransportSfCol.insert(TransportSFRow);
			// insert the rows into the subform through the variable
			input.Transportation_details.insert(TransportSfCol);
			disable Transportation_details.Vehicle_No;
			disable Transportation_details.Name_of_Transport;
			disable Transportation_details.Driver_Name;
			disable Transportation_details.Driver_Contact_No;
			disable Transportation_details.GR_RR_Date;
			disable Transportation_details.GR_RR_No;
			disable Transportation_details.Picture_Description;
			disable Transportation_details.Picture_of_Item_Lorry;
			disable Transportation_details.Status;
		}
	}
	else
	{
		hide Transportation_details;
	} */
	input.Total_Value = ifnull(TotalValue,0.00);
	input.Total_Quantity = ifnull(tot_qty,0.00);
	html = "<html><head><style>#customers {font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;border-collapse: collapse;width: 100%;}#customers td, #customers th {border: 1px solid #ddd;padding: 8px;}#customers tr:nth-child(even){background-color: #f2f2f2;}#customers tr:hover {background-color: #ddd;}#customers th { padding-top: 12px;padding-bottom: 12px;text-align: left;background-color: #f9f9f9;}</style></head><body>";
	html = html + "<table id='customers'><th style='text-align:center;'>PO Form</th></tr>";
	Val_url = "https://app.zohocreator.in/carrierwheels/erp/#Page:PO_Template?ID=" + input.Purchase_Order + "&zc_LoadIn=dialog&zc_Header=false";
	urlvalue = "<a href='" + Val_url + "'>View PO</a>";
	html = html + "</td><td>" + urlvalue + "</td></tr>";
	html = html + "</table></body></html>";
	input.plain = html;
}
disable Material_Landing_Rack;
if(input.Material_Landing_Rack == null)
{
	fet_mat = Rack_Master[Racks_Bins == "Store Incoming Area"];
	input.Material_Landing_Rack = fet_mat.ID;
}
fetblk = FG_Block_Stock1[ID == input.FG_Block_Stock_ID];
hide FG_Block_Stock_ID;
input.Work_Order_No = fetblk.WO_No;
input.Blocked_Qty = fetblk.Block_Qty;
input.Part_No = fetblk.Part_No;
input.Part_Name = fetblk.Part_Name;
input.Unblocking_Date = zoho.currentdate;
input.Unblocked_By = Employee_Details[Employee_Email == zoho.loginuserid].ID;
input.Unblock_Qty = fetblk.Block_Qty;
disable Part_No;
disable Part_Name;
disable Blocked_Qty;
disable Unblocking_Date;
disable Work_Order_No;
disable Unblocked_By;
disable Balance_Blocked_Qty;
disable Blocked_Qty_So_far;
hide Blocked_Qty_So_far;
disable Balance_Blocked_Qty;
hide Status;
if(fetblk.Status == "Partially UnBlocked")
{
	input.Unblock_Qty = fetblk.Balance_Blocked_Qty;
	input.Balance_Blocked_Qty = fetblk.Balance_Blocked_Qty;
	input.Blocked_Qty_So_far = fetblk.Quantity_Blocked_So_far;
	show Blocked_Qty_So_far;
	show Balance_Blocked_Qty;
}
fetblk = FG_Block_Stock1[ID == input.FG_Block_Stock_ID];
if(fetblk.Status != "Partially UnBlocked")
{
	input.Balance_Blocked_Qty = ifnull(fetblk.Block_Qty,0) - ifnull(input.Unblock_Qty,0);
}
if(fetblk.Status == "Partially UnBlocked")
{
	input.Balance_Blocked_Qty = ifnull(fetblk.Quantity_Blocked_So_far,0) - ifnull(input.Unblock_Qty,0);
}
if(input.Balance_Blocked_Qty < 0)
{
	input.Balance_Blocked_Qty = 0;
}
if(input.Unblock_Qty <= 0)
{
	alert "Unblock qty not should be zero or less than zero";
	input.Unblock_Qty = null;
	input.Balance_Blocked_Qty = 0;
	input.Balance_Blocked_Qty = 0;
}
else if(input.Unblock_Qty > Blocked_Qty)
{
	alert "Unblock qty not more than blocked qty";
	input.Unblock_Qty = null;
}
if(fetblk.Status == "Partially UnBlocked" && input.Unblock_Qty > fetblk.Balance_Blocked_Qty)
{
	alert "Unblock Qty shouldn't be greater than Balance Blocked Qty";
	input.Unblock_Qty = fetblk.Balance_Blocked_Qty;
}
fetch_inv = Inventory[Part_No == input.Part_No] sort by Available_Qty desc;
fet_chk = FG_Block_Stock1[ID == input.FG_Block_Stock_ID];
if(input.Unblock_Qty == fet_chk.Block_Qty || input.Unblock_Qty == fet_chk.Balance_Blocked_Qty)
{
	fet_chk.Quantity_Blocked_So_far=ifnull(fet_chk.Quantity_Blocked_So_far,0) + input.Unblock_Qty;
	fet_chk.Unblocked_Qty=fet_chk.Block_Qty;
	fet_chk.Balance_Blocked_Qty=0;
	fetch_inv.Block_Qty=ifnull(fetch_inv.Block_Qty,0) - input.Unblock_Qty;
	fetch_inv.Available_Qty=ifnull(fetch_inv.Available_Qty,0) + input.Unblock_Qty;
	fet_chk.Status="Fully UnBlocked";
	input.Status = "Fully UnBlocked";
}
else if(input.Unblock_Qty < fet_chk.Block_Qty && input.Unblock_Qty != fet_chk.Balance_Blocked_Qty)
{
	fet_chk.Quantity_Blocked_So_far=ifnull(fet_chk.Quantity_Blocked_So_far,0) + input.Unblock_Qty;
	fet_chk.Unblocked_Qty=ifnull(fet_chk.Quantity_Blocked_So_far,0);
	if(fet_chk.Balance_Blocked_Qty == null)
	{
		fet_chk.Balance_Blocked_Qty=fet_chk.Block_Qty - input.Unblock_Qty;
	}
	else
	{
		fet_chk.Balance_Blocked_Qty=fet_chk.Balance_Blocked_Qty - input.Unblock_Qty;
	}
	fetch_inv.Block_Qty=ifnull(fetch_inv.Block_Qty,0) - input.Unblock_Qty;
	fetch_inv.Available_Qty=ifnull(fetch_inv.Available_Qty,0) + input.Unblock_Qty;
	fet_chk.Status="Partially UnBlocked";
	input.Status = "Partially UnBlocked";
}
openUrl("#Form:Alert_Messages?Status=" + "UNBlOCK" + "&Value=" + input.Unblock_Qty + "&zc_LoadIn=dialog","same window");
void Payments.Payments(int booksid)
{
	fet_payBook = Get_Payments_ID_from_Books[ID == input.booksid];
	bksid = fet_payBook.Payment_Books_ID;
	books_access = thisapp.Books.Get_Books_Access();
	conn_tok = books_access.get("connection");
	org_id = books_access.get("organisation_id");
	get_payresp = zoho.books.getRecordsByID("customerpayments",org_id,bksid,conn_tok);
	//	info get_payresp;
	pay_data = get_payresp.tomap().get("payment");
	//	info pay_data ;
	custname = pay_data.get("customer_name");
	payid = pay_data.get("payment_id");
	custid = pay_data.get("customer_id");
	//info custid;
	invoices = pay_data.get("invoices").toList();
	invlist = List();
	invid = List();
	invamt = List();
	payamnt = List();
	for each  rec in invoices
	{
		map_val = rec.toMap();
		invoice_ID = map_val.get("invoice_id");
		invoice_no = map_val.get("invoice_number");
		inv_amnt = map_val.get("invoice_amount");
		pay_amnt = map_val.get("amount_applied");
		fetinv = Invoice[Zoho_Books_ID == invoice_ID].ID;
		fetinvno = Invoice[Invoice_No == invoice_no];
		fetinvamnt = Invoice[Grand_Total == inv_amnt];
		fetpayamnt = Payments[Payment_Amount == pay_amnt];
		invlist.add(fetinvno);
		invid.add(fetinv);
		invamt.add(inv_amnt);
		pay_amnt.add(pay_amnt);
	}
	customer_id = Customers[Customer_Books_ID == custid].ID;
	amtrec = pay_data.get("amount");
	paydate = pay_data.get("date");
	//--------------------------------------------------
	paymode = pay_data.get("payment_mode");
	invdate = pay_data.get("date");
	//	invno = pay_data.get("invoice_number");
	payno = pay_data.get("payment_number");
	payins = insert into Payments
	[
		Added_User=zoho.loginuser
		Customer_Name=customer_id
		Payment_ID=payid
		Customer_ID=custid
		Amount_Received=amtrec
		Payment_Date=paydate
		Payment_Mode=paymode
		Invoice_Date=invdate
		Inv_ID=invid
		Invoice_No1=invlist
		Payment_No=payno
		Payment_Status="Success"
		Invoice_Amount=invamt
		Payment_Amount=payamnt
	];
}
void Materials.Items_CRM_Sync(int mat_id)
{
	mat = Materials[ID == mat_id];
	matmap = Map();
	matmap.put("Product_Code",mat.Part_No);
	matmap.put("Product_Name",mat.Part_Description);
	matmap.put("Specification",mat.Specification);
	matmap.put("Usage_Unit",mat.Primary_UoM.UOM);
	matmap.put("Creator_ID",mat.ID.toString());
	matmap.put("Brand_Name",ifNull(mat.Brand_Name.Brand_Name,""));
	matmap.put("Alternate_UoM",mat.Alternate_UoM.UOM);
	matmap.put("Rounding_Value",mat.Rounding_Value);
	matmap.put("Primary_UoM",mat.Primary_UoM.UOM);
	matmap.put("MOQ_Minimum_Lot_Size",mat.MOQ);
	matmap.put("Procurement_Lead_Time_Days",mat.Procurement_Lead_Time_Days);
	matmap.put("Planning_Procedure",mat.Planning_Procedure);
	matmap.put("Blank_Length",mat.Blank_Length);
	matmap.put("Blank_Width",mat.Blank_Width);
	matmap.put("Blank_Thickness",mat.Blank_Thickness);
	matmap.put("Blank_Weight",mat.Blank_Weight);
	matmap.put("Final_Weight",mat.Final_Weight);
	matmap.put("Surface_Area_in_mm2",mat.Surface_Area);
	matmap.put("Maximum_Stock",mat.Maximum_Stock);
	matmap.put("Minimum_Stock",mat.Minimum_Stock);
	matmap.put("GST_Details",mat.GST_Details.Tax_Name);
	matmap.put("IGST_Details",mat.IGST_Details.Tax_Name);
	matmap.put("HSN_SAC",mat.HSN_SAC);
	if(mat.Zoho_Books_ID != Null)
	{
		matmap.put("Books_ID",mat.Zoho_Books_ID.toString());
	}
	dummymap = Map();
	if(isNull(mat.CRM_ID))
	{
		crmsync = zoho.crm.createRecord("Products",matmap,dummymap,"crm_connection");
		mat.CRM_ID=crmsync.get("id");
		info crmsync;
	}
	else
	{
		updsync = zoho.crm.updateRecord("Products",mat.CRM_ID.toLong(),matmap,dummymap,"crm_connection");
		//info updsync;
	}
}
void Invoice.Invoice_Eway_bill_Details_Update()
{
	books_access = thisapp.Books.Get_Books_Access();
	conn_tok = books_access.get("connection");
	org_id = books_access.get("organisation_id");
	invoicedata = Invoice[Zoho_Books_ID != null && E_Way_Bill_No == ""] sort by Added_Time desc range from 1 to 20;
	//	invoicedata = Invoice[Zoho_Books_ID != null && E_Way_Bill_No == "" && Sale_Order_No == null] sort by ID desc range from 21 to 30;
	//invoicedata = Invoice[Zoho_Books_ID != null && E_Way_Bill_No == "" && Sale_Order_No != null];
	//invoicedata = Invoice[Zoho_Books_ID == "917835000036874439" && E_Way_Bill_No == ""];
	info invoicedata.count();
	i = 0;
	for each  recxx in invoicedata
	{
		zbid = recxx.Zoho_Books_ID;
		invoice_resp = zoho.books.getRecordsByID("invoices",org_id,zbid.tostring(),conn_tok);
		//info "invoice resp code " + invoice_resp.get("code") + "---" + zbid;
		ewaybill = invoice_resp.get("invoice").toMap().get("eway_bill_details");
		info ewaybill;
		if(!isempty(ewaybill))
		{
			bno = ewaybill.get("eway_bill_number");
			if(!isnull(bno))
			{
				recxx.E_Way_Bill_No=ewaybill.get("eway_bill_number");
			}
			if(!isnull(ewaybill.get("eway_bill_date")))
			{
				recxx.E_Way_Bill_Date=ewaybill.get("eway_bill_date").toString("dd-MMM-yyyy");
			}
			i = i + 1;
		}
		else if(!isnull(ewaybill))
		{
			bno = ewaybill.get("eway_bill_number");
			if(!isnull(bno))
			{
				recxx.E_Way_Bill_No=ewaybill.get("eway_bill_number");
			}
			if(!isnull(ewaybill.get("eway_bill_date")))
			{
				recxx.E_Way_Bill_Date=ewaybill.get("eway_bill_date").toString("dd-MMM-yyyy");
			}
			i = i + 1;
		}
	}
	info i;
}
void Indent.Indent_Email_Notification(int myindent_ID)
{
	myindent = Indent[ID == myindent_ID];
	myindent_itemdetails = Indent_Sub_Form[Indent_Form_RECID == myindent_ID];
	getindentor = Employee_Details[ID == myindent.Request_Raised_By];
	emailto = getindentor.Employee_Email;
	getemail = Email_Template[Template_No == 4];
	sub = getemail.Subject_field;
	body = getemail.Body;
	sub = sub.replaceAll("{prno}",myindent.Indent_No,true);
	sub = sub.replaceAll("{prstatus}",myindent.Approval_Status,true);
	body = body.replaceAll("{prno}",myindent.Indent_No,true);
	body = body.replaceAll("{prdate}",myindent.Indent_Request_Date.tostring("d-MMM-yyyy"),true);
	body = body.replaceAll("{prstatus}",myindent.Approval_Status,true);
	body = body.replaceAll("{indentor}",getindentor.Employee_Name,true);
	if(myindent.Project_Name != null)
	{
		project = "The indent was placed for the project " + myindent.Project_Name.Project_Number + " - " + myindent.Project_Name.Project_Title;
	}
	else
	{
		project = null;
	}
	body = body.replaceAll("{project}",ifnull(project,""),true);
	IndentLink = "<a href='https://creatorapp.zoho.in/carrierwheels/erp#Report:All_Indents?Indent_No=" + myindent.Indent_No + "' title='Click to Open Indent' target='_blank'>Click to Open Indent " + myindent.Indent_No + "</a>";
	body = body.replaceAll("{link}",IndentLink,true);
	tab = "<html><style>th,td {padding: 5px;}</style><table border = 1> <th>S. No.</th> <th>Part No.</th> <th>Part Description</th> <th>Specification</th> <th>Required Qty</th><th>UOM</th> <th>Remarks</th> <th>Purpose of Indent</th>";
	count = 1;
	for each  tablerec in myindent_itemdetails
	{
		getuom = Unit_of_Measurement[ID == tablerec.UoM].UOM;
		tab = tab + "<tr><td>" + count + "</td>";
		tab = tab + "<td>" + tablerec.Part_No.Part_No + "</td>";
		tab = tab + "<td>" + tablerec.Part_Description.Part_Description + "</td>";
		tab = tab + "<td>" + ifnull(tablerec.Specification,"") + "</td>";
		tab = tab + "<td>" + ifnull(tablerec.Required_Qty,0) + "</td>";
		tab = tab + "<td>" + getuom + "</td>";
		tab = tab + "<td>" + ifNull(tablerec.Remarks,"") + "</td>";
		tab = tab + "<td>" + ifnull(tablerec.Purpose_of_Indent,"") + "</td></tr>";
		count = count + 1;
	}
	tab = tab + "</table></html>";
	body = body.replaceAll("{table}",tab,true);
	//info body;
	sendmail
	[
		from :"CWPL ERP <erp@carrierwheels.com>"
		to :emailto
		reply to :"sourcing@carrierwheels.com"
		subject :sub
		message :body
	]
}
void GRN.Create_GRN(Purchase_Order_Subform posub)
{
	poid = list();
	povendlist = list();
	for each  recval in posub
	{
		poid.add(recval);
		fetpomain = Purchase_Order[ID == recval.Purchase_Order_ExisID];
		povendlist.add(fetpomain.Vendor_Name);
	}
	if(povendlist.distinct().size() == 1)
	{
		openUrl("#Form:GRN?Purchase_Order_Subform_RECID=" + poid,"same window");
	}
	else
	{
		openUrl("#Form:Alert_Messages?Status=GRN&Value=Selected Vendors are not same pls check.&zc_LoadIn=dialog","same window");
	}
}
void GRN.GRN_Email_Notification(int ID)
{
	getgrnsubform = GRN_Subform[GRN_ID == input.ID];
	//info getgrnsubform;
	getgrnmain = GRN[ID == getgrnsubform.GRN_ID];
	//info getgrnmain;
	getposubform = Purchase_Order_Subform[ID == getgrnsubform.Purchase_Order_SubForm_RECID];
	//info getposubform;
	getpomain = Purchase_Order[ID == getposubform.Purchase_Order_ExisID];
	//info getpomain;
	//	getindentsf = Indent_Sub_Form[ID == getposubform.Indent_Sub_Form];
	getindentsf = Indent_Sub_Form[Purchase_Order_Subform_RECID == getgrnsubform.Purchase_Order_SubForm_RECID];
	//info getindentsf;
	getindent = Indent[ID == getindentsf.Indent_Form_RECID];
	//info "Get Indent:" + getindent;
	getindentor = Employee_Details[ID == getindent.Request_Raised_By];
	emailto = getindentor.Employee_Email;
	//info "Email To:" + emailto;
	getemail = Email_Template[Template_No == 3];
	sub = getemail.Subject_field;
	body = getemail.Body;
	sub = sub.replaceAll("{grnno}",getgrnmain.Goods_Received_Note_Number,true);
	sub = sub.replaceAll("{pono}",getpomain.Purchase_Order_No,true);
	body = body.replaceAll("{indentor}",ifnull(getindentor.Employee_Name,""),true);
	body = body.replaceAll("{grnno}",getgrnmain.Goods_Received_Note_Number,true);
	tab = "<html><style>th,td {padding: 5px;}</style><table border = 1> <th>Indent No.</th>  <th>Part No.</th> <th>Part Description</th> <th>Specification</th> <th>Quantity Received</th><th>UOM</th> <th>Remarks of Indent</th> <th>Purpose of Indent</th> <th>Zoho Project</th>";
	for each  tablerec in getgrnsubform
	{
		getindentno = Indent_Sub_Form[Purchase_Order_Subform_RECID == tablerec.Purchase_Order_SubForm_RECID];
		getuom = Unit_of_Measurement[ID == tablerec.UoM].UOM;
		if(getindentno.count() > 0)
		{
			IndentLink = "<a href='https://creatorapp.zoho.in/carrierwheels/erp#Report:All_Indents?Indent_No=" + ifnull(getindentno.Indent_No,"") + "' title='Click to Open Indent' target='_blank'>" + ifnull(getindentno.Indent_No,"") + "</a>";
			tab = tab + "<tr><td>" + ifnull(IndentLink,"") + "</td>";
			tab = tab + "<td>" + tablerec.Part_No.Part_No + "</td>";
			tab = tab + "<td>" + tablerec.Part_Description.Part_Description + "</td>";
			tab = tab + "<td>" + ifnull(tablerec.Specification,"") + "</td>";
			tab = tab + "<td>" + ifnull(tablerec.Received_Qty,0) + "</td>";
			tab = tab + "<td>" + getuom + "</td>";
			myindentsf = Indent_Sub_Form[Purchase_Order_Subform_RECID == tablerec.Purchase_Order_SubForm_RECID];
			tab = tab + "<td>" + ifNull(myindentsf.Remarks,"") + "</td>";
			tab = tab + "<td>" + ifNull(myindentsf.Purpose_of_Indent,"") + "</td>";
			tab = tab + "<td>" + ifnull(myindentsf.Project_Name,"") + "</td></tr>";
		}
		else
		{
			//info "else";
			IndentLink = "<a href='https://creatorapp.zoho.in/carrierwheels/erp#Report:All_Indents?Indent_No=" + ifnull(getindentno.Indent_No,"") + "' title='Click to Open Indent' target='_blank'>" + ifnull(getindentno.Indent_No,"") + "</a>";
			//info "Link:" + IndentLink;
			tab = tab + "<tr><td>" + IndentLink + "</td>";
			tab = tab + "<td>" + tablerec.Part_No.Part_No + "</td>";
			tab = tab + "<td>" + tablerec.Part_Description.Part_Description + "</td>";
			tab = tab + "<td>" + ifnull(tablerec.Specification,"") + "</td>";
			tab = tab + "<td>" + ifnull(tablerec.Received_Qty,0) + "</td>";
			tab = tab + "<td>" + getuom + "</td>";
			myindentsf = Indent_Sub_Form[Purchase_Order_Subform_RECID == tablerec.Purchase_Order_SubForm_RECID];
			tab = tab + "<td>" + ifNull(myindentsf.Remarks,"") + "</td>";
			tab = tab + "<td>" + ifNull(myindentsf.Purpose_of_Indent,"") + "</td>";
			tab = tab + "<td>" + ifnull(myindentsf.Project_Name,"") + "</td></tr>";
		}
	}
	//info "Tab:" + tab;
	tab = tab + "</table></html>";
	body = body.replaceAll("{table}",tab,true);
	//info "Body:" + body;
	//emp = Employee_Details[Department_Name.Department_Name == "Stores"];
	if(getindentno.count() > 0)
	{
		sendmail
		[
			from :"CWPL ERP<erp@carrierwheels.com>"
			to :emailto
			cc:"sourcing@carrierwheels.com"
			reply to :"stores@carrierwheels.com"
			subject :sub
			message :body
		]
	}
	else
	{
		sendmail
		[
			from :"CWPL ERP<erp@carrierwheels.com>"
			to :"sourcing@carrierwheels.com"
			cc:"sourcing@carrierwheels.com"
			subject :sub
			message :body
		]
	}
	//cc:"sourcing@carrierwheels.com"
}
string financial_year()
{
	fin_str = "";
	curr_year = zoho.currentdate.getYear();
	curr_month = zoho.currentdate.getMonth();
	if(curr_month > 3)
	{
		next_year = curr_year.toLong() + 1;
		//last_2_dig = next_year.subString(2,4);
		fin_str = curr_year + "-" + next_year;
		//Use "last_2_dig" if u want to display last 2 digit of year
	}
	else
	{
		next_year = curr_year.toLong() - 1;
		//last_2_dig = curr_year.subString(2,4);
		fin_str = (curr_year - 1) + "-" + curr_year;
		//Use "last_2_dig" if u want to display last 2 digit of year
	}
	return fin_str;
}
void CRM.Employee_insert_in_CRM(int empid)
{
	books_access = thisapp.Books.Get_Books_Access();
	conn_tok = books_access.get("connection");
	org_id = books_access.get("organisation_id");
	fetch_emp_id = Employee_Details[ID == input.empid];
	mymap = Map();
	mymap.put("Name",fetch_emp_id.Employee_Name);
	mymap.put("Employee_code",fetch_emp_id.Employee_ID);
	mymap.put("Email",fetch_emp_id.Employee_Email);
	mymap.put("Phone",fetch_emp_id.Mobile_Number);
	mymap.put("Designation",fetch_emp_id.Designation);
	mymap.put("Status",fetch_emp_id.Status);
	// 	info mymap;
	dummymap = Map();
	// 	info fetch_emp_id.Zoho_CRM_ID;
	if(fetch_emp_id.Zoho_CRM_ID == null || fetch_emp_id.Zoho_CRM_ID == "")
	{
		createincrm = zoho.crm.createRecord("CWPL_Emp",mymap,dummymap,"crm_connection");
		emp_id = createincrm.get("id");
		//info createincrm;
	}
	else
	{
		updatrecincrm = zoho.crm.updateRecord("CWPL_Emp",fetch_emp_id.Zoho_CRM_ID.toLong(),mymap);
		emp_id = updatrecincrm.get("id");
		//info updatrecincrm;
	}
	// 	info createincrm;
	info emp_id;
	//Error in log file--Mismatch of data type expression. Expected BIGINT but found STRING Line:(26)
	if(fetch_emp_id.Zoho_CRM_ID == null || fetch_emp_id.Zoho_CRM_ID == "")
	{
		fetch_emp_id.Zoho_CRM_ID=emp_id;
	}
}
string Common.Number_Function_New(String module_name)
{
	//---------Sales Order - Contract prefix should be "CO" - Direct & Tooling is "SO" - user requirement dt 25/04/2023
	if(module_name == "Sales Order Direct")
	{
		fetch_sale_rec = Sales_Order[Sale_Order_No != null && Sale_Order_No != "" && Sales_Type != "Contract"] sort by Sale_Order_No desc;
		//fetch_sale_rec = Sales_Order[Sale_Order_No != null && Sale_Order_No != ""] sort by Sale_Order_No desc;
		fet_mod = Module_Master[Module_Name == module_name];
		fetch_module = Auto_Generate_Numbers[Module_Name.Module_Name == fet_mod.Module_Name];
		mod_short = fetch_module.Module_Short_Name;
		if(fetch_module.Choose_Prefix == "New Prefix")
		{
			num_prefix = fetch_module.Prefix;
		}
		else if(fetch_module.Choose_Prefix == "Company Short Name")
		{
			num_prefix = fetch_module.Company_Short_Name;
		}
		if(fetch_sale_rec.count() == 0)
		{
			so_value = fetch_module.Number_Should_Start_at;
		}
		else
		{
			last_so = getsuffix(getSuffix(fetch_sale_rec.Sale_Order_No,"-"),"-");
			so_value = (last_so.toLong() + 1).trim().leftpad(6).replaceAll(" ","0");
		}
		Order_no = mod_short + "-" + num_prefix + "-" + so_value;
	}
	//Sales Order Contract 27/04/2023
	else if(module_name == "Sales Order Contract")
	{
		fetch_sale_co = Sales_Order[Sale_Order_No != null && Sale_Order_No != "" && Sales_Type == "Contract"] sort by Added_Time desc;
		fet_mod = Module_Master[Module_Name == module_name];
		fetch_module = Auto_Generate_Numbers[Module_Name.Module_Name == fet_mod.Module_Name];
		mod_short = fetch_module.Module_Short_Name;
		if(fetch_module.Choose_Prefix == "New Prefix")
		{
			num_prefix = fetch_module.Prefix;
		}
		else if(fetch_module.Choose_Prefix == "Company Short Name")
		{
			num_prefix = fetch_module.Company_Short_Name;
		}
		if(fetch_sale_co.count() == 0)
		{
			co_value = fetch_module.Number_Should_Start_at;
		}
		else
		{
			last_co = getsuffix(getSuffix(fetch_sale_co.Sale_Order_No,"-"),"-");
			co_value = (last_co.toLong() + 1).trim().leftpad(6).replaceAll(" ","0");
		}
		Order_no = mod_short + "-" + num_prefix + "-" + co_value;
	}
	// for Dispatch Note Format
	else if(module_name == "Purchase Order")
	{
		get_prev_num = Purchase_Order[ID != null && Purchase_Order_No != ""] sort by Purchase_Order_No desc;
		fet_mod = Module_Master[Module_Name == module_name];
		fetch_module = Auto_Generate_Numbers[Module_Name.Module_Name == fet_mod.Module_Name];
		mod_short = fetch_module.Module_Short_Name;
		if(fetch_module.Choose_Prefix == "New Prefix")
		{
			num_prefix = fetch_module.Prefix;
		}
		else if(fetch_module.Choose_Prefix == "Company Short Name")
		{
			num_prefix = fetch_module.Company_Short_Name;
		}
		if(get_prev_num.count() == 0)
		{
			po_value = fetch_module.Number_Should_Start_at;
		}
		else
		{
			last_po = getsuffix(getSuffix(get_prev_num.Purchase_Order_No,"-"),"-");
			po_value = (last_po.toLong() + 1).trim().leftpad(6).replaceAll(" ","0");
		}
		Order_no = mod_short + "-" + num_prefix + "-" + po_value;
	}
	// for work order
	else if(module_name == "Work Order")
	{
		fetch_work_rec = Work_Order[ID != null && Work_Order_No != ""] sort by Work_Order_No desc;
		fet_mod = Module_Master[Module_Name == module_name];
		fetch_module = Auto_Generate_Numbers[Module_Name.Module_Name == fet_mod.Module_Name];
		mod_short = fetch_module.Module_Short_Name;
		if(fetch_module.Choose_Prefix == "New Prefix")
		{
			num_prefix = fetch_module.Prefix;
		}
		else if(fetch_module.Choose_Prefix == "Company Short Name")
		{
			num_prefix = fetch_module.Company_Short_Name;
		}
		if(fetch_work_rec.count() == 0)
		{
			wo_value = fetch_module.Number_Should_Start_at;
		}
		else
		{
			last_wo = getsuffix(getSuffix(fetch_work_rec.Work_Order_No,"-"),"-");
			wo_value = (last_wo.toLong() + 1).trim().leftpad(6).replaceAll(" ","0");
		}
		Order_no = mod_short + "-" + num_prefix + "-" + wo_value;
	}
	// for calibration Gauge No
	else if(module_name == "Gauge No")
	{
		fetch_gaug = Calibration_Master[ID != null && Gauge_No != ""] sort by Gauge_No desc;
		fet_mod = Module_Master[Module_Name == module_name];
		fetch_module = Auto_Generate_Numbers[Module_Name.Module_Name == fet_mod.Module_Name];
		mod_short = fetch_module.Module_Short_Name;
		if(fetch_module.Choose_Prefix == "New Prefix")
		{
			num_prefix = fetch_module.Prefix;
		}
		else if(fetch_module.Choose_Prefix == "Company Short Name")
		{
			num_prefix = fetch_module.Company_Short_Name;
		}
		if(fetch_gaug.count() == 0)
		{
			gaug_value = fetch_module.Number_Should_Start_at;
		}
		else
		{
			last_gaug = getsuffix(getSuffix(fetch_gaug.Gauge_No,"/"),"/");
			gaug_value = (last_gaug.toLong() + 1).trim().leftpad(6).replaceAll(" ","0");
		}
		Order_no = mod_short + "/" + num_prefix + "/" + gaug_value;
	}
	else if(module_name == "Cal Master No")
	{
		fetch_mast = Calibration_Master[ID != null && Cal_Master_No != ""] sort by Cal_Master_No desc;
		fet_mod = Module_Master[Module_Name == module_name];
		fetch_module = Auto_Generate_Numbers[Module_Name.Module_Name == fet_mod.Module_Name];
		mod_short = fetch_module.Module_Short_Name;
		if(fetch_module.Choose_Prefix == "New Prefix")
		{
			num_prefix = fetch_module.Prefix;
		}
		else if(fetch_module.Choose_Prefix == "Company Short Name")
		{
			num_prefix = fetch_module.Company_Short_Name;
		}
		if(fetch_mast.count() == 0)
		{
			mast_value = fetch_module.Number_Should_Start_at;
		}
		else
		{
			last_mast = getsuffix(getSuffix(fetch_mast.Cal_Master_No,"/"),"/");
			mast_value = (last_mast.toLong() + 1).trim().leftpad(6).replaceAll(" ","0");
		}
		Order_no = mod_short + "/" + num_prefix + "/" + mast_value;
	}
  return Order_no;
}
void Calibration.CalibrationSticker(Calibration_History calid)
{
	cid = List();
	itmlis = List();
	for each  rec in calid
	{
		cid.add(rec);
		calbid = Calibration_History[ID == rec.ID];
		itmlis.add(calbid.Item_Name);
	}
	openUrl("#Page:Test_Cal?var_text=" + cid,"new window");
}
star

Thu Jan 09 2025 14:13:54 GMT+0000 (Coordinated Universal Time)

@jrg_300i #undefined

star

Thu Jan 09 2025 12:18:18 GMT+0000 (Coordinated Universal Time)

@BilalRaza12

star

Thu Jan 09 2025 11:13:08 GMT+0000 (Coordinated Universal Time) https://cryptocurrency-exchange-development-company.com/

@raydensmith #crypto #cryptoexchangedevelopment #cryptoexchange #cryptoexchangesoftwaredevelopment

star

Thu Jan 09 2025 07:46:51 GMT+0000 (Coordinated Universal Time)

@E23CSEU1151

star

Thu Jan 09 2025 06:59:08 GMT+0000 (Coordinated Universal Time)

@Checkmate

star

Thu Jan 09 2025 05:54:48 GMT+0000 (Coordinated Universal Time)

@Checkmate

star

Thu Jan 09 2025 00:37:24 GMT+0000 (Coordinated Universal Time) https://poe.com/

@Fatolla

star

Wed Jan 08 2025 22:43:26 GMT+0000 (Coordinated Universal Time)

@davidmchale #flexbox #stretch #child

star

Wed Jan 08 2025 11:04:30 GMT+0000 (Coordinated Universal Time)

@rcrespocode

star

Wed Jan 08 2025 10:34:24 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/26460372/powershell-merge-two-csv-files-with-partially-duplicate-lines

@baamn #powershell #csv

star

Wed Jan 08 2025 06:18:25 GMT+0000 (Coordinated Universal Time)

@vishalsingh21

star

Wed Jan 08 2025 05:57:20 GMT+0000 (Coordinated Universal Time)

@Samuel1347 #dart

star

Wed Jan 08 2025 05:35:18 GMT+0000 (Coordinated Universal Time)

@FOHWellington

star

Wed Jan 08 2025 04:13:24 GMT+0000 (Coordinated Universal Time)

@rcrespocode

star

Wed Jan 08 2025 03:15:37 GMT+0000 (Coordinated Universal Time) https://appdev4tech.com/2023/02/code-interview-coderbyte-bracket-matcher-challenge-javascript-solution-source-code/

@canthuy0215 #javascript

star

Wed Jan 08 2025 01:53:40 GMT+0000 (Coordinated Universal Time) https://thinkingclaude.com/#get-started

@xyzemail23@gmail.com #ai

star

Wed Jan 08 2025 00:43:26 GMT+0000 (Coordinated Universal Time)

@rcrespocode

star

Wed Jan 08 2025 00:43:26 GMT+0000 (Coordinated Universal Time)

@rcrespocode

star

Wed Jan 08 2025 00:16:45 GMT+0000 (Coordinated Universal Time)

@E23CSEU1151

star

Tue Jan 07 2025 18:29:49 GMT+0000 (Coordinated Universal Time)

@E23CSEU1151

star

Tue Jan 07 2025 17:42:25 GMT+0000 (Coordinated Universal Time)

@E23CSEU1151

star

Tue Jan 07 2025 16:30:05 GMT+0000 (Coordinated Universal Time)

@negner

star

Tue Jan 07 2025 15:46:30 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:44:46 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:41:21 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:40:41 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:38:44 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:38:25 GMT+0000 (Coordinated Universal Time)

@miskat80

star

Tue Jan 07 2025 15:37:58 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:37:03 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:35:04 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:34:31 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:33:05 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:32:27 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:31:27 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:30:04 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:27:54 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:23:54 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:22:56 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:22:16 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:19:42 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:17:59 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:16:47 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:15:37 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:15:04 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:14:21 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:12:32 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:11:41 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:10:49 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Tue Jan 07 2025 15:08:18 GMT+0000 (Coordinated Universal Time)

@Pooja

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension