public ActionResult Edit([Bind(Include = "Id,JobName,Image,Quota,Description,CreatedBy,DateTime,CurrentApplicant,Status,ExpiredDate,CategoryId")] JobMaster jobMaster, HttpPostedFileBase image)
        {
            if (image.ContentLength > 0)
            {
                CloudBlobContainer blobContainer = _blobStorageService.GetCloudBlobContainer();
                CloudBlockBlob     blob          = blobContainer.GetBlockBlobReference(image.FileName);
                blob.UploadFromStream(image.InputStream);
                var uri = blob.Uri.AbsoluteUri;
                jobMaster.Image = uri;
            }

            if (ModelState.IsValid)
            {
                db.Entry(jobMaster).State = EntityState.Modified;
                db.SaveChanges();
                //return RedirectToAction("Index");
            }
            else
            {
                Response.StatusCode = 400;
                return(Content("Model State is Invalid! Please re-check your form!"));
            }
            //return View(jobMaster);
            return(RedirectToAction("Details", new { id = jobMaster.Id }));
        }
Example #2
0
        public IActionResult UpdateJob([FromBody] JobMaster model)
        {
            var msg  = new Message <JobMaster>();
            var data = DbClientFactory <JobMasterDbClient> .Instance.UpdateJob(model, appSettings.Value.DbConn);

            if (data == "C200")
            {
                msg.IsSuccess = true;
                if (model.JobId == 0)
                {
                    msg.ReturnMessage = "Job saved successfully";
                }
                else
                {
                    msg.ReturnMessage = "Job updated successfully";
                }
            }
            //else if (data == "C201")
            //{
            //    msg.IsSuccess = false;
            //    msg.ReturnMessage = "Email Id already exists";
            //}
            //else if (data == "C202")
            //{
            //    msg.IsSuccess = false;
            //    msg.ReturnMessage = "Mobile Number already exists";
            //}
            return(Ok(msg));
        }
        public ActionResult Create([Bind(Include = "Id,JobName,Image,Quota,Description,CreatedBy,DateTime,CurrentApplicant,Status,ExpiredDate,CategoryName")] JobMaster jobMaster, HttpPostedFileBase image)
        {
            //JobMaster x = new JobMaster();

            if (image.ContentLength > 0)
            {
                CloudBlobContainer blobContainer = _blobStorageService.GetCloudBlobContainer();
                CloudBlockBlob     blob          = blobContainer.GetBlockBlobReference(image.FileName);
                blob.UploadFromStream(image.InputStream);
                var uri = blob.Uri.AbsoluteUri;
                jobMaster.Image = uri;
            }


            if (ModelState.IsValid)
            {
                jobMaster.CreatedBy = User.Identity.Name;

                db.JobMasters.Add(jobMaster);
                db.SaveChanges();
                //return RedirectToAction("Details");
            }
            else //abis if di guard jangan langsung masuk RedirectToAction, errornya jadi gak ketangkep
            {
                Response.StatusCode = 400;
                return(Content("Model State is Invalid! Please re-check your form!"));
            }

            //return View(jobMaster);
            return(RedirectToAction("Details", new { id = jobMaster.Id }));
        }
Example #4
0
        public string UpdateJob(JobMaster jobMaster)
        {
            try
            {
                var            domainName = API_URL;
                HttpWebRequest request    = (HttpWebRequest)WebRequest.
                                            Create(String.Format("{0}/api/JobMaster/UpdateJob",
                                                                 domainName));
                request.UserAgent   = @"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36";
                request.ContentType = "application/json";
                request.Method      = "PUT";



                using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                {
                    var json = JsonConvert.SerializeObject(jobMaster);

                    streamWriter.Write(json);
                }

                var httpResponse = (HttpWebResponse)request.GetResponse();
                var streamReader = new StreamReader(httpResponse.GetResponseStream());
                var result       = streamReader.ReadToEnd();
                return(result);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
                return(ex.Message.ToString());
            }
        }
Example #5
0
        protected async void AddJob <T>(JobMaster jobMaster) where T : JobBase
        {
            if (jobMaster != null)
            {
                // define the job and tie it to our T class
                IJobDetail job = JobBuilder.Create <T>()
                                 .WithIdentity(jobMaster.JobCode, GroupWorker)
                                 .Build();

                // Trigger the job
                ITrigger trigger = TriggerBuilder.Create()
                                   .WithIdentity(jobMaster.JobCode, GroupWorker)
                                   .WithCronSchedule(jobMaster.CronSchedule)
                                   .ForJob(jobMaster.JobCode, GroupWorker)
                                   .Build();

                // Tell quartz to schedule the job
                await Scheduler.ScheduleJob(job, trigger);

                //Log
                Log.Information(GroupWorker + " - " + jobMaster.JobCode + ": Registered.");
            }
            else
            {
                Log.Information(this.GroupWorker + " - " + typeof(T).Name + ": Job master configuration not found.");
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            JobMaster jobMaster = db.JobMasters.Find(id);

            db.JobMasters.Remove(jobMaster);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
        public async Task <IActionResult> DeleteJobMaster([FromBody] JobMasterView view)
        {
            JobMasterModule invMod    = new JobMasterModule();
            JobMaster       jobMaster = await invMod.JobMaster.Query().MapToEntity(view);

            invMod.JobMaster.DeleteJobMaster(jobMaster).Apply();

            return(Ok(view));
        }
Example #8
0
        public IHttpActionResult GetJobMaster(int id)
        {
            JobMaster jobMaster = db.JobMasters.Find(id);

            if (jobMaster == null)
            {
                return(NotFound());
            }

            return(Ok(jobMaster));
        }
Example #9
0
        public async Task TestAddUpdatDelete()
        {
            JobCostLedgerModule JobCostLedgerMod = new JobCostLedgerModule();
            Contract            contract         = await JobCostLedgerMod.Contract.Query().GetEntityById(6);

            JobMaster jobMaster = await JobCostLedgerMod.JobMaster.Query().GetEntityById(40);

            JobPhase jobPhase = await JobCostLedgerMod.JobPhase.Query().GetEntityById(180);

            JobCostType jobCostType = await JobCostLedgerMod.JobCostType.Query().GetEntityById(2);

            JobCostLedgerView view = new JobCostLedgerView()
            {
                JobMasterId     = jobMaster.JobMasterId,
                ContractId      = contract.ContractId,
                EstimatedHours  = 0,
                EstimatedAmount = 0,
                JobPhaseId      = jobPhase.JobPhaseId,
                ActualHours     = 0,
                ActualCost      = 0,
                ProjectedHours  = 0,
                CommittedHours  = 0,
                CommittedAmount = 100M,
                Description     = "JC Ledger Detail",
                TransactionType = "PO",
                Source          = "Job Costing",
                JobCostTypeId   = jobCostType.JobCostTypeId
            };
            NextNumber nnNextNumber = await JobCostLedgerMod.JobCostLedger.Query().GetNextNumber();

            view.JobCostLedgerNumber = nnNextNumber.NextNumberValue;

            JobCostLedger jobCostLedger = await JobCostLedgerMod.JobCostLedger.Query().MapToEntity(view);

            JobCostLedgerMod.JobCostLedger.AddJobCostLedger(jobCostLedger).Apply();

            JobCostLedger newJobCostLedger = await JobCostLedgerMod.JobCostLedger.Query().GetEntityByNumber(view.JobCostLedgerNumber);

            Assert.NotNull(newJobCostLedger);

            newJobCostLedger.Description = "JobCostLedger Test Update";

            JobCostLedgerMod.JobCostLedger.UpdateJobCostLedger(newJobCostLedger).Apply();

            JobCostLedgerView updateView = await JobCostLedgerMod.JobCostLedger.Query().GetViewById(newJobCostLedger.JobCostLedgerId);

            Assert.Same(updateView.Description, "JobCostLedger Test Update");
            JobCostLedgerMod.JobCostLedger.DeleteJobCostLedger(newJobCostLedger).Apply();
            JobCostLedger lookupJobCostLedger = await JobCostLedgerMod.JobCostLedger.Query().GetEntityById(view.JobCostLedgerId);

            Assert.Null(lookupJobCostLedger);
        }
Example #10
0
        public async Task <IActionResult> UpdateJobMaster([FromBody] JobMasterView view)
        {
            JobMasterModule invMod = new JobMasterModule();

            JobMaster jobMaster = await invMod.JobMaster.Query().MapToEntity(view);


            invMod.JobMaster.UpdateJobMaster(jobMaster).Apply();

            JobMasterView retView = await invMod.JobMaster.Query().GetViewById(jobMaster.JobMasterId);


            return(Ok(retView));
        }
        // GET: Job/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            JobMaster jobMaster = db.JobMasters.Find(id);

            if (jobMaster == null)
            {
                return(HttpNotFound());
            }
            return(View(jobMaster));
        }
        // GET: Job/Edit/5
        public ActionResult Edit(int?id, HttpPostedFileBase image)
        {
            JobMaster jobMaster = db.JobMasters.Find(id);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (jobMaster == null)
            {
                return(HttpNotFound());
            }

            return(View(jobMaster));
        }
Example #13
0
        public async Task <IActionResult> AddJobMaster([FromBody] JobMasterView view)
        {
            JobMasterModule invMod = new JobMasterModule();

            NextNumber nnJobMaster = await invMod.JobMaster.Query().GetNextNumber();

            view.JobMasterNumber = nnJobMaster.NextNumberValue;

            JobMaster jobMaster = await invMod.JobMaster.Query().MapToEntity(view);

            invMod.JobMaster.AddJobMaster(jobMaster).Apply();

            JobMasterView newView = await invMod.JobMaster.Query().GetViewByNumber(view.JobMasterNumber);


            return(Ok(newView));
        }
Example #14
0
        public IActionResult SaveJob([FromBody] JobMaster model)
        {
            var msg  = new Message <JobMaster>();
            var data = DbClientFactory <JobMasterDbClient> .Instance.SaveJob(model, appSettings.Value.DbConn);

            if (data == null || data == String.Empty)
            {
                msg.IsSuccess     = false;
                msg.ReturnMessage = "Job Saving Failed";
            }
            else
            {
                msg.IsSuccess     = true;
                msg.ReturnMessage = "Job saved successfully";
            }
            return(Ok(data));
        }
        public string SaveJob(JobMaster model, string connString)
        {
            var outParam = new SqlParameter("@JobId", SqlDbType.Int, 20)
            {
                Direction = ParameterDirection.Output
            };

            SqlParameter[] param =
            {
                new SqlParameter("@JobTitle",       model.JobTitle),
                new SqlParameter("@JobDescription", model.JobDescription),
                new SqlParameter("@IsActive",       model.IsActive),
                outParam
            };
            SqlHelper.ExecuteProcedureReturnString(connString, "sp_JobMaster_Insert", param);
            return(outParam.Value.ToString());
        }
        public string UpdateJob(JobMaster model, string connString)
        {
            var outParam = new SqlParameter("@ReturnCode", SqlDbType.NVarChar, 20)
            {
                Direction = ParameterDirection.Output
            };

            SqlParameter[] param =
            {
                new SqlParameter("@JobId",          model.JobId),
                new SqlParameter("@JobTitle",       model.JobTitle),
                new SqlParameter("@JobDescription", model.JobDescription),
                new SqlParameter("@IsActive",       model.IsActive),
                outParam
            };
            SqlHelper.ExecuteProcedureReturnString(connString, "sp_JobMaster_Update", param);
            return((string)outParam.Value);
        }
Example #17
0
        public async Task TestAddUpdatDelete()
        {
            JobPhaseModule JobPhaseMod = new JobPhaseModule();
            JobMaster      jobMaster   = await JobPhaseMod.JobMaster.Query().GetEntityById(3);

            Contract contract = await JobPhaseMod.Contract.Query().GetEntityById(5);

            JobCostType jobCostType = await JobPhaseMod.JobCostType.Query().GetEntityById(4);

            JobPhaseView view = new JobPhaseView()
            {
                JobMasterId    = jobMaster.JobMasterId,
                JobDescription = jobMaster.JobDescription,
                ContractId     = contract.ContractId,
                ContractTitle  = contract.Title,
                PhaseGroup     = 1,
                Phase          = "Site Preparation",
                JobCostTypeId  = jobCostType.JobCostTypeId,
                CostCode       = jobCostType.CostCode
            };
            NextNumber nnNextNumber = await JobPhaseMod.JobPhase.Query().GetNextNumber();

            view.JobPhaseNumber = nnNextNumber.NextNumberValue;

            JobPhase jobPhase = await JobPhaseMod.JobPhase.Query().MapToEntity(view);

            JobPhaseMod.JobPhase.AddJobPhase(jobPhase).Apply();

            JobPhase newJobPhase = await JobPhaseMod.JobPhase.Query().GetEntityByNumber(view.JobPhaseNumber);

            Assert.NotNull(newJobPhase);

            newJobPhase.Phase = "JobPhase Test Update";

            JobPhaseMod.JobPhase.UpdateJobPhase(newJobPhase).Apply();

            JobPhaseView updateView = await JobPhaseMod.JobPhase.Query().GetViewById(newJobPhase.JobPhaseId);

            Assert.Same(updateView.Phase, "JobPhase Test Update");
            JobPhaseMod.JobPhase.DeleteJobPhase(newJobPhase).Apply();
            JobPhase lookupJobPhase = await JobPhaseMod.JobPhase.Query().GetEntityById(view.JobPhaseId);

            Assert.Null(lookupJobPhase);
        }
Example #18
0
 public IFluentJobMaster AddJobMaster(JobMaster newObject)
 {
     unitOfWork.jobMasterRepository.AddObject(newObject);
     this.processStatus = CreateProcessStatus.Insert;
     return(this as IFluentJobMaster);
 }
Example #19
0
        public decimal CalculateHRA(int UsagesCode, decimal DeductibleCosts, JobMaster JobDetail)
        {
            decimal?HRADedLimitPrimary      = JobDetail.HRADedLimitPrimary == null ? 0 : JobDetail.HRADedLimitPrimary;
            decimal?HRAMaxReimbursePrimary  = JobDetail.HRAMaxReimbursePrimary == null ? 0 : JobDetail.HRAMaxReimbursePrimary;
            decimal?HRAReimburseRatePrimary = JobDetail.HRAReimburseRatePrimary == null ? 0 : JobDetail.HRAReimburseRatePrimary;

            decimal?HRADedLimitDependent      = JobDetail.HRADedLimitDependent == null ? 0 : JobDetail.HRADedLimitDependent;
            decimal?HRAMaxReimburseDependent  = JobDetail.HRAMaxReimburseDependent == null ? 0 : JobDetail.HRAMaxReimburseDependent;
            decimal?HRAReimburseRateDependent = JobDetail.HRAReimburseRateDependent == null ? 0 : JobDetail.HRAReimburseRateDependent;

            //decimal? FamilyHRAReimbursementTotal = 0;
            decimal?HRAReimbursement = 0;


            if (UsagesCode == 1)
            {
                if ((DeductibleCosts - HRADedLimitPrimary) < 0)
                {
                    return((decimal)HRAReimbursement);
                }


                if (HRAMaxReimbursePrimary > 0)
                {
                    if ((DeductibleCosts - HRADedLimitPrimary) * HRAReimburseRatePrimary < HRAMaxReimbursePrimary)
                    {
                        HRAReimbursement = (DeductibleCosts - HRADedLimitPrimary) * HRAReimburseRatePrimary;
                    }
                    else
                    {
                        HRAReimbursement = HRAMaxReimbursePrimary;
                    }
                }
                return((decimal)HRAReimbursement);
            }
            else
            {
                if (HRAMaxReimburseDependent > 0)
                {
                    if ((DeductibleCosts - HRADedLimitDependent) < 0)
                    {
                        return((decimal)HRAReimbursement);
                    }

                    if ((DeductibleCosts - HRADedLimitDependent) * HRAReimburseRateDependent < HRAMaxReimburseDependent)
                    {
                        HRAReimbursement = (DeductibleCosts - HRADedLimitDependent) * HRAReimburseRateDependent;
                    }
                    else
                    {
                        HRAReimbursement = HRAMaxReimburseDependent;
                    }
                }
                else
                {
                    if ((DeductibleCosts - HRADedLimitPrimary) < 0)
                    {
                        return((decimal)HRAReimbursement);
                    }

                    if (HRAMaxReimbursePrimary > 0)
                    {
                        if ((DeductibleCosts - HRADedLimitPrimary) * HRAReimburseRatePrimary < HRAMaxReimbursePrimary)
                        {
                            HRAReimbursement = (DeductibleCosts - HRADedLimitPrimary) * HRAReimburseRatePrimary;
                        }
                        else
                        {
                            HRAReimbursement = HRAMaxReimbursePrimary;
                        }
                    }
                }
                return((decimal)HRAReimbursement);
            }
        }
Example #20
0
        public async Task TestAddUpdatDelete()
        {
            JobMasterModule JobMasterMod = new JobMasterModule();
            Customer        customer     = await JobMasterMod.Customer.Query().GetEntityById(12);

            AddressBook addressBookCustomer = await JobMasterMod.AddressBook.Query().GetEntityById(customer?.AddressId);

            Contract contract = await JobMasterMod.Contract.Query().GetEntityById(5);

            //public long? ProjectManagerId { get; set; }
            JobMasterView view = new JobMasterView()
            {
                CustomerId               = customer.CustomerId,
                CustomerName             = addressBookCustomer?.Name,
                ContractId               = contract.ContractId,
                ContractTitle            = contract?.Title,
                JobDescription           = "Kuna 4 plex project",
                Address1                 = " 123 ABC",
                City                     = "Kuna",
                State                    = "Id",
                Zipcode                  = "83709",
                TotalCommittedAmount     = 600000,
                RemainingCommittedAmount = 400000,
                RetainageAmount          = 200000,
                JobMasterNumber          = (await JobMasterMod.JobMaster.Query().GetNextNumber()).NextNumberValue
            };

            JobMaster jobMaster = await JobMasterMod.JobMaster.Query().MapToEntity(view);

            JobMasterMod.JobMaster.AddJobMaster(jobMaster).Apply();

            JobMaster newJobMaster = await JobMasterMod.JobMaster.Query().GetEntityByNumber(view.JobMasterNumber);

            JobCostType jobPhaseCostTypeMisc = await JobMasterMod.JobCostType.Query().GetEntityById(4);

            Assert.NotNull(newJobMaster);

            IList <JobPhaseView> listJobPhaseViews = new List <JobPhaseView> {
                new JobPhaseView {
                    ContractId     = contract.ContractId,
                    ContractTitle  = contract.Title,
                    JobMasterId    = newJobMaster.JobMasterId,
                    JobDescription = newJobMaster.JobDescription,
                    PhaseGroup     = 1,
                    Phase          = "Work Site Preparation - Safety",
                    JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue,
                    JobCostTypeId  = jobPhaseCostTypeMisc.JobCostTypeId,
                    CostCode       = jobPhaseCostTypeMisc.CostCode
                },
                new JobPhaseView {
                    ContractId     = contract.ContractId,
                    ContractTitle  = contract.Title,
                    JobMasterId    = newJobMaster.JobMasterId,
                    JobDescription = newJobMaster.JobDescription,
                    PhaseGroup     = 1,
                    Phase          = "Foundations",
                    JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue,
                    JobCostTypeId  = jobPhaseCostTypeMisc.JobCostTypeId,
                    CostCode       = jobPhaseCostTypeMisc.CostCode
                },
                new JobPhaseView {
                    ContractId     = contract.ContractId,
                    ContractTitle  = contract.Title,
                    JobMasterId    = newJobMaster.JobMasterId,
                    JobDescription = newJobMaster.JobDescription,
                    PhaseGroup     = 1,
                    Phase          = "Building Structure",
                    JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue,
                    JobCostTypeId  = jobPhaseCostTypeMisc.JobCostTypeId,
                    CostCode       = jobPhaseCostTypeMisc.CostCode
                }
                ,
                new JobPhaseView {
                    ContractId     = contract.ContractId,
                    ContractTitle  = contract.Title,
                    JobMasterId    = newJobMaster.JobMasterId,
                    JobDescription = newJobMaster.JobDescription,
                    PhaseGroup     = 1,
                    Phase          = "Facade",
                    JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue,
                    JobCostTypeId  = jobPhaseCostTypeMisc.JobCostTypeId,
                    CostCode       = jobPhaseCostTypeMisc.CostCode
                }
                ,
                new JobPhaseView {
                    ContractId     = contract.ContractId,
                    ContractTitle  = contract.Title,
                    JobMasterId    = newJobMaster.JobMasterId,
                    JobDescription = newJobMaster.JobDescription,
                    PhaseGroup     = 1,
                    Phase          = "Interior Construction",
                    JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue,
                    JobCostTypeId  = jobPhaseCostTypeMisc.JobCostTypeId,
                    CostCode       = jobPhaseCostTypeMisc.CostCode
                }
                ,
                new JobPhaseView {
                    ContractId     = contract.ContractId,
                    ContractTitle  = contract.Title,
                    JobMasterId    = newJobMaster.JobMasterId,
                    JobDescription = newJobMaster.JobDescription,
                    PhaseGroup     = 1,
                    Phase          = "Commissioning",
                    JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue,
                    JobCostTypeId  = jobPhaseCostTypeMisc.JobCostTypeId,
                    CostCode       = jobPhaseCostTypeMisc.CostCode
                }
                ,
                new JobPhaseView {
                    ContractId     = contract.ContractId,
                    ContractTitle  = contract.Title,
                    JobMasterId    = newJobMaster.JobMasterId,
                    JobDescription = newJobMaster.JobDescription,
                    PhaseGroup     = 1,
                    Phase          = "Grading and Landscaping",
                    JobPhaseNumber = (await JobMasterMod.JobPhase.Query().GetNextNumber()).NextNumberValue,
                    JobCostTypeId  = jobPhaseCostTypeMisc.JobCostTypeId,
                    CostCode       = jobPhaseCostTypeMisc.CostCode
                }
            };

            IList <JobPhase> listJobPhases = await JobMasterMod.JobPhase.Query().MapToEntity(listJobPhaseViews);

            JobMasterMod.JobPhase.AddJobPhases(listJobPhases.ToList <JobPhase>()).Apply();

            //Add Purchase Order
            PurchaseOrderModule PurchaseOrderMod = new PurchaseOrderModule();
            ChartOfAccount      chartOfAccount   = await PurchaseOrderMod.ChartOfAccount.Query().GetEntityById(16);

            Supplier supplier = await PurchaseOrderMod.Supplier.Query().GetEntityById(3);

            AddressBook addressBook = await PurchaseOrderMod.AddressBook.Query().GetEntityById(supplier?.AddressId);

            Contract pocontract = await PurchaseOrderMod.Contract.Query().GetEntityById(5);

            Buyer buyer = await PurchaseOrderMod.Buyer.Query().GetEntityById(1);

            AddressBook buyerAddressBook = await PurchaseOrderMod.AddressBook.Query().GetEntityById(buyer?.AddressId);

            TaxRatesByCode taxRatesByCode = await PurchaseOrderMod.TaxRatesByCode.Query().GetEntityById(1);

            //create purchase order and detail
            PurchaseOrderView viewPurchaseOrder = new PurchaseOrderView()
            {
                DocType               = "STD",
                PaymentTerms          = "Net 30",
                Amount                = (24 * 75) + 25,
                AmountPaid            = 0,
                Remark                = " installation not included ",
                Gldate                = DateTime.Parse("1/14/2020"),
                AccountId             = chartOfAccount.AccountId,
                Location              = chartOfAccount.Location,
                BusUnit               = chartOfAccount.BusUnit,
                Subsidiary            = chartOfAccount.Subsidiary,
                SubSub                = chartOfAccount.SubSub,
                Account               = chartOfAccount.Account,
                AccountDescription    = chartOfAccount.Description,
                SupplierId            = supplier.SupplierId,
                CustomerId            = contract?.CustomerId,
                SupplierName          = addressBook.Name,
                ContractId            = contract?.ContractId,
                Description           = " Standard doors - white",
                Ponumber              = "PO-123",
                TakenBy               = "David Nishimoto",
                ShippedToName         = " abc corp",
                ShippedToAddress1     = " 123 abc",
                ShippedToAddress2     = " zone 1",
                ShippedToCity         = "Kuna",
                ShippedToState        = "ID",
                ShippedToZipcode      = "83709",
                BuyerId               = buyer.BuyerId,
                BuyerName             = buyerAddressBook?.Name,
                RequestedDate         = DateTime.Parse("1/20/2014"),
                PromisedDeliveredDate = DateTime.Parse("1/20/2014"),
                Tax                 = 24 * 75 * taxRatesByCode.TaxRate,
                TransactionDate     = DateTime.Parse("1/14/2020"),
                TaxCode1            = taxRatesByCode.TaxCode,
                TaxCode2            = "",
                TaxRate             = taxRatesByCode.TaxRate ?? 0,
                PurchaseOrderNumber = (await PurchaseOrderMod.PurchaseOrder.Query().GetNextNumber()).NextNumberValue
            };

            PurchaseOrder purchaseOrder = await PurchaseOrderMod.PurchaseOrder.Query().MapToEntity(viewPurchaseOrder);

            PurchaseOrderMod.PurchaseOrder.AddPurchaseOrder(purchaseOrder).Apply();

            PurchaseOrder newPurchaseOrder = await PurchaseOrderMod.PurchaseOrder.Query().GetEntityByNumber(viewPurchaseOrder.PurchaseOrderNumber);

            Supplier supplierPODetail = await PurchaseOrderMod.Supplier.Query().GetEntityById(newPurchaseOrder?.SupplierId);

            AddressBook addressBookSupplier = await PurchaseOrderMod.AddressBook.Query().GetEntityById(supplierPODetail?.AddressId);

            IList <PurchaseOrderDetailView> listPurchaseOrderDetailViews = new List <PurchaseOrderDetailView> {
                new PurchaseOrderDetailView()
                {
                    PurchaseOrderId           = newPurchaseOrder.PurchaseOrderId,
                    Amount                    = 75 * 24,
                    OrderedQuantity           = 24,
                    LineDescription           = "Standard Door",
                    LineNumber                = 1,
                    UnitPrice                 = 75,
                    UnitOfMeasure             = "Each",
                    ExpectedDeliveryDate      = DateTime.Parse("1/30/2020"),
                    OrderDate                 = DateTime.Parse("1/16/2020"),
                    ReceivedQuantity          = 0,
                    RemainingQuantity         = 24,
                    SupplierId                = newPurchaseOrder.SupplierId,
                    SupplierName              = addressBookSupplier?.Name,
                    PurchaseOrderDetailNumber = (await PurchaseOrderMod.PurchaseOrderDetail.Query().GetNextNumber()).NextNumberValue
                },
                new PurchaseOrderDetailView()
                {
                    PurchaseOrderId           = newPurchaseOrder.PurchaseOrderId,
                    Amount                    = 25 * 1,
                    OrderedQuantity           = 25,
                    LineDescription           = "Door Hinges",
                    LineNumber                = 2,
                    UnitPrice                 = 25,
                    UnitOfMeasure             = "Box",
                    ExpectedDeliveryDate      = DateTime.Parse("1/30/2020"),
                    OrderDate                 = DateTime.Parse("1/16/2020"),
                    ReceivedQuantity          = 0,
                    RemainingQuantity         = 24,
                    SupplierId                = newPurchaseOrder.SupplierId,
                    SupplierName              = addressBookSupplier?.Name,
                    PurchaseOrderDetailNumber = (await PurchaseOrderMod.PurchaseOrderDetail.Query().GetNextNumber()).NextNumberValue
                }
            };
            IList <PurchaseOrderDetail> listPurchaseOrderDetail = await PurchaseOrderMod.PurchaseOrderDetail.Query().MapToEntity(listPurchaseOrderDetailViews);

            PurchaseOrderMod.PurchaseOrderDetail.AddPurchaseOrderDetails(listPurchaseOrderDetail.ToList <PurchaseOrderDetail>()).Apply();

            IList <PurchaseOrderDetail> listNewPurchaseOrderDetail = await PurchaseOrderMod.PurchaseOrderDetail.Query().GetEntitiesByPurchaseOrderId(newPurchaseOrder.PurchaseOrderId);


            //*****************Create Accounts Payable

            AccountPayableModule AccountPayableMod = new AccountPayableModule();
            ChartOfAccount       chartOfAccount2   = await AccountPayableMod.ChartOfAccount.Query().GetEntityById(17);

            AccountPayableView accountPayableView = new AccountPayableView()
            {
                DocNumber            = (await AccountPayableMod.AccountPayable.Query().GetNextDocNumber()),
                GrossAmount          = newPurchaseOrder.Amount,
                Tax                  = newPurchaseOrder.Tax,
                DiscountAmount       = null,
                Remark               = null,
                Gldate               = DateTime.Now,
                SupplierId           = newPurchaseOrder.SupplierId,
                ContractId           = newPurchaseOrder.ContractId,
                PoquoteId            = null,
                Description          = newPurchaseOrder.Description,
                PurchaseOrderId      = newPurchaseOrder.PurchaseOrderId,
                AccountId            = chartOfAccount.AccountId,
                DocType              = "STD",
                PaymentTerms         = newPurchaseOrder.PaymentTerms,
                DiscountPercent      = 0,
                AmountOpen           = newPurchaseOrder.Amount,
                OrderNumber          = newPurchaseOrder.Ponumber,
                AmountPaid           = 0,
                AccountPayableNumber = (await AccountPayableMod.AccountPayable.Query().GetNextNumber()).NextNumberValue
            };

            AccountPayable accountPayable = await AccountPayableMod.AccountPayable.Query().MapToEntity(accountPayableView);

            AccountPayableMod.AccountPayable.AddAccountPayable(accountPayable).Apply();
            AccountPayable lookupAccountPayable = await AccountPayableMod.AccountPayable.Query().GetEntityByNumber(accountPayableView.AccountPayableNumber);

            //****************Create the invoice payment
            InvoiceModule invoiceMod = new InvoiceModule();
            Supplier      supplier2  = await invoiceMod.Supplier.Query().GetEntityById(purchaseOrder.SupplierId);

            AddressBook addressBookSupplinvModier2 = await invoiceMod.AddressBook.Query().GetEntityById(supplier?.AddressId);

            TaxRatesByCode taxRatesByCode2 = await invoiceMod.TaxRatesByCode.Query().GetEntityByTaxCode(purchaseOrder.TaxCode1);

            NextNumber nextNumber = await invoiceMod.Invoice.Query().GetNextNumber();

            InvoiceView invoiceView = new InvoiceView
            {
                InvoiceDocument  = "Inv-" + nextNumber.NextNumberValue.ToString(),
                InvoiceDate      = DateTime.Parse("1/17/2020"),
                Amount           = purchaseOrder.Amount,
                SupplierId       = supplier2?.SupplierId,
                SupplierName     = addressBookCustomer?.Name,
                Description      = purchaseOrder.Description,
                PaymentTerms     = purchaseOrder.PaymentTerms,
                TaxAmount        = taxRatesByCode2.TaxRate * purchaseOrder.Amount,
                CompanyId        = 1,
                TaxRatesByCodeId = taxRatesByCode2.TaxRatesByCodeId,
                InvoiceNumber    = nextNumber.NextNumberValue
            };

            Invoice invoice = await invoiceMod.Invoice.Query().MapToEntity(invoiceView);

            invoiceMod.Invoice.AddInvoice(invoice).Apply();

            Invoice newInvoice = await invoiceMod.Invoice.Query().GetEntityByNumber(invoiceView.InvoiceNumber);

            InvoiceDetailModule       invDetailMod           = new InvoiceDetailModule();
            IList <InvoiceDetailView> listInvoiceDetailViews = new List <InvoiceDetailView>();

            foreach (var item in listNewPurchaseOrderDetail)
            {
                InvoiceDetailView invoiceDetailView = new InvoiceDetailView()
                {
                    Amount                = item.Amount,
                    InvoiceId             = newInvoice.InvoiceId,
                    InvoiceDetailNumber   = (await invDetailMod.InvoiceDetail.Query().GetNextNumber()).NextNumberValue,
                    UnitOfMeasure         = item.UnitOfMeasure,
                    Quantity              = (int)item.OrderedQuantity,
                    UnitPrice             = item.UnitPrice,
                    DiscountPercent       = 0,
                    DiscountAmount        = 0,
                    SupplierId            = item.SupplierId,
                    SupplierName          = (await(invDetailMod.AddressBook.Query().GetEntityById((await invDetailMod.Supplier.Query().GetEntityById(item.SupplierId)).AddressId))).Name,
                    PurchaseOrderId       = item.PurchaseOrderId,
                    PurchaseOrderDetailId = item.PurchaseOrderDetailId,
                    ExtendedDescription   = item.LineDescription
                };
                listInvoiceDetailViews.Add(invoiceDetailView);
            }

            List <InvoiceDetail> listInvoiceDetails = (await invDetailMod.InvoiceDetail.Query().MapToEntity(listInvoiceDetailViews)).ToList <InvoiceDetail>();

            invDetailMod.InvoiceDetail.AddInvoiceDetails(listInvoiceDetails).Apply();


            IList <InvoiceDetail> listLookupInvoiceDetails = await invDetailMod.InvoiceDetail.Query().GetEntitiesByInvoiceId(newInvoice.InvoiceId);

            //Update Accounts Payable - by invoices associated to a po

            IList <Invoice> listInvoiceByPurchaseOrder = await invoiceMod.Invoice.Query().GetEntitiesByPurchaseOrderId(newPurchaseOrder.PurchaseOrderId);

            lookupAccountPayable.AmountOpen = lookupAccountPayable.GrossAmount - listInvoiceByPurchaseOrder.Sum(e => e.Amount);
            AccountPayableMod.AccountPayable.UpdateAccountPayable(lookupAccountPayable).Apply();

            //add to job costing PO
            JobCostLedgerModule JobCostLedgerMod = new JobCostLedgerModule();
            JobPhase            jobPhase2        = await JobMasterMod.JobPhase.Query().GetEntityByJobIdAndPhase(newJobMaster.JobMasterId, "Work Site Preparation - Safety");

            JobCostType jobCostTypeMisc = await JobMasterMod.JobCostType.Query().GetEntityById(2);

            JobCostType jobCostTypeMaterial = await JobMasterMod.JobCostType.Query().GetEntityById(1);

            IList <JobCostLedgerView> listJobCostLedgerView = new List <JobCostLedgerView>
            {
                new JobCostLedgerView()
                {
                    JobMasterId         = jobMaster.JobMasterId,
                    ContractId          = jobMaster.ContractId,
                    EstimatedHours      = 0,
                    EstimatedAmount     = 0,
                    JobPhaseId          = jobPhase2.JobPhaseId,
                    ActualHours         = 0,
                    ActualCost          = 0,
                    ProjectedHours      = 0,
                    CommittedHours      = 0,
                    PurchaseOrderId     = newPurchaseOrder.PurchaseOrderId,
                    SupplierId          = newPurchaseOrder.SupplierId,
                    CommittedAmount     = newPurchaseOrder.Amount,
                    Description         = newPurchaseOrder.Description,
                    TransactionType     = "PO",
                    Source              = "Job Costing",
                    JobCostTypeId       = jobCostTypeMisc.JobCostTypeId,
                    JobCostLedgerNumber = (await JobCostLedgerMod.JobCostLedger.Query().GetNextNumber()).NextNumberValue
                },
                new JobCostLedgerView()
                {
                    JobMasterId         = jobMaster.JobMasterId,
                    ContractId          = jobMaster.ContractId,
                    EstimatedHours      = 0,
                    EstimatedAmount     = 0,
                    JobPhaseId          = jobPhase2.JobPhaseId,
                    ActualHours         = 0,
                    ActualCost          = lookupAccountPayable.AmountPaid,
                    ProjectedHours      = 0,
                    CommittedHours      = 0,
                    PurchaseOrderId     = lookupAccountPayable.PurchaseOrderId,
                    SupplierId          = lookupAccountPayable.SupplierId,
                    CommittedAmount     = 0,
                    Description         = lookupAccountPayable.Description,
                    TransactionType     = "AP",
                    Source              = "Job Costing",
                    TaxAmount           = lookupAccountPayable.Tax,
                    JobCostTypeId       = jobCostTypeMaterial.JobCostTypeId,
                    JobCostLedgerNumber = (await JobCostLedgerMod.JobCostLedger.Query().GetNextNumber()).NextNumberValue
                }
            };

            IList <JobCostLedger> listJobCostLedger = await JobCostLedgerMod.JobCostLedger.Query().MapToEntity(listJobCostLedgerView);

            JobCostLedgerMod.JobCostLedger.AddJobCostLedgers(listJobCostLedger.ToList <JobCostLedger>()).Apply();


            //Create the general ledger entry
            //Create the supplier ledger entry
            //Create Pay Roll
            //Add Pay Roll to job costing


            invDetailMod.InvoiceDetail.DeleteInvoiceDetails((listLookupInvoiceDetails).ToList <InvoiceDetail>()).Apply();
            invoiceMod.Invoice.DeleteInvoice(newInvoice).Apply();
            AccountPayableMod.AccountPayable.DeleteAccountPayable(lookupAccountPayable).Apply();
            PurchaseOrderMod.PurchaseOrderDetail.DeletePurchaseOrderDetails(listPurchaseOrderDetail.ToList <PurchaseOrderDetail>()).Apply();
            JobMasterMod.JobPhase.DeleteJobPhases(listJobPhases.ToList <JobPhase>()).Apply();
            IList <JobPhase> lookupListJobPhases = await JobMasterMod.JobPhase.Query().GetEntitiesByJobMasterId(newJobMaster.JobMasterId);

            if (lookupListJobPhases.Count > 0)
            {
                Assert.True(false);
            }
            newJobMaster.JobDescription = "JobMaster Test Update";
            JobMasterMod.JobMaster.UpdateJobMaster(newJobMaster).Apply();
            JobMasterView updateView = await JobMasterMod.JobMaster.Query().GetViewById(newJobMaster.JobMasterId);

            Assert.Same(updateView.JobDescription, "JobMaster Test Update");
            JobMasterMod.JobMaster.DeleteJobMaster(newJobMaster).Apply();
            JobMaster lookupJobMaster = await JobMasterMod.JobMaster.Query().GetEntityById(view.JobMasterId);

            Assert.Null(lookupJobMaster);
        }
Example #21
0
 public IFluentJobMaster UpdateJobMaster(JobMaster updateObject)
 {
     unitOfWork.jobMasterRepository.UpdateObject(updateObject);
     this.processStatus = CreateProcessStatus.Update;
     return(this as IFluentJobMaster);
 }
Example #22
0
 public int Edit(JobMaster entity)
 {
     context.SbEdit(entity);
     return(context.SaveChanges());
 }
Example #23
0
 public int Add(JobMaster entity)
 {
     context.SbAdd(entity);
     return(context.SaveChanges());
 }
Example #24
0
        public decimal CalculateCompanyHSA(int UsageCode, decimal EmployeeHSA, JobMaster jobdetail)
        {
            bool    isHSAMatch      = Convert.ToBoolean(jobdetail.IsHSAMatch);
            decimal HSAMatchLimit1  = Convert.ToDecimal(jobdetail.HSAMatchLimit1);
            decimal HSAMatchRate1   = Convert.ToDecimal(jobdetail.HSAMatchRate1);
            decimal HSAMatchLimit2  = Convert.ToDecimal(jobdetail.HSAMatchLimit2);
            decimal HSAMatchRate2   = Convert.ToDecimal(jobdetail.HSAMatchRate2);
            decimal HSAMatchLimit3  = Convert.ToDecimal(jobdetail.HSAMatchLimit3);
            decimal HSAMatchRate3   = Convert.ToDecimal(jobdetail.HSAMatchRate3);
            decimal HSAMatchLimit4  = Convert.ToDecimal(jobdetail.HSAMatchLimit4);
            decimal HSAMatchRate4   = Convert.ToDecimal(jobdetail.HSAMatchRate4);
            decimal CompanyHSAMatch = 0;

            try
            {
                if (isHSAMatch)
                {
                    if (UsageCode == 1)
                    {
                        if (EmployeeHSA * HSAMatchRate1 > HSAMatchLimit1 * HSAMatchRate1)
                        {
                            CompanyHSAMatch = HSAMatchLimit1 * HSAMatchRate1;
                        }
                        else
                        {
                            CompanyHSAMatch = EmployeeHSA * HSAMatchRate1;
                        }
                    }
                    else if (UsageCode == 2)
                    {
                        if (EmployeeHSA * HSAMatchRate2 > HSAMatchLimit2 * HSAMatchRate2)
                        {
                            CompanyHSAMatch = HSAMatchLimit2 * HSAMatchRate2;
                        }
                        else
                        {
                            CompanyHSAMatch = EmployeeHSA * HSAMatchRate2;
                        }
                    }
                    else if (UsageCode == 3)
                    {
                        if (EmployeeHSA * HSAMatchRate3 > HSAMatchLimit3 * HSAMatchRate3)
                        {
                            CompanyHSAMatch = HSAMatchLimit3 * HSAMatchRate3;
                        }
                        else
                        {
                            CompanyHSAMatch = EmployeeHSA * HSAMatchRate3;
                        }
                    }
                    else
                    {
                        if (EmployeeHSA * HSAMatchRate4 > HSAMatchLimit4 * HSAMatchRate4)
                        {
                            CompanyHSAMatch = HSAMatchLimit4 * HSAMatchRate4;
                        }
                        else
                        {
                            CompanyHSAMatch = EmployeeHSA * HSAMatchRate4;
                        }
                    }
                }

                return(CompanyHSAMatch);
            }
            catch (Exception ex)
            {
                throw new System.Exception("Company HSA limit is not defined. ");
            }
        }
Example #25
0
 public IFluentJobMaster DeleteJobMaster(JobMaster deleteObject)
 {
     unitOfWork.jobMasterRepository.DeleteObject(deleteObject);
     this.processStatus = CreateProcessStatus.Delete;
     return(this as IFluentJobMaster);
 }