コード例 #1
0
        public async Task <IActionResult> Edit(string id, [Bind("VendorPaymentId,CashRepositoryId,EmployeeId,PaymentAmount,PaymentDate,PaymentNumber,PaymentTypeId,createdAt,purchaseOrderId")] VendorPayment vendorPayment)
        {
            if (id != vendorPayment.VendorPaymentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vendorPayment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VendorPaymentExists(vendorPayment.VendorPaymentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CashRepositoryId"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName", vendorPayment.CashRepositoryId);
            ViewData["EmployeeId"]       = new SelectList(_context.Employee, "EmployeeId", "DisplayName", vendorPayment.EmployeeId);
            ViewData["PaymentTypeId"]    = new SelectList(_context.PaymentType, "PaymentTypeId", "PaymentTypeName", vendorPayment.PaymentTypeId);
            ViewData["purchaseOrderId"]  = new SelectList(_context.PurchaseOrder, "purchaseOrderId", "purchaseOrderNumber", vendorPayment.purchaseOrderId);
            return(View(vendorPayment));
        }
コード例 #2
0
        /// <summary>
        /// Categorize an Uncategorized transaction as vendor payment.
        /// </summary>
        /// <param name="transactionId">The id of the transaction.</param>
        /// <param name="vendorPayment">The vendor payment data to use.</param>
        /// <returns>A response indicating whether the request was successful.</returns>
        public async Task <bool> CategorizeAsVendorPayment(string transactionId, VendorPayment vendorPayment)
        {
            // TODO Double check this for missing fields - https://www.zoho.com/books/api/v3/#Bank-Transactions_Categorize_as_expense
            var response = await PostDataAsync <VendorPayment, ZohoBooksMessage>
                               (string.Format("uncategorized/{0}/categorize/expenses", transactionId), vendorPayment, OrganizationIdFilter);

            return(response.Code == 0);
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("VendorPaymentId,CashRepositoryId,EmployeeId,PaymentAmount,PaymentDate,PaymentNumber,PaymentTypeId,createdAt,purchaseOrderId")] VendorPayment vendorPayment)
        {
            var username       = HttpContext.User.Identity.Name;
            var cashrepository = await _context.CashRepository.Where(x => x.CashRepositoryId == vendorPayment.CashRepositoryId).FirstOrDefaultAsync();

            if (cashrepository.Balance < vendorPayment.PaymentAmount)
            {
                TempData["StatusMessage"] = "Σφάλμα. Υπάρχει πρόβλημα στα ταμειακά διαθέσιμα. Το υπόλοιπο του ταμείου σας (" + cashrepository.Balance + "€), δεν επαρκεί για να καλύψει το ποσόν της πληρωμής(" + vendorPayment.PaymentAmount + "€). Αλλάξτε ταμείο ή πληρώστε λιγότερα.";
                return(RedirectToAction(nameof(Create)));
            }
            if (ModelState.IsValid)
            {
                vendorPayment.PaymentNumber = _numberSequence.GetNumberSequence("ΠΛΠ");
                _context.Add(vendorPayment);
                await _context.SaveChangesAsync();

                var purchaseorder = await _context.PurchaseOrder
                                    .Include(p => p.vendorPayment)
                                    .SingleOrDefaultAsync(m => m.purchaseOrderId == vendorPayment.purchaseOrderId);

                purchaseorder.totalVendorPayment = purchaseorder.vendorPayment.Sum(x => x.PaymentAmount);
                purchaseorder.InvoiceBalance     = purchaseorder.totalOrderAmount - purchaseorder.totalVendorPayment;

                if (purchaseorder.InvoiceBalance == 0)
                {
                    purchaseorder.Paid = true;
                }
                _context.Update(purchaseorder);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "purchaseOrder", new { id = purchaseorder.purchaseOrderId }));
            }
            var query =
                from PurchaseOrder in _context.PurchaseOrder
                select new
            {
                PurchaseOrder.purchaseOrderId,
                description = (PurchaseOrder.purchaseOrderNumber + " (" + PurchaseOrder.vendor.vendorName + ")"),
                PurchaseOrder.Paid
            };

            ViewData["purchaseOrderId"]  = new SelectList(query.Where(x => x.Paid == false), "purchaseOrderId", "description", vendorPayment.purchaseOrderId);
            ViewData["PaymentTypeId"]    = new SelectList(_context.PaymentType, "PaymentTypeId", "PaymentTypeName", vendorPayment.PaymentTypeId);
            ViewData["employeeId"]       = new SelectList(_context.Employee, "EmployeeId", "DisplayName");
            ViewData["CashRepositoryId"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName");

            if (!(HttpContext.User.IsInRole("ApplicationUser") || HttpContext.User.IsInRole("Secretary")))
            {
                ViewData["EmployeeId"]       = new SelectList(_context.Employee.Where(x => x.PaymentReceiver == true && x.UserName == username), "EmployeeId", "DisplayName");
                ViewData["CashRepositoryId"] = new SelectList(_context.CashRepository.Where(x => x.Employee.UserName == username), "CashRepositoryId", "CashRepositoryName");
            }
            return(View(vendorPayment));
        }
コード例 #4
0
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                var vendorPaymentsApi = service.GetVendorPaymentsApi();
                var parameters        = new Dictionary <object, object>();
                parameters.Add("filter_by", "PaymentMode.BankTransfer");
                var vendorpayments  = vendorPaymentsApi.GetVendorPayments(parameters);
                var vendorPaymentId = vendorpayments[1].payment_id;
                if (vendorpayments != null)
                {
                    foreach (var vendorpayment in vendorpayments)
                    {
                        Console.WriteLine("{0},{1},{2}", vendorpayment.payment_id, vendorpayment.vendor_id, vendorpayment.amount);
                    }
                }
                var vendorpayment1 = vendorPaymentsApi.Get(vendorPaymentId);
                if (vendorpayment1 != null)
                {
                    Console.WriteLine("{0},{1},{2}", vendorpayment1.payment_id, vendorpayment1.vendor_id, vendorpayment1.amount);
                }

                var newVendorPaymentInfo = new VendorPayment()
                {
                    vendor_id = "{vendor id}",
                    amount    = 1560,
                };
                var newVendorPayment = vendorPaymentsApi.Create(newVendorPaymentInfo);

                if (newVendorPayment != null)
                {
                    Console.WriteLine("{0},{1},{2}", newVendorPayment.payment_id, newVendorPayment.vendor_id, newVendorPayment.amount);
                }
                var updateinfo = new VendorPayment()
                {
                    amount = 10
                };
                var updatedVendorPayment = vendorPaymentsApi.Update(vendorPaymentId, updateinfo);
                if (updatedVendorPayment != null)
                {
                    Console.WriteLine("{0},{1},{2}", updatedVendorPayment.payment_id, updatedVendorPayment.vendor_id, updatedVendorPayment.amount);
                }
                var delvendorpayments = vendorPaymentsApi.Delete(vendorpayments[3].payment_id);
                Console.WriteLine(delvendorpayments);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
コード例 #5
0
        // GET: VendorPayment/Create
        public IActionResult Create(string id)
        {
            ViewData["StatusMessage"] = TempData["StatusMessage"];
            VendorPayment vp       = new VendorPayment();
            var           username = HttpContext.User.Identity.Name;

            var purchaseorder = (
                from PurchaseOrder in _context.PurchaseOrder
                select new
            {
                PurchaseOrder.purchaseOrderId,
                description = (PurchaseOrder.purchaseOrderNumber + " (" + PurchaseOrder.vendor.vendorName + ")"),
                PurchaseOrder.Paid,
                PurchaseOrder.InvoiceBalance,
            }).ToList();

            purchaseorder.Insert(0,
                                 new
            {
                purchaseOrderId = "0000",
                description     = "Επιλέξτε",
                Paid            = false,
                InvoiceBalance  = 0.0m
            });
            var employee = (from Employee in _context.Employee
                            select new
            {
                Employee.EmployeeId,
                Employee.DisplayName,
                Employee.UserName,
                Employee.PaymentReceiver
            }).ToList();

            employee.Insert(0,
                            new
            {
                EmployeeId      = "0000",
                DisplayName     = "Επιλέξτε",
                UserName        = "",
                PaymentReceiver = true
            });
            if (id != null)
            {
                ViewData["purchaseOrderId"] = new SelectList(purchaseorder, "purchaseOrderId", "description", id);
                vp.PaymentDate     = DateTime.Today;
                vp.purchaseOrderId = id;
                vp.PaymentAmount   = _context.PurchaseOrder.Where(x => x.purchaseOrderId == id).FirstOrDefault().InvoiceBalance;
            }
            else
            {
                ViewData["purchaseOrderId"] = new SelectList(purchaseorder, "purchaseOrderId", "description");
            }

            var cashrepository          = _context.CashRepository.Include(x => x.Employee).Where(x => x.MainRepository == true).FirstOrDefault();
            List <PurchaseOrder> poList = _context.PurchaseOrder.Where(x => x.purchaseOrderStatus == PurchaseOrderStatus.Completed && x.Paid == false).ToList();

            poList.Insert(0, new PurchaseOrder {
                purchaseOrderId = "0", purchaseOrderNumber = "Επιλέξτε"
            });

            ViewData["CashRepositoryId"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName", cashrepository.CashRepositoryId);
            ViewData["EmployeeId"]       = new SelectList(_context.Employee, "EmployeeId", "DisplayName", cashrepository.Employee.EmployeeId);
            ViewData["PaymentTypeId"]    = new SelectList(_context.PaymentType, "PaymentTypeId", "PaymentTypeName");
            ViewData["purchaseOrderId"]  = new SelectList(poList, "purchaseOrderId", "purchaseOrderNumber");
            vp.PaymentDate = DateTime.Today;
            return(View(vp));
        }