Exemplo n.º 1
0
 public void Run()
 {
     inventoryCmd  = new InventoryCommand();
     managementCmd = new ManagementCommand();
     PrintWelcome();
     RequestCommand();
 }
 public InventoryCommandRequest(short pServiceId, short pCustomerAcctId, InventoryCommand pInventoryCommand, PersonDto pPerson, InventoryCommandFilter pFilter)
 {
     ServiceId        = pServiceId;
     CustomerAcctId   = pCustomerAcctId;
     InventoryCommand = pInventoryCommand;
     Person           = pPerson;
     Filter           = pFilter;
 }
 public InventoryExportRequest(short pServiceId, short pCustomerAcctId, InventoryCommand pCommand, BatchDto[] pSelectedBatches, PersonDto pPerson, InventoryCommandFilter pFilter)
 {
     ServiceId      = pServiceId;
     CustomerAcctId = pCustomerAcctId;
     Command        = pCommand;
     Person         = pPerson;
     Filter         = pFilter;
 }
 public void Configure(InventoryCommand command)
 {
     command.TakeNoAction           = true;
     command.ResetParameters        = true;
     command.OutputPower            = Power;
     command.FilterStrongest        = BoolToTriState(StrongestTag);
     command.IncludeTransponderRssi = BoolToTriState(IncludeRssi);
 }
Exemplo n.º 5
0
        public void GetInventory(InventoryConfig config)
        {
            var command = new InventoryCommand();

            config.Configure(command);
            command.TakeNoAction = false;
            _tagMonitor.OnTagReceived(command);
            _commander.Execute(command);
        }
Exemplo n.º 6
0
        /*
         * start the program
         */
        public void Run()
        {
            // instance program classes
            inventoryCmd  = new InventoryCommand();
            managementCmd = new ManagementCommand();

            // print welcome msgs and request commands
            PrintWelcome();
            RequestCommand();
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            warehouse1 = new WarehouseCommand {
                locality = "SP",
                quantity = 12,
                type     = "PHYSICAL_STORE"
            };

            warehouse2 = new WarehouseCommand {
                locality = "SP",
                quantity = 12,
                type     = "ECOMMERCE"
            };

            warehouseZero = new WarehouseCommand {
                locality = "SP",
                quantity = 0,
                type     = "PHYSICAL_STORE"
            };
            var tempList = new List <WarehouseCommand>();

            tempList.Add(warehouse1);
            tempList.Add(warehouse2);

            inventory            = new InventoryCommand();
            inventory.warehouses = tempList.ToArray();


            validCommand = new CreateProductCommand {
                name      = "L'Oréal Professionnel Expert Absolut Repair Cortex Lipidium - Máscara de Reconstrução 500g",
                sku       = 43264,
                inventory = inventory
            };

            var zeroTempList = new List <WarehouseCommand>();
            var isMarketableFalseInventory = new InventoryCommand {
                warehouses = zeroTempList.ToArray()
            };

            isMarketableFalseCommand = new CreateProductCommand {
                name = "L'Oréal Professionnel Expert Absolut Repair Cortex Lipidium - Máscara de Reconstrução 500g",
                sku  = 43264,
                //inventory = isMarketableFalseInventory
            };

            invalidCommand = new CreateProductCommand
            {
                name = "",
                sku  = 0
            };

            repository = new ProductRepository();
            handler    = new ProductHandler(repository);
        }
        public override void ItemRequestedByValue(DevExpress.Xpo.Session session, object source, DevExpress.Web.ASPxEditors.ListEditItemRequestedByValueEventArgs e)
        {
            ASPxComboBox     combo = source as ASPxComboBox;
            InventoryCommand obj   = session.GetObjectByKey <InventoryCommand>(e.Value);

            if (obj != null)
            {
                combo.DataSource = new InventoryCommand[] { obj };
                combo.DataBindItems();
            }
        }
 public InventoryCommandRequest(short pServiceId, short pCustomerAcctId, int pPinLength, decimal pDenomination, InventoryCommand pInventoryCommand, BatchDto[] pBatches, PersonDto pPerson, bool pActivateOnLoad)
 {
     ServiceId        = pServiceId;
     CustomerAcctId   = pCustomerAcctId;
     PinLength        = pPinLength;
     Denomination     = pDenomination;
     InventoryCommand = pInventoryCommand;
     Batches          = pBatches;
     Person           = pPerson;
     ActivateOnLoad   = pActivateOnLoad;
     Filter           = InventoryCommandFilter.All;
 }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class
        /// </summary>
        /// <param name="displayResponder">Captures all responses from the reader and relays them to the user interface</param>
        /// <param name="commander">Used to setup the responder chain and execute ASCII commands</param>
        /// <param name="settings">The display settings</param>
        public MainViewModel(DisplayResponder displayResponder, IAsciiCommandExecuting commander, IDisplaySettings settings, serviceSocket socket)
        {
            InventoryCommand inventoryResponder;
            BarcodeCommand   barcodeResponder;

            if (displayResponder == null)
            {
                throw new ArgumentNullException("displayResponder");
            }

            if (commander == null)
            {
                throw new ArgumentNullException("commander");
            }

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            this.socket   = socket;
            this.settings = settings;

            // Create a display responder to capture and display all reader responses
            displayResponder.ReceivedLine += delegate(object sender, AsciiLineEventArgs e)
            {
                this.OnResponseLine(e.Line.FullLine);
            };

            // setup an asynchronous responder for inventory
            inventoryResponder = new InventoryCommand();
            inventoryResponder.TransponderReceived += this.AsynchronousTransponder_Received;

            // setup an asynchronous responder for barcodes
            barcodeResponder = new BarcodeCommand();
            barcodeResponder.BarcodeReceived += this.AsynchronousBarcode_Received;

            // set up the responder chain
            this.commander = commander;
            this.commander.ClearResponders();
            this.commander.AddResponder(new LoggerResponder());
            this.commander.AddResponder(displayResponder);
            this.commander.AddSynchronousResponder();
            this.commander.AddResponder(inventoryResponder.Responder);
            this.commander.AddResponder(barcodeResponder.Responder);

            this.synchronousBarcodeCommand = new BarcodeCommand();
            this.synchronousBarcodeCommand.BarcodeReceived += this.SynchronousBarcode_Received;

            this.synchronousInventoryCommand = new InventoryCommand();
            this.synchronousInventoryCommand.TransponderReceived += this.SynchronousTransponder_Received;
        }
        public override NASCustomFieldPredefinitionData GetSelectedPredefinitionDataFromList(object source)
        {
            NASCustomFieldPredefinitionData ret = null;
            Session session = null;

            try
            {
                ASPxComboBox combo = source as ASPxComboBox;
                session = XpoHelper.GetNewSession();

                if (combo.Value == null)
                {
                    return(null);
                }

                Guid commandId = (Guid)combo.Value;

                InventoryCommand command =
                    session.GetObjectByKey <InventoryCommand>(commandId);

                if (command != null)
                {
                    ret = new NASCustomFieldPredefinitionData()
                    {
                        Code              = command.Code,
                        Description       = command.Description,
                        Name              = command.Name,
                        PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum),
                                                         SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_INPUT_INVENTORY_COMMAND),
                        RefId = command.InventoryCommandId
                    };
                }

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Exemplo n.º 12
0
        public async Task Configure(InventoryConfig config)
        {
            var command = new InventoryCommand();

            config.Configure(command);
            await Task.Run(() =>
            {
                try
                {
                    _commander.Execute(command);
                }
                catch (Exception ex)
                {
                    LogException(ex.Message);
                }
            });
        }
        public override NASCustomFieldPredefinitionData GetPredefinitionDataOfObject(Guid objectCustomFieldId)
        {
            NASCustomFieldPredefinitionData ret = null;
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();
                ObjectCustomFieldData objectCustomFieldData =
                    session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId).ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData != null)
                {
                    PredefinitionData predefinitionData =
                        (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                    InventoryCommand command =
                        session.GetObjectByKey <InventoryCommand>(predefinitionData.RefId);

                    if (command != null)
                    {
                        ret = new NASCustomFieldPredefinitionData()
                        {
                            Code              = command.Code,
                            Description       = command.Description,
                            Name              = command.Name,
                            PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum),
                                                             SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_INPUT_INVENTORY_COMMAND),
                            RefId = command.InventoryCommandId
                        };
                    }
                }
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
Exemplo n.º 14
0
        public InventoryCommand GetAllocatedInputInventoryCommandByManualTransaction(Session session, Guid manualBookingTransactionId)
        {
            InventoryCommand ret = null;

            try
            {
                Transaction transaction =
                    session.GetObjectByKey <Transaction>(manualBookingTransactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.First();
                if (transactionObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_INPUT_INVENTORY_COMMAND);

                ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <InventoryCommand>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 15
0
        public NAS.DAL.Invoice.PurchaseInvoice GetAllocatedPurchaseInvoiceByInventoryCommand(Session session, Guid inventoryCommandId)
        {
            NAS.DAL.Invoice.PurchaseInvoice ret = null;
            try
            {
                InventoryCommand command =
                    session.GetObjectByKey <InventoryCommand>(inventoryCommandId);
                InventoryCommandObject commandObject = command.InventoryCommandObjects.First();
                if (commandObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.INVENTORY_IN_PURCHASE_INVOICE);

                ObjectCustomField objectCustomField = commandObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <NAS.DAL.Invoice.PurchaseInvoice>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 16
0
        public OnTheWayBuyingGoodArtifact GetOnTheWayBuyingGoodArtifact(
            Session session,
            Guid FinancialOnTheWayBuyingGoodSummaryId,
            Guid PurchaseInvoiceId,
            Guid InputCommandId)
        {
            OnTheWayBuyingGoodArtifact result = null;

            try
            {
                Util util = new Util();
                FinancialOnTheWayBuyingGoodSummary summary = session.GetObjectByKey <FinancialOnTheWayBuyingGoodSummary>(FinancialOnTheWayBuyingGoodSummaryId);
                NAS.DAL.Invoice.PurchaseInvoice    invoice = util.GetXpoObjectByFieldName <NAS.DAL.Invoice.PurchaseInvoice, Guid>(session, "BillId", PurchaseInvoiceId, BinaryOperatorType.Equal);
                InventoryCommand command = util.GetXpoObjectByFieldName <InventoryCommand, Guid>(session, "InventoryCommandId", InputCommandId, BinaryOperatorType.Equal);


                if (summary == null || invoice == null || command == null)
                {
                    return(null);
                }
                else
                {
                    CriteriaOperator criteria_RowStatus = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
                    CriteriaOperator criteria_summary   = new BinaryOperator("FinancialOnTheWayBuyingGoodSummaryId", summary, BinaryOperatorType.Equal);
                    CriteriaOperator criteria_invoice   = new BinaryOperator("InvoiceCode", invoice.Code, BinaryOperatorType.Equal);
                    CriteriaOperator criteria_command   = new BinaryOperator("LegalInvoiceCode", command.Code, BinaryOperatorType.Equal);
                    CriteriaOperator criteria           = CriteriaOperator.And(criteria_RowStatus, criteria_summary, criteria_invoice, criteria_command);

                    result = session.FindObject <OnTheWayBuyingGoodArtifact>(criteria);

                    return(result);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Kiểm tra phiếu kho đã ghi sổ hay chưa
        /// </summary>
        /// <param name="_InventoryCommand"></param>
        /// <returns></returns>
        public bool IsBookedEntriesForInventoryCommand(Session _Session, Guid _InventoryCommand)
        {
            try
            {
                NAS.BO.Accounting.Journal.TransactionBOBase transactionBOBase = new TransactionBOBase();
                InventoryCommand command = _Session.GetObjectByKey <InventoryCommand>(_InventoryCommand);
                if (command == null)
                {
                    throw new Exception("The InventoryCommand is not exist in system");
                }

                command.Reload();

                if (command.InventoryCommandFinancialTransactions != null && command.InventoryCommandFinancialTransactions.Count > 0)
                {
                    foreach (InventoryCommandFinancialTransaction t in command.InventoryCommandFinancialTransactions)
                    {
                        Transaction transaction = null;
                        if (!transactionBOBase.IsBookedTransaction(_Session, t.TransactionId, out transaction))
                        {
                            return(false);
                        }
                    }
                }

                if (command.RowStatus != Utility.Constant.ROWSTATUS_BOOKED_ENTRY)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 18
0
        public OnTheWayBuyingGoodArtifact CreateOnTheWayBuyingGoodArtifact(Session session,
                                                                           Guid FinancialOnTheWayBuyingGoodSummaryId,
                                                                           Guid PurchaseInvoiceId,
                                                                           Guid InputCommandId)
        {
            OnTheWayBuyingGoodArtifact result = new OnTheWayBuyingGoodArtifact(session);

            try
            {
                Util util = new Util();

                FinancialOnTheWayBuyingGoodSummary summary = session.GetObjectByKey <FinancialOnTheWayBuyingGoodSummary>(FinancialOnTheWayBuyingGoodSummaryId);

                NAS.DAL.Invoice.PurchaseInvoice invoice = util.GetXpoObjectByFieldName <NAS.DAL.Invoice.PurchaseInvoice, Guid>(session, "BillId", PurchaseInvoiceId, BinaryOperatorType.Equal);
                InventoryCommand command = util.GetXpoObjectByFieldName <InventoryCommand, Guid>(session, "InventoryCommandId", InputCommandId, BinaryOperatorType.Equal);


                if (summary == null || invoice == null || command == null)
                {
                    return(null);
                }

                result.RowStatus = Constant.ROWSTATUS_ACTIVE;
                result.FinancialOnTheWayBuyingGoodSummaryId = summary;
                result.InvoiceCode            = invoice.Code;
                result.InvoiceIssuedDate      = invoice.IssuedDate;
                result.LegalInvoiceCode       = command.Code;
                result.LegalInvoiceIssuedDate = command.IssueDate;
                result.Save();
                return(result);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            string url  = "irc.chat.twitch.tv";
            int    port = 80;

            string user       = "******";
            string oAuthToken = System.IO.File.ReadAllText(@"token.txt"); // token.txt must be in the same folder as EXE
            string channel    = "lobosjr";

            //Set up one IrcClient, only one is required it allows better cooldown managerment and traffic will
            //never cause this code to run slower then any twitch cool down for bots.
            TwitchClientFactory icf    = new TwitchClientFactory();
            ITwitchClient       client = icf.create(url, port, user, oAuthToken, channel, 600,
                                                    new OperationRequestEventRaiser(), new PrivMessageEventRaiser(),
                                                    new WhisperMessageEventRaiser());

            client.DefaultMessageHandler += (o, e) =>
            {
                Console.WriteLine(string.Format("System: {0}", e.Raw));
            };

            //Set up Legacy Item -> IEquipment converter.
            LegacyItemEquipmentConverter liec = new LegacyItemEquipmentConverter();
            //Set up Equipment repository, if legacy then this will load all items from old files and convert them
            //into IEquipment in memory.
            IEquipmentRepository equipmentRepository = LegacyEquipmentRepository
                                                       .getInstance(liec, LegacyEquipmentRepository.LEGACY_ITEM_BRIDGE_FILE_PATH,
                                                                    LegacyEquipmentRepository.LEGACY_ITEM_PREFIX_FILE_PATH);

            //Set up Player Repository, Factory and default ILevelObservers
            ILevelObserver levelUpNotifier = new LevelupNotifier(client);
            PlayerFactory  pf = new PlayerFactory(3, 20, levelUpNotifier);
            ILevelObserver classChoiceNotifier = new ClassChoiceNotifier(client, pf, 3);

            pf.GetCurrentDefaultObservers().Add(classChoiceNotifier);
            IPlayerRepository playerRepo = LegacyPlayerRepository.getInstance(3, 20, pf,
                                                                              equipmentRepository, LegacyPlayerRepository.LEGACY_USER_COINS_FILE_PATH,
                                                                              LegacyPlayerRepository.LEGACY_USER_XP_FILE_PATH,
                                                                              LegacyPlayerRepository.LEGACY_USER_CLASS_FILE_PATH, "players.json");


            //Set up Adventure repository.
            IAdventureRepository adventureRepository = LegacyAdventureRepository
                                                       .getInstance(LegacyAdventureRepository.LEGACY_DUNGEON_BRIDGE_FILE_PATH,
                                                                    LegacyAdventureRepository.LEGACY_DUNGEON_FILE_PATH_PREFIX, equipmentRepository);

            //Set up Adventure manager who's Run() func should be used to run adventures on a daemon thread
            IAdventureManager adventureManager = new AdventureManager(client, 3);

            new Thread(() =>
            {
                Thread.CurrentThread.Name         = "Adventure Manager";
                Thread.CurrentThread.IsBackground = true;
                adventureManager.Run();
            }).Start();
            //Set up Party Pool, this keeps track of current parties.
            IPartyPool partyPool = new PartyPool(client);
            //Set up Group finder, use the current adventure managers queue. Decide party size capacity for
            // group finder.
            GroupFinderFactory gff         = new GroupFinderFactory();
            IGroupFinder       groupFinder = gff.Create(partyPool, 3, adventureRepository,
                                                        adventureManager);

            //Set up FutureTask Registry which will keep track of time based operations
            FutureTaskRegistry futureTaskRegistry = new FutureTaskRegistry();

            //Set up Custom Command Factory and Repository for the Command Manager allowing
            //for saved custom commands to be used aswell as providing capability for new
            //custom commands to be created from chat(broadcaster/mod only).
            CustomCommandFactory    ccf            = new CustomCommandFactory();
            CustomCommandRepository ccr            = new CustomCommandRepository();
            CommandManager          commandManager = new CommandManager(client, ccf, ccr);

            //Initialise all commands to be added to the command manager, seperated by
            //the source of the request, either PRVMSG or WHISPER.
            #region Initialisation of Commands

            #region General Commands

            UptimeCommand          uptime       = new UptimeCommand();
            Command <IPrivRequest> broadcasting = new BroadcastingFlagCommand(user, playerRepo,
                                                                              pf, uptime, client, futureTaskRegistry, 1, 3, 2, TimeSpan.FromMinutes(30));
            Command <IPrivRequest> time     = new TimeCommand();
            Command <IPrivRequest> playlist = new PlaylistCommand("http://open.spotify.com/user/1251282601/playlist/2j1FVSjJ4zdJiqGQgXgW3t");
            Command <IPrivRequest> opinion  = new OpinionCommand();
            Command <IPrivRequest> pun      = new PunCommand();
            Command <IPrivRequest> quote    = new QuoteCommand();
            Command <IPrivRequest> raffle   = new RaffleCommand(client, 5, futureTaskRegistry);

            #endregion

            #region RPG Commands

            #region General

            Command <IWhisperRequest> stats     = new StatsCommand(pf, playerRepo);
            Command <IWhisperRequest> inventory = new InventoryCommand(pf, playerRepo);
            Command <IWhisperRequest> item      = new ItemCommand(equipmentRepository, pf, playerRepo);
            Command <IWhisperRequest> equip     = new EquipCommand(equipmentRepository, pf, playerRepo);
            Command <IWhisperRequest> unequip   = new UnequipCommand(equipmentRepository, pf,
                                                                     playerRepo);
            Command <IWhisperRequest> shop        = new ShopCommand();
            Command <IWhisperRequest> classChoice = new ClassChoice(pf, playerRepo, 3);
            Command <IWhisperRequest> gloat       = new GloatCommand(client, pf, playerRepo);
            Command <IWhisperRequest> respec      = new RespecCommand(pf, playerRepo);
            Command <IWhisperRequest> daily       = new DailyCommand(pf, playerRepo);
            Command <IWhisperRequest> queue       = new QueueCommand(groupFinder, pf, playerRepo);
            Command <IWhisperRequest> leaveQueue  = new LeaveQueueCommand(groupFinder, pf, playerRepo);
            Command <IWhisperRequest> queueTime   = new QueueTimeCommand(groupFinder, pf, playerRepo);

            #endregion

            #region Party Commands

            Command <IWhisperRequest> createParty = new CreatePartyCommand(partyPool, pf,
                                                                           playerRepo);
            Command <IWhisperRequest> pendingInvite = new PendingInvite(partyPool, pf, playerRepo);
            Command <IWhisperRequest> leaveParty    = new LeavePartyCommand(pf, playerRepo);

            #region Party Leader Commands

            Command <IWhisperRequest> partyAdd   = new AddPartyCommand(client, pf, playerRepo);
            Command <IWhisperRequest> partyKick  = new KickPartyCommand(client, pf, playerRepo);
            Command <IWhisperRequest> partyStart = new StartPartyCommand(groupFinder, pf,
                                                                         playerRepo);
            Command <IWhisperRequest> partyPromote = new PromotePartyCommand(client, pf,
                                                                             playerRepo);

            #endregion

            #endregion

            #region Broadcaster only

            Command <IWhisperRequest> addPlayerXp    = new AddPlayerXP(pf, playerRepo);
            Command <IWhisperRequest> addPlayerCoin  = new AddPlayerCoin(pf, playerRepo);
            Command <IWhisperRequest> setPlayerLevel = new SetPlayerLevel(pf, playerRepo);

            #endregion

            #endregion

            #endregion

            commandManager.AddAll(uptime, broadcasting, time, playlist, opinion, pun, quote,
                                  raffle);
            commandManager.AddAll(stats, inventory, item, equip, unequip, shop, classChoice,
                                  gloat, respec, daily, queue, leaveQueue, queueTime, createParty, pendingInvite,
                                  leaveParty, partyAdd, partyKick, partyStart, partyPromote,
                                  addPlayerXp, addPlayerCoin, setPlayerLevel);

            //Provide Handles for events raised by client, multiple handles can be added
            //allow for parsing of PRVMSG chat for mirroring certain messages.
            #region Client Event Handling

            client.AddOperationHandler    += commandManager.Handle;
            client.CancelOperationHandler += commandManager.Handle;
            client.DeleteOperationHandler += commandManager.Handle;
            client.EditOperationHandler   += commandManager.Handle;
            client.InfoOperationHandler   += commandManager.Handle;

            client.PrivHandler += (o, e) =>
            {
                Console.WriteLine(string.Format("{0}: {1}", e.User, e.Message));
            };
            client.PrivRequestHandler += commandManager.Handle;

            client.WhisperHandler += (o, e) =>
            {
                Console.WriteLine(string.Format("Whisper {0}: {1}", e.User, e.Message));
            };
            client.WhisperRequestHandler += commandManager.Handle;



            #endregion

            //new thread for sending messages back to twitch server.
            new Thread(() =>
            {
                Thread.CurrentThread.Name         = "Twitch Client";
                Thread.CurrentThread.IsBackground = true;
                client.Run();
            }).Start();



            futureTaskRegistry.Run();
        }
Exemplo n.º 20
0
        public ETL_GoodsInInventoryTransaction ExtractTransaction(Session session, Guid TransactionId, string AccountCode)
        {
            ETL_GoodsInInventoryTransaction resultTransaction = null;

            try
            {
                bool             Acceptable = false;
                CriteriaOperator criteria_RowStatus
                    = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
                CriteriaOperator criteria_Code = new BinaryOperator("Code", AccountCode, BinaryOperatorType.Equal);
                CriteriaOperator criteria      = CriteriaOperator.And(criteria_Code, criteria_RowStatus);
                Account          account       = session.FindObject <Account>(criteria);

                Organization defaultOrg       = Organization.GetDefault(session, OrganizationEnum.NAAN_DEFAULT);
                Organization currentDeployOrg = Organization.GetDefault(session, OrganizationEnum.QUASAPHARCO);
                Account      defaultAccount   = Account.GetDefault(session, DefaultAccountEnum.NAAN_DEFAULT);
                Transaction  transaction      = session.GetObjectByKey <Transaction>(TransactionId);
                if (transaction == null)
                {
                    return(resultTransaction);
                }

                resultTransaction = new ETL_GoodsInInventoryTransaction();
                if (currentDeployOrg != null)
                {
                    resultTransaction.OwnerOrgId = currentDeployOrg.OrganizationId;
                }
                else
                {
                    resultTransaction.OwnerOrgId = defaultOrg.OrganizationId;
                }

                resultTransaction.TransactionId      = transaction.TransactionId;
                resultTransaction.Amount             = transaction.Amount;
                resultTransaction.Code               = transaction.Code;
                resultTransaction.CreateDate         = transaction.CreateDate;
                resultTransaction.Description        = transaction.Description;
                resultTransaction.IsBalanceForward   = (transaction is BalanceForwardTransaction);
                resultTransaction.IssuedDate         = transaction.IssueDate;
                resultTransaction.UpdateDate         = transaction.UpdateDate;
                resultTransaction.GeneralJournalList = new List <ETL_GeneralJournal>();

                double           numOfItem = 0;
                InventoryCommand command   = null;
                if (transaction != null)
                {
                    InventoryJournal inventoryJournal = null;
                    try
                    {
                        inventoryJournal = transaction.InventoryJournalFinancials.FirstOrDefault().InventoryJournalId;
                        numOfItem        = inventoryJournal.Debit > 0 ? inventoryJournal.Debit : inventoryJournal.Credit;
                        command          = (inventoryJournal.InventoryTransactionId as InventoryCommandItemTransaction).InventoryCommandId;
                    }
                    catch (Exception)
                    {
                        numOfItem = 0;
                        command   = null;
                    }
                }

                resultTransaction.Quantity   = numOfItem;
                resultTransaction.ArtifactId = command == null ? Guid.Empty : command.InventoryCommandId;

                if (numOfItem != 0)
                {
                    resultTransaction.Price = (decimal)resultTransaction.Amount / (decimal)numOfItem;
                }
                else
                {
                    resultTransaction.Price = 0;
                }

                foreach (GeneralJournal journal
                         in
                         transaction.GeneralJournals.Where(i => i.RowStatus == Constant.ROWSTATUS_BOOKED_ENTRY || i.RowStatus == Constant.ROWSTATUS_ACTIVE))
                {
                    if ((journal.Debit + journal.Credit) == 0)
                    {
                        continue;
                    }

                    ETL_GeneralJournal tempJournal = new ETL_GeneralJournal();
                    if (journal.AccountId != null)
                    {
                        tempJournal.AccountId = journal.AccountId.AccountId;
                    }
                    else
                    {
                        tempJournal.AccountId = defaultAccount.AccountId;
                    }

                    tempJournal.CreateDate = journal.CreateDate;
                    tempJournal.Credit     = journal.Credit;
                    if (journal.CurrencyId == null)
                    {
                        tempJournal.CurrencyId = CurrencyBO.DefaultCurrency(session).CurrencyId;
                    }
                    else
                    {
                        tempJournal.CurrencyId = journal.CurrencyId.CurrencyId;
                    }
                    tempJournal.Debit            = journal.Debit;
                    tempJournal.Description      = journal.Description;
                    tempJournal.GeneralJournalId = journal.GeneralJournalId;
                    tempJournal.JournalType      = journal.JournalType;
                    resultTransaction.GeneralJournalList.Add(tempJournal);

                    Account tmpAccount       = session.GetObjectByKey <Account>(tempJournal.AccountId);
                    bool    flgIsLeafAccount = tmpAccount.Accounts == null || tmpAccount.Accounts.Count == 0 ? true : false;

                    if (flgIsLeafAccount &&
                        accountingBO.IsRelateAccount(session, account.AccountId, tempJournal.AccountId))
                    {
                        Acceptable = true;
                    }
                }
                if (!Acceptable)
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            resultTransaction.AccountCode = AccountCode;
            return(resultTransaction);
        }
Exemplo n.º 21
0
        public void CreateFinancialOnTheWayBuyingGoodDetail(Session session, ETL_FinancialOnTheWayBuyingGoodDetail Detail, string MainAccountCode)
        {
            try
            {
                if (Detail == null ||
                    MainAccountCode.Equals(string.Empty) ||
                    Detail.PurchaseInvoiceId.Equals(Guid.Empty) ||
                    Detail.InputInventoryCommandId.Equals(Guid.Empty) ||
                    Detail.OwnerOrgId.Equals(Guid.Empty) ||
                    Detail.IssueDate == null)
                {
                    return;
                }

                //bool flgNewSummary = false;
                Util util = new Util();
                CorrespondFinancialAccountDim defaultCorrespondindAcc = CorrespondFinancialAccountDim.GetDefault(session, CorrespondFinancialAccountDimEnum.NAAN_DEFAULT);
                FinancialAccountDim           defaultFinancialAcc     = FinancialAccountDim.GetDefault(session, FinancialAccountDimEnum.NAAN_DEFAULT);
                ETLAccountingBO accountingBO = new ETLAccountingBO();
                FinancialOnTheWayBuyingGoodSummary summary   = GetFinancialOnTheWayBuyingGoodSummary(session, Detail.OwnerOrgId, Detail.IssueDate, MainAccountCode);
                FinancialOnTheWayBuyingGoodDetail  newDetail = new FinancialOnTheWayBuyingGoodDetail(session);
                if (summary == null)
                {
                    summary = CreateFinancialOnTheWayBuyingGoodSummary(session, Detail.OwnerOrgId, Detail.IssueDate, MainAccountCode);
                    if (summary == null)
                    {
                        return;
                    }
                }
                else
                {
                    var date = new DateTime(Detail.IssueDate.Year, Detail.IssueDate.Month, 1);
                    FinancialOnTheWayBuyingGoodSummary previousSummary = GetFinancialOnTheWayBuyingGoodSummary(session,
                                                                                                               Detail.OwnerOrgId, date.AddMonths(-1), MainAccountCode);

                    if (previousSummary != null)
                    {
                        summary.BeginBalance = previousSummary.EndBalance;
                    }
                }
                /*2014/02/22 Duc.Vo MOD START*/
                CorrespondFinancialAccountDim correspondFinancialAccountDim = null;
                FinancialAccountDim           financialAccountDim           = null;
                InventoryCommand InputCommand = null;
                NAS.DAL.Invoice.PurchaseInvoice PurchaseInvoice = null;

                if (!Detail.CorrespondAccountCode.Equals(string.Empty))
                {
                    correspondFinancialAccountDim = util.GetXpoObjectByFieldName <CorrespondFinancialAccountDim, string>(session, "Code", Detail.CorrespondAccountCode, BinaryOperatorType.Equal);
                }

                if (!MainAccountCode.Equals(string.Empty))
                {
                    financialAccountDim = util.GetXpoObjectByFieldName <FinancialAccountDim, string>(session, "Code", MainAccountCode, BinaryOperatorType.Equal);
                }

                if (!Detail.InputInventoryCommandId.Equals(Guid.Empty))
                {
                    InputCommand = util.GetXpoObjectByFieldName <InventoryCommand, Guid>(session, "InventoryCommandId", Detail.InputInventoryCommandId, BinaryOperatorType.Equal);
                    if (InputCommand == null)
                    {
                        return;
                    }
                }
                if (!Detail.PurchaseInvoiceId.Equals(Guid.Empty))
                {
                    PurchaseInvoice = util.GetXpoObjectByFieldName <NAS.DAL.Invoice.PurchaseInvoice, Guid>(session, "BillId", Detail.PurchaseInvoiceId, BinaryOperatorType.Equal);
                    if (PurchaseInvoice == null)
                    {
                        return;
                    }
                }

                OnTheWayBuyingGoodArtifact artifact = GetOnTheWayBuyingGoodArtifact(
                    session,
                    summary.FinancialOnTheWayBuyingGoodSummaryId,
                    PurchaseInvoice.BillId,
                    InputCommand.InventoryCommandId);

                if (artifact == null)
                {
                    artifact = CreateOnTheWayBuyingGoodArtifact(
                        session,
                        summary.FinancialOnTheWayBuyingGoodSummaryId,
                        PurchaseInvoice.BillId,
                        InputCommand.InventoryCommandId);

                    if (artifact == null)
                    {
                        return;
                    }
                }

                /*2014/02/22 Duc.Vo INS START*/
                if (financialAccountDim == null && !MainAccountCode.Equals(string.Empty))
                {
                    financialAccountDim = accountingBO.CreateFinancialAccountDim(session, MainAccountCode);
                }

                if (correspondFinancialAccountDim == null && !Detail.CorrespondAccountCode.Equals(string.Empty))
                {
                    correspondFinancialAccountDim = accountingBO.CreateCorrespondFinancialAccountDim(session, Detail.CorrespondAccountCode);
                }

                CurrencyDim currencyDim = util.GetXpoObjectByFieldName <CurrencyDim, string>(
                    session,
                    "Code",
                    Detail.CurrencyCode,
                    BinaryOperatorType.Equal);

                if (currencyDim == null && !Detail.CurrencyCode.Equals(string.Empty))
                {
                    currencyDim = accountingBO.CreateCurrencyDim(session, Detail.CurrencyCode);
                }

                FinancialTransactionDim financialTransactionDim = util.GetXpoObjectByFieldName <FinancialTransactionDim, Guid>(
                    session,
                    "RefId",
                    Detail.TransactionId,
                    BinaryOperatorType.Equal);

                if (financialTransactionDim == null)
                {
                    financialTransactionDim = accountingBO.CreateFinancialTransactionDim(session, Detail.TransactionId);
                    if (financialTransactionDim == null)
                    {
                        return;
                    }
                }

                newDetail.CorrespondFinancialAccountDimId = correspondFinancialAccountDim;
                newDetail.Credit                       = Detail.Credit;
                newDetail.Debit                        = Detail.Debit;
                newDetail.ActuaPrice                   = Detail.ActualPrice;
                newDetail.BookingPrice                 = Detail.BookedPrice;
                newDetail.FinancialAccountDimId        = financialAccountDim;
                newDetail.OnTheWayBuyingGoodArtifactId = artifact;
                newDetail.FinancialTransactionDimId    = financialTransactionDim;
                newDetail.CurrencyDimId                = currencyDim;
                /*2014-02-22 ERP-1417 Duc.Vo INS START*/

                if (newDetail.FinancialAccountDimId == null)
                {
                    newDetail.FinancialAccountDimId = defaultFinancialAcc;
                }
                if (newDetail.CorrespondFinancialAccountDimId == null)
                {
                    newDetail.CorrespondFinancialAccountDimId = defaultCorrespondindAcc;
                }
                /*2014-02-22 ERP-1417 Duc.Vo INS END*/
                newDetail.RowStatus = Constant.ROWSTATUS_ACTIVE;
                newDetail.Save();

                if (Detail.IsBalanceForward)
                {
                    summary.BeginBalance = summary.EndBalance = (decimal)Detail.Debit;
                    summary.CreditSum    = summary.DebitSum = 0;
                }
                else
                {
                    CorrespondFinancialAccountDim defaultAccDim = CorrespondFinancialAccountDim.GetDefault(session, CorrespondFinancialAccountDimEnum.NAAN_DEFAULT);
                    summary.CreditSum = (decimal)summary.OnTheWayBuyingGoodArtifacts.SelectMany(t => t.FinancialOnTheWayBuyingGoodDetails).
                                        Where(i => i.RowStatus == 1 &&
                                              i.Credit > 0 && i.CorrespondFinancialAccountDimId == defaultCorrespondindAcc).Sum(i => i.Credit);

                    summary.DebitSum = (decimal)summary.OnTheWayBuyingGoodArtifacts.SelectMany(t => t.FinancialOnTheWayBuyingGoodDetails).
                                       Where(i => i.RowStatus == 1 &&
                                             i.Debit > 0 && i.CorrespondFinancialAccountDimId == defaultCorrespondindAcc).Sum(i => i.Debit);

                    summary.BeginBalance = summary.BeginBalance + summary.DebitSum - summary.CreditSum;
                }

                summary.Save();
            }
            catch (Exception)
            {
                return;
            }
        }
Exemplo n.º 22
0
        private static void logInventoryHistory(Rbr_Db pDb, PersonDto pPerson, DateTime pTimestamp, short pServiceId, decimal pDenomination, int pBatchId, int pNumberOfCards, InventoryCommand pInventoryCommand, short pCustomerAcctId, int pResellerPartnerId, int pResellerAgentId)
        {
            var _inventoryHistoryRow = new InventoryHistoryRow();

            _inventoryHistoryRow.Service_id       = pServiceId;
            _inventoryHistoryRow.Batch_id         = pBatchId;
            _inventoryHistoryRow.Timestamp        = pTimestamp;
            _inventoryHistoryRow.InventoryCommand = pInventoryCommand;
            _inventoryHistoryRow.Number_of_cards  = pNumberOfCards;
            _inventoryHistoryRow.Denomination     = pDenomination;
            _inventoryHistoryRow.Person_id        = pPerson.PersonId;

            if (pCustomerAcctId > 0)
            {
                _inventoryHistoryRow.Customer_acct_id = pCustomerAcctId;                 //N/A FOR THIS COMMAND
            }

            if (pResellerPartnerId > 0)
            {
                _inventoryHistoryRow.Reseller_partner_id = pResellerPartnerId;                 //N/A FOR THIS COMMAND
            }

            if (pResellerAgentId > 0)
            {
                _inventoryHistoryRow.Reseller_agent_id = pResellerAgentId;                 //N/A FOR THIS COMMAND
            }

            pDb.InventoryHistoryCollection.Insert(_inventoryHistoryRow);
        }
Exemplo n.º 23
0
        public override void LoadInventoryCommandReport(Guid InventoryCommandId)
        {
            UnitOfWork uow = XpoHelper.GetNewUnitOfWork();

            try
            {
                InventoryCommand command = uow.GetObjectByKey <InventoryCommand>(InventoryCommandId);
                if (command == null)
                {
                    return;
                }

                if (!command.CommandType.Equals('I'))
                {
                    throw new Exception("The command is invalid");
                }

                NAS.DAL.Invoice.Bill bill = ICBO.GetSourceArtifactFromInventoryCommand(uow, command.InventoryCommandId);
                XPCollection <InventoryCommandItemTransaction> Transactions
                    = new XPCollection <InventoryCommandItemTransaction>(uow,
                                                                         CriteriaOperator.Or(
                                                                             new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.Equal),
                                                                             new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_BOOKED_ENTRY, BinaryOperatorType.Equal)));

                CriteriaOperator criteria = CriteriaOperator.And(
                    new BinaryOperator("Credit", 0, BinaryOperatorType.Greater),
                    new BinaryOperator("JournalType", 'A', BinaryOperatorType.Equal),
                    new NotOperator(new NullOperator("InventoryTransactionId")),
                    CriteriaOperator.Or(
                        new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.Equal),
                        new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_BOOKED_ENTRY, BinaryOperatorType.Equal)));

                XPCollection <InventoryJournal> retJournal1 = new XPCollection <InventoryJournal>(uow,
                                                                                                  Transactions.SelectMany(r => r.InventoryJournals), criteria);
                IEnumerable <InventoryJournal> retJournal2 = retJournal1.Where(r => r.InventoryTransactionId != null &&
                                                                               (r.RowStatus == Utility.Constant.ROWSTATUS_ACTIVE || r.RowStatus == Utility.Constant.ROWSTATUS_BOOKED_ENTRY) &&
                                                                               (r.InventoryTransactionId as InventoryCommandItemTransaction) != null &&
                                                                               (r.InventoryTransactionId.RowStatus == Utility.Constant.ROWSTATUS_ACTIVE || r.InventoryTransactionId.RowStatus == Utility.Constant.ROWSTATUS_BOOKED_ENTRY) &&
                                                                               (r.InventoryTransactionId as InventoryCommandItemTransaction).InventoryCommandId != null &&
                                                                               (r.InventoryTransactionId as InventoryCommandItemTransaction).InventoryCommandId.InventoryCommandId == InventoryCommandId &&
                                                                               ((r.InventoryTransactionId as InventoryCommandItemTransaction).InventoryCommandId.RowStatus == Utility.Constant.ROWSTATUS_ACTIVE ||
                                                                                (r.InventoryTransactionId as InventoryCommandItemTransaction).InventoryCommandId.RowStatus == Utility.Constant.ROWSTATUS_BOOKED_ENTRY));

                int    idx          = 1;
                double totalValue   = 0;
                Person pStoreKeeper = ICBO.GetSelectedActorInventoryCommandCombobox(InventoryCommandId, DefaultInventoryCommandActorTypeEnum.STOREKEEPER);
                Person pShipper     = ICBO.GetSelectedActorInventoryCommandCombobox(InventoryCommandId, DefaultInventoryCommandActorTypeEnum.SHIPPER);
                Person pCreator     = ICBO.GetSelectedActorInventoryCommandCombobox(InventoryCommandId, DefaultInventoryCommandActorTypeEnum.CREATOR);

                RPT_InventoryCommand_Rows =
                    retJournal2.Select(
                        i => new RPT_InputInventoryCommand_Row()
                {
                    ////////////////////Setting - Header//////////////////START
                    SeqNo               = idx++.ToString(),
                    Code                = command.Code,
                    CreateDate          = command.IssueDate,
                    InventoryName       = command.RelevantInventoryId.Name,
                    InventoryAddress    = command.RelevantInventoryId.Address,
                    AmountByString      = string.Empty,
                    PurchaseInvoiceCode = bill == null ? string.Empty : bill.Code,
                    PurchaseInvoiceDate = command.IssueDate,
                    ShipperName         = pShipper == null ? string.Empty : pShipper.Name,
                    CreatorName         = pCreator == null ? string.Empty : pCreator.Name,
                    StoreKeeperName     = pStoreKeeper == null ? string.Empty : pStoreKeeper.Name,
                    ////////////////////Setting - Item List//////////////////START
                    ItemCode     = i.ItemUnitId.ItemId.Code,
                    ItemName     = i.ItemUnitId.ItemId.Name,
                    ItemUnit     = i.ItemUnitId.UnitId.Name,
                    Quantity     = i.Credit,
                    PlanQuantity = i.PlanCredit,
                    Price        = bill != null && bill.BillItems != null && bill.BillItems.Count > 0 ?
                                   bill.BillItems.Where(r => r.ItemUnitId == i.ItemUnitId).FirstOrDefault().Price : 0,
                    TotalOfRow = bill != null && bill.BillItems != null && bill.BillItems.Count > 0 ?
                                 i.Credit * bill.BillItems.Where(r => r.ItemUnitId == i.ItemUnitId).FirstOrDefault().Price : 0
                    ,
                    TotalString = Utility.Accounting.NumberToString((totalValue = totalValue + (bill != null && bill.BillItems != null && bill.BillItems.Count > 0 ?
                                                                                                i.Credit * bill.BillItems.Where(r => r.ItemUnitId == i.ItemUnitId).FirstOrDefault().Price : 0)))
                                  ////////////////////Setting - Item List//////////////////END
                }).ToList <RPT_InventoryCommand_Row>();

                ////////////////////Setting - Financial List//////////////////START
                IEnumerable <GeneralJournal> GeneralJournals = command.InventoryCommandFinancialTransactions.Where(t =>
                                                                                                                   (t.RowStatus == Utility.Constant.ROWSTATUS_ACTIVE ||
                                                                                                                    t.RowStatus == Utility.Constant.ROWSTATUS_BOOKED_ENTRY)).SelectMany(
                    j => j.GeneralJournals).Where(j => (j.RowStatus == Utility.Constant.ROWSTATUS_ACTIVE ||
                                                        j.RowStatus == Utility.Constant.ROWSTATUS_BOOKED_ENTRY) &&
                                                  j.JournalType.Equals('A') &&
                                                  j.AccountId != null &&
                                                  j.TransactionId != null);

                if (GeneralJournals != null && GeneralJournals.Count() > 0)
                {
                    RPT_GenernalJournals_Objects = GeneralJournals.Select(
                        j => new RPT_GenernalJournal
                    {
                        GeneralJournalId = j.GeneralJournalId,
                        AccountId        = j.AccountId.AccountId,
                        AccountName      = j.AccountId.Name,
                        AccountCode      = j.AccountId.Code,
                        Credit           = j.Credit,
                        Debit            = j.Debit,
                        Description      = j.Description,
                        JournalType      = j.JournalType,
                        IssueDate        = j.TransactionId.IssueDate,
                        TransactionId    = j.TransactionId.TransactionId
                    }
                        ).ToList <RPT_GenernalJournal>();

                    RPT_GenernalJournals_Objects = this.GetProcessedJournalForReport();
                }
                ////////////////////Setting - Financial List//////////////////END
            }
            catch (Exception)
            {
                throw;
            }
            finally {
                uow.Dispose();
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Ghi sổ tài chính phiếu kho
        /// </summary>
        /// <param name="_InventoryCommand"></param>
        public void BookFinancialEntriesOfInventoryCommand(Guid _InventoryCommand)
        {
            UnitOfWork uow = null;

            try
            {
                uow = XpoHelper.GetNewUnitOfWork();
                NAS.BO.Accounting.Journal.TransactionBOBase transactionBOBase = new TransactionBOBase();
                InventoryCommand command = uow.GetObjectByKey <InventoryCommand>(_InventoryCommand);
                if (command == null)
                {
                    throw new Exception("The InventoryCommand is not exist in system");
                }

                InventoryCommandBO CheckBO = new InventoryCommandBO();

                if (CheckBO.IsBookedEntriesForInventoryCommand(uow, _InventoryCommand))
                {
                    throw new Exception(string.Format("Không thể tiến hành vì Phiếu '{0}' đã hạch toán từ trước!", command.Code));
                }

                int  objectFinacialType = int.MinValue;
                int  objectItemType     = int.MinValue;
                Bill billArtifact       = GetSourceArtifactFromInventoryCommand(uow, command.InventoryCommandId);

                if (command.CommandType == INVENTORY_COMMAND_TYPE.IN)
                {
                    objectFinacialType = Utility.Constant.BusinessObjectType_InputInventoryCommandFinancialTransaction;
                    objectItemType     = Utility.Constant.BusinessObjectType_InputInventoryCommandItemTransaction;
                }
                else if (command.CommandType == INVENTORY_COMMAND_TYPE.OUT)
                {
                    objectFinacialType = Utility.Constant.BusinessObjectType_OutputInventoryCommandFinancialTransaction;
                    objectItemType     = Utility.Constant.BusinessObjectType_OutputInventoryCommandItemTransaction;
                }

                if (command.InventoryCommandFinancialTransactions != null && command.InventoryCommandFinancialTransactions.Count > 0)
                {
                    foreach (InventoryCommandFinancialTransaction t in command.InventoryCommandFinancialTransactions)
                    {
                        if (t.RowStatus != Utility.Constant.ROWSTATUS_BOOKED_ENTRY && t.RowStatus != Utility.Constant.ROWSTATUS_ACTIVE)
                        {
                            continue;
                        }

                        CanBookingEntryReturnValue rs = transactionBOBase.CanBookingEntry(t.TransactionId, true);
                        if (rs == CanBookingEntryReturnValue.DEBIT_CREDIT_ZERO)
                        {
                            throw new Exception(string.Format("Bút toán '{0}' không hợp lệ! Nợ = Có = 0", t.Code));
                        }
                        else if (rs == CanBookingEntryReturnValue.HAVE_NO_JOURNAL)
                        {
                            throw new Exception(string.Format("Bút toán '{0}' không chưa nhập định khoản", t.Code));
                        }
                        else if (rs == CanBookingEntryReturnValue.INVALID_TRANSACTION_STATUS)
                        {
                            throw new Exception(string.Format("Bút toán '{0}' có trạng thái không hợp lệ", t.Code));
                        }
                        else if (rs == CanBookingEntryReturnValue.MANY_SIDE)
                        {
                            throw new Exception(string.Format("Bút toán '{0}' không hợp lệ vì có nhiều tài khoản nợ và nhiều tài khoản có", t.Code));
                        }
                        else if (rs == CanBookingEntryReturnValue.NOT_BALANCED)
                        {
                            throw new Exception(string.Format("Bút toán '{0}' chưa cân bằng", t.Code));
                        }
                    }
                }

                foreach (InventoryCommandFinancialTransaction t in command.InventoryCommandFinancialTransactions)
                {
                    if (t.RowStatus != Utility.Constant.ROWSTATUS_BOOKED_ENTRY && t.RowStatus != Utility.Constant.ROWSTATUS_ACTIVE)
                    {
                        continue;
                    }

                    if (!transactionBOBase.BookEntry(uow, t.TransactionId))
                    {
                        throw new Exception("Xử lý ghi sổ phát sinh lỗi");
                    }
                    t.AccountingPeriodId = AccountingPeriodBO.GetAccountingPeriod(uow, t.IssueDate);
                    uow.FlushChanges();
                }

                foreach (InventoryTransaction t in command.InventoryCommandItemTransactions)
                {
                    if (t.RowStatus != Utility.Constant.ROWSTATUS_BOOKED_ENTRY && t.RowStatus != Utility.Constant.ROWSTATUS_ACTIVE)
                    {
                        continue;
                    }

                    if (billArtifact != null)
                    {
                        CurrencyBO      currencyBO             = new CurrencyBO();
                        COGSBO          CogsBO                 = new COGSBO();
                        COGSBussinessBO COGSInventoryCommandBO = new COGSBussinessBO();

                        foreach (InventoryJournal j in t.InventoryJournals)
                        {
                            #region setting COGS
                            if (command.CommandType == INVENTORY_COMMAND_TYPE.IN)
                            {
                                if (j.JournalType.Equals('A') && j.Debit > 0 && j.Credit == 0)
                                {
                                    BillItem billItem = billArtifact.BillItems.Where(
                                        i => i.RowStatus == Utility.Constant.ROWSTATUS_ACTIVE &&
                                        i.ItemUnitId == j.ItemUnitId).FirstOrDefault();

                                    if (billItem == null)
                                    {
                                        throw new Exception("The ItemUnit is not exist in Bill");
                                    }

                                    COGSInventoryCommandBO.CreateCOGS(
                                        uow,
                                        0,
                                        j.Debit,
                                        DateTime.Now,
                                        billItem.Price,
                                        t.IssueDate,
                                        t.InventoryTransactionId,
                                        command.RelevantInventoryId.InventoryId,
                                        j.ItemUnitId.ItemUnitId,
                                        currencyBO.GetDefaultCurrency(uow).CurrencyId);
                                }
                            }
                            else if (command.CommandType == INVENTORY_COMMAND_TYPE.OUT)
                            {
                                if (!j.JournalType.Equals('A') && j.Debit == 0 && j.Credit > 0)
                                {
                                    COGS LastCogs =
                                        CogsBO.GetLastCOGS(
                                            uow,
                                            j.ItemUnitId.ItemUnitId,
                                            currencyBO.GetDefaultCurrency(uow).CurrencyId,
                                            command.RelevantInventoryId.InventoryId);

                                    COGSInventoryCommandBO.CreateCOGS(
                                        uow,
                                        j.Credit,
                                        0,
                                        DateTime.Now,
                                        LastCogs == null ? 0 : LastCogs.COGSPrice,
                                        t.IssueDate,
                                        t.InventoryTransactionId,
                                        command.RelevantInventoryId.InventoryId,
                                        j.ItemUnitId.ItemUnitId,
                                        currencyBO.GetDefaultCurrency(uow).CurrencyId);
                                }
                            }
                            #endregion
                            //j.RowStatus = Utility.Constant.ROWSTATUS_BOOKED_ENTRY;
                        }
                        uow.FlushChanges();
                    }
                    t.AccountingPeriodId = AccountingPeriodBO.GetAccountingPeriod(uow, t.IssueDate);
                    t.RowStatus          = Utility.Constant.ROWSTATUS_BOOKED_ENTRY;
                }

                command.RowStatus = Utility.Constant.ROWSTATUS_BOOKED_ENTRY;

                foreach (InventoryTransaction t in command.InventoryCommandItemTransactions)
                {
                    if (t.RowStatus != Utility.Constant.ROWSTATUS_BOOKED_ENTRY && t.RowStatus != Utility.Constant.ROWSTATUS_ACTIVE)
                    {
                        continue;
                    }

                    BusinessObjectBO.CreateBusinessObject(uow,
                                                          objectItemType,
                                                          t.InventoryTransactionId,
                                                          t.IssueDate);
                }

                foreach (InventoryCommandFinancialTransaction tf in command.InventoryCommandFinancialTransactions)
                {
                    if (tf.RowStatus != Utility.Constant.ROWSTATUS_BOOKED_ENTRY && tf.RowStatus != Utility.Constant.ROWSTATUS_ACTIVE)
                    {
                        continue;
                    }

                    BusinessObjectBO.CreateBusinessObject(uow,
                                                          objectFinacialType,
                                                          tf.TransactionId,
                                                          tf.IssueDate);
                }
                uow.CommitChanges();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (uow != null)
                {
                    uow.Dispose();
                }
            }
        }
Exemplo n.º 25
0
 public void Initialize(InventoryCommand command, Action onClick)
 {
     this.command  = command;
     text.text     = command.CommandName;
     onClickAction = onClick;
 }
Exemplo n.º 26
0
        public ETL_TransactionS04a6DN ExtractTransaction(Session session, Guid TransactionId, string AccountCode)
        {
            ETL_TransactionS04a6DN resultTransaction = null;

            try
            {
                bool             Acceptable             = false;
                Util             util                   = new Util();
                InventoryCommand command                = null;
                NAS.DAL.Invoice.PurchaseInvoice invoice = null;
                CriteriaOperator criteria_RowStatus     = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
                CriteriaOperator criteria_Code          = new BinaryOperator("Code", AccountCode, BinaryOperatorType.Equal);
                CriteriaOperator criteria               = CriteriaOperator.And(criteria_Code, criteria_RowStatus);
                Account          account                = session.FindObject <Account>(criteria);
                Organization     defaultOrg             = Organization.GetDefault(session, OrganizationEnum.NAAN_DEFAULT);
                Organization     currentDeployOrg       = Organization.GetDefault(session, OrganizationEnum.QUASAPHARCO);
                Account          defaultAccount         = Account.GetDefault(session, DefaultAccountEnum.NAAN_DEFAULT);
                Transaction      transaction            = session.GetObjectByKey <Transaction>(TransactionId);
                if (transaction == null)
                {
                    return(resultTransaction);
                }

                try
                {
                    if (transaction is InventoryCommandFinancialTransaction)
                    {
                        command = (((transaction as InventoryCommandFinancialTransaction).
                                    InventoryJournalFinancials.FirstOrDefault().InventoryJournalId.InventoryTransactionId)
                                   as InventoryCommandItemTransaction).InventoryCommandId;

                        invoice = GetAllocatedPurchaseInvoiceByInventoryCommand(session, command.InventoryCommandId);
                    }
                    else
                    {
                        command = GetAllocatedInputInventoryCommandByManualTransaction(session, transaction.TransactionId);
                        invoice = GetAllocatedPurchaseInvoiceByManualTransaction(session, transaction.TransactionId);
                    }
                }
                catch (Exception)
                {
                    command = null;
                    invoice = null;
                }

                if (command == null)
                {
                    return(null);
                }

                if (invoice == null)
                {
                    return(null);
                }

                resultTransaction = new ETL_TransactionS04a6DN();

                resultTransaction.InputInventoryCommandId = command.InventoryCommandId;
                resultTransaction.PurchaseInvoiceId       = invoice.BillId;

                if (currentDeployOrg != null)
                {
                    resultTransaction.OwnerOrgId = currentDeployOrg.OrganizationId;
                }
                else
                {
                    resultTransaction.OwnerOrgId = defaultOrg.OrganizationId;
                }

                if (resultTransaction.SupplierOrgId == Guid.Empty)
                {
                    resultTransaction.SupplierOrgId = defaultOrg.OrganizationId;
                }

                if (resultTransaction.CustomerOrgId == Guid.Empty)
                {
                    resultTransaction.CustomerOrgId = defaultOrg.OrganizationId;
                }

                resultTransaction.TransactionId    = transaction.TransactionId;
                resultTransaction.Amount           = transaction.Amount;
                resultTransaction.Code             = transaction.Code;
                resultTransaction.CreateDate       = transaction.CreateDate;
                resultTransaction.Description      = transaction.Description;
                resultTransaction.IsBalanceForward = (transaction is BalanceForwardTransaction);
                resultTransaction.IssuedDate       = transaction.IssueDate;
                resultTransaction.UpdateDate       = transaction.UpdateDate;

                double numOfItem = 0;
                if (transaction != null)
                {
                    InventoryJournal inventoryJournal = null;
                    try
                    {
                        inventoryJournal = transaction.InventoryJournalFinancials.FirstOrDefault().InventoryJournalId;
                        numOfItem        = inventoryJournal.Debit > 0 ? inventoryJournal.Debit : inventoryJournal.Credit;
                    }
                    catch (Exception)
                    {
                        numOfItem = 0;
                    }
                }
                resultTransaction.ActualPrice = resultTransaction.Amount / numOfItem;
                resultTransaction.BookedPrice = resultTransaction.ActualPrice;

                resultTransaction.GeneralJournalList = new List <ETL_GeneralJournal>();
                foreach (GeneralJournal journal in
                         transaction.GeneralJournals.Where(i => i.RowStatus == Constant.ROWSTATUS_BOOKED_ENTRY || i.RowStatus == Constant.ROWSTATUS_ACTIVE))
                {
                    ETL_GeneralJournal tempJournal = new ETL_GeneralJournal();
                    /*2014/02/20 Duc.Vo MOD START*/
                    if (journal.AccountId != null)
                    {
                        tempJournal.AccountId = journal.AccountId.AccountId;
                    }
                    else
                    {
                        tempJournal.AccountId = defaultAccount.AccountId;
                    }
                    /*2014/02/20 Duc.Vo MOD END*/
                    tempJournal.CreateDate = journal.CreateDate;
                    tempJournal.Credit     = journal.Credit;
                    if (journal.CurrencyId == null)
                    {
                        tempJournal.CurrencyId = CurrencyBO.DefaultCurrency(session).CurrencyId;
                    }
                    else
                    {
                        tempJournal.CurrencyId = journal.CurrencyId.CurrencyId;
                    }
                    tempJournal.Debit            = journal.Debit;
                    tempJournal.Description      = journal.Description;
                    tempJournal.GeneralJournalId = journal.GeneralJournalId;
                    tempJournal.JournalType      = journal.JournalType;
                    tempJournal.GeneralJournalId = journal.GeneralJournalId;

                    resultTransaction.GeneralJournalList.Add(tempJournal);
                    if (accountingBO.IsRelateAccount(session, account.AccountId, tempJournal.AccountId) && journal.Credit > 0)
                    {
                        Acceptable = true;
                    }
                }
                if (!Acceptable)
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(resultTransaction);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Lấy chứng từ phiếu gốc của phiếu xuất/nhập/chuyển kho
        /// </summary>
        /// <param name="uow"></param>
        /// <param name="_InventoryCommandId"></param>
        /// <returns></returns>
        public Bill GetSourceArtifactFromInventoryCommand(
            UnitOfWork uow,
            Guid _InventoryCommandId)
        {
            InventoryCommand command = uow.GetObjectByKey <InventoryCommand>(_InventoryCommandId);

            if (command == null)
            {
                throw new Exception("The InventoryCommand is not exist in system");
            }

            ObjectTypeCustomField ArtifactTypeCustomField = null;
            ObjectCustomField     ArtifactCustomField     = null;
            Bill billArtifact = null;

            if (command.CommandType.Equals(INVENTORY_COMMAND_TYPE.OUT))
            {
                ArtifactTypeCustomField =
                    ObjectTypeCustomField.GetDefault(uow, DefaultObjectTypeCustomFieldEnum.INVENTORY_OUT_SALE_INVOICE);
                try
                {
                    ArtifactCustomField = command.InventoryCommandObjects.First().ObjectId.ObjectCustomFields
                                          .Where(r => r.ObjectTypeCustomFieldId.Equals(ArtifactTypeCustomField)).First();
                }
                catch (Exception)
                {
                    if (ArtifactCustomField == null)
                    {
                        return(null);
                    }
                }
            }
            else if (command.CommandType.Equals(INVENTORY_COMMAND_TYPE.IN))
            {
                ArtifactTypeCustomField =
                    ObjectTypeCustomField.GetDefault(uow, DefaultObjectTypeCustomFieldEnum.INVENTORY_IN_PURCHASE_INVOICE);
                try
                {
                    //ArtifactCustomField = command.InventoryCommandObjects.First().ObjectId.ObjectCustomFields
                    //.Where(r => r.ObjectTypeCustomFieldId.Equals(ArtifactTypeCustomField)).First();

                    foreach (ObjectCustomField cf in command.InventoryCommandObjects.First().ObjectId.ObjectCustomFields)
                    {
                        if (cf.ObjectTypeCustomFieldId.Code != null && cf.ObjectTypeCustomFieldId.Code.Equals(ArtifactTypeCustomField.Code))
                        {
                            ArtifactCustomField = cf;
                        }
                    }
                }
                catch (Exception)
                {
                    if (ArtifactCustomField == null)
                    {
                        return(null);
                    }
                }
            }
            else
            {
                return(null);
            }

            if (ArtifactCustomField != null)
            {
                try
                {
                    billArtifact = uow.GetObjectByKey <Bill>((ArtifactCustomField.ObjectCustomFieldDatas.First().CustomFieldDataId as PredefinitionData).RefId);
                }
                catch (Exception)
                {
                    billArtifact = null;
                }
            }
            return(billArtifact);
        }
Exemplo n.º 28
0
 public void Before_Each_Test()
 {
     mock       = MockRepository.GenerateMock <IConsoleFacade>();
     repository = MockRepository.GenerateMock <IRepository <Item> >();
     cmd        = new InventoryCommand(mock, repository);
 }