Business-AU-Ledger

 view release on metacpan or  search on metacpan

htdocs/assets/templates/business/au/ledger/monthly.tabs.js  view on Meta::CPAN

			{key: "amount"},
			{key: "category"},
			{key: "day"},
			{key: "error"},
			{key: "gst_amount"},
			{key: "gst_category"},
			{key: "payment_method"},
			{key: "petty_cash_in"},
			{key: "petty_cash_out"},
			{key: "private_use_amount"},
			{key: "private_use_percent"},
			{key: "reference"},
			{key: "submit"},
			{key: "tx_detail"}
			]
			};
			var column_defs =
			[
			 {key: "day", label: "Day"},
			 {key: "category",  label: "Category"},
			 {key: "tx_detail",  label: "Detail"},
			 {key: "payment_method",  label: "Pay via"},
			 {key: "reference",  label: "Reference"},
			 {key: "amount",  label: "$"},
			 {key: "gst_category", label: "GST category"},
			 {key: "gst_amount",  label: "GST $"},
			 //{key: "private_use_percent",  label: "Priv. %"},
			 //{key: "private_use_amount",  label: "Priv. $"},
			 //{key: "petty_cash_in",  label: "Petty $ in"},
			 //{key: "petty_cash_out",  label: "Petty $ out"},
			 {key: "submit",  label: ""}
			];
			var data_table = new YAHOO.widget.DataTable(div_name, column_defs, json_data);
		}
		else
		{
			var e = document.getElementById(div_name);

lib/Business/AU/Ledger/Database/Payment.pm  view on Meta::CPAN

	return $payment;

} # End of get_payments_via_ym.

# --------------------------------------------------

sub save_payment_record
{
	my($self, $context, $payment) = @_;
	my($table_name)               = 'payments';
	my(@field)                    = (qw/category_code gst_code month payment_method tx_detail amount comment gst_amount petty_cash_in petty_cash_out private_use_amount private_use_percent reference timestamp/);
	my($data)                     = {};
	my(%id)                       =
	(
	 category_code  => 1,
	 gst_code       => 1,
	 month          => 1,
	 payment_method => 1,
	 tx_detail      => 1,
	);

lib/Business/AU/Ledger/Util/Create.pm  view on Meta::CPAN

gst_code_id integer not null references gst_codes(id),
month_id integer not null references months(id),
payment_method_id integer not null references payment_methods(id),
tx_detail_id integer not null references tx_details(id),
amount numeric(10, 2) not null,
comment varchar(255) not null,
gst_amount numeric(10, 2) not null,
petty_cash_in numeric(10, 2) not null,
petty_cash_out numeric(10, 2) not null,
private_use_amount numeric(10, 2) not null,
private_use_percent numeric(6, 2) not null,
reference varchar(255) not null,
timestamp timestamp $time_option not null
)
SQL
	$self -> log("Created table $table_name");

}	# End of create_payments_table.

# --------------------------------------------------

lib/Business/AU/Ledger/Util/Validate.pm  view on Meta::CPAN

# -----------------------------------------------

sub payment_profile
{
	my($self) = @_;

	return
	{
		constraint_method_regexp_map =>
		{
			qr/(?:(?:|gst_|private_use_|)amount|petty_cash_(?:in|out)|private_use_percent)/ => validate_amount(),
		},
		constraint_methods =>
		{
			day   => sub {return validate_day(pop)},
			month => sub {return validate_month(pop)},
			rm    => sub {return pop eq 'submit_payment' ? 1 : 0},
		},
		filters                => [sub {return clean_user_data(shift, 250)}, 'strip'],
		missing_optional_valid => 1,
		msgs                   =>
		{
			any_errors => 'error',
			prefix     => 'field_',
		},
		optional_regexp => qr/^(?:gst_amount|gst_code|petty_cash_in|petty_cash_out|private_use_amount|private_use_percent|reference|tx_detail)_\d+$/,
		required        => [qw/month rm sid/],
		required_regexp => qr/^(?:amount|category_code|day|payment_method|submit)_\d+$/,
	};

} # End of payment_profile.

# --------------------------------------------------

sub receipt
{

lib/Business/AU/Ledger/View/Payment.pm  view on Meta::CPAN


	$self -> field_width
	(
	 {
		 amount              => 12,
		 day                 =>  5, # For 'Total'.
		 gst_amount          => 12,
		 petty_cash_in       =>  7,
		 petty_cash_out      =>  7,
		 private_use_amount  => 10,
		 private_use_percent =>  6,
		 reference           => 10,
	 }
	);
	$self -> row_count(0);

} # End of BUILD;

# -----------------------------------------------

sub format

lib/Business/AU/Ledger/View/Payment.pm  view on Meta::CPAN


# -----------------------------------------------

sub format_fields
{
	my($self, $default) = @_;
	$default            ||= {};

	# Ensure all fields, except menus, have defaults.

	for (qw/amount day error gst_amount petty_cash_in petty_cash_out private_use_amount private_use_percent reference timestamp/)
	{
		if (! defined $$default{$_})
		{
			$$default{$_} = '';
		}
	}

	$self -> row_count($self -> row_count + 1);

	# The 'day' field will either come from the timestamp in a pre-existing record, or a total, or we leave it blank.

lib/Business/AU/Ledger/View/Payment.pm  view on Meta::CPAN

		amount              => qq|<input type="text" name="amount_$row_count" id="amount_$row_count" size="$$field_width{'amount'}" value="$$default{'amount'}" />|,
		category            => $self -> build_select('payment', 'category_code', "_$row_count", $$default{'category_code_id'} || 1),
		day                 => qq|<input type="text" name="day_$row_count" id="day_$row_count" size="$$field_width{'day'}" value="$$default{'day'}" />|,
		error               => $$default{'error'},
		gst_amount          => qq|<input type="text" name="gst_amount_$row_count" id="gst_amount_$row_count" size="$$field_width{'gst_amount'}" value="$$default{'gst_amount'}" />|,
		gst_category        => $self -> build_select('payment', 'gst_code', "_$row_count", $$default{'gst_code_id'} || 1),
		payment_method      => $self -> build_select('payment', 'payment_method', "_$row_count", $$default{'payment_method_id'} || 1),
		petty_cash_in       => qq|<input type="text" name="petty_cash_in_$row_count" id="petty_cash_in_$row_count" size="$$field_width{'petty_cash_in'}" value="$$default{'petty_cash_in'}" />|,
		petty_cash_out      => qq|<input type="text" name="petty_cash_out_$row_count" id="petty_cash_out_$row_count" size="$$field_width{'petty_cash_out'}" value="$$default{'petty_cash_out'}" />|,
		private_use_amount  => qq|<input type="text" name="private_use_amount_$row_count" id="private_use_amount_$row_count" size="$$field_width{'private_use_amount'}" value="$$default{'private_use_amount'}" />|,
		private_use_percent => qq|<input type="text" name="private_use_percent_$row_count" id="private_use_percent_$row_count" size="$$field_width{'private_use_percent'}" value="$$default{'private_use_percent'}" />|,
		reference           => qq|<input type="text" name="reference_$row_count" id="reference_$row_count" size="$$field_width{'reference'}" value="$$default{'reference'}" />|,
		submit              => qq|<input type="submit" name="submit_$row_count" id="submit_$row_count" value="Submit" />|,
		tx_detail           => $self -> build_select('payment', 'tx_detail', "_$row_count", $$default{'tx_detail_id'} || 1),
	};

	# Clean up the total line.

	if (! $$default{'timestamp'})
	{
		if ($$default{'day'} eq 'Total')
		{
			for (qw/category tx_detail gst_category payment_method private_use_percent reference submit/)
			{
				$$result{$_} = '';
			}
		}
	}

	return $result;

} # End of format_fields.

lib/Business/AU/Ledger/View/Payment.pm  view on Meta::CPAN

			}

			# Set defaults for optional fields.

			$$input{'comment'}             ||= '';
			$$input{'gst_amount'}          ||= 0.00;
			$$input{'month'}               = $month_number;
			$$input{'petty_cash_in'}       ||= 0.00;
			$$input{'petty_cash_out'}      ||= 0.00;
			$$input{'private_use_amount'}  ||= 0.00;
			$$input{'private_use_percent'} ||= 0.00;
			$$input{'reference'}           ||= '';

			for (sort keys %$input)
			{
				$self -> log("Saving $_ => $$input{$_}");
			}

			$self -> db -> payment -> add($input);
		}



( run in 0.379 second using v1.01-cache-2.11-cpan-709fd43a63f )