#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2011 RoyaltyShare, Inc.   All Rights Reserved
#---------------------------------------------------------------
package BookPub::RDAS::Form::POSData::File;
use strict;
use warnings;
use Carp;

use lib '/app/tools/common/lib';
use lib '/app/tools/bookpub/lib';
use Common::Date;
use Common::RSApp;
use Common::Util;
use Common::Assert;
use Common::FormObject;

use base 'Common::FormObject';

sub _init {
    my ( $self, %args ) = @_;

    $self->SUPER::_init(%args);
    $self->_initProperties( \%args );

    return $self;
}

sub _initProperties {
    my ( $self, $props ) = @_;

    $self->{Filename}  = $props->{filename};
    $self->{Content}   = $props->{content};
    $self->{StartDate} = $props->{startDate};
    $self->{POSFileID} = $props->{posFileID};
}

sub Content   { shift->{Content} }
sub Filename  { shift->{Filename} }
sub POSFileID { shift->{POSFileID} }

sub periodLength { 1 }    # in days

sub StartDate {
    my $date = shift->{StartDate};
    assert($date);

    return Common::Date->new($date)->asString();
}

sub EndDate {
    my $self = shift;

    assert( $self->StartDate );

    my $addDays = $self->periodLength - 1;
    return $self->StartDate unless ($addDays);

    my $start = new Common::Date( $self->StartDate );
    my $end   = $start->clone->addDays($addDays);

    return $end->asString();
}

###
1;    #
###
