Exemplo n.º 1
0
        private void CalculateActual(OrderedItem orderedItem, JobOrder Jo)
        {
            if (Jo != null)
            {
                //Job Order Charges
                PreviousActualInINR += Jo.GetCumulativeJOCharges();

                //GRN Reciept Value
                if (Jo.GRNReciept.OtherChargesInINR != null && Jo.GRNReciept.OtherChargesInINR.Value != 0 && Jo.GRNReciept.RecievedInHandWrapper != 0)
                {
                    decimal perUnitGRNRecieptValue = Jo.GRNReciept.OtherChargesInINR.Value / Jo.GRNReciept.RecievedInHandWrapper;
                    PreviousActualInINR += perUnitGRNRecieptValue;
                }

                //Purchase Order Value
                PreviousActualInINR += orderedItem.ActualInINR / orderedItem.OrderedQuantity;
            }
        }
 public OrderedItemGrnViewModel(OrderedItem orderedItem)
 {
     this.OrderedItem = orderedItem;
 }
        private void positiveBtn_Click_1(object sender, RoutedEventArgs e)
        {
            if (positiveBtn.Content.ToString() == "Generate" || positiveBtn.Content.ToString() == "Submit")
            {
                ViewModel.PurchaseOrder.Validate();
                if (!ViewModel.PurchaseOrder.HasErrors)
                {
                    if (positiveBtn.Content.ToString() == "Generate")
                    {
                        ViewModel.PurchaseOrder = DBResources.Instance.Context.PurchaseOrders.Add(ViewModel.PurchaseOrder);
                    }

                    foreach (IPurchaseOrderItem item in ViewModel.SelectedItems)
                    {
                        item.PurchaseOrder = ViewModel.PurchaseOrder;
                    }

                    if (ViewModel.PurchaseOrder.Approval == null)
                    {
                        Order.PurchaseOrders.Add(ViewModel.PurchaseOrder);
                        Approval approval = new Approval();
                        approval.ApprovalEntityTypeID = 2;
                        approval.Order = ViewModel.Order;
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Generated by " + DBResources.Instance.CurrentUser.UserName + " at " + DBResources.Instance.GetServerTime().ToString());
                        sb.AppendLine();
                        approval.Comments = sb.ToString();
                        ViewModel.PurchaseOrder.Approval = approval;
                        approval.PurchaseOrders.Add(ViewModel.PurchaseOrder);
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Submitted By " + DBResources.Instance.CurrentUser.UserName + " at " + DBResources.Instance.GetServerTime().ToString());
                        sb.AppendLine();
                        ViewModel.PurchaseOrder.Approval.Comments = sb.ToString() + ViewModel.PurchaseOrder.Approval.Comments;
                        ViewModel.PurchaseOrder.Approval.IsApproved = null;
                    }

                    DBResources.Instance.Save();
                    

                    if (positiveBtn.Content.ToString() == "Generate")
                    {
                        SetUIAccesibility(PurchaseOrderState.Generated);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Purchase Order Successfully Created");
                        sb.AppendLine("Submitted For Approval !.");
                        InformUser(sb.ToString());
                        Reset();
                        if (PurchaseOrderStatusChanged != null)
                        {
                            PurchaseOrderStatusChanged(PurchaseOrderState.Generated);
                        }
                    }
                    else
                    {
                        SetUIAccesibility(PurchaseOrderState.Submitted);
                        InformUser("Purchase Order Successfully Submitted");
                    }
                }
                else
                {
                    InformUser("Fix the Highlighted Errors and try again");
                }
            }
            else if(positiveBtn.Content.ToString() == "Approve")
            {
                
                foreach (IPurchaseOrderItem item in ViewModel.SelectedItems)
                {
                    if (item is ProductMaterialItem)
                    {
                        ProductMaterialItem pmItem = item as ProductMaterialItem;
                        OrderedItem itemToOrder = new OrderedItem { ProductMaterialItem = pmItem, OrderedQuantity = pmItem.Quantity };
                        itemToOrder.CostWrapper = item.CostWrapper;
                        itemToOrder.TaxPerUnitWrapper = item.TaxPerUnitWrapper;
                        pmItem.SupplierWrapper = ViewModel.PurchaseOrder.Company;
                        pmItem.LastPOGeneratedOn = DBResources.Instance.GetServerTime();
                        ViewModel.PurchaseOrder.OrderedItems.Add(itemToOrder);
                        item.PurchaseOrder = ViewModel.PurchaseOrder;
                    }
                }


                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Approved By " + DBResources.Instance.CurrentUser.UserName + " at " + DBResources.Instance.GetServerTime().ToString());
                sb.AppendLine();
                ViewModel.PurchaseOrder.Approval.Comments = sb.ToString() + ViewModel.PurchaseOrder.Approval.Comments;
                ViewModel.PurchaseOrder.Approval.IsApproved = true;

                DBResources.Instance.Save();

                SetUIAccesibility(PurchaseOrderState.Approved);
            }
            else if (positiveBtn.Content.ToString() == "PDF")
            {
                PurchaseOrderPDFGenerator pdfGenerator = new PurchaseOrderPDFGenerator(ViewModel.PurchaseOrder);
                string generatedFile = pdfGenerator.GeneratePurchaseOrder();
                if (string.IsNullOrEmpty(generatedFile))
                {
                    InformUser("Failed to Generate !");
                }
                else
                {
                    //Initiate PDF Viewer
                    System.Diagnostics.Process.Start(generatedFile);

                    //Initiate New Outlook Message
                    try
                    {
                        InitiateNewOutlookMessage(generatedFile);
                    }
                    catch
                    {

                    }
                }
            }

            ViewModel.PurchaseOrder.RefreshUIProperties();
        }
Exemplo n.º 4
0
        public object Clone()
        {
            OrderedItem clonedItem = new OrderedItem();
            clonedItem.ProductMaterialItem = this.ProductMaterialItem;

            return clonedItem;
        }
Exemplo n.º 5
0
 private void CalculateBudget(OrderedItem orderedItem)
 {
     BudgetInINR = orderedItem.BudgetInINR / orderedItem.OrderedQuantity;
 }
Exemplo n.º 6
0
 public void Initialize(OrderedItem orderedItem, JobOrder parentJO)
 {
     CalculateBudget(orderedItem);
     CalculateActual(orderedItem, parentJO);
 }