mirror of
https://github.com/frappe/books.git
synced 2025-01-09 09:50:27 +00:00
fix: refactored
This commit is contained in:
parent
1ea6867e1f
commit
0eda30623c
@ -11,6 +11,9 @@ export class POSSettings extends Doc {
|
|||||||
cashAccount?: string;
|
cashAccount?: string;
|
||||||
writeOffAccount?: string;
|
writeOffAccount?: string;
|
||||||
weightEnabledBarcode?: boolean;
|
weightEnabledBarcode?: boolean;
|
||||||
|
checkDigit?: number;
|
||||||
|
itemCodeDigits?: number;
|
||||||
|
itemWeight?: number;
|
||||||
|
|
||||||
posUI?: 'Classic' | 'Modern';
|
posUI?: 'Classic' | 'Modern';
|
||||||
|
|
||||||
@ -25,5 +28,8 @@ export class POSSettings extends Doc {
|
|||||||
hidden: HiddenMap = {
|
hidden: HiddenMap = {
|
||||||
weightEnabledBarcode: () =>
|
weightEnabledBarcode: () =>
|
||||||
!this.fyo.singles.InventorySettings?.enableBarcodes,
|
!this.fyo.singles.InventorySettings?.enableBarcodes,
|
||||||
|
checkDigit: () => !this.fyo.singles.InventorySettings?.enableBarcodes,
|
||||||
|
itemCodeDigits: () => !this.fyo.singles.InventorySettings?.enableBarcodes,
|
||||||
|
itemWeight: () => !this.fyo.singles.InventorySettings?.enableBarcodes,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -73,25 +73,20 @@ export default defineComponent({
|
|||||||
|
|
||||||
const isWeightEnabled =
|
const isWeightEnabled =
|
||||||
this.fyo.singles.POSSettings?.weightEnabledBarcode;
|
this.fyo.singles.POSSettings?.weightEnabledBarcode;
|
||||||
const randomNumberLength = this.fyo.singles.POSSettings
|
const checkDigit = this.fyo.singles.POSSettings?.checkDigit as number;
|
||||||
?.randomNumberLength as number;
|
const itemCodeDigits = this.fyo.singles.POSSettings
|
||||||
const ItemBarcodeLength = this.fyo.singles.POSSettings
|
?.itemCodeDigits as number;
|
||||||
?.ItemBarcodeLength as number;
|
const itemWeight = this.fyo.singles.POSSettings?.itemWeight as number;
|
||||||
const quantityBarcodeLength = this.fyo.singles.POSSettings
|
|
||||||
?.quantityBarcodeLength as number;
|
|
||||||
|
|
||||||
if (
|
if (code.length !== checkDigit + itemCodeDigits + itemWeight) {
|
||||||
code.length !==
|
|
||||||
randomNumberLength + ItemBarcodeLength + quantityBarcodeLength
|
|
||||||
) {
|
|
||||||
return this.error(this.t`Barcode ${barcode} has an invalid length.`);
|
return this.error(this.t`Barcode ${barcode} has an invalid length.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const filters: Record<string, string> = isWeightEnabled
|
const filters: Record<string, string> = isWeightEnabled
|
||||||
? {
|
? {
|
||||||
weightBarcode: barcode.slice(
|
weightBarcode: barcode.slice(
|
||||||
randomNumberLength,
|
checkDigit,
|
||||||
randomNumberLength + ItemBarcodeLength
|
checkDigit + itemCodeDigits
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
: { barcode };
|
: { barcode };
|
||||||
@ -109,7 +104,7 @@ export default defineComponent({
|
|||||||
? this.parseBarcode(
|
? this.parseBarcode(
|
||||||
barcode,
|
barcode,
|
||||||
unit as string,
|
unit as string,
|
||||||
randomNumberLength + ItemBarcodeLength
|
checkDigit + itemCodeDigits
|
||||||
)
|
)
|
||||||
: 1;
|
: 1;
|
||||||
|
|
||||||
@ -118,7 +113,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
parseBarcode(barcode: string, unitType: string, sliceDigit: number) {
|
parseBarcode(barcode: string, unitType: string, sliceDigit: number) {
|
||||||
const weightRaw = parseInt(barcode.slice(sliceDigit), sliceDigit);
|
const weightRaw = parseInt(barcode.slice(sliceDigit));
|
||||||
|
|
||||||
let itemQuantity = 0;
|
let itemQuantity = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user