I can now emit the invoice
[breadcrumbs.git] / src / lib / Bcd / Commands / GetPriceEstimateCommand.pm
blob72416d2edbbaacc8ea61abaa82107899400afc83
1 package Bcd::Commands::GetPriceEstimateCommand;
3 # This file is part of the breadcrumbs daemon (bcd).
4 # Copyright (C) 2007 Pasqualino Ferrentino
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
21 # Contact: lino.ferrentino@yahoo.it (in Italian, English or German).
23 use strict;
24 use warnings;
26 use threads;
27 use threads::shared;
29 #My base class is the create user command
30 use Bcd::Commands::SessionCommand;
31 use base(qq/Bcd::Commands::SessionCommand/);
32 use Data::Dumper;
34 use constant NAME => "cad_get_price_estimate";
36 sub get_name{
37 return NAME;
40 sub new {
41 my $class = shift;
42 my $self = $class->SUPER::new(@_);
44 $self->{privilege_required} = Bcd::Data::Users::ANT_ROLE;
46 push (@{$self->{parameters}}, "seller_id");
47 push (@{$self->{parameters}}, "price");
48 push (@{$self->{parameters}}, "can_use_credit");
50 bless ($self, $class);
51 return $self;
54 sub _exec{
55 #I should get the name and password of the user.
56 my ($self, $stash) = @_;
57 my $my_id = $stash->get_session_id($self->{session_id});
59 #ok, I should only call the function.
60 my
62 $credits_towards_seller,
63 $cheque_amount,
64 $cheque_price,
65 $convertible_tao,
66 $total_price,
67 $can_be_payed_now) = Bcd::Data::CreditsAndDebits->get_price_estimate_report_for_a_payment
68 ($stash, $my_id, $self->{seller_id}, $self->{price}, $self->{can_use_credit});
70 $self->{credits_towards_seller} = $credits_towards_seller;
71 $self->{cheque_amount} = $cheque_amount;
72 $self->{cheque_price} = $cheque_price;
73 $self->{convertible_tao} = $convertible_tao;
74 $self->{total_price} = $total_price;
75 $self->{can_be_payed_now} = $can_be_payed_now;
77 #ok, it should be all ok
78 $self->{exit_code} = Bcd::Errors::ErrorCodes::BEC_OK;
82 sub _add_your_specific_output{
83 my ($self, $output) = @_;
85 $self->_add_scalar("credits_towards_seller", $self->{credits_towards_seller}, $output);
86 $self->_add_scalar("cheque_amount", $self->{cheque_amount}, $output);
87 $self->_add_scalar("cheque_price", $self->{cheque_price}, $output);
88 $self->_add_scalar("convertible_tao", $self->{convertible_tao}, $output);
89 $self->_add_scalar("total_price", $self->{total_price}, $output);
90 $self->_add_scalar("can_be_payed_now", $self->{can_be_payed_now}, $output);