sales tax
This commit is contained in:
parent
4deff2a0a9
commit
f3ab99bc02
23 changed files with 607 additions and 111 deletions
|
|
@ -44,36 +44,37 @@ sub description {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub handler {
|
||||
my $self = shift;
|
||||
|
||||
### Add to group action
|
||||
# If group is 'everyone', skip
|
||||
unless ($self->{_product}->get('groupId') eq '7') {
|
||||
my $g = WebGUI::Group->new($self->session,$self->{_product}->get('groupId'));
|
||||
my $expiresOffset;
|
||||
|
||||
# Parse the value
|
||||
if ($self->{_product}->get('groupExpiresOffset') =~ /^(\d+)month/i) {
|
||||
$expiresOffset = $1 * 3600*24*30; # One month
|
||||
} elsif ($self->{_product}->get('groupExpiresOffset') =~ /^(\d+)year/i) {
|
||||
$expiresOffset = $1 * 3600*24*365; # One year
|
||||
}
|
||||
|
||||
# Multiply by how many quantity we're purchasing
|
||||
#!!! TODO !!! - handlers don't know how many we're purchasing
|
||||
|
||||
# If user has time left
|
||||
my $remains = $g->userGroupExpireDate($self->session->user->userId);
|
||||
if ($remains) {
|
||||
# Add any remaining time to the offset
|
||||
$expiresOffset += $remains - time();
|
||||
}
|
||||
|
||||
# Add user to group
|
||||
$g->addUsers([$self->session->user->userId],$expiresOffset);
|
||||
}
|
||||
my $self = shift;
|
||||
|
||||
### Add to group action
|
||||
# If group is 'everyone', skip
|
||||
unless ($self->{_product}->get('groupId') eq '7') {
|
||||
my $g = WebGUI::Group->new($self->session,$self->{_product}->get('groupId'));
|
||||
my $expiresOffset;
|
||||
|
||||
# Parse the value
|
||||
if ($self->{_product}->get('groupExpiresOffset') =~ /^(\d+)month/i) {
|
||||
$expiresOffset = $1 * 3600*24*30; # One month
|
||||
} elsif ($self->{_product}->get('groupExpiresOffset') =~ /^(\d+)year/i) {
|
||||
$expiresOffset = $1 * 3600*24*365; # One year
|
||||
}
|
||||
|
||||
# Multiply by how many quantity we're purchasing
|
||||
#!!! TODO !!! - handlers don't know how many we're purchasing
|
||||
|
||||
# If user has time left
|
||||
my $remains = $g->userGroupExpireDate($self->session->user->userId);
|
||||
if ($remains) {
|
||||
# Add any remaining time to the offset
|
||||
$expiresOffset += $remains - time();
|
||||
}
|
||||
|
||||
# Add user to group
|
||||
$g->addUsers([$self->session->user->userId],$expiresOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub id {
|
||||
return $_[0]->{_variant}->{variantId};
|
||||
|
|
@ -121,6 +122,12 @@ sub price {
|
|||
return $_[0]->{_variant}->{price};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub useSalesTax {
|
||||
my $self = shift;
|
||||
return $self->{_product}->get('useSalesTax') ? 1 : 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub type {
|
||||
return 'Product';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue