TableSpec for Food Bank Transaction Headers

USR_FOODBANKTXHEADER

The food bank transaction (TX) header table stores top-level inventory transaction records for a food bank. Every time someone donates or receives food from a food bank, a row is created in this table. Top-level transaction information such as the constituent who donated or received food, the total amount of food for a given transaction, the transaction date, and receipt information are tracked in this table. The USR_FOODBANKTXHEADER table tracks the type of transaction ("Receive" or "Distribute") and is used to calculate current inventory levels for a food bank. The FOODBANKTXTYPECODE field supports an Enumeration with a value of 0 – Receive and 1 – Distribute. A food bank tracks one-to-many transaction header records. A constituent can participate in one-to-many food bank transactions.

<TableSpec 
	xmlns="bb_appfx_table"
	xmlns:common="bb_appfx_commontypes" 
	ID="a63143ab-d71e-4a5a-aa75-a93b3a052459"
	Name="Food Bank Transaction Header"
	Description="Top level food bank transaction table."
	Author="Technical Training"
	IsCustomizable="true"
	Tablename="USR_FOODBANKTXHEADER"		   
	>

	<!-- define fields on the table -->
	<Fields>
		<ForeignKeyField
			 ForeignTable="USR_FOODBANK"
			 Description="A food bank can have many transaction header rows."
			 Name="FOODBANKID"
			 OnDelete="CascadeDelete"
			 Required="true"
			 Cardinality="ManyToOne"
		/>


		<ForeignKeyField
			Name="CONSTITUENTID"
			ForeignTable="CONSTITUENT"
			Description="The constituent who either donates food or receives food from the food bank."
			Cardinality="ManyToOne"
			OnDelete="RaiseError"
			Required="true"
			/>


			
			<MoneyField Name="TOTALAMOUNT" DefaultValue="0" Description="Total transaction amount.  Sum of food item amounts on the food bank transactiopn detail."/>

		<EnumField DefaultValue="0" Name="FOODBANKTXTYPECODE" Description="The tx type code.">
			<EnumValues>
				<EnumValue ID="0" Translation="Receive"/>
				<EnumValue ID="1" Translation="Distribute"/>
			</EnumValues>
		</EnumField>

		
		
		<DateField Name="TXDATE" Required="true"/>

		<BooleanField Name="RECEIPTPRINTED" DefaultValue="0"  Description="Was a receipt printed?"  />
    

	</Fields>


	<!-- define any indexes on the table -->
	<Indexes>
		<Index>
			<IndexFields>
				<IndexField Name="FOODBANKID"/>
			</IndexFields>
		</Index>
		<Index>
			<IndexFields>
				<IndexField Name="CONSTITUENTID"/>
			</IndexFields>
		</Index>
	</Indexes>
		 

</TableSpec>