示例#1
0
        public Invoice Create(InvoiceModel model, InvoicerContext context)
        {
            Invoice result = new Invoice()
            {
                Id           = model.Id,
                BillCustomer = context.Customers.Find(model.BillCustomerId),
                ShipCustomer = context.Customers.Find(model.ShipCustomerId),
                Date         = model.Date,
                Other        = model.Other,
                Status       = model.Status,
                Entries      = new System.Collections.Generic.List <InvoiceEntry>()
            };
            double untaxedPrice = 0;

            foreach (var item in model.Entries)
            {
                InvoiceEntry invoiceEntry = Create(item, context, result);
                result.Entries.Add(invoiceEntry);
                untaxedPrice += invoiceEntry.Price;
            }

            //TODO: make tax configurable
            double taxedPrice = untaxedPrice + (untaxedPrice * 0.17);

            result.Total = taxedPrice + result.Other;
            result.Tax   = 17;

            return(result);
        }
示例#2
0
        private void createInvoiceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InvoiceEntry obj = new InvoiceEntry();

            obj.MdiParent = this;
            obj.Show();
        }
示例#3
0
 private void InvoiceEntry_Click(object sender, EventArgs e)
 {
     InvoiceEntry frmInvoiceEntry = new InvoiceEntry();
     frmInvoiceEntry.MdiParent = this;
     frmInvoiceEntry.WindowState = FormWindowState.Maximized;
     frmInvoiceEntry.Show();
 }
 private void GenerateJointChecks(IEnumerable <APAdjust> adjustments,
                                  PayBillsFilter filter, APInvoice invoice)
 {
     adjustments.ForEach(a => InitializeAdjustments(a, filter));
     InvoiceEntry.Clear();
     InvoiceJointPayeePayments = GetInsertedInvoiceJointPayeePayments(
         invoice.DocType, invoice.RefNbr).ToList();
     InvoiceEntry.Document.Current = invoice;
     InvoiceEntry.GetExtension <ApInvoiceEntryExt>().Initialize();
     CreateJointChecks(InvoiceJointPayeePayments);
 }
 private void GenerateVendorCheck(APInvoice invoice, IEnumerable <APAdjust> adjustments)
 {
     InvoiceEntry.Clear();
     SetVendorAmountToPay(invoice, adjustments);
     InvoiceJointPayeePayments     = GetInsertedInvoiceJointPayeePayments(invoice.DocType, invoice.RefNbr).ToList();
     InvoiceEntry.Document.Current = invoice;
     InitializeComplianceDocuments();
     GenerateVendorCheck();
     InvoiceEntry.Views.Caches.Add(typeof(JointPayeePayment));
     InvoiceEntry.Persist();
 }
        public override APPayment CreateJointChecks(List <JointPayeePayment> jointPayeePayments)
        {
            JointPayeePayments.Cache.Clear();
            var jointChecks = GenerateJointChecks();

            InvoiceEntry.Views.Caches.Add(typeof(JointPayeePayment));
            InvoiceEntry.Persist();
            MarkPaymentForLienWaiverGeneration(true);
            PaymentEntry.Persist();
            return(jointChecks.FirstOrDefault());
        }
示例#7
0
        static List <InvoiceEntry> LoadRawData()
        {
            Console.WriteLine($"Loading workbook {_settings.InputDocumentPath}");
            Console.WriteLine("This might take a while ^^");

            using (var workbook = new XLWorkbook(_settings.InputDocumentPath))
            {
                Console.WriteLine($"{_settings.InputDocumentPath} loaded.");

                foreach (var sheet in workbook.Worksheets)
                {
                    Console.WriteLine($"Processing sheet {sheet.Name}");

                    Settings.EntriesWorksheetColumns sheetSettings;
                    if (!_settings.Worksheets.TryGetValue(sheet.Name, out sheetSettings))
                    {
                        Console.WriteLine($"{sheet.Name}, skipped, not found in settings file");
                        continue;
                    }

                    var rowCount   = sheet.RowCount();
                    var currentRow = sheetSettings.FirstRow;
                    while (currentRow <= rowCount &&
                           !string.IsNullOrEmpty(sheet.Cell(currentRow, "A").GetString()))
                    {
                        Console.WriteLine($"Processing row {currentRow}");

                        var invoiceEntry = new InvoiceEntry
                        {
                            Date            = sheet.Cell(currentRow, sheetSettings.Date).GetString(),
                            InvoiceId       = sheet.Cell(currentRow, sheetSettings.InvoiceId).GetString(),
                            ClientId        = sheet.Cell(currentRow, sheetSettings.ClientId).GetString(),
                            ItemId          = sheet.Cell(currentRow, sheetSettings.ItemId).GetString(),
                            ItemDescription = sheet.Cell(currentRow, sheetSettings.ItemDescription).GetString(),
                            Amount          = sheet.Cell(currentRow, sheetSettings.Amount).GetDouble(),
                            Assesed         = sheet.Cell(currentRow, sheetSettings.Assessed).GetDouble(),
                        };

                        _allEntries.Add(invoiceEntry);

                        if (!_clients.ContainsKey(invoiceEntry.ClientId))
                        {
                            _clients[invoiceEntry.ClientId] = new AssesedClient(invoiceEntry.ClientId);
                        }
                        _clients[invoiceEntry.ClientId].AddEntry(invoiceEntry);

                        currentRow++;
                    }

                    Console.WriteLine($"{sheet.Name} done. Processed {currentRow - sheetSettings.FirstRow + 1} rows.");
                }
            }
            return(_allEntries);
        }
 public void GenerateChecks(APInvoice invoice, IReadOnlyCollection <APAdjust> adjustments, PayBillsFilter filter)
 {
     using (var scope = new PXTransactionScope())
     {
         LineNumbers = adjustments.Select(adj => adj.AdjdLineNbr);
         GenerateVendorCheck(invoice, adjustments);
         GenerateJointChecks(adjustments, filter, invoice);
         ComplianceDocumentsService.ClearLinkToPaymentFlag(ComplianceDocuments);
         OpenPaymentCycleWorkflow();
         InvoiceEntry.Caches <ComplianceDocumentReference>().Persist(PXDBOperation.Delete);
         scope.Complete();
     }
 }
示例#9
0
        public InvoiceEntry Create(InvoiceEntryModel model, InvoicerContext context, Invoice invoice)
        {
            InvoiceEntry result = new InvoiceEntry()
            {
                Id       = model.Id,
                Article  = context.Articles.Find(model.Article),
                Invoice  = invoice,
                Quantity = model.Quantity
            };

            result.Price = result.Quantity * result.Article.Price;
            return(result);
        }
示例#10
0
        public async Task <int> AddUpdateInvoiceEntry(int CompanyId, InvoiceEntry invoiceEntry)
        {
            InvoiceDetail invoiceDetail = new InvoiceDetail();

            if (invoiceEntry.InvoiceParticularId > 0)
            {
                var existingParticular = await _dbContext.InvoiceParticulars.Where(_ =>
                                                                                   _.Id == invoiceEntry.InvoiceParticularId).FirstOrDefaultAsync();

                existingParticular.Amount      = invoiceEntry.Amount;
                existingParticular.year        = invoiceEntry.Year;
                existingParticular.CreatedDate = invoiceEntry.CreatedDate ?? DateTime.Now;
                existingParticular.UpdatedDate = DateTime.Now;
            }
            else
            {
                if (invoiceEntry.InvoiceId > 0)
                {
                    invoiceDetail = await _dbContext.InvoiceDetails.Where(_ => _.Id == invoiceEntry.InvoiceId).FirstOrDefaultAsync();

                    invoiceDetail.Remarks = invoiceEntry.Remarks;
                }
                else
                {
                    invoiceDetail.ClientId       = invoiceEntry.ClientId;
                    invoiceDetail.CompanyId      = invoiceEntry.CompanyId;
                    invoiceDetail.Invoice_Number = GenerateInvoiceNumber((int)invoiceDetail.CompanyId, invoiceEntry.InvoiceDate);
                    invoiceDetail.UpdatedDate    = DateTime.Now;
                    invoiceDetail.CreatedDate    = DateTime.Now;
                    invoiceDetail.InvoiceDate    = invoiceEntry.InvoiceDate;
                    invoiceDetail.CreatedBy      = Convert.ToInt32(SessionHelper.UserId);
                    invoiceDetail.Remarks        = invoiceEntry.Remarks;
                    _dbContext.InvoiceDetails.Add(invoiceDetail);
                    await _dbContext.SaveChangesAsync();
                }

                InvoiceParticular invoiceParticular = new InvoiceParticular();
                invoiceParticular.Amount       = invoiceEntry.Amount;
                invoiceParticular.year         = invoiceEntry.Year;
                invoiceParticular.CreatedDate  = DateTime.Now;
                invoiceParticular.UpdatedDate  = DateTime.Now;
                invoiceParticular.InvoiceId    = invoiceDetail.Id;
                invoiceParticular.ParticularId = invoiceEntry.ParticularId;
                invoiceParticular.CreatedBy    = Convert.ToInt32(SessionHelper.UserId);

                _dbContext.InvoiceParticulars.Add(invoiceParticular);
            }
            await _dbContext.SaveChangesAsync();

            return(Convert.ToInt32(invoiceDetail.Id));
        }
示例#11
0
 //  Creates a new invoice entry (InvoiceEntry object ) and add it to the invoice.
 public bool addInvEntry(Item sku, int AIDQnty)
 {
     if (sku.updateAvlblQty(AIDQnty) == true) // If the available quantity is >= 0, get the price and add it to the list.
     {
         InvoiceEntry num = new InvoiceEntry(sku, invNums, AIDQnty);
         updateTotal(sku.getPrice());
         itemList.Add(num);
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#12
0
 //method to add inventory item
 public bool addInvEntry(Item a, int ReqQuantity)
 {
     if (a.updateAvlblQty(ReqQuantity) == true)
     {
         InvoiceEntry name = new InvoiceEntry(a, i, ReqQuantity);
         updateTotal(a.getPrice());
         itemList.Add(name);
         i++;
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#13
0
    public bool addInvEntry(Item i, int ReqQuantity)
    {
        if (i.getAvlblQnty() >= ReqQuantity)
        {
            i.updateAvlbQty(ReqQuantity * -1);
            InvoiceEntry x = new InvoiceEntry(entry.Count, ReqQuantity, i);
            entry.Add(x);
            return(true);
        }

        else
        {
            return(false);
        }
    }
示例#14
0
        public InvoiceEntry CreateNewInvoiceEntry(AddInvoiceEntryModel model)
        {
            var newInvoiceEntry = new InvoiceEntry
            {
                Amount       = model.Amount,
                CreationDate = model.CreationDate,
                InvoiceId    = model.InvoiceId,
                Subject      = model.Subject
            };

            _dbContext.Add(newInvoiceEntry);

            _dbContext.SaveChanges();

            return(newInvoiceEntry);
        }
示例#15
0
    public bool removeInvEntry(int l)
    {
        InvoiceEntry toRemove = null;

        foreach (InvoiceEntry i in entry)
        {
            if (i.getLine() == l)
            {
                toRemove = i;
            }
        }
        entry.Remove(toRemove);

        if (toRemove != null)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }