rtslink.com
Home / Free Tally utilities / Recycle bin for Tally


Recycle bin for Tally ERP 9, Tally 9 and Tally 7.2



Recycle bin for Tally

Recycle bin


Recycle bin is a FREE add-on utility for Tally Software.

Recycle bin allows you to retrieve records that you may have accidentally deleted in Tally Accounting Software.

It is similar to Windows Recycle-bin which allows you to recover the deleted files.

Recycle bin works with Tally ERP 9, Tally 9 and Tally 7.2.

To use the Recycle bin utility, you need to make certain changes in your Tally.ini file which are given underneath.

And if you are familiar with TDL, you can go through the source-code also.







How to install and use it ?

  • Download the Recycle bin for Tally TCP files (zip)
  • Copy the file according to your Tally version. i.e.
    If you are using Tally ERP 9, then copy rbin9-erp.tcp into the Tally folder  or;
    If you are using Tally 9, then copy rbin9v.tcp into the Tally folder  or;
    If you are using Tally 7.2, then copy rbin.tcp  into your Tally folder
  • Open Tally.ini file and make the changes as shown below :-

    For Tally ERP 9 users
    User TDL=Yes
    tdl=c:\tally\rbin9-erp.tcp

    For Tally 9 users
    User TDL=Yes
    tdl=c:\tally\rbin9v.tcp

    For Tally 7.2 users
    User TDL=Yes
    tdl=c:\tally\rbin.tcp
  • Save the file and start Tally. You would see extra option of Recycle Bin.
  • After this, when you delete any voucher in Tally; it is still available in the Recycle bin and you can restore it back; if required.


Source Code for Recycle bin TCP (for Tally 9 and Tally 7.2 only)

For better clarity, we decided to put up the code with step-by-step instructions rather than pasting the whole code altogether. The Recycle bin source-code consists of 5 files viz:
rbin.txt; rbin1.txt; rbin2.txt; rbin3.txt; rbin4.txt


Here's the source-code for Recycle bin utility with comments and explanation. 

STEP 1
[Task:- Add a menu option to the "Gateway of Tally" menu]


TDL Code:-

[#Menu: Gateway of Tally]
   Add: Item: Before:  Reports: @@locRecyclebin :Display :Rpt Deleted Vouchers :NOT $$IsEmpty:$$SelectedCmps
   Add: Item: After: @@locRecyclebin: Blank 
   Control :@@locRecyclebin: $$Allow:Create:Vouchers

[System: Formula] 
    locRecyclebin : $$LocaleString:"Recycle Bin"

Remarks:-
a) The above code adds a new menu-option "Recycle-bin" before the static menu-item 'Reports'. It  displays a Report 
     "RptDeleted Vouchers" which we shall be creating in the next step. 
b) The condition  'NOT: $$IsEmpty:$$SelectedCmps'   disables the 'Recycle bin' menu-option if NO company is selected / open.
c)  A blank line is added after the new menu-option.
d) The CONTROL attribute is used to specify the  Access-rights to the 'Recycle bin' menu option. The menu-option is displayed  only
     if the user has the rights to Create Vouchers.
e) locRecyclebin is a defined as Global String [formula].


STEP 2
[Task:- Define a new Report named 'Rpt Deleted Vouchers' and some Global variables]


TDL Code:-

;;Report  definition
[Report: Rpt  Deleted Vouchers] 
   Use: Voucher Register
   Title : "Recycle Bin"
   Local: Line: DSP Vchdetail: Empty: NOT $fldDeleted 
  
   ;;Set values for Pre-defined Global variables
   Set: FamilyVoucherFlag: Yes 
   Set: SV ToDate : $$YearEnd:##SVCurrentDate
  
   ;;Set values for user-defined Global variables
   Set: lConfirmation: Yes 
   Set: IsRestoreMode: Yes

;;Global variables required in our program
[System: Variable]
   RecycleBinFlag: "No"
   IsRestoreMode: "No"
   lConfirmation: "No"

;;Variable definition
[Variable: RecycleBinFlag]
   Type: Logical
   Volatile: Yes
   Persistent: No

[Variable: IsRestoreMode]
   Type: Logical
   Volatile: No
   Persistent: no

[Variable: lConfirmation]
   Type: Logical
   Persistent: No
   Volatile : Yes
   Default: No

Remarks:-
a) The above code adds a new report based (inherited) on the pre-defined report 'Voucher Register'.
b) The TITLE attribute is used to set the title of this new report as 'Recycle bin'.
c) The attribute LOCAL is used to locally modify the pre-defined LINE 'DSP VchDetail'. It specifies a condition that the line
    'DSP VchDetail' must be displayed only when the field 'fldDeleted' is set to Yes (i.e not empty). We shall be declaring the
    field 'fldDeleted'  later on.
d) We have also declared some variables and assgined values to them. This shall be discussed later on.
e) In brief, this report shall display the Deleted Records.


STEP 3
[Task:- Add a logical Field  to the Voucher-entry FORM]


TDL Code:-

[#Form: Voucher]
   Local: Line : VCH NarrPrompt: Add: Fields: Recycle Bin
   Set Always: RecycleBinFlag: If ##IsRestoreMode then ##RecyclebinFlag else No

;; User Defined Fields
[System: UDF]
   fldDeleted: Logical : 1

[Field: Recycle Bin]
   Use: Logical field
   Storage: fldDeleted
   Set as: If ##IsRestoreMode then No else ##RecyclebinFlag
   Set Always: Yes
   Type: Logical
   Invisible: No

Remarks:-
a) The attribute LOCAL is used to locally modify the pre-defined LINE 'VCH NarrPrompt' and add  a new field 'Recycle bin'.
b) Next, we define the UDF 'fldDeleted'.

And here's what we have done so far with the whole code for the 1st file i.e. RBIN.TXT.

* We have added a logical field 'Recycle bin' (storage UDF 'fldDeleted') to the FORM  'Voucher' which is set as NO by default. 
   When a record is deleted by the user, we shall set this field to YES.
* We have defined a new Report 'Rpt Deleted Vouchers' that displays only those records which have been marked as deleted.
    i.e where the field 'fldDeleted'  is set to YES.

Here's RBIN.TXT Source-code, our first file.

TDL Code:-
;;Global variables definition
[System: Variable]
   RecycleBinFlag:  "No"
   IsRestoreMode: "No"
   lConfirmation: "No"

[Variable: RecycleBinFlag]
   Type: Logical
   Volatile: Yes
   Persistent: No

[Variable: IsRestoreMode]
   Type: Logical
   Volatile: No
   Persistent: No

[Variable: lConfirmation]
   Type: Logical
   Persistent: No
   Volatile : Yes
   Default: No

;;Global formula definition
[System: Formula] 
    locRecyclebin : $$LocaleString:"Recycle Bin"

;;Adding a new option to the 'Gateway of Tally'
[#Menu: GatewayofTally]
   Add: Item: Before:  Reports: @@locRecyclebin :Display :Rpt Deleted Vouchers :NOT $$IsEmpty:$$SelectedCmps
   Add: Item: After: @@locRecyclebin: Blank 
   Control :@@locRecyclebin: $$Allow:Create:Vouchers

;;A new Report that displays the deleted Vouchers
[Report: Rpt Deleted Vouchers] 
   Use: Voucher Register
   Title : "Recycle Bin"
  
   ;;This will filter out Deleted records. i.e. where the FIELD 'fldDeleted'' is set to YES
   Local: Line: DSP Vchdetail: Empty: NOT $fldDeleted
  
   ;;Set values for Pre-defined Global variables
   Set: FamilyVoucherFlag: Yes 
   Set: SV ToDate : $$YearEnd:##SVCurrentDate
  
   ;;Set values for user-defined Global variables
   Set: lConfirmation: Yes 
   Set: IsRestoreMode: Yes

;;Add a new (invisible) field to the Voucher-entry screen
[#Form: Voucher]
   Local: Line : VCH NarrPrompt: Add: Fields: Recycle Bin
   Set Always: RecycleBinFlag: If ##IsRestoreMode then ##RecyclebinFlag else No

;; User Defined Fields
[System: UDF]
   fldDeleted: Logical : 1

[Field: Recycle Bin]
   Use: Logical field
   Storage: fldDeleted
   Set as: If ##IsRestoreMode then No else ##RecyclebinFlag
   Set Always: Yes
   Type: Logical
   Invisible: No

;;Include other files code. We shall be creating these files in the later
[INCLUDE: rbin1.txt]
[INCLUDE: rbin2.txt]
[INCLUDE: rbin3.txt]
[INCLUDE: rbin4.txt]



If this has been too much for you, then go, have a break. We still have a long way to go. I am having a cup of tea. What
about you ?






Let's move to the next file.

FILE : RBIN1.TXT

STEP 4
[Task:- Modify the default functionality for the key Alt+D when used in the Voucher Alteration screen]

Here's the code for Rbin1.TXT file.


TDL Code:-

;;Modify the key 'Form Delete'  i.e. ALT+D functionality
[#Key: Form Delete]
   Option: RbinFormDelete: if ($$IsVoucher AND NOT ##IsRestoreMode) then Yes else No

[!Key: RbinFormDelete] 
   Key: Alt+D
   Action: Alter: Rpt Confirmation

;;Modify the key 'Delete Line Object' i.e. ALT+D functionality 
[#Key: Delete Line Object]
   Option: RbinDeleteLineObject: if ($$IsVoucher AND NOT ##IsRestoreMode) then Yes else No

[!Key: RbinDeleteLineObject]
   Key: Alt+D Action: Alter Object

;;CTRL+R - Restore Voucher
[Key: Restore from Bin]
    Key: CTRL+R Action: Alter Object


Remarks:-
a) The above code modifies TWO pre-defined Key definitions. vizi 'FORM DELETE' and 'DELETE LINE OBJECT'. In simple words, it
modifies the default functionality for key Alt+D.
b)  FORM DELETE
     When the user presses Alt+D key in the 'Voucher Alteration' screen, instead of prompting the user to prompt for Voucher 
    deletion, we have provided a new screen 'Rpt Deletion' which displays  a custom message 'Send to Recycle-bin'.
c) The condition $$IsVoucher ensures that the new functionality for Alt+D button is applicable only when the object is a Voucher.
     This will not affect when Alt+D is used to delete any Master record.
d)  DELETE LINE OBEJCT
     The other case is when user presses Alt+D in Daybook or other reports. This invokes the  'Delete Line Object' code. Herein we
     have modified the default functionality and instead of deleting the record, we use 'ALTER OBJECT'  to modify the OBJECT.
e) We have defined a new key 'Restore from Bin' which again uses the code 'ALTER OBJECT'  to modify the current object.

FILE : RBIN2.TXT

STEP 5
[Task:- Define Report 'Rpt Confirmation' which displays a custom message ''Delete Voucher [Yes/No]' when user presses Alt+D]


TDL Code:-
;;Define Report which prompts user for confirmation
[Report: Rpt Confirmation]
   Add: Form: frm Confirmation
   Variable: lConfirmation
   Set: lConfirmation: Yes
   Title: "Confirm"

[Form: frm Confirmation]
   Add: Part: Prt Heading,Prt Title, Prt YesNo
   Add: Bottom Part: Prt Caption
   Full Width : No
   No Confirm : Yes
   Space Left : 5
   Space Right : 5
   Space Top : 2
   Space Bottom: 1
   Width: 50% screen
   Height: 50% screen

[Part: Prt Heading]
   Horizontal Align: Centre
   Lines : ln Heading

[Part: Prt Title]
   Horizontal Align: Centre
   Lines : Form SubTitle
   Local : Field : Form SubTitle : Info : $$LocaleString:"Delete Voucher [Yes/No]"

[Part: Prt YesNo]
   Horizontal Align: Centre
   Lines : ln Confirmation

[Part: Prt Caption]
   Horizontal Align: Centre
   Lines : ln Caption1

[Line: ln Heading]
   Add: Field : fldHeading

[Line: ln Confirmation]
   Add: Field: fldConfirmation,fldRecyclebinFlag,fldOptionalFlag

[Line: ln Caption1]
   Add: Field: fldCaption1

[Field: fldConfirmation]
   Use: Logical Field
   Set as: ##lConfirmation
  
   ;;Store the field-value to Global variable lConfirmation
   Modifies: lConfirmation

[Field: fldRecycleBinFlag]
   Use: Logical Field
   Set as: #fldConfirmation
   Set Always: Yes
  
   ;;Store the field-value to Global variable RecyclebinFlag
   Modifies: RecycleBinFlag
   Skip: Yes
   Invisible: Yes

[Field: fldOptionalFlag]
   Use: Logical Field
   Set as: #fldConfirmation
   Set Always: Yes
  
   ;;Store the field-value to pre-defined Global variable OptionalFlag
   Modifies: OptionalFlag
   Skip: Yes
   Invisible: Yes

[Field: fldHeading]
   Info: "Recycle-bin for Tally"

[Field: fldCaption1] 
    Info: "Visit: www.tdlplayground.blogspot.com"

Remarks:-
a) The above code defines a dialog-screen (Report) named Rpt Confirmation.
b) This dialog-screen is invoked when the user presses Alt+D in the 'Voucher Alteration'  screen.  It  prompts the user with a Custom
     message 'DELETE VOUCHER [YES/NO]'.
c) The field 'fldConfirmation' is used to hold the value (Yes or No) entered by the user.
d) When the user enters Yes or No, it is automatically assigned to other fields viz. 'fldRecyclebinFlag' and 'fldOptionalFlag'. See that
    we have used Set as: '#fldConfirmation' to assign values.
e) The MODIFIES attribute at the field level assigns the field value to the Variables. i.e. If the User enters YES, it is assigned to
     Global vairables  'RecyclebinFlag' and 'OptionalFlag'
f) 'OptionalFlag' is a pre-defined Global variable whereas 'RecyclebinFlag' is a user-defined Global variable.
g) In breif, when the user presses Alt+D key, the Global variables 'RecyclebinFlag' and 'OptionalFlag'  are set to Yes.


FILE : RBIN3.TXT

STEP 6
[Task:- Hide the deleted records in Daybook and Ledger report (i.e. where fldDeleted is set to Yes)]



TDL Code:-

;;Daybook must display all vouchers except which are marked for  deletion (i.e. field 'fldDeleted' is set to YES)
[#Report: Daybook]
  Local: Line: DSP VchDetail: Empty : $fldDeleted
  Set: IsRestoreMode: No

;;Ledger Report must display all vouchers except which are marked for  deletion (i.e. field 'fldDeleted' is set to YES)
[#Report: Ledger Vouchers]
  Local: Line: DSP VchDetail: Empty : $fldDeleted
  Set: IsRestoreMode: No

;;Add Ctrl+R functional to Restore Voucher
[#Line: DSP VchDetail]
  Add: Option: DSP VchDetail Restore: $fldDeleted

[!Line: DSP VchDetail Restore]
  Add: Keys: Restore from Bin

Remarks:-
a) The Daybook Report has been modified so as to display records which have been marked as deleted (i.e. fldDeleted is Yes). This
     is accomplished using condition EMPTY: $fldDeleted.
b) We have also added functionality for Ctrl+R key to Restore Voucher.


FILE : RBIN4.TXT

STEP 7
[Task:- Modify the existing Voucher Entry screen and display message to prompt user for 'Deleting' or 'Restoring' the Voucher]



TDL Code:-

;;The field 'VCH Optional' is modified so as to display a custom message as defined by the Option 'Rbin VCH Delete' and
;;Option 'Rbin VCH Restore' 
[#Field: VCH Optional]
  Option: Rbin VCH Delete: ##OptionalFlag and NOT ##IsRestoreMode
  Option: Rbin VCH Restore: ##OptionalFlag and ##IsRestoreMode

;;Optional field definition
[!Field: Rbin VCH Delete] 
  Style: My Style
  Set as: if #Recyclebin then "Press ENTER-KEY to send this voucher to the RECYCLE-BIN." else @UseOptStr
  Skip: if #Recyclebin then No else Yes

[Style: My Style]
  Font: Verdana
  Height: 18
  Bold: Yes

;;Optional field definition
[!Field: Rbin VCH Restore] 
  Add: Fields: Long Prompt,fldConfirmation,SetRecyclebinFlag,SetRecyclebinField,SetOptionalFlag,SetOptionalField 
  Local: Field: Long Prompt: Info: "About to RESTORE Voucher. Press ENTER-key to confirm."
  Local: Field: Long Prompt: Full Width: Yes
  Local: Field: Long Prompt: Align: Right
  Local: Field: Long Prompt: Style: My Style

[Field: SetRecyclebinFlag]
  Use: Logical field
  Type: Logical : Forced
  Modifies: RecyclebinFlag
  Set as: NOT #fldConfirmation
  Set Always: Yes
  Invisible: Yes
  Skip: Yes

[Field: SetRecyclebinField]
  Use: Logical field
  Type: Logical
  Storage: fldDeleted
  Set as: #SetRecyclebinFlag
  Set Always: Yes
  Invisible: Yes
  Skip: Yes

[Field: SetOptionalFlag]
  Use: Logical field
  Type: Logical
  Modifies: OptionalFlag
  Set as: #SetRecyclebinFlag
  Set Always: Yes
  Invisible: Yes
  Skip: Yes

[Field: SetOptionalField]
  Use : Logical Field
  Storage : Is Optional
  Set as : #SetOptionalFlag
  Set always : Yes
  Invisible : Yes
  Skip : Yes

;; Modify Voucher entry screen
[#Form: Voucher]
  Option: RbinVoucher: ##OptionalFlag

[!Form: RbinVoucher]
   Key: SaveVoucher

[Key: SaveVoucher]
  Key: Enter
  Action: Form Accept

[#Field: Plain VCH Date]
   Option: Rbin Plain VCH Date: ##OptionalFlag

[!Field: RBin Plain VCH Date]
  Skip: if #RecycleBin then Yes else No


Remarks:-
a) The default Voucher Entry screen has a field named 'VCH Optional' which is used to display a text-string 'Optional' in case 
    if the Voucher has been marked as Optional. Instead of defining a new-field, we use this field 'VCH Optional' to display our own
    Custom message.
   
    We have defined 'Rbin VCH Delete' and 'Rbin VCH Restore' as Optional fields for the field 'VCH Optional'. In simple words, the
    definition for field 'VCH Optional' is replaced by the either 'Rbin VCH Delete' or 'Rbin VCH Restore' definition depending upon
    the condition specified therein.

b) Now, let's see what happens when User presses Alt+D key in the 'Voucher Alteration' screen.
    - First, a dailog box is displayed that prompts the user to Delete Voucher (as defined in STEP 5) 
    - If the user selects Yes, the variables 'RecycleBinFlag' and 'OptionalFlag' are set to Yes (as defined earlier in STEP 5)
    - Now in STEP 7, the 'VCH Optional' is set to a custom message and 'fldConfirmation' is used to accept user-input Yes or No. 
    - The FORM  (i.e. voucher) is saved when user hits the ENTER key (as the default value for 'fldConfirmation' is Yes).
    - This sets  the field  'flddeleted' to Yes and field 'Optional' to Yes.

c) Similar provision is kept for Voucher Restoration.
   

CONCLUSION

Our Objective was to change the default functionality for the key Alt+D which is used to delete Vouchers. Instead of deleting the Voucher, we now do the following :-

a) Mark the Voucher as Optional.
b) Set the UDF-field  'fldDeleted'  to Yes.

This takes care of the following:-
*  Marking the Voucher as Optional ensures that the Voucher is not reflected in any books of Accounts.
*  The UDF-field 'fldDeleted'  is used in the reports (Daybook; Ledger Voucher) to filter out records where the field
    'fldDeleted'  is set to No.
*  The same UDF-field 'fldDeleted' is used in the report 'Rpt Deleted Vouchers' as shown in Step-1. This report displays only those 
    records where  the UDF-field 'fldDeleted' is set as Yes.

That's All. 


Download the source-code for Recycle bin utility for Tally ERP 9. It's FREE.

Download the source-code for Recycle bin utility for older Tally versions. It's FREE.

Download the TCP file for Recycle bin utility for Tally ERP 9 , Tally 9 and Tally 7.2. It's FREE


Tags:-
Tally Definition Language, Tally Customization, Tally ERP 9, Tally 9, Tally 7.2, Free Tally TDL, Training, Download Tally TDL
Tally is a registered trademark of Tally Solutions FZ LLC.


Valid HTML 4.01 Transitional