You are on page 1of 5

--update version

update swversioninfo
set swverno='Raptor 4.00',swlstupddate=convert(varchar(10),getdate(),121)
GO

if not exists(select * from sysobjects o inner join syscolumns c on o.id=c.id where


o.name='POSDtls' and c.name='LabelTable')
BEGIN
alter table POSDtls
ADD LabelTable varchar(10) default 'TABLE:'
END
GO

update POSDtls set LabelTable = 'TABLE:'


GO

if not exists(select * from sysobjects o inner join syscolumns c on o.id=c.id where


o.name='POS_KPs' and c.name='Area')
BEGIN
alter table POS_KPs
ADD Area varchar(4)
END
GO

if not exists(select * from sysobjects o inner join syscolumns c on o.id=c.id where


o.name='PLU' and c.name='Description')
BEGIN
alter table PLU
ADD Description varchar(255)
END
GO

update plu set description=pluname

GO

if not exists(select * from sysobjects o inner join syscolumns c on o.id=c.id where


o.name='POSDefaults' and c.name='LastVoid')
BEGIN
alter table POSDefaults
ADD LastVoid bit default 1
END
GO

update POSDefaults set LastVoid = 1


GO

Insert Into Functions


(functionid,Type,Type_Chinese,Class,featuretitle1,featuretitle2,featuretitle3,Param
eterTitle)
Values (135,'Stock Adjust In','Stock Adjust In',2,'','','','')

GO

if not exists(select * from sysobjects o inner join syscolumns c on o.id=c.id where


o.name='Operator' and c.name='OpReopenbill')
BEGIN
alter table Operator
ADD OpReopenbill bit default 0
END
GO

---PluStock_SelectData

Create procedure PluStock_SelectData


@PLUName varchar(25)
As
begin
SELECT P.PLUName,P.PLUNumber,P.PLUActive,(isnull(Q.Qty,0))as Qty,p.costPrice
FROM PLU P
left outer join Stock_Location Q on p.PluNumber = Q.PluNO
WHERE (LnkTo = 'T' or LnkTo = 'V') and PLUName like @PLUName + '%'
ORDER BY PLUName
End

Go

if not exists(select * from sysobjects o inner join syscolumns c on o.id=c.id where


o.name='POSDefaults' and c.name='PrintBarCode')
BEGIN
alter table POSDefaults
ADD PrintBarCode bit default 0
END
GO

-- New table reopenlog

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Logreopen](
[Sno] [int] IDENTITY(1,1) NOT NULL,
[SalesNo] [int] NULL,
[SplitNo] [smallint] NULL,
[SDate] [datetime] NULL,
[Operatorno] [smallint] NULL
) ON [PRIMARY]

GO
-- SP for re-open bill

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-----------------------------------
ReopenBill---------------------------------------
Create procedure [dbo].[ReopenBill]
@Salesno integer,
@Splitno smallint,
@Operatorno smallint

AS

Declare @intErrorCode int


Begin Tran
--Check First
Declare @tableno varchar(20)
select @tableno = tableno from salestblstemp
Where Salesno = @Salesno and Splitno = @Splitno and Operatorno = @Operatorno

If Not Exists (Select * from Heldtables Where tableno = @Tableno)

Begin
--Update Salestblstemp to return value
Update Salestblstemp
Set TransStatus = 'H',
Balance = GTotal,
PaidAmount = 0,
Close_Date = NULL,
Close_Time = NULL
Where Salesno = @Salesno and Splitno = @Splitno and Operatorno =
@Operatorno

Select @intErrorCode = @@Error


If (@intErrorCode <> 0) Goto Problem

--Delete Salesitemtemp where is payment have been add


Delete SalesItemstemp
Where Functionid in (1,2,3,4,5,6,7,8,9,0) and
Salesno = @Salesno and Splitno = @Splitno and Operatorno =
@Operatorno

Select @intErrorCode = @@Error


If (@intErrorCode <> 0) Goto Problem

--Update bill
Update RcptDtls
Set Finalized = 0,
Printed = 0,
Copyno = 0
Where Salesno = @Salesno and Splitno = @Splitno and Operatorno =
@Operatorno

Select @intErrorCode = @@Error


If (@intErrorCode <> 0) Goto Problem

--Move data from Salesitemstemp to helditems


insert into Helditems
(POSID,OperatorNo,Covers,TableNo,SalesNo,SplitNo,PLUSalesRef
,ItemSeqNo,PLUNo,Department,SDate,STime,Quantity,ItemName
,ItemName_Chinese,ItemAmount,PaidAmount,ChangeAmount
,Gratuity,Tax0,Tax1,Tax2,Tax3,Tax4,Tax5,Tax6,Tax7,Tax8,Tax9
,Adjustment,DiscountType,DiscountPercent,Discount,PromotionId
,PromotionType,PromotionSaving,TransMode,RefundID,TransStatus
,FunctionID,SubFunctionID,MembershipID,LoyaltyCardNo,CustomerID
,CardScheme,CreditCardNo,AvgCost,RecipeId,PriceShift,CategoryId
,TransferredTable,TransferredOp,KitchenPrint1,KitchenPrint2
,KitchenPrint3,RedemptionItem,PointsRedeemed,ShiftID,PrintFreePrep
,PrintPrepWithPrice,Preparation,FOCItem,FOCType,ApplyTax0,ApplyTax1
,ApplyTax2,ApplyTax3,ApplyTax4,ApplyTax5,ApplyTax6,ApplyTax7,ApplyTax8
,ApplyTax9,LnkTo,BuyXfreeYapplied,RndingAdjustments,Setmenu,SetMenuRef
,Instruction,PostSendVoid,TblHold,DepositID,TSalesRef,TSalesNo,TSplitNo
,RentalItem,RentToDate,RentToTime,MinsRented,SeatNo,SalesAreaID,Busines
sDate
,ServerNo,OperatorFOC,OperatornoFirst,cc_promo1,cc_promo2,Voucherseqno
,tbl_servedtime,ServedStatus,comments,Switchid,OperatorPromo,Trackprep
,RentFromTime,promptRentalWarning,CPRVoucherNo,ForeignPaidAmnt)

select POSID,OperatorNo,Covers,TableNo,SalesNo,SplitNo,PLUSalesRef
,ItemSeqNo,PLUNo,Department,SDate,STime,Quantity,ItemName
,ItemName_Chinese,ItemAmount,PaidAmount,ChangeAmount
,Gratuity,Tax0,Tax1,Tax2,Tax3,Tax4,Tax5,Tax6,Tax7,Tax8,Tax9
,Adjustment,DiscountType,DiscountPercent,Discount,PromotionId
,PromotionType,PromotionSaving,TransMode,RefundID,TransStatus
,FunctionID,SubFunctionID,MembershipID,LoyaltyCardNo,CustomerID
,CardScheme,CreditCardNo,AvgCost,RecipeId,PriceShift,CategoryId
,TransferredTable,TransferredOp,KitchenPrint1,KitchenPrint2
,KitchenPrint3,RedemptionItem,PointsRedeemed,ShiftID,PrintFreePrep
,PrintPrepWithPrice,Preparation,FOCItem,FOCType,ApplyTax0,ApplyTax1
,ApplyTax2,ApplyTax3,ApplyTax4,ApplyTax5,ApplyTax6,ApplyTax7,ApplyTax8
,ApplyTax9,LnkTo,BuyXfreeYapplied,RndingAdjustments,Setmenu,SetMenuRef
,Instruction,PostSendVoid,TblHold,DepositID,TSalesRef,TSalesNo,TSplitNo
,RentalItem,RentToDate,RentToTime,MinsRented,SeatNo,SalesAreaID,Busines
sDate
,ServerNo,OperatorFOC,OperatornoFirst,cc_promo1,cc_promo2,Voucherseqno
,tbl_servedtime,ServedStatus,comments,Switchid,OperatorPromo,Trackprep
,RentFromTime,promptRentalWarning,CPRVoucherNo,ForeignPaidAmnt
from Salesitemstemp
Where Salesno = @Salesno and Splitno = @Splitno and Operatorno =
@Operatorno

Delete Salesitemstemp
Where Salesno = @Salesno and Splitno = @Splitno and Operatorno =
@Operatorno

Select @intErrorCode = @@Error


If (@intErrorCode <> 0) Goto Problem

--Move data from SalesTblstemp to heldtables


Insert into Heldtables
(POSID,SalesNo,SplitNo,LastSplit,OperatorNo,TableNo
,Covers,TransMode,TransStatus,MembershipID,LoyaltyCardNo
,PromotionId,Open_Date,Open_Time,Close_Date,Close_Time
,STotal,GTotal,PaidAmount,Balance,RsvtnID,PrntStatus
,RcptNo,SalesAreaID,BusinessDate,OperatornoFirst,OperatorFOC
,tblCardNo,Remarks,BalancePoints,Balances,
BonusValue,DepositValue,RemarksLine)

Select POSID,SalesNo,SplitNo,LastSplit,OperatorNo,TableNo
,Covers,TransMode,TransStatus,MembershipID,LoyaltyCardNo
,PromotionId,Open_Date,Open_Time,Close_Date,Close_Time
,STotal,GTotal,PaidAmount,Balance,RsvtnID,PrntStatus
,RcptNo,SalesAreaID,BusinessDate,OperatornoFirst,OperatorFOC
,tblCardNo,Remarks,BalancePoints,Balances,
BonusValue,DepositValue,RemarksLine
from salestblstemp
Where Salesno = @Salesno and Splitno = @Splitno and Operatorno =
@Operatorno

Delete salestblstemp
Where Salesno = @Salesno and Splitno = @Splitno and Operatorno =
@Operatorno

Select @intErrorCode = @@Error


If (@intErrorCode <> 0) Goto Problem

--Update TblLayout
Declare @Tblno varchar(20)
select @Tblno = Tableno from HeldTables
Where Salesno = @Salesno and Splitno = @Splitno and Operatorno =
@Operatorno

Update TblLayout
set TblStatus = 'H'
Where Tblno = @Tblno

-- Insert into log


Insert into LogreOpen (Salesno,Splitno,Sdate,Operatorno) values
(@salesno,@splitno,Current_TimeStamp,@Operatorno)

Select @intErrorCode = @@Error


If (@intErrorCode <> 0) Goto Problem

Raiserror ('Success!',16,1)

End
Else
Raiserror ('Table has already used it, please wait!',16,1)
Commit Tran

PROBLEM:
If (@intErrorCode <> 0) Begin
Print 'Unexpected error occurred!'
Rollback Tran
END

GO

You might also like