-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #709 from akshayitzme/feat-pos-page
feat: point of sale
- Loading branch information
Showing
46 changed files
with
3,155 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Doc } from 'fyo/model/doc'; | ||
import { Money } from 'pesa'; | ||
|
||
export abstract class CashDenominations extends Doc { | ||
denomination?: Money; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Doc } from 'fyo/model/doc'; | ||
import { FormulaMap } from 'fyo/model/types'; | ||
import { Money } from 'pesa'; | ||
|
||
export class ClosingAmounts extends Doc { | ||
closingAmount?: Money; | ||
differenceAmount?: Money; | ||
expectedAmount?: Money; | ||
openingAmount?: Money; | ||
paymentMethod?: string; | ||
|
||
formulas: FormulaMap = { | ||
differenceAmount: { | ||
formula: () => { | ||
if (!this.closingAmount) { | ||
return this.fyo.pesa(0); | ||
} | ||
|
||
if (!this.expectedAmount) { | ||
return this.fyo.pesa(0); | ||
} | ||
|
||
return this.closingAmount.sub(this.expectedAmount); | ||
}, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { CashDenominations } from './CashDenominations'; | ||
|
||
export class ClosingCash extends CashDenominations { | ||
count?: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { CashDenominations } from './CashDenominations'; | ||
|
||
export class DefaultCashDenominations extends CashDenominations {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Doc } from 'fyo/model/doc'; | ||
import { Money } from 'pesa'; | ||
|
||
export class OpeningAmounts extends Doc { | ||
amount?: Money; | ||
paymentMethod?: 'Cash' | 'Transfer'; | ||
|
||
get openingCashAmount() { | ||
return this.parentdoc?.openingCashAmount as Money; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { CashDenominations } from './CashDenominations'; | ||
|
||
export class OpeningCash extends CashDenominations { | ||
count?: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Doc } from 'fyo/model/doc'; | ||
import { FiltersMap } from 'fyo/model/types'; | ||
import { | ||
AccountRootTypeEnum, | ||
AccountTypeEnum, | ||
} from 'models/baseModels/Account/types'; | ||
|
||
export class POSSettings extends Doc { | ||
inventory?: string; | ||
cashAccount?: string; | ||
writeOffAccount?: string; | ||
|
||
static filters: FiltersMap = { | ||
cashAccount: () => ({ | ||
rootType: AccountRootTypeEnum.Asset, | ||
accountType: AccountTypeEnum.Cash, | ||
}), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { ClosingAmounts } from './ClosingAmounts'; | ||
import { ClosingCash } from './ClosingCash'; | ||
import { Doc } from 'fyo/model/doc'; | ||
import { OpeningAmounts } from './OpeningAmounts'; | ||
import { OpeningCash } from './OpeningCash'; | ||
|
||
export class POSShift extends Doc { | ||
closingAmounts?: ClosingAmounts[]; | ||
closingCash?: ClosingCash[]; | ||
closingDate?: Date; | ||
isShiftOpen?: boolean; | ||
openingAmounts?: OpeningAmounts[]; | ||
openingCash?: OpeningCash[]; | ||
openingDate?: Date; | ||
|
||
get openingCashAmount() { | ||
if (!this.openingCash) { | ||
return this.fyo.pesa(0); | ||
} | ||
|
||
let openingAmount = this.fyo.pesa(0); | ||
|
||
this.openingCash.map((row: OpeningCash) => { | ||
const denomination = row.denomination ?? this.fyo.pesa(0); | ||
const count = row.count ?? 0; | ||
|
||
const amount = denomination.mul(count); | ||
openingAmount = openingAmount.add(amount); | ||
}); | ||
return openingAmount; | ||
} | ||
|
||
get closingCashAmount() { | ||
if (!this.closingCash) { | ||
return this.fyo.pesa(0); | ||
} | ||
|
||
let closingAmount = this.fyo.pesa(0); | ||
|
||
this.closingCash.map((row: ClosingCash) => { | ||
const denomination = row.denomination ?? this.fyo.pesa(0); | ||
const count = row.count ?? 0; | ||
|
||
const amount = denomination.mul(count); | ||
closingAmount = closingAmount.add(amount); | ||
}); | ||
return closingAmount; | ||
} | ||
|
||
get openingTransferAmount() { | ||
if (!this.openingAmounts) { | ||
return this.fyo.pesa(0); | ||
} | ||
|
||
const transferAmountRow = this.openingAmounts.filter( | ||
(row) => row.paymentMethod === 'Transfer' | ||
)[0]; | ||
|
||
return transferAmountRow.amount ?? this.fyo.pesa(0); | ||
} | ||
} |
Oops, something went wrong.