Skip to content

Commit

Permalink
add pegah gold and fix duplicate record from retrieve-price-persian-api
Browse files Browse the repository at this point in the history
  • Loading branch information
bahram1249 committed Feb 11, 2025
1 parent 7472f76 commit 35ca7ce
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 14 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/deploy-pegah.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: deploy-pegahgold
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '20'
- name: update-chabokan
env:
CHABOKAN_TOKEN: ${{ secrets.PEGAH_CHABOKAN_TOKEN }}
run: |
npm install -g @chabokan.net/cli
chabok login -t $CHABOKAN_TOKEN
chabok deploy -s pegahgold
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export class RetrievePricePersianApiService {
? InventoryStatusEnum.available
: InventoryStatusEnum.unavailable;

let oldInventoryPrices = await this.inventoryPriceRepository.findAll(
let oldInventoryPrice = await this.inventoryPriceRepository.findOne(
new QueryOptionsBuilder()
.filter(
Sequelize.where(
Expand All @@ -312,6 +312,7 @@ export class RetrievePricePersianApiService {
.filter({
inventoryId: inventories[index].id,
})
.filter({ variationPriceId: VariationPriceEnum.firstPrice })
.build(),
);

Expand All @@ -326,20 +327,23 @@ export class RetrievePricePersianApiService {
);
inventoryPrice = _.omit(newPrice, ['buyPrice']);

await this.inventoryPriceRepository.create({
inventoryId: inventories[index].id,
variationPriceId: inventoryPrice.variationPriceId,
price: inventoryPrice.price,
buyPrice: newPrice.buyPrice,
userId: 1,
});
if (
oldInventoryPrice.price != newPrice.price ||
oldInventoryPrice.buyPrice != newPrice.buyPrice
) {
await this.inventoryPriceRepository.create({
inventoryId: inventories[index].id,
variationPriceId: inventoryPrice.variationPriceId,
price: inventoryPrice.price,
buyPrice: newPrice.buyPrice,
userId: 1,
});

for (let i = 0; i < oldInventoryPrices.length; i++) {
oldInventoryPrices[i].isDeleted = true;
await oldInventoryPrices[i].save();
}
oldInventoryPrice.isDeleted = true;
await oldInventoryPrice.save();

inventories[index] = await inventories[index].save();
inventories[index] = await inventories[index].save();
}

const keepJobs = this.config.get<number>(
'PRODUCT_INVENTORY_STATUS_KEEPJOBS',
Expand Down
2 changes: 1 addition & 1 deletion apps/main/src/sql/Core/Core-Permission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4012,7 +4012,7 @@ BEGIN
DECLARE @groupId int = null;

DECLARE @entityName nvarchar(256) = N'Transactions'
DECLARE @groupName nvarchar(256) = N'ecommerce.admin.tranactions'
DECLARE @groupName nvarchar(256) = N'ecommerce.admin.transactions'
DECLARE @findParentMenu bit = 0;
DECLARE @parentMenuName nvarchar(256) = N'پرداخت و حمل و نقل'
DECLARE @menuName nvarchar(256) = N'تراکنش ها'
Expand Down
7 changes: 7 additions & 0 deletions apps/main/src/sql/Ecommerce/Pegah-Settings.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

INSERT INTO Settings([key], [value], [type], [createdAt], [updatedAt])
SELECT N'SITE_NAME', 'ecommerce', 'string', getdate(), getdate()


INSERT INTO Settings([key], [value], [type], [createdAt], [updatedAt])
SELECT N'CUSTOMER_NAME', 'pegahgallery', 'string', getdate(), getdate()

0 comments on commit 35ca7ce

Please sign in to comment.