Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/src/components/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ const menus = computed<Menu[]>(() => [
label: "Return Invoice",
icon: RotateCcw,
shortcut: "Ctrl+R",
hidden: () => !hasPermission("sale_return"),
disabled: () => !posStore.allowReturn,
action: () => {
window.dispatchEvent(new CustomEvent("xpos:show-return-dialog"));
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
</Button>
</TooltipWrapper>

<TooltipWrapper v-if="posStore.allowReturn" :content="__('Process Return')">
<TooltipWrapper v-if="posStore.allowReturn && hasPermission('sale_return')" :content="__('Process Return')">
<Button
variant="ghost"
size="sm"
Expand All @@ -108,7 +108,7 @@
</TooltipWrapper>

<TooltipWrapper
v-if="posStore.allowPrintLastInvoice && posStore.lastInvoiceName && hasPermission('allow_reprint_invoice')"
v-if="posStore.lastInvoiceName && hasPermission('allow_reprint_invoice')"
:content="__('Print Last Invoice')"
>
<Button
Expand Down Expand Up @@ -334,7 +334,7 @@ function handleShowRepeatDialog() {
}

function handleShowReturnDialog() {
if (!posStore.allowReturn) return;
if (!posStore.allowReturn || !hasPermission("sale_return")) return;
showReturnDialog.value = true;
}

Expand All @@ -345,7 +345,7 @@ function handleKeyboard(e: KeyboardEvent) {
}
if (e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "r") {
e.preventDefault();
if (posStore.allowReturn) showReturnDialog.value = true;
if (posStore.allowReturn && hasPermission("sale_return")) showReturnDialog.value = true;
}
}

Expand Down
7 changes: 4 additions & 3 deletions frontend/src/components/cart/CartItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</p>

<div class="flex items-center gap-1 mt-0.5 flex-wrap">
<template v-if="posStore.allowEditRate">
<template v-if="hasPermission('allow_change_price')">
<span class="text-[11px] text-muted-foreground">{{ currencySymbol }}</span>
<input
ref="rateInput"
Expand Down Expand Up @@ -127,7 +127,7 @@
<Plus class="w-2.5 h-2.5" />
</Button>

<template v-if="posStore.allowEditItemDiscount">
<template v-if="hasPermission('show_edit_discount_field')">
<button
@click="showDiscountInput = !showDiscountInput"
class="ms-1 px-1.5 py-0.5 rounded text-[10px] font-medium transition-all"
Expand All @@ -144,7 +144,7 @@
</div>

<div
v-if="showDiscountInput && posStore.allowEditItemDiscount"
v-if="showDiscountInput && hasPermission('show_edit_discount_field')"
class="mt-1.5 p-2 bg-emerald-50 dark:bg-emerald-900/20 rounded-md border border-emerald-200 dark:border-emerald-800"
>
<div class="flex items-center gap-2">
Expand Down Expand Up @@ -208,6 +208,7 @@
<script setup lang="ts">
import { ref, computed, watch, onMounted, nextTick } from "vue";
import { usePosStore } from "@/stores/posStore";
import { hasPermission } from "@/services/userRights";
import { useCartStore } from "@/stores/cartStore";
import { useItemStore } from "@/stores/itemStore";
import { Button } from "@/components/ui/button";
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/cart/CartSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<div class="flex gap-2">
<TooltipWrapper :content="__('Additional Discount')">
<Button
v-if="posStore.allowEditAdditionalDiscount"
v-if="hasPermission('apply_additional_discount')"
variant="outline"
size="sm"
:class="{
Expand Down Expand Up @@ -343,6 +343,7 @@
<script setup lang="ts">
import { ref, computed, watch } from "vue";
import { usePosStore } from "@/stores/posStore";
import { hasPermission } from "@/services/userRights";
import { useCartStore } from "@/stores/cartStore";
import { useOfferStore } from "@/stores/offerStore";
import { call, showSuccess, showError } from "@/services/api";
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/dialogs/ItemDetailDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
{{ __("Price") }}
</label>
<NumberInput
v-if="posStore.allowEditRate"
v-if="hasPermission('allow_change_price')"
v-model="priceInput"
:min="0"
:precision="2"
Expand Down Expand Up @@ -192,6 +192,7 @@ import { ref, computed, watch, nextTick } from "vue";
import { useItemStore } from "@/stores/itemStore";
import { useCartStore } from "@/stores/cartStore";
import { usePosStore } from "@/stores/posStore";
import { hasPermission } from "@/services/userRights";
import { showError } from "@/services/api";
import {
Dialog,
Expand Down
48 changes: 24 additions & 24 deletions frontend/src/components/dialogs/PaymentDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -407,30 +407,6 @@
/>
</div>

<div class="space-y-1">
<div class="flex items-center justify-between">
<label
class="text-xs font-semibold text-muted-foreground uppercase tracking-wider"
>
{{ __("Posting Date") }}
</label>
<span
v-if="!posStore.allowChangePostingDate"
class="text-xs text-muted-foreground"
>
{{ __("Locked by POS Profile") }}
</span>
</div>
<DateTimePicker
v-model="cartStore.postingDate"
mode="date"
:disabled="!posStore.allowChangePostingDate"
:clearable="false"
placeholder="Posting date"
class="text-sm"
/>
</div>

<div class="flex gap-2 mt-auto">
<div
v-if="changeAmount > 0"
Expand Down Expand Up @@ -463,6 +439,30 @@
</p>
</div>
</div>

<div class="space-y-1">
<div class="flex items-center justify-between">
<label
class="text-xs font-semibold text-muted-foreground uppercase tracking-wider"
>
{{ __("Posting Date") }}
</label>
<span
v-if="!posStore.allowChangePostingDate"
class="text-xs text-muted-foreground"
>
{{ __("Locked by POS Profile") }}
</span>
</div>
<DateTimePicker
v-model="cartStore.postingDate"
mode="date"
:disabled="!posStore.allowChangePostingDate"
:clearable="false"
placeholder="Posting date"
class="text-sm"
/>
</div>
</div>

<div class="hidden lg:flex flex-col w-64 border-s border-border p-4 gap-3">
Expand Down
54 changes: 2 additions & 52 deletions frontend/src/services/userRights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,32 @@ import { isElectron } from "./electronBridge";
import { call } from "./api";

export interface PosPermissions {
close_bill: boolean;
close_shift: boolean;
allow_reprint_invoice: boolean;
print_draft_invoice: boolean;
shift_report: boolean;
allow_cancel_invoice: boolean;
unsettled_invoices: boolean;
apply_additional_discount: boolean;
apply_standard_discount: boolean;
show_edit_discount_field: boolean;
edit_tax_template: boolean;
allow_change_price: boolean;
quotation: boolean;
sale_return: boolean;
local_purchase: boolean;
purchase_order: boolean;
purchase_invoice: boolean;
stock_adjustment: boolean;
stock_entry: boolean;
near_expiry_items: boolean;
expense: boolean;
bank_drop: boolean;
list_of_invoices: boolean;
list_of_cancelled_invoices: boolean;
list_of_errors: boolean;
list_of_purchase_invoices: boolean;
list_of_quotations: boolean;
list_of_stock_entries: boolean;
list_of_local_purchases: boolean;
list_of_stock_adjustments: boolean;
list_of_expense: boolean;
list_of_bank_drops: boolean;
invoice_settlement_report: boolean;
sales_report_by_time: boolean;
sales_summary_by_hour: boolean;
current_stock_by_brand: boolean;
stock_register: boolean;
current_stock_report: boolean;
}

const DEFAULT_PERMISSIONS: PosPermissions = {
close_bill: true,
close_shift: false,
allow_reprint_invoice: false,
print_draft_invoice: false,
shift_report: false,
allow_cancel_invoice: false,
unsettled_invoices: false,
apply_additional_discount: false,
apply_standard_discount: false,
show_edit_discount_field: false,
edit_tax_template: false,
allow_change_price: false,
quotation: false,
sale_return: false,
local_purchase: false,
purchase_order: false,
purchase_invoice: false,
stock_adjustment: false,
stock_entry: false,
near_expiry_items: false,
expense: false,
bank_drop: false,
list_of_invoices: true,
list_of_cancelled_invoices: false,
list_of_errors: false,
list_of_purchase_invoices: false,
list_of_quotations: false,
list_of_stock_entries: false,
list_of_local_purchases: false,
list_of_stock_adjustments: false,
list_of_expense: false,
list_of_bank_drops: false,
invoice_settlement_report: false,
sales_report_by_time: false,
sales_summary_by_hour: false,
current_stock_by_brand: false,
stock_register: false,
current_stock_report: false,
};

Expand Down
17 changes: 0 additions & 17 deletions frontend/src/stores/posStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export const usePosStore = defineStore("pos", () => {

const defaultCustomer = computed(() => posProfile.value?.customer || "");

const allowEditRate = computed(() => !!posProfile.value?.allow_rate_change);

const hideImages = computed(() => !!posProfile.value?.hide_images);

const hideUnavailableItems = computed(() => !!posProfile.value?.hide_unavailable_items);
Expand All @@ -100,12 +98,6 @@ export const usePosStore = defineStore("pos", () => {

const useOfflineMode = computed(() => !!posProfile.value?.use_offline_mode);

const allowEditItemDiscount = computed(() => !!posProfile.value?.allow_discount_change);

const allowEditAdditionalDiscount = computed(
() => !!posProfile.value?.allow_user_to_edit_additional_discount,
);

const allowChangePostingDate = computed(() => !!posProfile.value?.allow_change_posting_date);

const displayItemsInStock = computed(() => !!posProfile.value?.display_items_in_stock);
Expand All @@ -122,8 +114,6 @@ export const usePosStore = defineStore("pos", () => {

const allowDeleteOfflineInvoice = computed(() => !!posProfile.value?.allow_delete_offline_invoice);

const allowPrintLastInvoice = computed(() => !!posProfile.value?.allow_print_last_invoice);

const displayAdditionalNotes = computed(() => !!posProfile.value?.display_additional_notes);

const allowWriteOffChange = computed(() => !!posProfile.value?.allow_write_off_change);
Expand Down Expand Up @@ -164,8 +154,6 @@ export const usePosStore = defineStore("pos", () => {

const applyCustomerDiscount = computed(() => !!posProfile.value?.apply_customer_discount);

const allowPrintDraftInvoices = computed(() => !!posProfile.value?.allow_print_draft_invoices);

const enableCashierSettlement = computed(() => !!posProfile.value?.enable_cashier_settlement);

const printBackupReceipt = computed(() => !!posProfile.value?.print_backup_receipt);
Expand Down Expand Up @@ -506,9 +494,6 @@ export const usePosStore = defineStore("pos", () => {
companyName,
sellingPriceList,
defaultCustomer,
allowEditRate,
allowEditItemDiscount,
allowEditAdditionalDiscount,
allowChangePostingDate,
displayItemsInStock,
allowPartialPayment,
Expand All @@ -517,7 +502,6 @@ export const usePosStore = defineStore("pos", () => {
allowReturnWithoutInvoice,
allowSalesOrder,
allowDeleteOfflineInvoice,
allowPrintLastInvoice,
displayAdditionalNotes,
allowWriteOffChange,
displayItemCode,
Expand All @@ -538,7 +522,6 @@ export const usePosStore = defineStore("pos", () => {
returnValidityDays,
useCustomerCredit,
applyCustomerDiscount,
allowPrintDraftInvoices,
enableCashierSettlement,
printBackupReceipt,
cashModeOfPayment,
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/types/pos.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,19 @@ export interface POSProfile {
write_off_cost_center?: string;
selling_price_list?: string;
default_customer?: string;
allow_rate_change?: boolean;
allow_change_posting_date?: boolean;
allow_user_to_edit_additional_discount?: boolean;
allow_discount_change?: boolean;
display_items_in_stock?: boolean;
allow_partial_payment?: boolean;
allow_credit_sale?: boolean;
allow_return?: boolean;
allow_return_without_invoice?: boolean;
allow_sales_order?: boolean;
allow_delete_offline_invoice?: boolean;
allow_print_last_invoice?: boolean;
display_additional_notes?: boolean;
allow_write_off_change?: boolean;
input_qty?: boolean;
display_item_code?: boolean;
allow_zero_rated_items?: boolean;
allow_print_draft_invoices?: boolean;
enable_cashier_settlement?: boolean;
print_backup_receipt?: boolean;
auto_set_batch?: boolean;
Expand Down
Loading
Loading