Example #1
0
        public static ZohoPurchaseOrder Map(ZohoSalesOrder salesorder, Order order, List <ZohoLineItem> items,
                                            List <HSLineItem> lineitems, ZohoAddress delivery_address, ZohoContact vendor)
        {
            var po = new ZohoPurchaseOrder()
            {
                line_items = items.Select(p => new ZohoLineItem()
                {
                    //account_id = p.purchase_account_id,
                    item_id     = p.item_id,
                    description = p.description,
                    rate        = Math.Round(decimal.ToDouble(lineitems.First(l => l.SKU() == p.sku).UnitPrice.Value), 2),
                    quantity    = lineitems.First(l => l.SKU() == p.sku)?.Quantity
                }).ToList(),
                salesorder_id        = salesorder.salesorder_id,
                purchaseorder_number = order.ID,
                reference_number     = salesorder.reference_number,
                sub_total            = decimal.ToDouble(order.Subtotal),
                tax_total            = decimal.ToDouble(order.TaxCost),
                total                = decimal.ToDouble(order.Total),
                vendor_id            = vendor.contact_id,
                delivery_customer_id = salesorder.customer_id
            };

            return(po);
        }
Example #2
0
        private async Task <ZohoPurchaseOrder> CreatePurchaseOrder(ZohoSalesOrder z_order, HSOrder order, List <ZohoLineItem> items, List <HSLineItem> lineitems, ZohoAddress delivery_address, ZohoContact contact)
        {
            var po = await _zoho.PurchaseOrders.ListAsync(new ZohoFilter()
            {
                Key = "purchaseorder_number", Value = order.ID
            });

            if (po.Items.Any())
            {
                return(await _zoho.PurchaseOrders.SaveAsync(ZohoPurchaseOrderMapper.Map(z_order, order, items, lineitems, delivery_address, contact, po.Items.FirstOrDefault())));
            }
            return(await _zoho.PurchaseOrders.CreateAsync(ZohoPurchaseOrderMapper.Map(z_order, order, items, lineitems, delivery_address, contact)));
        }