Skip to content

Commit 7db0cf5

Browse files
committed
fix: party creation from POS
1 parent 8186f12 commit 7db0cf5

File tree

2 files changed

+32
-21
lines changed

2 files changed

+32
-21
lines changed

src/pages/POS/POS.vue

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</PageHeader>
1010

1111
<OpenPOSShiftModal
12+
v-if="!isPosShiftOpen"
1213
:open-modal="!isPosShiftOpen"
1314
@toggle-modal="toggleModal"
1415
/>
@@ -57,18 +58,12 @@
5758
<div class="flex flex-col gap-3" style="height: calc(100vh - 6rem)">
5859
<div class="bg-white border grow h-full p-4 rounded-md">
5960
<!-- Customer Search -->
61+
6062
<Link
6163
class="flex-shrink-0"
62-
size="medium"
6364
:border="true"
64-
:df="{
65-
label: t`Customer`,
66-
fieldtype: 'Link',
67-
fieldname: 'customer',
68-
target: 'Party',
69-
schemaName: 'SalesInvoice',
70-
}"
7165
:value="sinvDoc.party"
66+
:df="sinvDoc.fieldMap.party"
7267
@change="(value) => (sinvDoc.party = value)"
7368
/>
7469

@@ -217,7 +212,9 @@ export default defineComponent({
217212
},
218213
provide() {
219214
return {
215+
doc: computed(() => this.sinvDoc),
220216
cashAmount: computed(() => this.cashAmount),
217+
isDiscountingEnabled: computed(() => this.isDiscountingEnabled),
221218
itemDiscounts: computed(() => this.itemDiscounts),
222219
itemQtyMap: computed(() => this.itemQtyMap),
223220
itemSerialNumbers: computed(() => this.itemSerialNumbers),
@@ -255,6 +252,11 @@ export default defineComponent({
255252
};
256253
},
257254
computed: {
255+
defaultPOSCashAccount: () =>
256+
fyo.singles.POSSettings?.cashAccount ?? undefined,
257+
isDiscountingEnabled(): boolean {
258+
return !!fyo.singles.AccountingSettings?.enableDiscounting;
259+
},
258260
isPosShiftOpen: () => !!fyo.singles.POSShift?.isShiftOpen,
259261
},
260262
watch: {
@@ -294,6 +296,7 @@ export default defineComponent({
294296
this.sinvDoc = this.fyo.doc.getNewDoc(ModelNameEnum.SalesInvoice, {
295297
account: 'Debtors',
296298
party: this.sinvDoc.party ?? this.defaultCustomer,
299+
isPOS: true,
297300
}) as SalesInvoice;
298301
},
299302
setTotalQuantity() {
@@ -404,7 +407,6 @@ export default defineComponent({
404407
}
405408
},
406409
async makePayment() {
407-
await validateShipment(this.itemSerialNumbers);
408410
const paymentMethod = this.cashAmount.isZero() ? 'Transfer' : 'Cash';
409411
await this.paymentDoc.set('paymentMethod', paymentMethod);
410412
@@ -417,35 +419,39 @@ export default defineComponent({
417419
}
418420
419421
if (paymentMethod === 'Cash') {
420-
await this.paymentDoc.set('amount', this.cashAmount as Money);
422+
await this.paymentDoc.setMultiple({
423+
paymentAccount: this.defaultPOSCashAccount,
424+
amount: this.cashAmount as Money,
425+
});
421426
}
422427
423428
try {
424429
await this.paymentDoc?.sync();
425430
await this.paymentDoc?.submit();
426431
} catch (error) {
427-
showToast({
432+
return showToast({
428433
type: 'error',
429434
message: t`${error as string}`,
430435
});
431436
}
432437
},
433438
async makeStockTransfer() {
434-
const shipment = (await this.sinvDoc.getStockTransfer()) as Shipment;
435-
if (!shipment.items) {
439+
const shipmentDoc = (await this.sinvDoc.getStockTransfer()) as Shipment;
440+
if (!shipmentDoc.items) {
436441
return;
437442
}
438443
439-
for (const item of shipment.items) {
444+
for (const item of shipmentDoc.items) {
445+
item.location = fyo.singles.POSSettings?.inventory;
440446
item.serialNumber =
441447
this.itemSerialNumbers[item.item as string] ?? undefined;
442448
}
443449
444450
try {
445-
await shipment.sync();
446-
await shipment.submit();
451+
await shipmentDoc.sync();
452+
await shipmentDoc.submit();
447453
} catch (error) {
448-
showToast({
454+
return showToast({
449455
type: 'error',
450456
message: t`${error as string}`,
451457
});
@@ -455,12 +461,11 @@ export default defineComponent({
455461
try {
456462
await this.validate();
457463
await this.sinvDoc.runFormulas();
458-
await this.sinvDoc._callAllTableFieldsApplyFormula();
459464
await this.sinvDoc.sync();
460465
await this.sinvDoc.submit();
461466
this.paymentDoc = this.sinvDoc.getPayment() as Payment;
462467
} catch (error) {
463-
showToast({
468+
return showToast({
464469
type: 'error',
465470
message: t`${error as string}`,
466471
});

src/router.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,14 @@ const routes: RouteRecordRaw[] = [
128128
{
129129
path: '/pos',
130130
name: 'Point of Sale',
131-
component: POS,
132-
props: {},
131+
components: {
132+
default: POS,
133+
edit: QuickEditForm,
134+
},
135+
props: {
136+
default: true,
137+
edit: (route) => route.query,
138+
},
133139
},
134140
];
135141

0 commit comments

Comments
 (0)