Пример #1
0
        public WriteoffWaybill(string number, DateTime date, Storage senderStorage, AccountOrganization sender, WriteoffReason writeoffReason, User curator, User createdBy, DateTime creationDate) :
            base(WaybillType.WriteoffWaybill, number, date, curator, createdBy, creationDate)
        {
            ValidationUtils.NotNull(senderStorage, "Не указано место хранения отправителя.");
            ValidationUtils.NotNull(sender, "Не указана организация отправителя.");
            ValidationUtils.NotNull(writeoffReason, "Не указано основание для списания.");

            State = WriteoffWaybillState.Draft;

            Sender         = sender;
            SenderStorage  = senderStorage;
            WriteoffReason = writeoffReason;
        }
Пример #2
0
        /// <summary>
        /// Удаление связанной собственной организации
        /// </summary>
        /// <param name="accountOrganization">Собственная организация</param>
        public virtual void RemoveAccountOrganization(AccountOrganization accountOrganization)
        {
            if (!accountOrganizations.Contains(accountOrganization))
            {
                throw new Exception("Данная организация не связана с этим местом хранения. Возможно, она была удалена.");
            }

            accountOrganizations.Remove(accountOrganization);
            if (accountOrganization.Storages.Contains(this))
            {
                accountOrganization.RemoveStorage(this);
            }
        }
Пример #3
0
        /// <summary>
        /// Добавление связанной собственной организации
        /// </summary>
        /// <param name="accountOrganization">Собственная организация</param>
        public virtual void AddAccountOrganization(AccountOrganization accountOrganization)
        {
            if (accountOrganizations.Contains(accountOrganization))
            {
                throw new Exception(String.Format("Организация «{0}» уже связана с местом хранения «{1}».", accountOrganization.ShortName, this.Name));
            }

            accountOrganizations.Add(accountOrganization);
            if (!accountOrganization.Storages.Contains(this))
            {
                accountOrganization.AddStorage(this);
            }
        }
Пример #4
0
        /// <summary>
        /// Смена места хранения
        /// </summary>
        /// <param name="receiptStorage">Новое место хранения</param>
        /// <param name="accountOrganization">Новая организация</param>
        public virtual void ChangeReceiptStorage(Storage receiptStorage, AccountOrganization accountOrganization)
        {
            ValidationUtils.Assert(!IsCreatedFromProductionOrderBatch, "Данный метод не подходит для накладной, созданной по партии заказа.");

            ValidationUtils.NotNull(receiptStorage, "Место хранения не указано.");
            ValidationUtils.NotNull(accountOrganization, "Организация не указана.");
            ValidationUtils.Assert(accountOrganization.Storages.Contains(receiptStorage),
                                   String.Format("Место хранения «{0}» не связано с организацией «{1}».", receiptStorage.Name, accountOrganization.ShortName));
            ValidationUtils.Assert(ProviderContract == null || ProviderContract.AccountOrganization == accountOrganization,
                                   "Невозможно изменить место хранения. Собственная организация не соответствует организации, с которой заключен договор.");
            ValidationUtils.Assert(!HasReservedArticles, "Невозможно изменить место хранения и организацию для накладной, по которой имеется резервирование товара.");

            ReceiptStorage      = receiptStorage;
            AccountOrganization = accountOrganization;
        }
Пример #5
0
        /// <summary>
        /// Конструктор
        /// </summary>
        public MovementWaybill(string number, DateTime date, Storage senderStorage, AccountOrganization sender,
                               Storage recipientStorage, AccountOrganization recipient, ValueAddedTax valueAddedTax, User curator, User createdBy, DateTime creationDate)
            : base(WaybillType.MovementWaybill, number, date, curator, createdBy, creationDate)
        {
            ValidationUtils.Assert(senderStorage != recipientStorage, "Места хранения отправителя и получателя не могут совпадать.");

            ValidationUtils.Assert(valueAddedTax.Value == 0M || sender != recipient,
                                   "Накладная, в которой организации-отправитель и получатель совпадают, не может иметь ненулевой НДС.");

            SenderStorage    = senderStorage;
            Sender           = sender;
            RecipientStorage = recipientStorage;
            Recipient        = recipient;
            ValueAddedTax    = valueAddedTax;

            State = MovementWaybillState.Draft;
        }
Пример #6
0
        public ReturnFromClientWaybill(string number, DateTime date, AccountOrganization recipient, Deal deal, Team team, Storage recipientStorage,
                                       ReturnFromClientReason returnFromClientReason, User curator, User createdBy, DateTime creationDate)
            : base(WaybillType.ReturnFromClientWaybill, number, date, curator, createdBy, creationDate)
        {
            ValidationUtils.NotNull(deal, "Не указана сделка.");
            ValidationUtils.NotNull(recipient, "Не указана организация-приемщик.");
            ValidationUtils.NotNull(recipientStorage, "Не указано место хранения-приемщик.");
            ValidationUtils.NotNull(returnFromClientReason, "Не указана причина возврата.");
            ValidationUtils.NotNull(team, "Не указана команда.");

            State         = ReturnFromClientWaybillState.Draft;
            distributions = new HashedSet <DealPaymentDocumentDistributionToReturnFromClientWaybill>();

            Recipient              = recipient;
            RecipientStorage       = recipientStorage;
            ReturnFromClientReason = returnFromClientReason;
            Deal = deal;
            Team = team;

            // Автоматически переводим сделку на этап "Закрытие договора", если она была закрыта
            deal.MoveToContractClosingStage();
        }
Пример #7
0
 public ChangeOwnerWaybill(string number, DateTime date, Storage storage, AccountOrganization sender, AccountOrganization recipient, ValueAddedTax valueAddedTax,
                           User curator, User createdBy, DateTime creationDate)
     : base(WaybillType.ChangeOwnerWaybill, number, date, curator, createdBy, creationDate)
 {
     Storage       = storage;
     Sender        = sender;
     Recipient     = recipient;
     ValueAddedTax = valueAddedTax;
     State         = ChangeOwnerWaybillState.Draft;
 }