public static string GetDescription(InventoryTransactionType type)
        {
            switch (type)
            {
            case InventoryTransactionType.ReceiveTreatmentOrder: return("Received inventory treatment order.");

            case InventoryTransactionType.ReceiveInventory: return("Received inventory.");

            case InventoryTransactionType.ProductionResults: return("Production results.");

            case InventoryTransactionType.InventoryAdjustment: return("Adjusted inventory.");

            case InventoryTransactionType.CreatedMillAndWetdown: return("Created mill and wetdown.");

            case InventoryTransactionType.ReceivedDehydratedMaterials: return("Dehydrated materials received.");

            case InventoryTransactionType.ReceivedOtherMaterials: return("Other raw materials received.");

            case InventoryTransactionType.InternalMovement: return("Internal movement.");

            case InventoryTransactionType.PickedForBatch: return("Picked for Production Batch.");

            case InventoryTransactionType.PostedInterWarehouseOrder:
            case InventoryTransactionType.PostedTreatmentOrder:
            case InventoryTransactionType.PostedCustomerOrder:
            case InventoryTransactionType.PostedMiscellaneousOrder:
                return("Posted order.");

            default: throw new ArgumentOutOfRangeException("type");
            }
        }
Example #2
0
        public static bool ValidateTransactionAction(string palletNo, InventoryTransactionType transAction, string invoiceNo = "")
        {
            if (transAction == InventoryTransactionType.Add)
            {
                if (string.IsNullOrEmpty(palletNo))
                {
                    ShowMessage("Either PalletNo/InvoiceNo is empty !", MessageBoxIcon.Warning);
                    return(false);
                }
                if (!InventoryRepository.ValidateInvoiceTransaction(palletNo, transAction))
                {
                    ShowMessage("Pallet Number already exist ! Please try different one", MessageBoxIcon.Error);
                    return(false);
                }
            }
            else if (transAction == InventoryTransactionType.Restore)
            {
                if (string.IsNullOrEmpty(palletNo) || string.IsNullOrEmpty(invoiceNo))
                {
                    ShowMessage("Either PalletNo/InvoiceNo is empty !", MessageBoxIcon.Warning);
                    return(false);
                }
                if (!InventoryRepository.ValidateInvoiceTransaction(palletNo, transAction, invoiceNo))
                {
                    ShowMessage("Pallet Number or Invoice Number already exist ! Please try different one", MessageBoxIcon.Error);
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
        public async Task <IActionResult> PutInventoryTransactionType(int id, InventoryTransactionType inventoryTransactionType)
        {
            if (id != inventoryTransactionType.InventoryTransactionTypeId)
            {
                return(BadRequest());
            }

            _context.Entry(inventoryTransactionType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InventoryTransactionTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #4
0
 public InventoryTransactionParameters(IEmployeeKey employeeKey, DateTime timeStamp, InventoryTransactionType transactionType, string sourceReference, ILotKey destinationLotKey = null)
 {
     EmployeeKey       = employeeKey;
     TimeStamp         = timeStamp;
     TransactionType   = transactionType;
     Description       = InventoryTransactionsHelper.GetDescription(transactionType);
     SourceReference   = sourceReference;
     DestinationLotKey = destinationLotKey;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static InventoryTransactionTypeViewModel ToViewModel(this InventoryTransactionType entity)
        {
            return(entity == null ? null : new InventoryTransactionTypeViewModel
            {
                Id = entity.Id,
                Type_Name = entity.Type_Name



                            //
                            //RowGuid = entity.RowGuid,
                            //ModifiedDate = entity.ModifiedDate
            });
        }
Example #6
0
        public static bool ValidateInvoiceTransaction(string palletnumber, InventoryTransactionType transType, string invoiceNumber = "$$$$")
        {
            bool            valid          = false;
            OleDbConnection repoConnection = null;

            try
            {
                repoConnection = DBConnection.OpenConnection();
                OleDbCommand cmd = null;
                if (transType == InventoryTransactionType.Add)
                {
                    cmd = new OleDbCommand(
                        string.Format("SELECT count(*) from InventoryDailyFActs where PalletNo='{0}'", palletnumber),
                        repoConnection);
                }
                else
                {
                    cmd = new OleDbCommand(
                        string.Format("SELECT count(*) from InventoryDailyFActs where InvoiceNo='{0}'", invoiceNumber),
                        repoConnection);
                }
                int count = Convert.ToInt32(cmd.ExecuteScalar());
                if (count > 0)
                {
                    valid = false;
                }
                else
                {
                    valid = true;
                }
            }
            catch (Exception exp)
            {
                RepoLogger.LogMsg(LogModes.REPO, LogLevel.ERROR,
                                  "Error while Getting ValidateInvoiceTransaction - " + exp.Message + " StackTrace:- " + exp.StackTrace);
                throw;
            }
            finally
            {
                DBConnection.CloseConnection(repoConnection);
            }
            return(valid);
        }
Example #7
0
        /// <summary>
        /// 收货取消
        /// </summary>
        /// <param name="warehouseId"></param>
        /// <param name="productId"></param>
        /// <param name="merchantId"></param>
        /// <param name="qtyReceipt"></param>
        /// <param name="isOpenTrans"></param>
        /// <returns></returns>
        public bool UpdateInventoryByUnReceive(string sourceNo, InventoryTransactionType type, string warehouseId, string productId, string merchantId, int qtyReceipt,
                                               DbTransaction isOpenTrans)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(
                @"UPDATE [Inventory] SET QtyOnHand = QtyOnHand - @QtyReceipt, QtyAllocated = QtyAllocated - @QtyReceipt");
            strSql.Append(" WHERE ProductId = @ProductId");
            strSql.Append(" AND WarehouseId = @WarehouseId");
            strSql.Append(" AND MerchantId = @MerchantId ");
            strSql.Append(" AND QtyOnHand - @QtyReceipt >= 0");

            var updateParameters = new List <DbParameter>
            {
                DbFactory.CreateDbParameter("@WarehouseId", warehouseId),
                DbFactory.CreateDbParameter("@ProductId", productId),
                DbFactory.CreateDbParameter("@MerchantId", merchantId),
                DbFactory.CreateDbParameter("@QtyReceipt", qtyReceipt)
            };

            InventoryTransactionEntity transaction = new InventoryTransactionEntity();

            transaction.Create();
            transaction.Type         = (int)type;
            transaction.WarehouseId  = warehouseId;
            transaction.ProductId    = productId;
            transaction.MerchantFrom = merchantId;
            transaction.MerchantTo   = merchantId;
            transaction.Qty          = -1 * qtyReceipt;
            transaction.SourceNo     = sourceNo;

            var isOK = new InventoryTransactionBLL().InsertTransaction(transaction, isOpenTrans);

            if (isOK)
            {
                return(Repository().ExecuteBySql(strSql, updateParameters.ToArray(), isOpenTrans) > 0);
            }
            else
            {
                return(false);
            }
        }
Example #8
0
 private bool ValidateNullValues(InventoryItem item, InventoryTransactionType transAction)
 {
     lblReqPartnumber.Visible = false;
     lblQuantity.Visible      = false;
     lblReqPartnumber.Visible = false;
     lblReqPartnumber.Visible = false;
     if (string.IsNullOrEmpty(item.PartNumber))
     {
         ShowMessage("PartNumber should not empty", MessageBoxIcon.Warning);
         lblReqPartnumber.Visible = true;
         return(false);
     }
     if (item.CurrentStock <= 0)
     {
         ShowMessage("Quantity should be greater than Zero", MessageBoxIcon.Warning);
         lblQuantity.Visible = true;
         return(false);
     }
     if (transAction == InventoryTransactionType.Add || transAction == InventoryTransactionType.Restore)
     {
         if (string.IsNullOrEmpty(item.PalletNo))
         {
             ShowMessage("Palletnumber should not empty", MessageBoxIcon.Warning);
             lblReqPalletNumber.Visible = true;
             return(false);
         }
     }
     if (transAction == InventoryTransactionType.Restore)
     {
         if (item.InvoiceNo != null && string.IsNullOrEmpty(item.InvoiceNo))
         {
             ShowMessage("Invoice Number should not be empty", MessageBoxIcon.Warning);
             lblReqInvoiceNumber.Visible = true;
             return(false);
         }
     }
     lblReqPartnumber.Visible = true;
     lblQuantity.Visible      = true;
     lblReqPartnumber.Visible = true;
     lblReqPartnumber.Visible = true;
     return(true);
 }
        public void Create(DataCreationService dataCreationService, IWorkspace workspace)
        {
            this._workspace = workspace;
            var saleAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Sales)
            };
            var receivableAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Receiveable)
            };
            var paymentAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Payment)
            };
            var discountAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Discount)
            };
            var customerAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Customer)
            };

            _workspace.Add(receivableAccountType);
            _workspace.Add(saleAccountType);
            _workspace.Add(paymentAccountType);
            _workspace.Add(discountAccountType);
            _workspace.Add(customerAccountType);
            _workspace.CommitChanges();

            var customerEntityType = new EntityType {
                Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name
            };

            customerEntityType.EntityCustomFields.Add(new EntityCustomField {
                EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone
            });
            customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]";
            //var tableEntityType = new EntityType { Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name };

            _workspace.Add(customerEntityType);
            //_workspace.Add(tableEntityType);

            _workspace.CommitChanges();

            var accountScreen = new AccountScreen {
                Name = Resources.General
            };

            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40
            });
            _workspace.Add(accountScreen);

            var defaultSaleAccount = new Account {
                AccountTypeId = saleAccountType.Id, Name = Resources.Sales
            };
            var defaultReceivableAccount = new Account {
                AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables
            };
            var cashAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Cash
            };
            var creditCardAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard
            };
            var voucherAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher
            };
            var defaultDiscountAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Discount
            };
            var defaultRoundingAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Rounding
            };

            _workspace.Add(defaultSaleAccount);
            _workspace.Add(defaultReceivableAccount);
            _workspace.Add(defaultDiscountAccount);
            _workspace.Add(defaultRoundingAccount);
            _workspace.Add(cashAccount);
            _workspace.Add(creditCardAccount);
            _workspace.Add(voucherAccount);

            _workspace.CommitChanges();

            var discountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Discount),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultDiscountAccount.Id
            };

            var roundingTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Rounding),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultRoundingAccount.Id
            };

            var saleTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Sale),
                SourceAccountTypeId    = saleAccountType.Id,
                TargetAccountTypeId    = receivableAccountType.Id,
                DefaultSourceAccountId = defaultSaleAccount.Id,
                DefaultTargetAccountId = defaultReceivableAccount.Id
            };

            var paymentTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Payment),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerAccountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.AccountTransaction),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = customerAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id
            };

            var customerCashPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CashPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerCreditCardPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = creditCardAccount.Id
            };

            _workspace.Add(saleTransactionType);
            _workspace.Add(paymentTransactionType);
            _workspace.Add(discountTransactionType);
            _workspace.Add(roundingTransactionType);
            _workspace.Add(customerAccountTransactionType);
            _workspace.Add(customerCashPaymentType);
            _workspace.Add(customerCreditCardPaymentType);

            var discountService = new CalculationType
            {
                AccountTransactionType = discountTransactionType,
                CalculationMethod      = 0,
                DecreaseAmount         = true,
                Name = Resources.Discount
            };

            var roundingService = new CalculationType
            {
                AccountTransactionType = roundingTransactionType,
                CalculationMethod      = 2,
                DecreaseAmount         = true,
                IncludeTax             = true,
                Name = Resources.Round
            };

            var discountSelector = new CalculationSelector {
                Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign
            };

            discountSelector.CalculationTypes.Add(discountService);
            discountSelector.AddCalculationSelectorMap();

            var roundingSelector = new CalculationSelector {
                Name = Resources.Round, ButtonHeader = Resources.Round
            };

            roundingSelector.CalculationTypes.Add(roundingService);
            roundingSelector.AddCalculationSelectorMap();


            _workspace.Add(discountService);
            _workspace.Add(roundingService);
            _workspace.Add(discountSelector);
            _workspace.Add(roundingSelector);

            var screen = new ScreenMenu();

            _workspace.Add(screen);

            var ticketNumerator = new Numerator {
                Name = Resources.TicketNumerator
            };

            _workspace.Add(ticketNumerator);

            var orderNumerator = new Numerator {
                Name = Resources.OrderNumerator
            };

            _workspace.Add(orderNumerator);



            _workspace.CommitChanges();

            var ticketType = new TicketType
            {
                Name                = Resources.Ticket,
                TicketNumerator     = ticketNumerator,
                OrderNumerator      = orderNumerator,
                SaleTransactionType = saleTransactionType,
                ScreenMenuId        = screen.Id,
            };

            ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment {
                EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20
            });

            var cashPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = cashAccount,
                Name    = cashAccount.Name
            };

            cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var creditCardPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = creditCardAccount,
                Name    = creditCardAccount.Name
            };

            creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var voucherPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = voucherAccount,
                Name    = voucherAccount.Name
            };

            voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var accountPayment = new PaymentType
            {
                AccountTransactionType = customerAccountTransactionType,
                Name = Resources.CustomerAccount
            };

            accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            _workspace.Add(cashPayment);
            _workspace.Add(creditCardPayment);
            _workspace.Add(voucherPayment);
            _workspace.Add(accountPayment);
            _workspace.Add(ticketType);

            var warehouseType = new WarehouseType {
                Name = Resources.Warehouses
            };

            _workspace.Add(warehouseType);
            _workspace.CommitChanges();

            var localWarehouse = new Warehouse
            {
                Name            = Resources.LocalWarehouse,
                WarehouseTypeId = warehouseType.Id
            };

            _workspace.Add(localWarehouse);
            _workspace.CommitChanges();

            var department = new Department
            {
                Name         = Resources.Retail,
                TicketTypeId = ticketType.Id,
                WarehouseId  = localWarehouse.Id
            };

            _workspace.Add(department);

            var transactionType = new InventoryTransactionType
            {
                Name = Resources.PurchaseTransactionType,
                TargetWarehouseTypeId    = warehouseType.Id,
                DefaultTargetWarehouseId = localWarehouse.Id
            };

            _workspace.Add(transactionType);

            var transactionDocumentType = new InventoryTransactionDocumentType
            {
                Name = Resources.PurchaseTransaction,
                InventoryTransactionType = transactionType
            };

            _workspace.Add(transactionDocumentType);

            AddDefaultUsers();

            PrinterTemplate customerReceiptTemplate = AddDefaultPrintersAndTerminal();

            new RuleGenerator().GenerateSystemRules(_workspace);

            dataCreationService.ImportMenus(screen);
            //dataCreationService.ImportTableResources(tableEntityType, ticketType);
            //RL - import data and associate with an entity.
            //C:\Users\Roy Lawson\source\repos\sdselite\SambaPOS-3\Samba.Presentation\bin\Debug\Imports

            var customerScreen = new EntityScreen {
                Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id
            };

            customerScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerScreen);

            var customerTicketScreen = new EntityScreen {
                Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id
            };

            customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerTicketScreen);

            var customerCashDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.Cash),
                ButtonHeader        = Resources.Cash,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCashDocument.AddAccountTransactionDocumentTypeMap();
            customerCashDocument.TransactionTypes.Add(customerCashPaymentType);

            var customerCreditCardDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.CreditCard),
                ButtonHeader        = Resources.CreditCard,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCreditCardDocument.AddAccountTransactionDocumentTypeMap();
            customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType);

            _workspace.Add(customerCashDocument);
            _workspace.Add(customerCreditCardDocument);
        }
Example #10
0
        /// <summary>
        /// 更新商户在库库存(收货、拣货移入)
        /// </summary>
        /// <param name="sourceNo"></param>
        /// <param name="warehouseId"></param>
        /// <param name="productId"></param>
        /// <param name="merchantId"></param>
        /// <param name="moveInQty"></param>
        /// <param name="isOpenTrans"></param>
        public bool UpdateInventoryByReceive(string sourceNo, InventoryTransactionType type, string warehouseId, string productId, string merchantId, int moveInQty,
                                             DbTransaction isOpenTrans)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"SELECT * FROM dbo.Inventory WHERE WarehouseId = @WarehouseId");
            strSql.Append(" AND ProductId = @ProductId");
            strSql.Append(" AND MerchantId = @MerchantId");

            var parameter = new List <DbParameter>
            {
                DbFactory.CreateDbParameter("@WarehouseId", warehouseId),
                DbFactory.CreateDbParameter("@ProductId", productId),
                DbFactory.CreateDbParameter("@MerchantId", merchantId)
            };

            InventoryTransactionEntity transaction = new InventoryTransactionEntity();

            transaction.Create();
            transaction.Type         = (int)type;
            transaction.WarehouseId  = warehouseId;
            transaction.ProductId    = productId;
            transaction.MerchantFrom = merchantId;
            transaction.MerchantTo   = merchantId;
            transaction.Qty          = moveInQty;
            transaction.SourceNo     = sourceNo;

            var isOK = new InventoryTransactionBLL().InsertTransaction(transaction, isOpenTrans);

            if (isOK)
            {
                var inventory = Repository().FindEntityBySql(strSql.ToString(), parameter.ToArray());
                if (string.IsNullOrEmpty(inventory?.InventoryId))
                {
                    inventory = new InventoryEntity();
                    inventory.Create();
                    inventory.WarehouseId = warehouseId;
                    inventory.ProductId   = productId;
                    inventory.QtyOnHand   = moveInQty;
                    inventory.MerchantId  = merchantId;
                    return(Repository().Insert(inventory, isOpenTrans) > 0);
                }
                else
                {
                    StringBuilder strUpdateSql = new StringBuilder();
                    strUpdateSql.Append(
                        @"UPDATE [Inventory] SET QtyOnHand = QtyOnHand + @QtyOnHand WHERE InventoryId = @InventoryId ");

                    List <DbParameter> updateParameters = new List <DbParameter>
                    {
                        DbFactory.CreateDbParameter("@QtyOnHand", moveInQty),
                        DbFactory.CreateDbParameter("@InventoryId", inventory.InventoryId)
                    };
                    return(Repository().ExecuteBySql(strUpdateSql, updateParameters.ToArray(), isOpenTrans) > 0);
                }
            }
            else
            {
                return(false);
            }
        }
Example #11
0
        public void CreateData()
        {
            CreateDefaultCurrenciesIfNeeded();

            if (!ShouldCreateData())
            {
                return;
            }

            var saleAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Sales)
            };
            var receivableAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Receiveable)
            };
            var paymentAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Payment)
            };
            var discountAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Discount)
            };
            var customerAccountType = new AccountType {
                Name = string.Format(Resources.Accounts_f, Resources.Customer)
            };

            _workspace.Add(receivableAccountType);
            _workspace.Add(saleAccountType);
            _workspace.Add(paymentAccountType);
            _workspace.Add(discountAccountType);
            _workspace.Add(customerAccountType);
            _workspace.CommitChanges();

            var customerEntityType = new EntityType {
                Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name
            };

            customerEntityType.EntityCustomFields.Add(new EntityCustomField {
                EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone
            });
            customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]";
            var tableEntityType = new EntityType {
                Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name
            };

            _workspace.Add(customerEntityType);
            _workspace.Add(tableEntityType);

            _workspace.CommitChanges();

            var accountScreen = new AccountScreen {
                Name = Resources.General
            };

            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30
            });
            accountScreen.AccountScreenValues.Add(new AccountScreenValue {
                AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40
            });
            _workspace.Add(accountScreen);

            var defaultSaleAccount = new Account {
                AccountTypeId = saleAccountType.Id, Name = Resources.Sales
            };
            var defaultReceivableAccount = new Account {
                AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables
            };
            var cashAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Cash
            };
            var creditCardAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard
            };
            var voucherAccount = new Account {
                AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher
            };
            var defaultDiscountAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Discount
            };
            var defaultRoundingAccount = new Account {
                AccountTypeId = discountAccountType.Id, Name = Resources.Rounding
            };

            _workspace.Add(defaultSaleAccount);
            _workspace.Add(defaultReceivableAccount);
            _workspace.Add(defaultDiscountAccount);
            _workspace.Add(defaultRoundingAccount);
            _workspace.Add(cashAccount);
            _workspace.Add(creditCardAccount);
            _workspace.Add(voucherAccount);

            _workspace.CommitChanges();

            var discountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Discount),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultDiscountAccount.Id
            };

            var roundingTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Rounding),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = discountAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = defaultRoundingAccount.Id
            };

            var saleTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Sale),
                SourceAccountTypeId    = saleAccountType.Id,
                TargetAccountTypeId    = receivableAccountType.Id,
                DefaultSourceAccountId = defaultSaleAccount.Id,
                DefaultTargetAccountId = defaultReceivableAccount.Id
            };

            var paymentTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Transaction_f, Resources.Payment),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerAccountTransactionType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.AccountTransaction),
                SourceAccountTypeId    = receivableAccountType.Id,
                TargetAccountTypeId    = customerAccountType.Id,
                DefaultSourceAccountId = defaultReceivableAccount.Id
            };

            var customerCashPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CashPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = cashAccount.Id
            };

            var customerCreditCardPaymentType = new AccountTransactionType
            {
                Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment),
                SourceAccountTypeId    = customerAccountType.Id,
                TargetAccountTypeId    = paymentAccountType.Id,
                DefaultTargetAccountId = creditCardAccount.Id
            };

            _workspace.Add(saleTransactionType);
            _workspace.Add(paymentTransactionType);
            _workspace.Add(discountTransactionType);
            _workspace.Add(roundingTransactionType);
            _workspace.Add(customerAccountTransactionType);
            _workspace.Add(customerCashPaymentType);
            _workspace.Add(customerCreditCardPaymentType);

            var discountService = new CalculationType
            {
                AccountTransactionType = discountTransactionType,
                CalculationMethod      = 0,
                DecreaseAmount         = true,
                Name = Resources.Discount
            };

            var roundingService = new CalculationType
            {
                AccountTransactionType = roundingTransactionType,
                CalculationMethod      = 2,
                DecreaseAmount         = true,
                IncludeTax             = true,
                Name = Resources.Round
            };

            var discountSelector = new CalculationSelector {
                Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign
            };

            discountSelector.CalculationTypes.Add(discountService);
            discountSelector.AddCalculationSelectorMap();

            var roundingSelector = new CalculationSelector {
                Name = Resources.Round, ButtonHeader = Resources.Round
            };

            roundingSelector.CalculationTypes.Add(roundingService);
            roundingSelector.AddCalculationSelectorMap();


            _workspace.Add(discountService);
            _workspace.Add(roundingService);
            _workspace.Add(discountSelector);
            _workspace.Add(roundingSelector);

            var screen = new ScreenMenu();

            _workspace.Add(screen);

            var ticketNumerator = new Numerator {
                Name = Resources.TicketNumerator
            };

            _workspace.Add(ticketNumerator);

            var orderNumerator = new Numerator {
                Name = Resources.OrderNumerator
            };

            _workspace.Add(orderNumerator);



            _workspace.CommitChanges();

            var ticketType = new TicketType
            {
                Name                = Resources.Ticket,
                TicketNumerator     = ticketNumerator,
                OrderNumerator      = orderNumerator,
                SaleTransactionType = saleTransactionType,
                ScreenMenuId        = screen.Id,
            };

            ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment {
                EntityTypeId = tableEntityType.Id, EntityTypeName = tableEntityType.Name, SortOrder = 10
            });
            ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment {
                EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20
            });

            var cashPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = cashAccount,
                Name    = cashAccount.Name
            };

            cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var creditCardPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = creditCardAccount,
                Name    = creditCardAccount.Name
            };

            creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var voucherPayment = new PaymentType
            {
                AccountTransactionType = paymentTransactionType,
                Account = voucherAccount,
                Name    = voucherAccount.Name
            };

            voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            var accountPayment = new PaymentType
            {
                AccountTransactionType = customerAccountTransactionType,
                Name = Resources.CustomerAccount
            };

            accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap());

            _workspace.Add(cashPayment);
            _workspace.Add(creditCardPayment);
            _workspace.Add(voucherPayment);
            _workspace.Add(accountPayment);
            _workspace.Add(ticketType);

            var warehouseType = new WarehouseType {
                Name = Resources.Warehouses
            };

            _workspace.Add(warehouseType);
            _workspace.CommitChanges();

            var localWarehouse = new Warehouse
            {
                Name            = Resources.LocalWarehouse,
                WarehouseTypeId = warehouseType.Id
            };

            _workspace.Add(localWarehouse);
            _workspace.CommitChanges();

            var department = new Department
            {
                Name         = Resources.Restaurant,
                TicketTypeId = ticketType.Id,
                WarehouseId  = localWarehouse.Id
            };

            _workspace.Add(department);

            var transactionType = new InventoryTransactionType
            {
                Name = Resources.PurchaseTransactionType,
                TargetWarehouseTypeId    = warehouseType.Id,
                DefaultTargetWarehouseId = localWarehouse.Id
            };

            _workspace.Add(transactionType);

            var transactionDocumentType = new InventoryTransactionDocumentType
            {
                Name = Resources.PurchaseTransaction,
                InventoryTransactionType = transactionType
            };

            _workspace.Add(transactionDocumentType);

            var role = new UserRole("Admin")
            {
                IsAdmin = true, DepartmentId = 1
            };

            _workspace.Add(role);

            var u = new User("Administrator", "1234")
            {
                UserRole = role
            };

            _workspace.Add(u);

            var ticketPrinterTemplate = new PrinterTemplate {
                Name = Resources.TicketTemplate, Template = GetDefaultTicketPrintTemplate()
            };
            var kitchenPrinterTemplate = new PrinterTemplate {
                Name = Resources.KitchenOrderTemplate, Template = GetDefaultKitchenPrintTemplate()
            };
            var customerReceiptTemplate = new PrinterTemplate {
                Name = Resources.CustomerReceiptTemplate, Template = GetDefaultCustomerReceiptTemplate()
            };

            _workspace.Add(ticketPrinterTemplate);
            _workspace.Add(kitchenPrinterTemplate);
            _workspace.Add(customerReceiptTemplate);

            var printer1 = new Printer {
                Name = Resources.TicketPrinter
            };
            var printer2 = new Printer {
                Name = Resources.KitchenPrinter
            };
            var printer3 = new Printer {
                Name = Resources.InvoicePrinter
            };

            _workspace.Add(printer1);
            _workspace.Add(printer2);
            _workspace.Add(printer3);

            _workspace.CommitChanges();

            var t = new Terminal
            {
                IsDefault            = true,
                Name                 = Resources.Server,
                ReportPrinterId      = printer1.Id,
                TransactionPrinterId = printer1.Id,
            };

            var pm1 = new PrinterMap {
                PrinterId = printer1.Id, PrinterTemplateId = ticketPrinterTemplate.Id
            };

            _workspace.Add(pm1);

            var pj1 = new PrintJob
            {
                Name        = Resources.PrintBill,
                WhatToPrint = (int)WhatToPrintTypes.Everything,
            };

            pj1.PrinterMaps.Add(pm1);


            _workspace.Add(pj1);

            var pm2 = new PrinterMap {
                PrinterId = printer2.Id, PrinterTemplateId = kitchenPrinterTemplate.Id
            };
            var pj2 = new PrintJob
            {
                Name        = Resources.PrintOrdersToKitchenPrinter,
                WhatToPrint = (int)WhatToPrintTypes.Everything,
            };

            pj2.PrinterMaps.Add(pm2);

            _workspace.Add(pj2);
            _workspace.Add(t);

            new RuleGenerator().GenerateSystemRules(_workspace);

            ImportMenus(screen);
            ImportTableResources(tableEntityType, ticketType);

            var customerScreen = new EntityScreen {
                Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id
            };

            customerScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerScreen);

            var customerTicketScreen = new EntityScreen {
                Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id
            };

            customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap());
            _workspace.Add(customerTicketScreen);

            var customerCashDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.Cash),
                ButtonHeader        = Resources.Cash,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCashDocument.AddAccountTransactionDocumentTypeMap();
            customerCashDocument.TransactionTypes.Add(customerCashPaymentType);

            var customerCreditCardDocument = new AccountTransactionDocumentType
            {
                Name                = string.Format(Resources.Customer_f, Resources.CreditCard),
                ButtonHeader        = Resources.CreditCard,
                DefaultAmount       = string.Format("[{0}]", Resources.Balance),
                DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard),
                MasterAccountTypeId = customerAccountType.Id,
                PrinterTemplateId   = customerReceiptTemplate.Id
            };

            customerCreditCardDocument.AddAccountTransactionDocumentTypeMap();
            customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType);

            _workspace.Add(customerCashDocument);
            _workspace.Add(customerCreditCardDocument);

            ImportItems(BatchCreateEntities);
            ImportItems(BatchCreateTransactionTypes);
            ImportItems(BatchCreateTransactionTypeDocuments);

            _workspace.CommitChanges();
            _workspace.Dispose();
        }
 internal static Expression <Func <InventoryTransaction, bool> > ByTransactionType(InventoryTransactionType transactionType)
 {
     return(t => t.TransactionType == transactionType);
 }
Example #13
0
        public async Task <ActionResult <InventoryTransactionType> > PostInventoryTransactionType(InventoryTransactionType inventoryTransactionType)
        {
            _context.InventoryTransactionType.Add(inventoryTransactionType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetInventoryTransactionType", new { id = inventoryTransactionType.InventoryTransactionTypeId }, inventoryTransactionType));
        }
Example #14
0
        public static RestoreTransactionStatus ValidateRestoreTransaction(InventoryItem item, InventoryTransactionType transType)
        {
            bool            valid          = false;
            string          message        = "";
            OleDbConnection repoConnection = null;

            try
            {
                repoConnection = DBConnection.OpenConnection();
                OleDbCommand cmd = null;

                cmd = new OleDbCommand(
                    string.Format("SELECT count(*) from InventoryDailyFActs where PalletNo='{0}'", item.PalletNo),
                    repoConnection);

                int count = Convert.ToInt32(cmd.ExecuteScalar());

                cmd = new OleDbCommand(
                    string.Format("SELECT count(*) from InventoryDailyFActs where InvoiceNo='{0}'", item.InvoiceNo),
                    repoConnection);
                int count1 = Convert.ToInt32(cmd.ExecuteScalar());

                cmd = new OleDbCommand(
                    string.Format("SELECT count(*) from Inventory where CurrentStock > {0} and PartNumber='{1}'", item.CurrentStock, item.PartNumber),
                    repoConnection);

                int resultCount = Convert.ToInt32(cmd.ExecuteScalar());

                if (count > 0 && count1 == 0 && resultCount != 0)
                {
                    valid   = false;
                    message = "Pallet number /Invoice Number not exsit ! Please try again";
                }
                else if (count > 0 && count1 > 0)
                {
                    valid   = false;
                    message = "Invoice Number already exist";
                }
                else if (count == 0 && count1 == 0)
                {
                    valid   = false;
                    message = "Pallet number not exsit ! Please try again";
                }
                else if (resultCount == 0)
                {
                    valid   = false;
                    message = "No sufficinet quantity availlable for the partNumber " + item.PartNumber;
                }
                else if (count > 0 && count1 == 0)
                {
                    valid   = true;
                    message = "";
                }
                else
                {
                    message = "Pallet number /Invoice Number not exsit ! Please try again";
                    valid   = false;
                }

                return(new RestoreTransactionStatus()
                {
                    Message = message, Valid = valid
                });
            }
            catch (Exception exp)
            {
                RepoLogger.LogMsg(LogModes.REPO, LogLevel.ERROR,
                                  "Error while Getting ValidateInvoiceTransaction - " + exp.Message + " StackTrace:- " + exp.StackTrace);
                throw;
            }
            finally
            {
                DBConnection.CloseConnection(repoConnection);
            }
            return(new RestoreTransactionStatus()
            {
                Message = "Something went wrong ! Please check the administrator", Valid = false
            });
        }