Search This Blog

Saturday, May 28, 2022

Constructing the object to send the payload

 placeOrder()
  {
    let payload:any ={};
 
    payload['customerCode'] = this._storage.getCustomerCode();
    payload['contractNo'] = this.contractId;
    payload['ordType'] = "ZSPS";
 
   

    console.log(this.contractdetails.length);

    let items = [];

    for(let index = 0; index < this.contractdetails.length; index ++)
    {
     
      let item:any = {};

      item['itemNo']  = this.contractdetails[index].contOrderItmno;
      item['material'] = this.contractdetails[index].contOrderProduct;
      item['qty']  = this.contractdetails[index].SelectedQty ?  this.contractdetails[index].SelectedQty : 0;
 
      items.push(item);
     
    }

    payload['item'] = items;


   console.log(payload);

    this._authService.contractOrder(payload).subscribe((res:any)=>
    {
        let id:any = res.body.salesdocument;
        let remark:any = res.body.remark;
        let trackLink = res.body.trackLink;
        this.contGSTMessage =  res.body.contGSTMessage;
        this.orderTotal = this.orderTotal ? this.orderTotal : 0;

        if(res.body.error && res.body.error.length > 0)
        {
          this._PromptService.openDialog({title : 'ORDER NOT CREATED',
           url :this.redirecturl,
         
          btnLabel : 'OK',
          type : false,  
          status: false,  
          content: `${res.body.error[0].message}`})
        }

else
{
  this._PromptService.openDialog({title : 'ORDER CONFIRMED!', url :this.redirecturl, type : true, btnLabel1 : 'CLOSE',  status: false,  content: `Your Order for ${this.orderQuantity} items 0f <b class="amount-value"> ₹ ${this.orderTotal}/- </b> (${this.contGSTMessage}) has been confirmed. Your order ID is <b>${id}.</b> You can track the same via whatsapp @ <a class="cursor-pointer" href ='http://${trackLink}' target="_blank"> ${trackLink} </a>`})
}
     
    })
   
  }

No comments:

Post a Comment

Validating to select in sequencial order using angular

    < input type = "checkbox" (change) = "handleSelectTaskItem($event, taskItem)" [checked] = " taskItem . i...