Exemple #1
0
        public void Init()
        {
            try
            {
                UnitOfWork unitOfWork = new UnitOfWork();
                var        aoq        = unitOfWork.AOQRepo.Find(x => x.PRId == pr.Id);
                po = unitOfWork.PurchaseOrdersRepo.Find(x => x.Id == po.Id);
                var pos = po.PODetails.Select(x => x.ItemNo);

                this.aoqDetails = aoq.AOQDetails.Where(x => pos.All(m => m != x.ItemNo)).ToList();
                this.ItemsGridControl.DataSource = new BindingList <AOQDetails>(aoqDetails);
                //
            }
            catch (Exception e)
            {
            }
        }
Exemple #2
0
        public async Task <List <PurchaseOrders> > GetAsync(int id)
        {
            List <PurchaseOrders> ToReturn = new List <PurchaseOrders>();

            try
            {
                PurchaseOrders Res = await _PurchaseOrdersRepo.GetById(id, true);

                ToReturn.Add(Res);
            }
            catch (Exception ex)
            {
                var logger = _loggerFactory.CreateLogger("internal_error_log");
                logger.LogInformation("Problem happened in selecting the data for purchaseorders List by id with message" + ex.Message);
            }
            return(ToReturn);
        }
Exemple #3
0
        public void clbOrderNumbers_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            PurchaseOrdersObj purchaseorder = PurchaseOrders.GetByID((int)clbOrderNumbers.Items[e.Index]);

            if (e.NewValue == CheckState.Checked)
            {
                foreach (PurchaseOrderDetailsObj item in PurchaseOrderDetails.GetByPONumber(purchaseorder.PONumber).FindAll(m => m.QuantityRemaining != 0))
                {
                    bs.Add(item);
                }
            }
            else
            {
                foreach (PurchaseOrderDetailsObj item in purchaseorderdetailslist.FindAll(m => m.PONumber == purchaseorder.PONumber))
                {
                    bs.Remove(item);
                }
            }
        }
Exemple #4
0
        public ActionResult CreatePurchaseOrder(PurchaseOrders s)
        {
            PurchaseOrders po = new PurchaseOrders();

            using (SqlConnection C = new SqlConnection(DataLink.connectionString))
            {
                C.Open();

                string query = @"Insert into PurchaseOrder(DescriptionPurchase, SupplierID, ItemID, PurchaseOrderStatus,OrderQuantity)" +
                               "values('" + s.DescriptionPurchase + "','" + s.SupplierID + "','" + s.ItemID + "','" + s.PurchaseOrderStatus + "'," + s.OrderQuantity + ")";

                SqlCommand cmd = new SqlCommand(query, C);
                cmd.ExecuteNonQuery();
            }
            updateIncomingStock(s);


            return(RedirectToAction("PurchaseOrdersList"));
        }
Exemple #5
0
        public async Task <string> Update(int id, [FromBody] string value)
        {
            string UpdateResult        = "Success";
            bool   UpdateProcessOutput = false;

            try
            {
                PurchaseOrders PurchaseOrdersToUpdate = JsonConvert.DeserializeObject <PurchaseOrders>(value);
                PurchaseOrdersToUpdate.po_id = id;
                UpdateProcessOutput          = await _PurchaseOrdersRepo.Update(PurchaseOrdersToUpdate);

                var eventModel = new EventModel(poEventTableName)
                {
                    EntityId    = id,
                    EventName   = po_update,
                    RefrenceId  = id,
                    UserId      = PurchaseOrdersToUpdate.updated_by,
                    EventNoteId = id
                };
                await _eventRepo.AddEventAsync(eventModel);

                var userEvent = new EventModel(userEventTableName)
                {
                    EntityId    = PurchaseOrdersToUpdate.updated_by,
                    EventName   = po_update,
                    RefrenceId  = id,
                    UserId      = PurchaseOrdersToUpdate.updated_by,
                    EventNoteId = id
                };
                await _eventRepo.AddEventAsync(userEvent);
            }
            catch (Exception ex)
            {
                var logger = _loggerFactory.CreateLogger("internal_error_log");
                logger.LogInformation("Problem happened in updating purchaseorders with message" + ex.Message);
                UpdateResult = "Failed";
            }
            if (!UpdateProcessOutput)
            {
                UpdateResult = "Creation failed due to reason: No specific reson";
            }
            return(UpdateResult);
        }
        public void PostPurchaseOrders([FromBody] PurchaseOrders input)
        {
            var result = new PurchaseOrders();

            result.PoactShipDate = input.PoactShipDate;
            result.Pocompleted   = input.Pocompleted;
            result.Pocost        = input.Pocost;
            result.PoestShipDate = input.PoestShipDate;
            result.Poname        = input.Poname;
            result.Ponumber      = input.Ponumber;
            result.PorecDate     = input.PorecDate;
            result.Poprice       = input.Poprice;
            db.PurchaseOrders.Add(result);
            db.SaveChanges();



            foreach (var line in input.Pofixtures)
            {
                result.Pofixtures.Add(new Pofixtures
                {
                    FixtureId                = line.FixtureId,
                    FixtureCommision         = line.FixtureCommision,
                    FixtureCost              = line.FixtureCost,
                    FixtureQuantity          = line.FixtureQuantity,
                    FixturePrice             = line.FixturePrice,
                    PurchaseOrderId          = result.Id,
                    FixtureQuantityCompleted = line.FixtureQuantityCompleted,
                    FixtureQuantityShipped   = line.FixtureQuantityShipped
                });
            }
            foreach (var line in input.Poparts)
            {
                result.Poparts.Add(new Poparts
                {
                    PurchaseOrderId = result.Id,
                    PartId          = line.PartId,
                    Quantity        = line.Quantity,
                });
            }
            db.SaveChanges();
        }
Exemple #7
0
        public string getstockcardID(PurchaseOrders s)
        {
            StockCard sc = new StockCard();

            using (SqlConnection C = new SqlConnection(DataLink.connectionString))
            {
                C.Open();
                string          query  = @"SELECT ItemID,StockCardID from StockCard where ItemID ='" + s.ItemID + "'";
                SqlCommand      cmd    = new SqlCommand(query, C);
                ; SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    sc.ItemID      = (string)reader["ItemID"];
                    sc.StockCardID = (string)reader["StockCardID"];
                }

                return(sc.StockCardID); //pass to calling function (supplier controller)
            }
        }
Exemple #8
0
        public static List <PurchaseOrders> Search(string sqlStr, params SqlParameter[] parameters)
        {
            List <PurchaseOrders> list = new List <PurchaseOrders>();

            using (DbCommand cmd = db.GetSqlStringCommand(sqlStr))
            {
                cmd.Parameters.AddRange(parameters);
                DataSet ds = db.ExecuteDataSet(cmd);
                if (ds != null && ds.Tables.Count > 0)
                {
                    DataTable table = ds.Tables[0];
                    foreach (DataRow dr in table.Rows)
                    {
                        PurchaseOrders model = new PurchaseOrders(dr);
                        list.Add(model);
                    }
                }
            }
            return(list);
        }
Exemple #9
0
        public static bool Save(PurchaseOrders model)
        {
            string sqlStr           = "select count(1) from PurchaseOrders where 1=1 ";
            List <SqlParameter> pms = new List <SqlParameter>();

            sqlStr += " and OrderID=@OrderID ";
            pms.Add(new SqlParameter("OrderID", model.OrderID));
            using (DbCommand cmd = db.GetSqlStringCommand(sqlStr))
            {
                cmd.Parameters.AddRange(pms.ToArray());
                int i = (int)db.ExecuteScalar(cmd);
                if (i > 0)
                {
                    return(Update(model));
                }
                else
                {
                    return(Insert(model));
                }
            }
        }
Exemple #10
0
 public void SummarizeErrors(bool summarize)
 {
     Accounts.SummarizeErrors(summarize);
     BankTransactions.SummarizeErrors(summarize);
     BankTransfers.SummarizeErrors(summarize);
     Contacts.SummarizeErrors(summarize);
     ContactGroups.SummarizeErrors(summarize);
     CreditNotes.SummarizeErrors(summarize);
     Employees.SummarizeErrors(summarize);
     Employees.SummarizeErrors(summarize);
     Files.SummarizeErrors(summarize);
     Folders.SummarizeErrors(summarize);
     Inbox.SummarizeErrors(summarize);
     Invoices.SummarizeErrors(summarize);
     Items.SummarizeErrors(summarize);
     LinkedTransactions.SummarizeErrors(summarize);
     ManualJournals.SummarizeErrors(summarize);
     Payments.SummarizeErrors(summarize);
     PurchaseOrders.SummarizeErrors(summarize);
     Receipts.SummarizeErrors(summarize);
     TaxRates.SummarizeErrors(summarize);
     TrackingCategories.SummarizeErrors(summarize);
 }
Exemple #11
0
        private void Refresh()
        {
            ReturnedReturnablesCount = ReturnedReturnables?.Sum(p => p.Quantity) ?? 0;
            BrokenProductsCount      = Products.Where(p => p.RowKind == ModificationKind.Broken).Sum(p => p.Quantity);
            ImproperProductsCount    = Products.Where(p => p.RowKind == ModificationKind.Improper).Sum(p => p.Quantity);
            ExcessProductsCount      = Products.Where(p => p.RowKind == ModificationKind.Excess).Sum(p => p.Quantity);
            MissingProductsCount     = Products.Where(p => p.RowKind == ModificationKind.Missing).Sum(p => p.Quantity);
            ReturnablesCount         = Products.Where(p => p.HasReturnable).Sum(p => p.Quantity);
            ProductsToDeliverCount   = Products.Where(p => p.RowKind == ModificationKind.ToDeliver).Sum(p => p.Quantity);
            PurchaseOrdersCount      = PurchaseOrders.Count;
            ProductsDeliveredCount   = ProductsToDeliverCount + BrokenProductsCount + MissingProductsCount +
                                       ImproperProductsCount + ExcessProductsCount;

            DeliveryFeesWholeSalePrice = PurchaseOrders.Max(po => po.ExpectedDelivery.DeliveryFeesWholeSalePrice);
            DeliveryFeesVatPrice       = PurchaseOrders.Max(po => po.ExpectedDelivery.DeliveryFeesVatPrice);
            DeliveryFeesOnSalePrice    = PurchaseOrders.Max(po => po.ExpectedDelivery.DeliveryFeesOnSalePrice);

            if (PurchaseOrdersCount < 1)
            {
                Status = DeliveryStatus.Cancelled;
            }

            DeliveryBatch?.Refresh();
        }
Exemple #12
0
        public async Task <string> PostAsync([FromBody] string value)
        {
            string newPOId = "0";

            try
            {
                PurchaseOrders newPurchaseOrder = JsonConvert.DeserializeObject <PurchaseOrders>(value);
                newPOId = await _PurchaseOrdersRepo.Create(newPurchaseOrder);

                var eventModel = new EventModel(poEventTableName)
                {
                    EventName   = po_created,
                    EntityId    = Int32.Parse(newPOId),
                    RefrenceId  = 0,
                    UserId      = newPurchaseOrder.created_by,
                    EventNoteId = Int32.Parse(newPOId)
                };
                await _eventRepo.AddEventAsync(eventModel);

                var userEvent = new EventModel(userEventTableName)
                {
                    EventName   = po_created,
                    EntityId    = newPurchaseOrder.created_by,
                    RefrenceId  = Convert.ToInt32(newPOId),
                    UserId      = newPurchaseOrder.created_by,
                    EventNoteId = Int32.Parse(newPOId)
                };
                await _eventRepo.AddEventAsync(userEvent);
            }
            catch (Exception ex)
            {
                var logger = _loggerFactory.CreateLogger("internal_error_log");
                logger.LogInformation("Problem happened in making new purchaseorders create with message" + ex.Message);
            }
            return(newPOId);
        }
Exemple #13
0
 private Price getBalance()
 {
     return(new Price(CurrencyRates.Enums.CurrencyCode.OMR, PurchaseOrders.Where(p => p.IsPurchaseOrderClosed && !p.IsPurchaseOrderCancelled).Sum(p => p.Total.DefaultCurrencyValue) + PurchaseOrders.Where(p => p.Transitions.IsApproved()).Sum(p => p.Total.DefaultCurrencyValue)));
 }
Exemple #14
0
 public async Task <PurchaseOrder> UpdateAsync(PurchaseOrder item)
 {
     return(await PurchaseOrders.UpdateAsync(item));
 }
Exemple #15
0
 public async Task <IEnumerable <PurchaseOrder> > UpdateAsync(IEnumerable <PurchaseOrder> items)
 {
     return(await PurchaseOrders.UpdateAsync(items));
 }
        public void CreateWithDefaults()
        {
            var before = new PurchaseOrders(this.Session).Extent().ToArray();

            var expected = new PurchaseOrderBuilder(this.Session).WithDefaults(this.internalOrganisation).Build();

            Assert.True(expected.ExistTakenViaSupplier);
            Assert.True(expected.ExistTakenViaContactMechanism);
            Assert.True(expected.ExistTakenViaContactPerson);
            Assert.True(expected.ExistBillToContactMechanism);
            Assert.True(expected.ExistBillToContactPerson);
            Assert.True(expected.ExistShipToAddress);
            Assert.True(expected.ExistShipToContactPerson);
            Assert.True(expected.ExistStoredInFacility);
            Assert.True(expected.ExistCustomerReference);
            Assert.True(expected.ExistDescription);
            Assert.True(expected.ExistInternalComment);

            this.Session.Derive();

            var expectedTakenViaSupplier         = expected.TakenViaSupplier;
            var expectedTakenViaContactMechanism = expected.TakenViaContactMechanism;
            var expectedTakenViaContactPerson    = expected.TakenViaContactPerson;
            var expectedBillToContactMechanism   = expected.BillToContactMechanism;
            var expectedBillToContactPerson      = expected.BillToContactPerson;
            var expectedShipToAddress            = expected.ShipToAddress;
            var expectedShipToContactPerson      = expected.ShipToContactPerson;
            var expectedStoredInFacility         = expected.StoredInFacility;
            var expectedCustomerReference        = expected.CustomerReference;
            var expectedDescription     = expected.Description;
            var expectedInternalComment = expected.InternalComment;

            var purchaseOrderCreate = this.purchaseOrderListPage
                                      .CreatePurchaseOrder()
                                      .BuildForDefaults(expected);


            this.Session.Rollback();
            purchaseOrderCreate.SAVE.Click();

            this.Driver.WaitForAngular();
            this.Session.Rollback();

            var after = new PurchaseOrders(this.Session).Extent().ToArray();

            Assert.Equal(after.Length, before.Length + 1);

            var actual = after.Except(before).First();

            this.Driver.WaitForAngular();

            Assert.Equal(expectedTakenViaSupplier, actual.TakenViaSupplier);
            Assert.Equal(expectedTakenViaContactMechanism, actual.TakenViaContactMechanism);
            Assert.Equal(expectedTakenViaContactPerson, actual.TakenViaContactPerson);
            Assert.Equal(expectedBillToContactMechanism, actual.BillToContactMechanism);
            Assert.Equal(expectedBillToContactPerson, actual.BillToContactPerson);
            Assert.Equal(expectedShipToAddress, actual.ShipToAddress);
            Assert.Equal(expectedShipToContactPerson, actual.ShipToContactPerson);
            Assert.Equal(expectedStoredInFacility, actual.StoredInFacility);
            Assert.Equal(expectedCustomerReference, actual.CustomerReference);
            Assert.Equal(expectedDescription, actual.Description);
            Assert.Equal(expectedInternalComment, actual.InternalComment);
        }
Exemple #17
0
        public async Task <string> UpdateSpecific(int id, [FromBody] string value)
        {
            string UpdateResult = "Success";

            try
            {
                PurchaseOrders PurchaseOrdersToUpdate = JsonConvert.DeserializeObject <PurchaseOrders>(value);
                PurchaseOrdersToUpdate.po_id = id;
                Dictionary <String, String> ValuesToUpdate = new Dictionary <string, string>();

                if (PurchaseOrdersToUpdate.vendor_po_number != null)
                {
                    ValuesToUpdate.Add("vendor_po_number", PurchaseOrdersToUpdate.vendor_po_number);
                }
                if (PurchaseOrdersToUpdate.vendor_invoice_number != null)
                {
                    ValuesToUpdate.Add("vendor_invoice_number", PurchaseOrdersToUpdate.vendor_invoice_number);
                }
                if (PurchaseOrdersToUpdate.vendor_order_number != null)
                {
                    ValuesToUpdate.Add("vendor_order_number", PurchaseOrdersToUpdate.vendor_order_number.ToString());
                }
                if (PurchaseOrdersToUpdate.vendor_id != 0)
                {
                    ValuesToUpdate.Add("vendor_id", PurchaseOrdersToUpdate.vendor_id.ToString());
                }
                if (PurchaseOrdersToUpdate.defected != 0 && PurchaseOrdersToUpdate.defected != null)
                {
                    ValuesToUpdate.Add("defected", PurchaseOrdersToUpdate.defected.ToString());
                }
                if (PurchaseOrdersToUpdate.good_condition != 0 && PurchaseOrdersToUpdate.good_condition != null)
                {
                    ValuesToUpdate.Add("good_condition", PurchaseOrdersToUpdate.good_condition.ToString());
                }
                if (PurchaseOrdersToUpdate.total_styles != 0 && PurchaseOrdersToUpdate.total_styles != null)
                {
                    ValuesToUpdate.Add("total_styles", PurchaseOrdersToUpdate.total_styles.ToString());
                }
                if (PurchaseOrdersToUpdate.total_quantity != 0 && PurchaseOrdersToUpdate.total_quantity != null)
                {
                    ValuesToUpdate.Add("total_quantity", PurchaseOrdersToUpdate.total_quantity.ToString());
                }
                if (PurchaseOrdersToUpdate.subtotal != 0 && PurchaseOrdersToUpdate.subtotal != null)
                {
                    ValuesToUpdate.Add("subtotal", PurchaseOrdersToUpdate.subtotal.ToString());
                }
                if (PurchaseOrdersToUpdate.shipping != 0 && PurchaseOrdersToUpdate.shipping != null)
                {
                    ValuesToUpdate.Add("shipping", PurchaseOrdersToUpdate.shipping.ToString());
                }
                if (PurchaseOrdersToUpdate.delivery_window_start != null)
                {
                    ValuesToUpdate.Add("delivery_window_start", PurchaseOrdersToUpdate.delivery_window_start.ToString());
                }
                if (PurchaseOrdersToUpdate.delivery_window_end != null)
                {
                    ValuesToUpdate.Add("delivery_window_end", PurchaseOrdersToUpdate.delivery_window_end.ToString());
                }
                if (PurchaseOrdersToUpdate.po_status != 0)
                {
                    ValuesToUpdate.Add("po_status", PurchaseOrdersToUpdate.po_status.ToString());
                }
                if (PurchaseOrdersToUpdate.po_discount_id != 0)
                {
                    ValuesToUpdate.Add("po_discount_id", PurchaseOrdersToUpdate.po_discount_id.ToString());
                }
                if (PurchaseOrdersToUpdate.deleted != 0)
                {
                    ValuesToUpdate.Add("deleted", PurchaseOrdersToUpdate.deleted.ToString());
                }
                if (PurchaseOrdersToUpdate.ra_flag != 0)
                {
                    ValuesToUpdate.Add("ra_flag", PurchaseOrdersToUpdate.ra_flag.ToString());
                }
                if (PurchaseOrdersToUpdate.has_note != 0)
                {
                    ValuesToUpdate.Add("has_note", PurchaseOrdersToUpdate.has_note.ToString());
                }
                if (PurchaseOrdersToUpdate.has_doc != 0)
                {
                    ValuesToUpdate.Add("has_doc", PurchaseOrdersToUpdate.has_doc.ToString());
                }
                if (PurchaseOrdersToUpdate.created_by != 0)
                {
                    ValuesToUpdate.Add("created_by", PurchaseOrdersToUpdate.created_by.ToString());
                }
                if (PurchaseOrdersToUpdate.updated_by != 0)
                {
                    ValuesToUpdate.Add("updated_by", PurchaseOrdersToUpdate.updated_by.ToString());
                }
                if (PurchaseOrdersToUpdate.order_date != 0)
                {
                    ValuesToUpdate.Add("order_date", PurchaseOrdersToUpdate.order_date.ToString());
                }
                if (PurchaseOrdersToUpdate.created_at != 0)
                {
                    ValuesToUpdate.Add("created_at", PurchaseOrdersToUpdate.created_at.ToString());
                }
                if (PurchaseOrdersToUpdate.updated_at != 0)
                {
                    ValuesToUpdate.Add("updated_at", PurchaseOrdersToUpdate.updated_at.ToString());
                }

                await _PurchaseOrdersRepo.UpdateSpecific(ValuesToUpdate, "po_id=" + id);

                if (PurchaseOrdersToUpdate.po_status == 4)
                {
                    var eventModel = new EventModel(poEventTableName)
                    {
                        EntityId    = id,
                        EventName   = po_delete,
                        RefrenceId  = id,
                        UserId      = PurchaseOrdersToUpdate.updated_by,
                        EventNoteId = id
                    };
                    await _eventRepo.AddEventAsync(eventModel);

                    var userEvent = new EventModel(userEventTableName)
                    {
                        EntityId    = PurchaseOrdersToUpdate.updated_by,
                        EventName   = po_delete,
                        RefrenceId  = id,
                        UserId      = PurchaseOrdersToUpdate.updated_by,
                        EventNoteId = id
                    };
                    await _eventRepo.AddEventAsync(userEvent);
                }
                else
                {
                    var eventModel = new EventModel(poEventTableName)
                    {
                        EntityId    = id,
                        EventName   = po_specific_update,
                        RefrenceId  = id,
                        UserId      = PurchaseOrdersToUpdate.updated_by,
                        EventNoteId = id
                    };
                    await _eventRepo.AddEventAsync(eventModel);

                    var userEvent = new EventModel(userEventTableName)
                    {
                        EntityId    = PurchaseOrdersToUpdate.updated_by,
                        EventName   = po_specific_update,
                        RefrenceId  = id,
                        UserId      = PurchaseOrdersToUpdate.updated_by,
                        EventNoteId = id
                    };
                    await _eventRepo.AddEventAsync(userEvent);
                }
            }
            catch (Exception ex)
            {
                var logger = _loggerFactory.CreateLogger("internal_error_log");
                logger.LogInformation("Problem happened in updating new updatespecific purchaseorders with message" + ex.Message);
                UpdateResult = "Failed";
            }

            return(UpdateResult);
        }
Exemple #18
0
 public Task <IEnumerable <PurchaseOrder> > CreateAsync(IEnumerable <PurchaseOrder> items)
 {
     return(PurchaseOrders.CreateAsync(items));
 }
Exemple #19
0
 public PurchaseOrder Update(PurchaseOrder item)
 {
     return(PurchaseOrders.Update(item));
 }
Exemple #20
0
        public ActionResult ViewPurchaseForm()
        {
            PurchaseOrders po = new PurchaseOrders();

            return(View());
        }
Exemple #21
0
        public static Attachment PendingTasks()
        {
            PO POlist = new PO();

            POlist = Helper.GetDataHelper.GetPOs();
            PurchaseOrders POOrder = POlist.purchaseOrder.FirstOrDefault <PurchaseOrders>();

            var card = new AdaptiveCard("1.0")
            {
                Body = new List <AdaptiveElement>()
                {
                    new AdaptiveContainer()
                    {
                        Items = new List <AdaptiveElement>()
                        {
                            new AdaptiveTextBlock()
                            {
                                Text   = "Reminder: You have a pending task to review",
                                Weight = AdaptiveTextWeight.Default, // set the weight of text e.g. Bolder, Light, Normal
                                Size   = AdaptiveTextSize.Default    // set the size of text e.g. Extra Large, Large, Medium, Normal, Small
                            },
                            new AdaptiveTextBlock()
                            {
                                Text   = "Purchase Order",
                                Weight = AdaptiveTextWeight.Bolder, // set the weight of text e.g. Bolder, Light, Normal
                                Size   = AdaptiveTextSize.Large     // set the size of text e.g. Extra Large, Large, Medium, Normal, Small
                            },
                            new AdaptiveFactSet
                            {
                                Separator = true,
                                Facts     =
                                {
                                    // Describes a fact in a Adaptive FactSet as a key/value pair
                                    new AdaptiveFact
                                    {
                                        Title = "P.O. No.",
                                        Value = POOrder.PoNumber
                                    },
                                    new AdaptiveFact
                                    {
                                        Title = "Description",
                                        Value = POOrder.Description
                                    },
                                    new AdaptiveFact
                                    {
                                        Title = "Vendor Name",
                                        Value = POOrder.VendorName
                                    },
                                    new AdaptiveFact
                                    {
                                        Title = "Vendor No.",
                                        Value = POOrder.vendorNo
                                    },
                                    new AdaptiveFact
                                    {
                                        Title = "Amount",
                                        Value = POOrder.TotalAmount
                                    }
                                }
                            }
                        }
                    }
                },
                Actions = new List <AdaptiveAction>()
                {
                    // submit action gathers up input fields, merges with optional data field and generates event to client asking for data to be submitted
                    new AdaptiveSubmitAction()
                    {
                        Title = "Remind me later",
                        // DataJson = "get the data"
                    },
                    new AdaptiveShowCardAction
                    {
                        Title = "Review",
                        Card  = CardHelper.ReviewTasks()
                    }
                }
            };
            Attachment attachment = new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content     = card
            };

            return(attachment);
        }
Exemple #22
0
        private async Task <List <EntryData> > GetEntryData(string wStr, AsycudaDocumentSet docSet, Container container)
        {
            try
            {
                //var bookingPat = @"Booking #:  (?<BookingNo>[\w\-]*)";
                var res = new List <EntryData>();

                var containerMatch   = GetMatchFromPattern(wStr, container_StatusPat);
                var containerDateMat = GetMatchFromPattern(wStr, containerDatePat);
                var LineTotalMat     = GetAllMatchesFromPattern(wStr, LineChkPat);

                var entryData = new PurchaseOrders(true)
                {
                    TrackingState = TrackingState.Added
                };

                entryData.AsycudaDocumentSets.Add(new AsycudaDocumentSetEntryData(true)
                {
                    AsycudaDocumentSetId = docSet.AsycudaDocumentSetId,
                    EntryDataId          = entryData.EntryDataId,
                    TrackingState        = TrackingState.Added
                });


                if (containerMatch != null)
                {
                    entryData.EntryDataId = containerMatch.Groups["ContainerNo"].Value;
                    entryData.PONumber    = containerMatch.Groups["ContainerNo"].Value;
                }
                if (containerDateMat != null)
                {
                    entryData.EntryDataDate = Convert.ToDateTime(containerDateMat.Groups["ContainerDate"].Value);
                }

                if (LineTotalMat != null)
                {
                    entryData.ImportedLines = LineTotalMat.Count;
                }

                entryData.ImportedTotal = container.TotalValue;
                entryData.ContainerEntryData.Add(new ContainerEntryData()
                {
                    Container_Id  = container.Container_Id,
                    EntryDataId   = entryData.PONumber,
                    TrackingState = TrackingState.Added
                });


                //get Regex Groups

                var entryDetailsRegx = new Regex(entryDetailspat, RegexOptions.Compiled);
                //var lineChkMat = GetAllMatchesFromPattern(wStr, LineChkPat);

                var lcnt = 0;
                //var matches = entryDetailsRegx.Matches(wStr);
                //for (int i = 0; i < lineChkMat.Count; i++)
                //{

                //}
                foreach (Match m in entryDetailsRegx.Matches(wStr))
                {
                    var ed = new EntryDataDetails(true)
                    {
                        EntryDataId   = entryData.EntryDataId,
                        TrackingState = TrackingState.Added
                    };
                    lcnt += 1;
                    if (string.IsNullOrEmpty(m.Groups["ItemNumber"].Value))
                    {
                        // missing line create blank
                        ed.ItemNumber      = "Import Error";
                        ed.ItemDescription = "This line was not imported please manually create item.";
                        ed.Cost            = 0;
                        ed.LineNumber      = lcnt;
                        ed.Quantity        = 0;
                        ed.Units           = "";
                        entryData.EntryDataDetails.Add(ed);
                    }
                    else
                    {
                        ed.ItemNumber      = m.Groups["ItemNumber"].Value;
                        ed.ItemDescription = m.Groups["ItemDescription"].Value + " " +
                                             m.Groups["ExtItemDescription"].Value;
                        ed.Cost       = Convert.ToDouble(m.Groups["Cost"].Value);
                        ed.LineNumber = lcnt;
                        ed.Quantity   = Convert.ToDouble(m.Groups["Quantity"].Value);
                        ed.Units      = m.Groups["Unit"].Value;
                        entryData.EntryDataDetails.Add(ed);
                    }

                    itmList.Add(new InventoryItem(true)
                    {
                        ItemNumber  = ed.ItemNumber,
                        Description = ed.ItemDescription,
                        TariffCode  =
                            string.IsNullOrEmpty(m.Groups["TariffCode"].Value)
                                ? null
                                : m.Groups["TariffCode"].Value.Substring(0, 8)
                    });
                }

                res.Add(entryData);


                return(res);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #23
0
        private void dgvReceiving_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && dgvReceiving.Columns["clm2QuickPrint"].Index == e.ColumnIndex)
            {
                string          res      = "";
                InventoryRecord ir       = Inv.GetData(dgvReceiving.Rows[e.RowIndex].Cells["clm2SKU"].Value.ToString(), dgvReceiving.Rows[e.RowIndex].Cells["clm2SKU"].Value.ToString(), ref res);
                string          Barcode  = ir.Barcode;
                string          SKU      = ir.SKU;
                string          Price    = "$" + Math.Round(ir.Price, 2);
                string          ItemName = ir.ProductName;
                switch (dgvReceiving.Rows[e.RowIndex].Cells["clmPrintFormat"].Value.ToString())
                {
                case "BarcodeNOPrice":
                    Price = " ";
                    break;

                case "BarcodePrice3":
                    Price = "$" + Math.Round(ir.Price3, 2).ToString();
                    break;

                case "BarcodePrice4":
                    Price = "$" + Math.Round(ir.Price4, 2).ToString();

                    break;
                }


                printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 225, 125);
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();

                printDocument1.DocumentName = SKU + "," + Barcode + "," + ItemName + "," + Price;
                FileInfo fr = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//DPB.txt");
                if (fr.Exists)
                {
                    StreamReader sr = new StreamReader(fr.FullName);
                    string       xx = sr.ReadToEnd();
                    sr.Close();
                    printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = xx.Trim();
                }

                int Width  = 225;
                int hieght = 125;

                FileInfo frW = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//DPBW.txt");
                if (frW.Exists)
                {
                    StreamReader sr = new StreamReader(frW.FullName);
                    string       xx = sr.ReadToEnd();
                    sr.Close();
                    Width = Convert.ToInt16(Convert.ToDecimal(xx) * 100);
                }
                FileInfo frH = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//DPBH.txt");
                if (frH.Exists)
                {
                    StreamReader sr = new StreamReader(frH.FullName);
                    string       xx = sr.ReadToEnd();
                    sr.Close();
                    hieght = Convert.ToInt16(Convert.ToDecimal(xx) * 100);
                }
                printDocument1.DefaultPageSettings.PrinterSettings.Copies = Convert.ToInt16(dgvReceiving.Rows[e.RowIndex].Cells["clm2QtyReceived"].Value.ToString());
                printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", Width, hieght);
                printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);
                //printPreviewDialog.Document = printDocument1;

                //printPreviewDialog.Shown += new EventHandler(printPreviewDialog_Shown);

                //printPreviewDialog.ShowDialog();

                printDocument1.Print();
            }
            if (e.ColumnIndex == dgvReceiving.Columns["clm2Cost"].Index || e.ColumnIndex == dgvReceiving.Columns["clm2Price"].Index || e.ColumnIndex == dgvReceiving.Columns["clm2Price2"].Index || e.ColumnIndex == dgvReceiving.Columns["clm2Price3"].Index)
            {
                dgvReceiving.BeginEdit(true);
                return;
            }
            if (e.RowIndex >= 0 && dgvReceiving.Columns["clm2ViewOrder"].Index == e.ColumnIndex)
            {
                frmViewOrder f = new frmViewOrder();
                f.PONumber    = Convert.ToInt32(dgvReceiving.Rows[e.RowIndex].Cells["clm2PONum"].Value);
                f.PODate      = PurchaseOrders.GetByID(f.PONumber).PODate;
                f.OrderNumber = Convert.ToInt32(dgvReceiving.Rows[e.RowIndex].Cells["clm2OrderNumber"].Value);
                f.ShowDialog();
            }

            if (e.RowIndex >= 0 && dgvReceiving.Columns["clm2Cancel"].Index == e.ColumnIndex)
            {
                ReceiveObj rcv = (ReceiveObj)rbs[e.RowIndex];
                if (rcv.PONumber == 0)
                {
                    rbs.RemoveAt(e.RowIndex);
                    dgvReceiving.Refresh();
                }
                else
                {
                    PurchaseOrderDetailsObj pod = purchaseorderdetailslist.FirstOrDefault(m => m.PONumber == rcv.PONumber && m.LocalSKU == rcv.LocalSKU);
                    if (pod != null)
                    {
                        pod.QuantityRemaining += rcv.QtyReceived;
                        rbs.RemoveAt(e.RowIndex);
                        dgvReceiving.Refresh();
                        dgvEcpected.Refresh();
                    }
                    else
                    {
                        pod = PurchaseOrderDetails.GetByPONumber(rcv.PONumber).FirstOrDefault(m => m.LocalSKU == rcv.LocalSKU);
                        if (pod != null)
                        {
                            bs.Add(pod);
                            rbs.RemoveAt(e.RowIndex);
                            dgvReceiving.Refresh();
                            dgvEcpected.Refresh();
                        }
                    }
                }
                return;
            }
        }
Exemple #24
0
 public PurchaseOrders Save(PurchaseOrders model)
 {
     _context.PurchaseOrders.Add(model);
     model.Id = _context.SaveChanges();
     return(model);
 }
Exemple #25
0
 public Task <PurchaseOrder> CreateAsync(PurchaseOrder item)
 {
     return(PurchaseOrders.CreateAsync(item));
 }
Exemple #26
0
 public IEnumerable <PurchaseOrder> Update(IEnumerable <PurchaseOrder> items)
 {
     return(PurchaseOrders.Update(items));
 }
Exemple #27
0
 public PurchaseOrder Create(PurchaseOrder item)
 {
     return(PurchaseOrders.Create(item));
 }
Exemple #28
0
        // GET: PurchaseOrders/Details/5
        public async System.Threading.Tasks.Task <ActionResult> Details(int id)
        {
            PurchaseOrders PurchaseOrder = await new HttpClientLib().GetByIdAsync <PurchaseOrders>("API", "/api/PurchaseOrders/", id);

            return(View(PurchaseOrder));
        }
        public void EditWithDefaults()
        {
            var before = new PurchaseOrders(this.Session).Extent().ToArray();

            var expected = new PurchaseOrderBuilder(this.Session).WithDefaults(this.internalOrganisation).Build();

            Assert.True(expected.ExistTakenViaSupplier);
            Assert.True(expected.ExistTakenViaContactPerson);
            Assert.True(expected.ExistBillToContactPerson);
            Assert.True(expected.ExistShipToContactPerson);
            Assert.True(expected.ExistStoredInFacility);
            Assert.True(expected.ExistCustomerReference);
            Assert.True(expected.ExistDescription);
            Assert.True(expected.ExistComment);
            Assert.True(expected.ExistInternalComment);

            this.Session.Derive();

            var expectedTakenViaSupplier         = expected.TakenViaSupplier;
            var expectedTakenViaContactMechanism = expected.DerivedTakenViaContactMechanism;
            var expectedTakenViaContactPerson    = expected.TakenViaContactPerson;
            var expectedBillToContactMechanism   = expected.DerivedBillToContactMechanism;
            var expectedBillToContactPerson      = expected.BillToContactPerson;
            var expectedShipToAddress            = expected.DerivedShipToAddress;
            var expectedShipToContactPerson      = expected.ShipToContactPerson;
            var expectedStoredInFacility         = expected.StoredInFacility;
            var expectedCustomerReference        = expected.CustomerReference;
            var expectedDescription     = expected.Description;
            var expectedComment         = expected.Comment;
            var expectedInternalComment = expected.InternalComment;

            var purchaseOrder = before.First();
            var id            = purchaseOrder.Id;

            this.purchaseOrderListPage.Table.DefaultAction(purchaseOrder);
            var purchaseOrderOverview       = new PurchaseOrderOverviewComponent(this.purchaseOrderListPage.Driver);
            var purchaseOrderOverviewDetail = purchaseOrderOverview.PurchaseorderOverviewDetail.Click();

            purchaseOrderOverviewDetail.TakenViaSupplier.Select(expected.TakenViaSupplier.DisplayName());
            purchaseOrderOverviewDetail.DerivedTakenViaContactMechanism.Select(expected.DerivedTakenViaContactMechanism);
            purchaseOrderOverviewDetail.TakenViaContactPerson.Select(expected.TakenViaContactPerson);
            purchaseOrderOverviewDetail.DerivedBillToContactMechanism.Select(expected.DerivedBillToContactMechanism);
            purchaseOrderOverviewDetail.BillToContactPerson.Select(expected.BillToContactPerson);
            purchaseOrderOverviewDetail.DerivedShipToAddress.Select(expected.DerivedShipToAddress);
            purchaseOrderOverviewDetail.ShipToContactPerson.Select(expected.ShipToContactPerson);
            purchaseOrderOverviewDetail.StoredInFacility.Select(expected.StoredInFacility);
            purchaseOrderOverviewDetail.CustomerReference.Set(expected.CustomerReference);
            purchaseOrderOverviewDetail.Description.Set(expected.Description);
            purchaseOrderOverviewDetail.Comment.Set(expected.Comment);
            purchaseOrderOverviewDetail.InternalComment.Set(expected.InternalComment);

            this.Session.Rollback();
            purchaseOrderOverviewDetail.SAVE.Click();

            this.Driver.WaitForAngular();
            this.Session.Rollback();

            var after = new PurchaseOrders(this.Session).Extent().ToArray();

            purchaseOrder = (PurchaseOrder)this.Session.Instantiate(id);

            Assert.Equal(after.Length, before.Length);

            Assert.Equal(expectedTakenViaSupplier, purchaseOrder.TakenViaSupplier);
            Assert.Equal(expectedTakenViaContactMechanism, purchaseOrder.DerivedTakenViaContactMechanism);
            Assert.Equal(expectedTakenViaContactPerson, purchaseOrder.TakenViaContactPerson);
            Assert.Equal(expectedBillToContactMechanism, purchaseOrder.DerivedBillToContactMechanism);
            Assert.Equal(expectedBillToContactPerson, purchaseOrder.BillToContactPerson);
            Assert.Equal(expectedShipToAddress, purchaseOrder.DerivedShipToAddress);
            Assert.Equal(expectedShipToContactPerson, purchaseOrder.ShipToContactPerson);
            Assert.Equal(expectedStoredInFacility.Name, purchaseOrder.StoredInFacility.Name);
            Assert.Equal(expectedCustomerReference, purchaseOrder.CustomerReference);
            Assert.Equal(expectedDescription, purchaseOrder.Description);
            Assert.Equal(expectedComment, purchaseOrder.Comment);
            Assert.Equal(expectedInternalComment, purchaseOrder.InternalComment);
        }
Exemple #30
0
        public static void Full(this Singleton @this, DirectoryInfo dataPath, Faker faker)
        {
            var dutchLocale = new Locales(@this.Session()).DutchNetherlands;

            @this.AddAdditionalLocale(dutchLocale);

            var administrator = new PersonBuilder(@this.Session()).WithUserName("administrator").Build();

            new UserGroups(@this.Session()).Administrators.AddMember(administrator);
            new UserGroups(@this.Session()).Creators.AddMember(administrator);

            @this.Session().Derive();

            var euro = new Currencies(@this.Session()).FindBy(M.Currency.IsoCode, "EUR");

            var be = new Countries(@this.Session()).FindBy(M.Country.IsoCode, "BE");
            var us = new Countries(@this.Session()).FindBy(M.Country.IsoCode, "US");

            var allorsLogo = dataPath + @"\www\admin\images\logo.png";

            var allors = Organisations.CreateInternalOrganisation(
                session: @this.Session(),
                name: "Allors BVBA",
                address: "Kleine Nieuwedijkstraat 4",
                postalCode: "2800",
                locality: "Mechelen",
                country: be,
                phone1CountryCode: "+32",
                phone1: "2 335 2335",
                phone1Purpose: new ContactMechanismPurposes(@this.Session()).GeneralPhoneNumber,
                phone2CountryCode: string.Empty,
                phone2: string.Empty,
                phone2Purpose: null,
                emailAddress: "*****@*****.**",
                websiteAddress: "www.allors.com",
                taxNumber: "BE 0476967014",
                bankName: "ING",
                facilityName: "Allors Warehouse 1",
                bic: "BBRUBEBB",
                iban: "BE89 3200 1467 7685",
                currency: euro,
                logo: allorsLogo,
                storeName: "Allors Store",
                billingProcess: new BillingProcesses(@this.Session()).BillingForOrderItems,
                outgoingShipmentNumberPrefix: "a-CS",
                salesInvoiceNumberPrefix: "a-SI",
                salesOrderNumberPrefix: "a-SO",
                purchaseOrderNumberPrefix: "a-PO",
                purchaseInvoiceNumberPrefix: "a-PI",
                requestNumberPrefix: "a-RFQ",
                quoteNumberPrefix: "a-Q",
                productNumberPrefix: "A-",
                workEffortPrefix: "a-WO-",
                creditNoteNumberPrefix: "a-CN-",
                isImmediatelyPicked: true,
                autoGenerateShipmentPackage: true,
                isImmediatelyPacked: true,
                isAutomaticallyShipped: true,
                autoGenerateCustomerShipment: true,
                isAutomaticallyReceived: false,
                autoGeneratePurchaseShipment: false,
                useCreditNoteSequence: true,
                requestCounterValue: 1,
                quoteCounterValue: 1,
                orderCounterValue: 1,
                purchaseOrderCounterValue: 1,
                invoiceCounterValue: 1,
                purchaseInvoiceCounterValue: 1,
                purchaseOrderNeedsApproval: true,
                purchaseOrderApprovalThresholdLevel1: 1000M,
                purchaseOrderApprovalThresholdLevel2: 5000M,
                serialisedItemSoldOn: new SerialisedItemSoldOns(@this.Session()).CustomerShipmentShip,
                collectiveWorkEffortInvoice: true);

            var dipu = Organisations.CreateInternalOrganisation(
                session: @this.Session(),
                name: "Dipu BVBA",
                address: "Kleine Nieuwedijkstraat 2",
                postalCode: "2800",
                locality: "Mechelen",
                country: be,
                phone1CountryCode: "+32",
                phone1: "2 15 49 49 49",
                phone1Purpose: new ContactMechanismPurposes(@this.Session()).GeneralPhoneNumber,
                phone2CountryCode: string.Empty,
                phone2: string.Empty,
                phone2Purpose: null,
                emailAddress: "*****@*****.**",
                websiteAddress: "www.dipu.com",
                taxNumber: "BE 0445366489",
                bankName: "ING",
                facilityName: "Dipu Facility",
                bic: "BBRUBEBB",
                iban: "BE23 3300 6167 6391",
                currency: euro,
                logo: allorsLogo,
                storeName: "Dipu Store",
                billingProcess: new BillingProcesses(@this.Session()).BillingForOrderItems,
                outgoingShipmentNumberPrefix: "d-CS",
                salesInvoiceNumberPrefix: "d-SI",
                salesOrderNumberPrefix: "d-SO",
                purchaseOrderNumberPrefix: "d-PO",
                purchaseInvoiceNumberPrefix: "d-PI",
                requestNumberPrefix: "d-RFQ",
                quoteNumberPrefix: "d-Q",
                productNumberPrefix: "D-",
                workEffortPrefix: "a-WO-",
                creditNoteNumberPrefix: "d-CN-",
                isImmediatelyPicked: true,
                autoGenerateShipmentPackage: true,
                isImmediatelyPacked: true,
                isAutomaticallyShipped: true,
                autoGenerateCustomerShipment: true,
                isAutomaticallyReceived: false,
                autoGeneratePurchaseShipment: false,
                useCreditNoteSequence: true,
                requestCounterValue: 1,
                quoteCounterValue: 1,
                orderCounterValue: 1,
                purchaseOrderCounterValue: 1,
                purchaseInvoiceCounterValue: 1,
                invoiceCounterValue: 1,
                purchaseOrderNeedsApproval: false,
                purchaseOrderApprovalThresholdLevel1: null,
                purchaseOrderApprovalThresholdLevel2: null,
                serialisedItemSoldOn: new SerialisedItemSoldOns(@this.Session()).CustomerShipmentShip,
                collectiveWorkEffortInvoice: true);

            // Give Administrator access
            new EmploymentBuilder(@this.Session()).WithEmployee(administrator).WithEmployer(allors).Build();

            @this.Settings.DefaultFacility = allors.FacilitiesWhereOwner.First;

            var allorsEmployee1                   = allors.CreateEmployee("letmein", faker);
            var allorsEmployee2                   = allors.CreateEmployee("letmein", faker);
            var allorsProductQuoteApprover        = allors.CreateEmployee("letmein", faker);
            var allorsPurchaseInvoiceApprover     = allors.CreateEmployee("letmein", faker);
            var allorsPurchaseOrderApproverLevel1 = allors.CreateEmployee("letmein", faker);
            var allorsPurchaseOrderApproverLevel2 = allors.CreateEmployee("letmein", faker);

            var dipuEmployee                = dipu.CreateEmployee("letmein", faker);
            var dipuProductQuoteApprover    = dipu.CreateEmployee("letmein", faker);
            var dipuPurchaseInvoiceApprover = dipu.CreateEmployee("letmein", faker);

            new FacilityBuilder(@this.Session())
            .WithName("Allors warehouse 2")
            .WithFacilityType(new FacilityTypes(@this.Session()).Warehouse)
            .WithOwner(allors)
            .Build();

            var vatRate      = new VatRateBuilder(@this.Session()).WithRate(21).Build();
            var manufacturer = new OrganisationBuilder(@this.Session()).WithManufacturerDefaults(faker).Build();

            allors.CreateSupplier(faker);
            allors.CreateSupplier(faker);

            allors.CreateSubContractor(faker);
            allors.CreateSubContractor(faker);

            @this.Session().Derive();

            var nonSerialisedPart1 = allors.CreateNonSerialisedNonUnifiedPart(faker);
            var nonSerialisedPart2 = allors.CreateNonSerialisedNonUnifiedPart(faker);
            var serialisedPart1    = allors.CreateSerialisedNonUnifiedPart(faker);
            var serialisedPart2    = allors.CreateSerialisedNonUnifiedPart(faker);

            var good1 = new NonUnifiedGoodBuilder(@this.Session()).WithNonSerialisedPartDefaults(allors).Build();

            var good2 = new NonUnifiedGoodBuilder(@this.Session()).WithSerialisedPartDefaults(allors).Build();

            var serialisedItem = new SerialisedItemBuilder(@this.Session()).WithDefaults(allors).Build();

            serialisedPart1.AddSerialisedItem(serialisedItem);

            new InventoryItemTransactionBuilder(@this.Session())
            .WithSerialisedItem(serialisedItem)
            .WithFacility(allors.FacilitiesWhereOwner.First)
            .WithQuantity(1)
            .WithReason(new InventoryTransactionReasons(@this.Session()).IncomingShipment)
            .WithSerialisedInventoryItemState(new SerialisedInventoryItemStates(@this.Session()).Good)
            .Build();

            var good3 = new NonUnifiedGoodBuilder(@this.Session()).WithNonSerialisedPartDefaults(allors).Build();

            var good4 = new NonUnifiedGoodBuilder(@this.Session()).WithSerialisedPartDefaults(allors).Build();

            var productCategory1 = new ProductCategoryBuilder(@this.Session())
                                   .WithInternalOrganisation(allors)
                                   .WithName("Best selling gizmo's")
                                   .WithLocalisedName(new LocalisedTextBuilder(@this.Session()).WithText("Meest verkochte gizmo's").WithLocale(dutchLocale).Build())
                                   .Build();

            var productCategory2 = new ProductCategoryBuilder(@this.Session())
                                   .WithInternalOrganisation(allors)
                                   .WithName("Big Gizmo's")
                                   .WithLocalisedName(new LocalisedTextBuilder(@this.Session()).WithText("Grote Gizmo's").WithLocale(dutchLocale).Build())
                                   .Build();

            var productCategory3 = new ProductCategoryBuilder(@this.Session())
                                   .WithInternalOrganisation(allors)
                                   .WithName("Small gizmo's")
                                   .WithLocalisedName(new LocalisedTextBuilder(@this.Session()).WithText("Kleine gizmo's").WithLocale(dutchLocale).Build())
                                   .WithProduct(good1)
                                   .WithProduct(good2)
                                   .WithProduct(good3)
                                   .WithProduct(good4)
                                   .Build();

            new CatalogueBuilder(@this.Session())
            .WithInternalOrganisation(allors)
            .WithName("New gizmo's")
            .WithLocalisedName(new LocalisedTextBuilder(@this.Session()).WithText("Nieuwe gizmo's").WithLocale(dutchLocale).Build())
            .WithDescription("Latest in the world of Gizmo's")
            .WithLocalisedDescription(new LocalisedTextBuilder(@this.Session()).WithText("Laatste in de wereld van Gizmo's").WithLocale(dutchLocale).Build())
            .WithProductCategory(productCategory1)
            .Build();

            @this.Session().Derive();

            var email2 = new EmailAddressBuilder(@this.Session())
                         .WithElectronicAddressString("*****@*****.**")
                         .Build();

            for (var i = 0; i < 10; i++)
            {
                var b2BCustomer = allors.CreateB2BCustomer(faker);

                @this.Session().Derive();

                new FaceToFaceCommunicationBuilder(@this.Session())
                .WithDescription($"Meeting {i}")
                .WithSubject($"meeting {i}")
                .WithEventPurpose(new CommunicationEventPurposes(@this.Session()).Meeting)
                .WithFromParty(allors.CurrentContacts.First)
                .WithToParty(b2BCustomer.CurrentContacts.First)
                .WithOwner(administrator)
                .WithActualStart(@this.Session().Now())
                .Build();

                new EmailCommunicationBuilder(@this.Session())
                .WithDescription($"Email {i}")
                .WithSubject($"email {i}")
                .WithFromParty(allors.CurrentContacts.First)
                .WithToParty(b2BCustomer.CurrentContacts.First)
                .WithFromEmail(allors.GeneralEmail)
                .WithToEmail(email2)
                .WithEventPurpose(new CommunicationEventPurposes(@this.Session()).Meeting)
                .WithOwner(administrator)
                .WithActualStart(@this.Session().Now())
                .Build();

                new LetterCorrespondenceBuilder(@this.Session())
                .WithDescription($"Letter {i}")
                .WithSubject($"letter {i}")
                .WithFromParty(administrator)
                .WithToParty(b2BCustomer.CurrentContacts.First)
                .WithEventPurpose(new CommunicationEventPurposes(@this.Session()).Meeting)
                .WithOwner(administrator)
                .WithActualStart(@this.Session().Now())
                .Build();

                new PhoneCommunicationBuilder(@this.Session())
                .WithDescription($"Phone {i}")
                .WithSubject($"phone {i}")
                .WithFromParty(administrator)
                .WithToParty(b2BCustomer.CurrentContacts.First)
                .WithEventPurpose(new CommunicationEventPurposes(@this.Session()).Meeting)
                .WithOwner(administrator)
                .WithActualStart(@this.Session().Now())
                .Build();

                var requestForQuote = new RequestForQuoteBuilder(@this.Session())
                                      .WithEmailAddress($"customer{i}@acme.com")
                                      .WithTelephoneNumber("+1 234 56789")
                                      .WithRecipient(allors)
                                      .Build();

                var requestItem = new RequestItemBuilder(@this.Session())
                                  .WithSerialisedItem(serialisedItem)
                                  .WithProduct(serialisedItem.PartWhereSerialisedItem.NonUnifiedGoodsWherePart.FirstOrDefault())
                                  .WithComment($"Comment {i}")
                                  .WithQuantity(1)
                                  .Build();

                requestForQuote.AddRequestItem(requestItem);

                var quote = new ProductQuoteBuilder(@this.Session()).WithSerializedDefaults(allors).Build();

                var salesOrderItem1 = new SalesOrderItemBuilder(@this.Session())
                                      .WithDescription("first item")
                                      .WithProduct(good1)
                                      .WithAssignedUnitPrice(3000)
                                      .WithQuantityOrdered(1)
                                      .WithMessage(@"line1
line2")
                                      .WithInvoiceItemType(new InvoiceItemTypes(@this.Session()).ProductItem)
                                      .Build();

                var salesOrderItem2 = new SalesOrderItemBuilder(@this.Session())
                                      .WithDescription("second item")
                                      .WithAssignedUnitPrice(2000)
                                      .WithQuantityOrdered(2)
                                      .WithInvoiceItemType(new InvoiceItemTypes(@this.Session()).ProductItem)
                                      .Build();

                var salesOrderItem3 = new SalesOrderItemBuilder(@this.Session())
                                      .WithDescription("Fee")
                                      .WithAssignedUnitPrice(100)
                                      .WithQuantityOrdered(1)
                                      .WithInvoiceItemType(new InvoiceItemTypes(@this.Session()).Fee)
                                      .Build();

                var order = new SalesOrderBuilder(@this.Session())
                            .WithTakenBy(allors)
                            .WithBillToCustomer(b2BCustomer)
                            .WithBillToEndCustomerContactMechanism(b2BCustomer.BillingAddress)
                            .WithSalesOrderItem(salesOrderItem1)
                            .WithSalesOrderItem(salesOrderItem2)
                            .WithSalesOrderItem(salesOrderItem3)
                            .WithCustomerReference("a reference number")
                            .WithDescription("Sale of 1 used Aircraft Towbar")
                            .WithVatRegime(new VatRegimes(@this.Session()).Assessable)
                            .Build();

                var salesInvoiceItem1 = new SalesInvoiceItemBuilder(@this.Session())
                                        .WithDescription("first item")
                                        .WithProduct(good1)
                                        .WithAssignedUnitPrice(3000)
                                        .WithQuantity(1)
                                        .WithMessage(@"line1
line2")
                                        .WithInvoiceItemType(new InvoiceItemTypes(@this.Session()).ProductItem)
                                        .Build();

                var salesInvoiceItem2 = new SalesInvoiceItemBuilder(@this.Session())
                                        .WithDescription("second item")
                                        .WithAssignedUnitPrice(2000)
                                        .WithQuantity(2)
                                        .WithInvoiceItemType(new InvoiceItemTypes(@this.Session()).ProductItem)
                                        .Build();

                var salesInvoiceItem3 = new SalesInvoiceItemBuilder(@this.Session())
                                        .WithDescription("Fee")
                                        .WithAssignedUnitPrice(100)
                                        .WithQuantity(1)
                                        .WithInvoiceItemType(new InvoiceItemTypes(@this.Session()).Fee)
                                        .Build();

                var exw      = new IncoTermTypes(@this.Session()).Exw;
                var incoTerm = new IncoTermBuilder(@this.Session()).WithTermType(exw).WithTermValue("XW").Build();

                var salesInvoice = new SalesInvoiceBuilder(@this.Session())
                                   .WithBilledFrom(allors)
                                   .WithBillToCustomer(b2BCustomer)
                                   .WithBillToContactPerson(b2BCustomer.CurrentContacts.First)
                                   .WithBillToContactMechanism(b2BCustomer.BillingAddress)
                                   .WithSalesInvoiceItem(salesInvoiceItem1)
                                   .WithSalesInvoiceItem(salesInvoiceItem2)
                                   .WithSalesInvoiceItem(salesInvoiceItem3)
                                   .WithCustomerReference("a reference number")
                                   .WithDescription("Sale of 1 used Aircraft Towbar")
                                   .WithSalesInvoiceType(new SalesInvoiceTypes(@this.Session()).SalesInvoice)
                                   .WithSalesTerm(incoTerm)
                                   .WithVatRegime(new VatRegimes(@this.Session()).Assessable)
                                   .Build();

                for (var j = 0; j < 3; j++)
                {
                    var salesInvoiceItem = new SalesInvoiceItemBuilder(@this.Session())
                                           .WithDescription("Extra Charge")
                                           .WithAssignedUnitPrice(100 + j)
                                           .WithQuantity(j)
                                           .WithInvoiceItemType(new InvoiceItemTypes(@this.Session()).MiscCharge)
                                           .Build();

                    salesInvoice.AddSalesInvoiceItem(salesInvoiceItem);
                }
            }

            @this.Session().Derive();

            for (var i = 0; i < 4; i++)
            {
                var supplier = faker.Random.ListItem(allors.CurrentSuppliers);

                var purchaseInvoiceItem1 = new PurchaseInvoiceItemBuilder(@this.Session())
                                           .WithDescription("first item")
                                           .WithPart(nonSerialisedPart1)
                                           .WithAssignedUnitPrice(3000)
                                           .WithQuantity(1)
                                           .WithMessage(@"line1
line2")
                                           .WithInvoiceItemType(new InvoiceItemTypes(@this.Session()).PartItem)
                                           .Build();

                var purchaseInvoiceItem2 = new PurchaseInvoiceItemBuilder(@this.Session())
                                           .WithDescription("second item")
                                           .WithAssignedUnitPrice(2000)
                                           .WithQuantity(2)
                                           .WithPart(nonSerialisedPart2)
                                           .WithInvoiceItemType(new InvoiceItemTypes(@this.Session()).PartItem)
                                           .Build();

                var purchaseInvoiceItem3 = new PurchaseInvoiceItemBuilder(@this.Session())
                                           .WithDescription("Fee")
                                           .WithAssignedUnitPrice(100)
                                           .WithQuantity(1)
                                           .WithInvoiceItemType(new InvoiceItemTypes(@this.Session()).Fee)
                                           .Build();

                var purchaseInvoice = new PurchaseInvoiceBuilder(@this.Session())
                                      .WithBilledTo(allors)
                                      .WithBilledFrom(supplier)
                                      .WithPurchaseInvoiceItem(purchaseInvoiceItem1)
                                      .WithPurchaseInvoiceItem(purchaseInvoiceItem2)
                                      .WithPurchaseInvoiceItem(purchaseInvoiceItem3)
                                      .WithCustomerReference("a reference number")
                                      .WithDescription("Purchase of 1 used Aircraft Towbar")
                                      .WithPurchaseInvoiceType(new PurchaseInvoiceTypes(@this.Session()).PurchaseInvoice)
                                      .WithVatRegime(new VatRegimes(@this.Session()).Assessable)
                                      .Build();

                var purchaseOrderItem1 = new PurchaseOrderItemBuilder(@this.Session())
                                         .WithDescription("first purchase order item")
                                         .WithPart(nonSerialisedPart1)
                                         .WithQuantityOrdered(1)
                                         .Build();

                var purchaseOrder = new PurchaseOrderBuilder(@this.Session())
                                    .WithOrderedBy(allors)
                                    .WithTakenViaSupplier(supplier)
                                    .WithPurchaseOrderItem(purchaseOrderItem1)
                                    .WithCustomerReference("reference " + i)
                                    .Build();
            }

            var anOrganisation = new Organisations(@this.Session()).FindBy(M.Organisation.IsInternalOrganisation, false);

            var item = new SerialisedItemBuilder(@this.Session())
                       .WithSerialNumber("112")
                       .WithSerialisedItemAvailability(new SerialisedItemAvailabilities(@this.Session()).Sold)
                       .WithAvailableForSale(false)
                       .WithOwnedBy(anOrganisation)
                       .Build();

            nonSerialisedPart2.AddSerialisedItem(item);

            var workTask = new WorkTaskBuilder(@this.Session())
                           .WithTakenBy(allors)
                           .WithCustomer(anOrganisation)
                           .WithName("maintenance")
                           .Build();

            new WorkEffortFixedAssetAssignmentBuilder(@this.Session())
            .WithFixedAsset(item)
            .WithAssignment(workTask)
            .Build();

            var workOrderPart1 = allors.CreateNonSerialisedNonUnifiedPart(faker);
            var workOrderPart2 = allors.CreateNonSerialisedNonUnifiedPart(faker);
            var workOrderPart3 = allors.CreateNonSerialisedNonUnifiedPart(faker);

            @this.Session().Derive();

            var workOrder = new WorkTaskBuilder(@this.Session())
                            .WithName("Task")
                            .WithTakenBy(allors)
                            .WithFacility(new Facilities(@this.Session()).Extent().First)
                            .WithCustomer(anOrganisation)
                            .WithWorkEffortPurpose(new WorkEffortPurposes(@this.Session()).Maintenance)
                            .WithSpecialTerms("Net 45 Days")
                            .Build();

            new WorkEffortFixedAssetAssignmentBuilder(@this.Session())
            .WithFixedAsset(item)
            .WithAssignment(workOrder)
            .WithComment("Busted tailpipe")
            .Build();

            workOrder.CreateInventoryAssignment(workOrderPart1, 11);
            workOrder.CreateInventoryAssignment(workOrderPart2, 12);
            workOrder.CreateInventoryAssignment(workOrderPart3, 13);

            //// Work Effort Time Entries
            var yesterday      = DateTimeFactory.CreateDateTime(@this.Session().Now().AddDays(-1));
            var laterYesterday = DateTimeFactory.CreateDateTime(yesterday.AddHours(3));

            var today      = DateTimeFactory.CreateDateTime(@this.Session().Now());
            var laterToday = DateTimeFactory.CreateDateTime(today.AddHours(4));

            var tomorrow      = DateTimeFactory.CreateDateTime(@this.Session().Now().AddDays(1));
            var laterTomorrow = DateTimeFactory.CreateDateTime(tomorrow.AddHours(6));

            var standardRate = new RateTypes(@this.Session()).StandardRate;
            var overtimeRate = new RateTypes(@this.Session()).OvertimeRate;

            var frequencies = new TimeFrequencies(@this.Session());

            var timeEntryYesterday1 = workOrder.CreateTimeEntry(yesterday, laterYesterday, frequencies.Day, standardRate);
            var timeEntryToday1     = workOrder.CreateTimeEntry(today, laterToday, frequencies.Hour, standardRate);
            var timeEntryTomorrow1  = workOrder.CreateTimeEntry(tomorrow, laterTomorrow, frequencies.Minute, overtimeRate);

            allorsEmployee1.TimeSheetWhereWorker.AddTimeEntry(timeEntryYesterday1);
            allorsEmployee1.TimeSheetWhereWorker.AddTimeEntry(timeEntryToday1);
            allorsEmployee1.TimeSheetWhereWorker.AddTimeEntry(timeEntryTomorrow1);

            var timeEntryYesterday2 = workOrder.CreateTimeEntry(yesterday, laterYesterday, frequencies.Day, standardRate);
            var timeEntryToday2     = workOrder.CreateTimeEntry(today, laterToday, frequencies.Hour, standardRate);
            var timeEntryTomorrow2  = workOrder.CreateTimeEntry(tomorrow, laterTomorrow, frequencies.Minute, overtimeRate);

            allorsEmployee2.TimeSheetWhereWorker.AddTimeEntry(timeEntryYesterday2);
            allorsEmployee2.TimeSheetWhereWorker.AddTimeEntry(timeEntryToday2);
            allorsEmployee2.TimeSheetWhereWorker.AddTimeEntry(timeEntryTomorrow2);

            var po = new PurchaseOrders(@this.Session()).Extent().First;

            foreach (PurchaseOrderItem purchaseOrderItem in po.PurchaseOrderItems)
            {
                new WorkEffortPurchaseOrderItemAssignmentBuilder(@this.Session())
                .WithPurchaseOrderItem(purchaseOrderItem)
                .WithAssignment(workOrder)
                .WithQuantity(1)
                .Build();
            }

            @this.Session().Derive();
        }