示例#1
0
        public long Save(long tranId, DateTime valueDate, int storeId, string partyCode, int priceTypeId, string referenceNumber, string data, string statementReference, string attachmentsJSON)
        {
            if (!StockTransaction.IsValidStockTransactionByTransactionMasterId(tranId))
            {
                throw new InvalidOperationException(Resources.Warnings.InvalidStockTransaction);
            }

            if (!StockTransaction.IsValidPartyByTransactionMasterId(tranId, partyCode))
            {
                throw new InvalidOperationException(Resources.Warnings.InvalidParty);
            }

            Collection <StockDetail> details = CollectionHelper.GetStockMasterDetailCollection(data, storeId);

            if (!this.ValidateDetails(details, tranId))
            {
                return(0);
            }

            Collection <Attachment> attachments = CollectionHelper.GetAttachmentCollection(attachmentsJSON);

            int  officeId = CurrentSession.GetOfficeId();
            int  userId   = CurrentSession.GetUserId();
            long loginId  = CurrentSession.GetLogOnId();

            return(Data.Transactions.Return.PostTransaction(tranId, valueDate, officeId, userId, loginId, storeId, partyCode, priceTypeId, referenceNumber, statementReference, details, attachments));
        }
示例#2
0
        public long Save(DateTime valueDate, int storeId, string partyCode, int priceTypeId, string referenceNumber,
                         string data, string statementReference, string transactionIds, string attachmentsJSON, bool nonTaxable,
                         int salespersonId, int shipperId, string shippingAddressCode)
        {
            try
            {
                Collection <StockDetail> details = CollectionHelper.GetStockMasterDetailCollection(data, storeId);
                Collection <long>        tranIds = new Collection <long>();

                Collection <Attachment> attachments = CollectionHelper.GetAttachmentCollection(attachmentsJSON);

                if (!string.IsNullOrWhiteSpace(transactionIds))
                {
                    foreach (string transactionId in transactionIds.Split(','))
                    {
                        tranIds.Add(Conversion.TryCastInteger(transactionId));
                    }
                }

                int  officeId      = AppUsers.GetCurrent().View.OfficeId.ToInt();
                int  userId        = AppUsers.GetCurrent().View.UserId.ToInt();
                long loginId       = AppUsers.GetCurrent().View.LoginId.ToLong();
                int  validDuration = AppUsers.GetCurrent().View.SalesQuotationValidDuration.ToInt();

                long tranId = Data.Transactions.Quotation.Add(AppUsers.GetCurrentUserDB(), officeId, userId, loginId,
                                                              valueDate, partyCode, priceTypeId, details, referenceNumber, statementReference, tranIds,
                                                              attachments, nonTaxable, salespersonId, shipperId, shippingAddressCode, storeId);
                string token = Data.Transactions.Quotation.AddValidation(AppUsers.GetCurrentUserDB(), validDuration,
                                                                         tranId);

                if (tranId > 0)
                {
                    this.CreateEmail(tranId, partyCode, token);
                }

                return(tranId);
            }
            catch (Exception ex)
            {
                Log.Warning("Could not save sales quotation entry. {Exception}", ex);
                throw;
            }
        }