Skip to content

Commit

Permalink
POS: Quittung parken
Browse files Browse the repository at this point in the history
  • Loading branch information
z4m1n0 committed Jan 20, 2025
1 parent db7d17f commit 15a630c
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 16 deletions.
69 changes: 69 additions & 0 deletions SL/Controller/POS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use SL::DB::DeliveryOrder::TypeData qw(:types);
use SL::DB::TaxZone;
use SL::DB::Currency;

use SL::DBUtils qw(do_query);
use SL::Locale::String qw(t8);

use Rose::Object::MakeMethods::Generic
Expand All @@ -27,6 +28,10 @@ sub action_add {
my ($self) = @_;
$::form->{type} = SALES_ORDER_TYPE();

if ($::form->{id}) {
$self->load_receipt(delete $::form->{id});
}

$self->order(SL::Model::Record->update_after_new($self->order));

$self->order_controller->pre_render();
Expand Down Expand Up @@ -143,6 +148,47 @@ sub action_add_discount_item_dialog {
);
}

sub action_parking_receipt {
my ($self) = @_;
my $order = $self->order;

SL::DB->client->with_transaction( sub {
$order->save();
my $query = <<SQL;
SQL
do_query(
$::form,
SL::DB->client->dbh,
q| UPDATE oe SET record_type = ? WHERE id = ? |,
SALES_RECEIPT_ORDER_TYPE(), $order->id
);
$self->order(undef);
1;
});

$self->redirect_to(
action => 'add',
);
}

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

my $orders = SL::DB::Manager::Order->get_all(
where => [
record_type => SALES_RECEIPT_ORDER_TYPE(),
],
sort_by => 'itime',
);

$self->render(
'pos/_receipt_load_dialog', { layout => 0 },
popup_dialog => 1,
popup_js_close_function => '$("#receipt_load_dialog").dialog("close")',
ORDERS => $orders,
);
}

sub action_to_delivery_order {
my ($self) = @_;
my $order = $self->order;
Expand Down Expand Up @@ -182,6 +228,29 @@ sub order {
$self->order_controller->order(@_);
}

sub load_receipt {
my ($self, $order_id) = @_;

my $order_to_delete = SL::DB::Manager::Order->find_by(
id => $order_id,
record_type => SALES_RECEIPT_ORDER_TYPE,
);

return unless $order_to_delete;

$order_to_delete->record_type(SALES_ORDER_TYPE());

my $new_order = SL::Model::Record->new_from_workflow(
$order_to_delete,
SALES_ORDER_TYPE(),
no_linked_records => 1
);
$order_to_delete->delete;

return $self->order($new_order);
}


#
# intits
#
Expand Down
2 changes: 1 addition & 1 deletion SL/DB/MetaSetup/Order.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ __PACKAGE__->meta->columns(
payment_id => { type => 'integer' },
proforma => { type => 'boolean', default => 'false' },
quonumber => { type => 'text' },
record_type => { type => 'enum', check_in => [ 'request_quotation', 'sales_quotation', 'purchase_quotation_intake', 'purchase_order', 'sales_order_intake', 'sales_order', 'purchase_order_confirmation' ], db_type => 'order_types', not_null => 1 },
record_type => { type => 'enum', check_in => [ 'request_quotation', 'sales_quotation', 'purchase_quotation_intake', 'purchase_order', 'sales_order_intake', 'sales_order', 'purchase_order_confirmation', 'sales_receipt' ], db_type => 'order_types', not_null => 1 },
reqdate => { type => 'date' },
salesman_id => { type => 'integer' },
shippingpoint => { type => 'text' },
Expand Down
5 changes: 4 additions & 1 deletion SL/DB/Order/TypeData.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ use constant {
PURCHASE_QUOTATION_INTAKE_TYPE => 'purchase_quotation_intake',
SALES_ORDER_INTAKE_TYPE => 'sales_order_intake',
PURCHASE_ORDER_CONFIRMATION_TYPE => 'purchase_order_confirmation',
SALES_RECEIPT_ORDER_TYPE => 'sales_receipt',
};

my @export_types = qw(SALES_ORDER_TYPE PURCHASE_ORDER_TYPE REQUEST_QUOTATION_TYPE SALES_QUOTATION_TYPE
PURCHASE_QUOTATION_INTAKE_TYPE SALES_ORDER_INTAKE_TYPE PURCHASE_ORDER_CONFIRMATION_TYPE);
PURCHASE_QUOTATION_INTAKE_TYPE SALES_ORDER_INTAKE_TYPE PURCHASE_ORDER_CONFIRMATION_TYPE
SALES_RECEIPT_ORDER_TYPE
);
my @export_subs = qw(valid_types validate_type is_valid_type get get3);

our @EXPORT_OK = (@export_types, @export_subs);
Expand Down
11 changes: 11 additions & 0 deletions css/design40/less/pos.less
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@
padding: 0 !important;
display: inline-block;
}

.pos_button_div{
min-height: 50px;
min-width: 50px;
border: solid green !important;
text-align: center;
color: black;
font-weight: bold;
padding: 0 !important;
display: inline-block;
}
2 changes: 1 addition & 1 deletion css/design40/style.css

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions js/kivi.POS.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,18 @@ namespace('kivi.POS', function(ns) {
$.post("controller.pl", data, kivi.eval_json_result);
}

ns.open_receipt_load_dialog = function() {
kivi.popup_dialog({
url: 'controller.pl?action=POS/open_receipt_load_dialog',
id: 'receipt_load_dialog',
load: function() {
kivi.reinit_widgets();
},
dialog: {
title: kivi.t8('Open stored receipts'),
width: 800,
height: 600
}
});
}
});
6 changes: 6 additions & 0 deletions sql/Pg-upgrade2/oe_sales_receipt_order_types.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- @tag: oe_sales_receipt_order_types
-- @description: order_types-Eintrag für geparkte Quittung (sales_receipt)
-- @depends: release_3_9_0
-- @ignore: 0

ALTER TYPE order_types ADD VALUE IF NOT EXISTS 'sales_receipt';
38 changes: 38 additions & 0 deletions templates/design40_webpages/pos/_receipt_load_dialog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[% USE T8 %]
[% USE L %]
[% USE P %]
[% USE LxERP %]
[% USE HTML %]

<div>
<div>
[% FOREACH order = ORDERS %]
<div
class="pos_button_div control-panel"
onclick='document.forms["receipt_form_[% order.id %]"].submit()'
>
<form method="post" id="receipt_form_[% order.id %]" action="controller.pl">
[% L.hidden_tag("action", "POS/add") %]
[% L.hidden_tag("id", order.id) %]
</form>
<table class="tbl-list">
<caption>
[% order.customer.displayable_name %]
</caption>
<body>
[% FOREACH item = order.items_sorted %]
<tr>
<td>
[% item.part.displayable_name | html %]
</td>
</tr>
[% END %]
</body>
</table>
</div>
[% END %]
</div>
<p>
[% L.button_tag(popup_js_close_function, LxERP.t8('Cancel'), class="neutral") %]
</p>
</div>
38 changes: 25 additions & 13 deletions templates/design40_webpages/pos/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

<h1>[% FORM.title %]</h1>

[% SELF = SELF.order_controller %]

<form method="post" action="controller.pl" id="order_form">
[% L.hidden_tag('id', SELF.order.id) %]
[% L.hidden_tag('type', SELF.order.type) %]
Expand Down Expand Up @@ -50,8 +52,8 @@ <h1>[% FORM.title %]</h1>
<div class="left_input control-panel small">[% "Salesman" | $T8 %]
[% L.select_tag(
'order.salesman_id',
SELF.order_controller.all_salesmen,
default=(SELF.order.salesman_id ? SELF.order.salesman_id : SELF.order_controller.current_employee_id),
SELF.all_salesmen,
default=(SELF.order.salesman_id ? SELF.order.salesman_id : SELF.current_employee_id),
class='wi-lightwide',
title_key='safe_name'
) %]
Expand Down Expand Up @@ -133,21 +135,21 @@ <h1>[% FORM.title %]</h1>
<td>
[% L.select_tag(
'order.taxzone_id',
SELF.order_controller.all_taxzones,
SELF.all_taxzones,
default=SELF.order.taxzone_id,
title_key='description',
class='recalc wi-lightwide'
) %]
</td>
</tr>
<!-- CURRENCY und EXCAHANGERATE rausgenommen -->
[% IF SELF.order_controller.all_languages.size %]
[% IF SELF.all_languages.size %]
<tr>
<th>[% 'Language' | $T8 %]</th>
<td>
[% L.select_tag(
'order.language_id',
SELF.order_controller.all_languages,
SELF.all_languages,
default=SELF.order.language_id,
title_key='description',
with_empty=1,
Expand All @@ -156,13 +158,13 @@ <h1>[% FORM.title %]</h1>
</td>
</tr>
[% END %]
[% IF SELF.order_controller.all_departments.size %]
[% IF SELF.all_departments.size %]
<tr>
<th>[% 'Department' | $T8 %]</th>
<td>
[% L.select_tag(
'order.department_id',
SELF.order_controller.all_departments,
SELF.all_departments,
default=SELF.order.department_id,
title_key='description',
with_empty=1,
Expand Down Expand Up @@ -211,7 +213,7 @@ <h1>[% FORM.title %]</h1>
<td colspan="2">
<span class="label above">[% 'Payment Terms' | $T8 %]</span>
[% L.select_tag('order.payment_id',
SELF.order_controller.all_payment_terms,
SELF.all_payment_terms,
default = SELF.order.payment_id,
with_empty = 1,
title_key = 'description',
Expand All @@ -224,7 +226,7 @@ <h1>[% FORM.title %]</h1>
<span class="label above">[% 'Delivery Terms' | $T8 %]</span>
[% L.select_tag(
'order.delivery_term_id',
SELF.order_controller.all_delivery_terms,
SELF.all_delivery_terms,
default = SELF.order.delivery_term_id,
with_empty = 1,
title_key = 'description',
Expand All @@ -233,7 +235,7 @@ <h1>[% FORM.title %]</h1>
</td>
</tr>
<tr id="taxincluded_row_id">
[% IF !SELF.order_controller.taxes.size %]
[% IF !SELF.taxes.size %]
<th>
<label for="order.taxincluded">
[% 'Tax Included' | $T8 %]
Expand Down Expand Up @@ -289,7 +291,7 @@ <h1>[% FORM.title %]</h1>
<table>

[% SET n_col = 12 %]
[% IF SELF.order_controller.search_cvpartnumber %]
[% IF SELF.search_cvpartnumber %]
[% SET n_col = n_col + 1 %]
[% END %]

Expand Down Expand Up @@ -377,8 +379,18 @@ <h1>[% FORM.title %]</h1>
>
[% "on Delivery Order" | $T8 %]
</div>
<div class="pos_button control-panel">Quittung parken</div>
<div class="pos_button control-panel">geparkte Quittung</div>
<div
class="pos_button control-panel"
onclick="kivi.POS.submit({action: 'parking_receipt'})"
>
[% "Parking Receipt" | $T8 %]
</div>
<div
class="pos_button control-panel"
onclick="kivi.POS.open_receipt_load_dialog()"
>
[% "Parked Receipts" | $T8 %]
</div>
<div class="pos_button control-panel">Bezahlen</div>
<div class="pos_button control-panel">Abbrechen</div>
</div>
Expand Down

0 comments on commit 15a630c

Please sign in to comment.