public async Task <bool> GenerateInvoice(List <ProductSale> saleItems, int noOfItems, double totalAmount)
        {
            var invoiceNumber = await _tupleDetailsService.GetCount(TupleNames.CustomerInvoice);

            var invoiceDetailNumber = await _tupleDetailsService.GetCount(TupleNames.CustomerInvoiceDetails);

            invoiceNumber++;
            var customerId = saleItems[0].CustomerId;

            var invoiceQuery = $"INSERT INTO `ps_cus_invoice` VALUES ('{invoiceNumber}','','{customerId}','{totalAmount}','{noOfItems}');";
            await _dbContext.ExecuteQueryAsync(invoiceQuery);

            await Task.Delay(100);

            foreach (var item in saleItems)
            {
                invoiceDetailNumber++;
                var invoiceDetailQuery = $"INSERT INTO `ps_cus_inovoice_details` VALUES ('{invoiceDetailNumber}','{invoiceNumber}','{item.ProductId}','{item.Amount}','{item.Qty}');";
                await _dbContext.ExecuteQueryAsync(invoiceDetailQuery);

                await Task.Delay(100);

                await _productService.UpdateQty(item.ProductId, item.Qty);

                await Task.Delay(100);
            }

            await _transactionService.IncomeTransaction(Convert.ToInt32(totalAmount).ToString(), invoiceNumber.ToString());

            await _tupleDetailsService.UpdateCount(TupleNames.CustomerInvoice, invoiceNumber);

            return(await _tupleDetailsService.UpdateCount(TupleNames.CustomerInvoiceDetails, invoiceDetailNumber));
        }
        public async Task <bool> SaveAsync(List <ProductPurchase> products, int noOfItems, double totalAmount)
        {
            var invoiceNo = await _tupleDetailsService.GetCount(TupleNames.VendorInvoice);

            var invoiceDetailNo = await _tupleDetailsService.GetCount(TupleNames.VendorInvoiceDetails);

            invoiceNo++;
            var vendorId = products[0].VendorId;

            var invoiceQuery = $"INSERT INTO `ps_vn_invoice` VALUES ('{invoiceNo}','','{totalAmount}','{noOfItems}','{vendorId}');";
            await _dbContext.ExecuteQueryAsync(invoiceQuery);

            await Task.Delay(100);

            foreach (var product in products)
            {
                invoiceDetailNo++;
                var invoiceDetailQuery = $"INSERT INTO `ps_vn_invoice_details` VALUES ('{invoiceDetailNo}','{invoiceNo}','{product.ProductId}','{product.Qty}','{product.Amount}','');";
                await _dbContext.ExecuteQueryAsync(invoiceDetailQuery);

                await Task.Delay(100);

                await _productService.UpdateQtyAndPrice(product.ProductId, product.Qty, product.UnitPrice);
            }

            await _transactionService.ExpenseTransaction(totalAmount.ToString(CultureInfo.InvariantCulture), invoiceNo.ToString());

            await _tupleDetailsService.UpdateCount(TupleNames.VendorInvoice, invoiceNo);

            return(await _tupleDetailsService.UpdateCount(TupleNames.VendorInvoiceDetails, invoiceDetailNo));
        }
Beispiel #3
0
        public async Task <bool> SaveAsync(AccountTransaction model)
        {
            var transactionId = await _tupleDetailsService.GetCount(TupleNames.AccountTransaction); transactionId++;
            var query         = $"INSERT INTO `ps_ac_accounttransaction` VALUES ('{transactionId}','{model.Description}',sysdate(),'{model.AccountId}','{model.InvoiceId}','{model.Amount}');";
            await _dbContext.ExecuteQueryAsync(query); await Task.Delay(100);

            return(await _tupleDetailsService.UpdateCount(TupleNames.AccountTransaction, transactionId));
        }
        public async Task <bool> SaveAsync(Account model)
        {
            var accountNumber = await _tupeDetailsService.GetCount(TupleNames.Account);

            accountNumber++;
            var query = $"INSERT INTO `ps_ac_account` VALUES ('{accountNumber}','{model.Description}','{model.Active}','{model.TypeId}');";
            await _dbContext.ExecuteQueryAsync(query);

            await Task.Delay(100);

            return(await _tupeDetailsService.UpdateCount(TupleNames.Account, accountNumber));
        }
Beispiel #5
0
        public async Task <bool> SaveAsync(List <NameValuePair <bool> > menIds, string id)
        {
            var count = await _tupleDetailsService.GetCount(TupleNames.UserAccess);

            var deleteQuery = $"Delete From ps_us_userpermissions WHERE userId='{id}'";
            await _dbContext.ExecuteQueryAsync(deleteQuery);

            await Task.Delay(100);

            foreach (var menId in menIds)
            {
                count++;
                var query = $"INSERT INTO ps_us_userpermissions VALUES ('{id}','{menId.Name}', '{count}')";
                await _dbContext.ExecuteQueryAsync(query);

                await Task.Delay(100);
            }

            return(await _tupleDetailsService.UpdateCount(TupleNames.UserAccess, count));
        }